Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: chromeos/dbus/ibus/ibus_engine_factory_service_unittest.cc

Issue 10830004: Fix wrong usage of MethodCall resposne. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Same for IBusEngineService Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h" 5 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chromeos/dbus/ibus/ibus_constants.h" 8 #include "chromeos/dbus/ibus/ibus_constants.h"
9 #include "dbus/message.h" 9 #include "dbus/message.h"
10 #include "dbus/mock_bus.h" 10 #include "dbus/mock_bus.h"
(...skipping 14 matching lines...) Expand all
25 }; 25 };
26 26
27 class MockCreateEngineResponseSender { 27 class MockCreateEngineResponseSender {
28 public: 28 public:
29 MockCreateEngineResponseSender(const dbus::ObjectPath expected_path) 29 MockCreateEngineResponseSender(const dbus::ObjectPath expected_path)
30 : expected_path_(expected_path) {} 30 : expected_path_(expected_path) {}
31 MOCK_METHOD1(Run, void(dbus::Response*)); 31 MOCK_METHOD1(Run, void(dbus::Response*));
32 32
33 // Checks the given |response| meets expectation for the CreateEngine method. 33 // Checks the given |response| meets expectation for the CreateEngine method.
34 void CheckCreateEngineResponse(dbus::Response* response) { 34 void CheckCreateEngineResponse(dbus::Response* response) {
35 scoped_ptr<dbus::Response> response_deleter(response);
35 dbus::MessageReader reader(response); 36 dbus::MessageReader reader(response);
36 dbus::ObjectPath actual_path; 37 dbus::ObjectPath actual_path;
37 ASSERT_TRUE(reader.PopObjectPath(&actual_path)); 38 ASSERT_TRUE(reader.PopObjectPath(&actual_path));
38 EXPECT_EQ(expected_path_, actual_path); 39 EXPECT_EQ(expected_path_, actual_path);
39 } 40 }
40 41
41 private: 42 private:
42 dbus::ObjectPath expected_path_; 43 dbus::ObjectPath expected_path_;
43 }; 44 };
44 45
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 EXPECT_CALL(handler, Run(StrEq(kSampleEngine))) 123 EXPECT_CALL(handler, Run(StrEq(kSampleEngine)))
123 .WillOnce(Return(kObjectPath)); 124 .WillOnce(Return(kObjectPath));
124 service_->SetCreateEngineHandler(base::Bind(&MockCreateEngineHandler::Run, 125 service_->SetCreateEngineHandler(base::Bind(&MockCreateEngineHandler::Run,
125 base::Unretained(&handler))); 126 base::Unretained(&handler)));
126 message_loop_.RunAllPending(); 127 message_loop_.RunAllPending();
127 128
128 // Invoke method call. 129 // Invoke method call.
129 dbus::MethodCall method_call( 130 dbus::MethodCall method_call(
130 ibus::engine_factory::kServiceInterface, 131 ibus::engine_factory::kServiceInterface,
131 ibus::engine_factory::kCreateEngineMethod); 132 ibus::engine_factory::kCreateEngineMethod);
133 method_call.SetSerial(10);
132 dbus::MessageWriter writer(&method_call); 134 dbus::MessageWriter writer(&method_call);
133 writer.AppendString(kSampleEngine); 135 writer.AppendString(kSampleEngine);
134 ASSERT_FALSE( 136 ASSERT_FALSE(
135 method_exported_map_[ibus::engine_factory::kCreateEngineMethod] 137 method_exported_map_[ibus::engine_factory::kCreateEngineMethod]
136 .is_null()); 138 .is_null());
137 method_exported_map_[ibus::engine_factory::kCreateEngineMethod].Run( 139 method_exported_map_[ibus::engine_factory::kCreateEngineMethod].Run(
138 &method_call, 140 &method_call,
139 base::Bind(&MockCreateEngineResponseSender::Run, 141 base::Bind(&MockCreateEngineResponseSender::Run,
140 base::Unretained(&response_sender))); 142 base::Unretained(&response_sender)));
141 143
142 // Unset the handler so expect not calling handler. 144 // Unset the handler so expect not calling handler.
143 service_->UnsetCreateEngineHandler(); 145 service_->UnsetCreateEngineHandler();
144 method_exported_map_[ibus::engine_factory::kCreateEngineMethod].Run( 146 method_exported_map_[ibus::engine_factory::kCreateEngineMethod].Run(
145 &method_call, 147 &method_call,
146 base::Bind(&MockCreateEngineResponseSender::CheckCreateEngineResponse, 148 base::Bind(&MockCreateEngineResponseSender::CheckCreateEngineResponse,
147 base::Unretained(&response_sender))); 149 base::Unretained(&response_sender)));
148 150
149 message_loop_.RunAllPending(); 151 message_loop_.RunAllPending();
150 } 152 }
151 153
152 } // namespace chromeos 154 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/ibus/ibus_engine_factory_service.cc ('k') | chromeos/dbus/ibus/ibus_engine_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698