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

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

Issue 12017010: Introduce bypass logic for SetCursorLocation message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
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_panel_service.h" 5 #include "chromeos/dbus/ibus/ibus_panel_service.h"
6 6
7 #include <map> 7 #include <map>
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chromeos/dbus/ibus/ibus_constants.h" 11 #include "chromeos/dbus/ibus/ibus_constants.h"
12 #include "chromeos/dbus/ibus/ibus_input_context_client.h"
12 #include "chromeos/dbus/ibus/ibus_lookup_table.h" 13 #include "chromeos/dbus/ibus/ibus_lookup_table.h"
13 #include "chromeos/dbus/ibus/ibus_property.h" 14 #include "chromeos/dbus/ibus/ibus_property.h"
14 #include "chromeos/dbus/ibus/ibus_text.h" 15 #include "chromeos/dbus/ibus/ibus_text.h"
15 #include "dbus/message.h" 16 #include "dbus/message.h"
16 #include "dbus/mock_bus.h" 17 #include "dbus/mock_bus.h"
17 #include "dbus/mock_exported_object.h" 18 #include "dbus/mock_exported_object.h"
18 #include "dbus/object_path.h" 19 #include "dbus/object_path.h"
19 #include "dbus/values_util.h" 20 #include "dbus/values_util.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 15 matching lines...) Expand all
37 MOCK_METHOD2(UpdateLookupTable, void(const ibus::IBusLookupTable& table, 38 MOCK_METHOD2(UpdateLookupTable, void(const ibus::IBusLookupTable& table,
38 bool visible)); 39 bool visible));
39 MOCK_METHOD0(HideLookupTable, void()); 40 MOCK_METHOD0(HideLookupTable, void());
40 MOCK_METHOD2(UpdateAuxiliaryText, void(const std::string& text, 41 MOCK_METHOD2(UpdateAuxiliaryText, void(const std::string& text,
41 bool visible)); 42 bool visible));
42 MOCK_METHOD0(HideAuxiliaryText, void()); 43 MOCK_METHOD0(HideAuxiliaryText, void());
43 MOCK_METHOD3(UpdatePreeditText, void(const std::string& text, 44 MOCK_METHOD3(UpdatePreeditText, void(const std::string& text,
44 uint32 cursor_pos, 45 uint32 cursor_pos,
45 bool visible) ); 46 bool visible) );
46 MOCK_METHOD0(HidePreeditText, void()); 47 MOCK_METHOD0(HidePreeditText, void());
48 MOCK_METHOD2(SetCursorLocation, void(const ibus::Rect& cursor_location,
49 const ibus::Rect& composition_head));
47 50
48 private: 51 private:
49 DISALLOW_COPY_AND_ASSIGN(MockIBusPanelCandidateWindowHandler); 52 DISALLOW_COPY_AND_ASSIGN(MockIBusPanelCandidateWindowHandler);
50 }; 53 };
51 54
52 class MockIBusPanelPropertyHandler : public IBusPanelPropertyHandlerInterface { 55 class MockIBusPanelPropertyHandler : public IBusPanelPropertyHandlerInterface {
53 public: 56 public:
54 MockIBusPanelPropertyHandler() {} 57 MockIBusPanelPropertyHandler() {}
55 MOCK_METHOD1(RegisterProperties, 58 MOCK_METHOD1(RegisterProperties,
56 void(const ibus::IBusPropertyList& properties)); 59 void(const ibus::IBusPropertyList& properties));
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 ibus::panel::kServiceInterface, 286 ibus::panel::kServiceInterface,
284 ibus::panel::kStateChangedMethod, _, _)) 287 ibus::panel::kStateChangedMethod, _, _))
285 .WillRepeatedly( 288 .WillRepeatedly(
286 Invoke(this, &IBusPanelServiceTest::OnMethodExported)); 289 Invoke(this, &IBusPanelServiceTest::OnMethodExported));
287 290
288 // Suppress uninteresting mock function call warning. 291 // Suppress uninteresting mock function call warning.
289 EXPECT_CALL(*mock_bus_.get(), 292 EXPECT_CALL(*mock_bus_.get(),
290 AssertOnOriginThread()) 293 AssertOnOriginThread())
291 .WillRepeatedly(Return()); 294 .WillRepeatedly(Return());
292 295
296 stub_input_context_client_.reset(IBusInputContextClient::Create(
297 STUB_DBUS_CLIENT_IMPLEMENTATION));
298
293 // Create a service 299 // Create a service
294 service_.reset(IBusPanelService::Create( 300 service_.reset(IBusPanelService::Create(
295 REAL_DBUS_CLIENT_IMPLEMENTATION, 301 REAL_DBUS_CLIENT_IMPLEMENTATION,
296 mock_bus_.get())); 302 mock_bus_.get(),
303 stub_input_context_client_.get()));
297 304
298 // Set panel handler. 305 // Set panel handler.
299 candidate_window_handler_.reset(new MockIBusPanelCandidateWindowHandler()); 306 candidate_window_handler_.reset(new MockIBusPanelCandidateWindowHandler());
300 service_->SetUpCandidateWindowHandler(candidate_window_handler_.get()); 307 service_->SetUpCandidateWindowHandler(candidate_window_handler_.get());
301 property_handler_.reset(new MockIBusPanelPropertyHandler()); 308 property_handler_.reset(new MockIBusPanelPropertyHandler());
302 service_->SetUpPropertyHandler(property_handler_.get()); 309 service_->SetUpPropertyHandler(property_handler_.get());
303 } 310 }
304 311
305 protected: 312 protected:
306 // The service to be tested. 313 // The service to be tested.
307 scoped_ptr<IBusPanelService> service_; 314 scoped_ptr<IBusPanelService> service_;
308 // The mock candidate window panel handler. Do not free, this is owned by 315 // The mock candidate window panel handler. Do not free, this is owned by
309 // IBusPanelService. 316 // IBusPanelService.
310 scoped_ptr<MockIBusPanelCandidateWindowHandler> candidate_window_handler_; 317 scoped_ptr<MockIBusPanelCandidateWindowHandler> candidate_window_handler_;
311 // The mock property handler. Do not free, this is owned by IBusPanelService. 318 // The mock property handler. Do not free, this is owned by IBusPanelService.
312 scoped_ptr<MockIBusPanelPropertyHandler> property_handler_; 319 scoped_ptr<MockIBusPanelPropertyHandler> property_handler_;
320 // The stub input context client.
321 scoped_ptr<IBusInputContextClient> stub_input_context_client_;
313 // The mock bus. 322 // The mock bus.
314 scoped_refptr<dbus::MockBus> mock_bus_; 323 scoped_refptr<dbus::MockBus> mock_bus_;
315 // The mock exported object. 324 // The mock exported object.
316 scoped_refptr<dbus::MockExportedObject> mock_exported_object_; 325 scoped_refptr<dbus::MockExportedObject> mock_exported_object_;
317 // A message loop to emulate asynchronous behavior. 326 // A message loop to emulate asynchronous behavior.
318 MessageLoop message_loop_; 327 MessageLoop message_loop_;
319 // The map from method call to method call handler. 328 // The map from method call to method call handler.
320 std::map<std::string, dbus::ExportedObject::MethodCallCallback> 329 std::map<std::string, dbus::ExportedObject::MethodCallCallback>
321 method_callback_map_; 330 method_callback_map_;
322 331
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 EXPECT_NE(method_callback_map_.find(ibus::panel::kUpdatePropertyMethod), 616 EXPECT_NE(method_callback_map_.find(ibus::panel::kUpdatePropertyMethod),
608 method_callback_map_.end()); 617 method_callback_map_.end());
609 method_callback_map_[ibus::panel::kUpdatePropertyMethod].Run( 618 method_callback_map_[ibus::panel::kUpdatePropertyMethod].Run(
610 &method_call, 619 &method_call,
611 base::Bind(&MockResponseSender::Run, 620 base::Bind(&MockResponseSender::Run,
612 base::Unretained(&response_sender))); 621 base::Unretained(&response_sender)));
613 } 622 }
614 623
615 } // namespace ibus 624 } // namespace ibus
616 } // namespace chromeos 625 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/ibus/ibus_panel_service.cc ('k') | chromeos/dbus/ibus/mock_ibus_input_context_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698