diff options
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/dbus/dbus_thread_manager.cc | 4 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_constants.h | 14 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_input_context_client.cc | 57 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_input_context_client.h | 21 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_input_context_client_unittest.cc | 58 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_panel_service.cc | 21 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_panel_service.h | 8 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_panel_service_unittest.cc | 11 | ||||
-rw-r--r-- | chromeos/dbus/ibus/mock_ibus_input_context_client.cc | 17 | ||||
-rw-r--r-- | chromeos/dbus/ibus/mock_ibus_input_context_client.h | 8 |
10 files changed, 58 insertions, 161 deletions
diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc index da12b79..8d7a0d1 100644 --- a/chromeos/dbus/dbus_thread_manager.cc +++ b/chromeos/dbus/dbus_thread_manager.cc @@ -185,9 +185,7 @@ class DBusThreadManagerImpl : public DBusThreadManager { ibus_engine_factory_service_.reset( IBusEngineFactoryService::Create(ibus_bus_.get(), client_type)); ibus_panel_service_.reset( - ibus::IBusPanelService::Create(client_type, - ibus_bus_.get(), - ibus_input_context_client_.get())); + ibus::IBusPanelService::Create(client_type, ibus_bus_.get())); ibus_engine_services_.clear(); } diff --git a/chromeos/dbus/ibus/ibus_constants.h b/chromeos/dbus/ibus/ibus_constants.h index 1c4c027..f375099 100644 --- a/chromeos/dbus/ibus/ibus_constants.h +++ b/chromeos/dbus/ibus/ibus_constants.h @@ -124,20 +124,6 @@ const char kServiceInterface[] = "org.freedesktop.IBus.Config"; const char kSetValueMethod[] = "SetValue"; } // namespace config -// We can't use ui/gfx/rect.h in chromeos/, so we should use ibus::Rect instead. -struct Rect { - Rect() : x(0), y(0), width(0), height(0) {} - Rect(int x, int y, int width, int height) - : x(x), - y(y), - width(width), - height(height) {} - int x; - int y; - int width; - int height; -}; - } // namespace ibus } // namespace chromeos diff --git a/chromeos/dbus/ibus/ibus_input_context_client.cc b/chromeos/dbus/ibus/ibus_input_context_client.cc index 86d9536..8f86077 100644 --- a/chromeos/dbus/ibus/ibus_input_context_client.cc +++ b/chromeos/dbus/ibus/ibus_input_context_client.cc @@ -26,7 +26,6 @@ class IBusInputContextClientImpl : public IBusInputContextClient { public: IBusInputContextClientImpl() : proxy_(NULL), - is_xkb_layout_(true), weak_ptr_factory_(this) { } @@ -52,18 +51,6 @@ class IBusInputContextClientImpl : public IBusInputContextClient { } // IBusInputContextClient override. - virtual void SetSetCursorLocationHandler( - const SetCursorLocationHandler& set_cursor_location_handler) OVERRIDE { - DCHECK(!set_cursor_location_handler.is_null()); - set_cursor_location_handler_ = set_cursor_location_handler; - } - - // IBusInputContextClient override. - virtual void UnsetSetCursorLocationHandler() OVERRIDE { - set_cursor_location_handler_.Reset(); - } - - // IBusInputContextClient override. virtual void ResetObjectProxy() OVERRIDE { // Do not delete proxy here, proxy object is managed by dbus::Bus object. proxy_ = NULL; @@ -106,10 +93,17 @@ class IBusInputContextClientImpl : public IBusInputContextClient { } // IBusInputContextClient override. - virtual void SetCursorLocation(const ibus::Rect& cursor_location, - const ibus::Rect& composition_head) OVERRIDE { - if (!set_cursor_location_handler_.is_null()) - set_cursor_location_handler_.Run(cursor_location, composition_head); + virtual void SetCursorLocation(int32 x, int32 y, int32 width, + int32 height) OVERRIDE { + dbus::MethodCall method_call(ibus::input_context::kServiceInterface, + ibus::input_context::kSetCursorLocationMethod); + dbus::MessageWriter writer(&method_call); + writer.AppendInt32(x); + writer.AppendInt32(y); + writer.AppendInt32(width); + writer.AppendInt32(height); + CallNoResponseMethod(&method_call, + ibus::input_context::kSetCursorLocationMethod); } // IBusInputContextClient override. @@ -165,17 +159,6 @@ class IBusInputContextClientImpl : public IBusInputContextClient { CallNoResponseMethod(&method_call, ibus::input_context::kPropertyActivateMethod); } - - // IBusInputContextClient override. - virtual bool IsXKBLayout() OVERRIDE { - return is_xkb_layout_; - } - - // IBusInputContextClient override. - virtual void SetIsXKBLayout(bool is_xkb_layout) OVERRIDE { - is_xkb_layout_ = is_xkb_layout; - } - private: void CallNoResponseMethod(dbus::MethodCall* method_call, const std::string& method_name) { @@ -348,11 +331,6 @@ class IBusInputContextClientImpl : public IBusInputContextClient { // The pointer for input context handler. This can be NULL. IBusInputContextHandlerInterface* handler_; - SetCursorLocationHandler set_cursor_location_handler_; - - // True if the current input method is xkb layout. - bool is_xkb_layout_; - base::WeakPtrFactory<IBusInputContextClientImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(IBusInputContextClientImpl); @@ -366,24 +344,23 @@ class IBusInputContextClientStubImpl : public IBusInputContextClient { virtual ~IBusInputContextClientStubImpl() {} public: - // IBusInputContextClient overrides. + // IBusInputContextClient override. virtual void Initialize(dbus::Bus* bus, const dbus::ObjectPath& object_path) OVERRIDE {} virtual void SetInputContextHandler( IBusInputContextHandlerInterface* handler) OVERRIDE {} - virtual void SetSetCursorLocationHandler( - const SetCursorLocationHandler& set_cursor_location_handler) OVERRIDE {} - virtual void UnsetSetCursorLocationHandler() OVERRIDE {} + // IBusInputContextClient override. virtual void ResetObjectProxy() OVERRIDE {} + // IBusInputContextClient override. virtual bool IsObjectProxyReady() const OVERRIDE { return true; } + // IBusInputContextClient overrides. virtual void SetCapabilities(uint32 capability) OVERRIDE {} virtual void FocusIn() OVERRIDE {} virtual void FocusOut() OVERRIDE {} virtual void Reset() OVERRIDE {} - virtual void SetCursorLocation(const ibus::Rect& cursor_location, - const ibus::Rect& composition_head) OVERRIDE {} + virtual void SetCursorLocation(int32 x, int32 y, int32 w, int32 h) OVERRIDE {} virtual void ProcessKeyEvent( uint32 keyval, uint32 keycode, @@ -397,8 +374,6 @@ class IBusInputContextClientStubImpl : public IBusInputContextClient { uint32 end_index) OVERRIDE {} virtual void PropertyActivate(const std::string& key, ibus::IBusPropertyState state) OVERRIDE {} - virtual bool IsXKBLayout() OVERRIDE { return true; } - virtual void SetIsXKBLayout(bool is_xkb_layout) OVERRIDE {} private: DISALLOW_COPY_AND_ASSIGN(IBusInputContextClientStubImpl); diff --git a/chromeos/dbus/ibus/ibus_input_context_client.h b/chromeos/dbus/ibus/ibus_input_context_client.h index ca3d13a..a55064e 100644 --- a/chromeos/dbus/ibus/ibus_input_context_client.h +++ b/chromeos/dbus/ibus/ibus_input_context_client.h @@ -43,6 +43,7 @@ class CHROMEOS_EXPORT IBusInputContextHandlerInterface { // Called when the engine request hiding preedit string. virtual void HidePreeditText() = 0; + }; // A class to make the actual DBus calls for IBusInputContext service. @@ -53,9 +54,6 @@ class CHROMEOS_EXPORT IBusInputContextHandlerInterface { // one input context but it is enough for ChromeOS. class CHROMEOS_EXPORT IBusInputContextClient { public: - typedef base::Callback<void(const ibus::Rect& cursor_location, - const ibus::Rect& composition_head)> - SetCursorLocationHandler; typedef base::Callback<void(bool is_keyevent_used)> ProcessKeyEventCallback; typedef base::Callback<void()> ErrorCallback; @@ -70,13 +68,6 @@ class CHROMEOS_EXPORT IBusInputContextClient { virtual void SetInputContextHandler( IBusInputContextHandlerInterface* handler) = 0; - // Sets SetCursorLocation handler. - virtual void SetSetCursorLocationHandler( - const SetCursorLocationHandler& set_cursor_location_handler) = 0; - - // Unset SetCursorLocation handler. - virtual void UnsetSetCursorLocationHandler() = 0; - // Resets object proxy. If you want to use InputContext again, should call // Initialize function again. virtual void ResetObjectProxy() = 0; @@ -94,8 +85,8 @@ class CHROMEOS_EXPORT IBusInputContextClient { // Invokes Reset method call. virtual void Reset() = 0; // Invokes SetCursorLocation method call. - virtual void SetCursorLocation(const ibus::Rect& cursor_location, - const ibus::Rect& composition_head) = 0; + virtual void SetCursorLocation(int32 x, int32 y, int32 width, + int32 height) = 0; // Invokes ProcessKeyEvent method call. |callback| should not be null. virtual void ProcessKeyEvent(uint32 keyval, uint32 keycode, @@ -114,12 +105,6 @@ class CHROMEOS_EXPORT IBusInputContextClient { virtual void PropertyActivate(const std::string& key, ibus::IBusPropertyState state) = 0; - // Returns true if the current input method is XKB layout. - virtual bool IsXKBLayout() = 0; - - // Sets current input method is XKB layout or not. - virtual void SetIsXKBLayout(bool is_xkb_layout) = 0; - // Factory function, creates a new instance and returns ownership. // For normal usage, access the singleton via DBusThreadManager::Get(). static CHROMEOS_EXPORT IBusInputContextClient* Create( diff --git a/chromeos/dbus/ibus/ibus_input_context_client_unittest.cc b/chromeos/dbus/ibus/ibus_input_context_client_unittest.cc index fe3cee0..ff05074 100644 --- a/chromeos/dbus/ibus/ibus_input_context_client_unittest.cc +++ b/chromeos/dbus/ibus/ibus_input_context_client_unittest.cc @@ -36,10 +36,6 @@ const int32 kCursorHeight = 33; const uint32 kKeyval = 34; const uint32 kKeycode = 35; const uint32 kState = 36; -const int32 kCompositionX = 37; -const int32 kCompositionY = 38; -const int32 kCompositionWidth = 39; -const int32 kCompositionHeight = 40; const bool kIsKeyHandled = false; const char kSurroundingText[] = "Surrounding Text"; const uint32 kCursorPos = 2; @@ -78,9 +74,7 @@ MATCHER_P(IBusTextEq, expected_text, "The expected IBusText does not match") { class IBusInputContextClientTest : public testing::Test { public: - IBusInputContextClientTest() - : response_(NULL), - on_set_cursor_location_call_count_(0) {} + IBusInputContextClientTest() : response_(NULL) {} virtual void SetUp() OVERRIDE { // Create a mock bus. @@ -186,9 +180,24 @@ class IBusInputContextClientTest : public testing::Test { } // Handles SetCursorLocation method call. - void OnSetCursorLocation(const ibus::Rect& cursor_location, - const ibus::Rect& composition_head) { - ++on_set_cursor_location_call_count_; + void OnSetCursorLocation( + dbus::MethodCall* method_call, + int timeout_ms, + const dbus::ObjectProxy::ResponseCallback& callback, + const dbus::ObjectProxy::ErrorCallback& error_callback) { + EXPECT_EQ(ibus::input_context::kServiceInterface, + method_call->GetInterface()); + EXPECT_EQ(ibus::input_context::kSetCursorLocationMethod, + method_call->GetMember()); + dbus::MessageReader reader(method_call); + int32 x, y, width, height; + EXPECT_TRUE(reader.PopInt32(&x)); + EXPECT_TRUE(reader.PopInt32(&y)); + EXPECT_TRUE(reader.PopInt32(&width)); + EXPECT_TRUE(reader.PopInt32(&height)); + EXPECT_FALSE(reader.HasMoreData()); + + message_loop_.PostTask(FROM_HERE, base::Bind(callback, response_)); } // Handles SetCapabilities method call. @@ -315,8 +324,6 @@ class IBusInputContextClientTest : public testing::Test { MessageLoop message_loop_; // The map from signal to signal handler. std::map<std::string, dbus::ObjectProxy::SignalCallback> signal_callback_map_; - // Call count of OnSetCursorLocation. - int on_set_cursor_location_call_count_; private: // Used to implement the mock proxy. @@ -519,23 +526,18 @@ TEST_F(IBusInputContextClientTest, SetCapabilitiesTest) { } TEST_F(IBusInputContextClientTest, SetCursorLocationTest) { - on_set_cursor_location_call_count_ = 0; - client_->SetSetCursorLocationHandler( - base::Bind(&IBusInputContextClientTest::OnSetCursorLocation, - base::Unretained(this))); - const ibus::Rect cursor_location(kCursorX, - kCursorY, - kCursorWidth, - kCursorHeight); - const ibus::Rect composition_location(kCompositionX, - kCompositionY, - kCompositionWidth, - kCompositionHeight); - // Call SetCursorLocation. - client_->SetCursorLocation(cursor_location, composition_location); + // Set expectations. + EXPECT_CALL(*mock_proxy_, CallMethodWithErrorCallback(_, _, _, _)) + .WillOnce(Invoke(this, + &IBusInputContextClientTest::OnSetCursorLocation)); + // Create response. + scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); + response_ = response.get(); - EXPECT_EQ(1, on_set_cursor_location_call_count_); - client_->UnsetSetCursorLocationHandler(); + // Call SetCursorLocation. + client_->SetCursorLocation(kCursorX, kCursorY, kCursorWidth, kCursorHeight); + // Run the message loop. + message_loop_.RunUntilIdle(); } TEST_F(IBusInputContextClientTest, OnProcessKeyEvent) { diff --git a/chromeos/dbus/ibus/ibus_panel_service.cc b/chromeos/dbus/ibus/ibus_panel_service.cc index 95bee52..644a937 100644 --- a/chromeos/dbus/ibus/ibus_panel_service.cc +++ b/chromeos/dbus/ibus/ibus_panel_service.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/callback.h" #include "chromeos/dbus/ibus/ibus_constants.h" -#include "chromeos/dbus/ibus/ibus_input_context_client.h" #include "chromeos/dbus/ibus/ibus_lookup_table.h" #include "chromeos/dbus/ibus/ibus_property.h" #include "chromeos/dbus/ibus/ibus_text.h" @@ -24,8 +23,7 @@ namespace ibus { class IBusPanelServiceImpl : public IBusPanelService { public: - explicit IBusPanelServiceImpl(dbus::Bus* bus, - IBusInputContextClient* input_context) + explicit IBusPanelServiceImpl(dbus::Bus* bus) : bus_(bus), candidate_window_handler_(NULL), property_handler_(NULL), @@ -126,10 +124,6 @@ class IBusPanelServiceImpl : public IBusPanelService { ibus::panel::kServiceName, base::Bind(&IBusPanelServiceImpl::OnRequestOwnership, weak_ptr_factory_.GetWeakPtr())); - - input_context->SetSetCursorLocationHandler( - base::Bind(&IBusPanelServiceImpl::SetCursorLocation, - weak_ptr_factory_.GetWeakPtr())); } virtual ~IBusPanelServiceImpl() { @@ -344,11 +338,6 @@ class IBusPanelServiceImpl : public IBusPanelService { response_sender.Run(response); } - void SetCursorLocation(const ibus::Rect& cursor_location, - const ibus::Rect& composition_head) { - // TODO(nona): implement this function. - } - // Handles FocusIn, FocusOut, StateChanged method calls from IBus, and ignores // them. void NoOperation(dbus::MethodCall* method_call, @@ -417,12 +406,10 @@ IBusPanelService::~IBusPanelService() { } // static -IBusPanelService* IBusPanelService::Create( - DBusClientImplementationType type, - dbus::Bus* bus, - IBusInputContextClient* input_context) { +IBusPanelService* IBusPanelService::Create(DBusClientImplementationType type, + dbus::Bus* bus) { if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { - return new IBusPanelServiceImpl(bus, input_context); + return new IBusPanelServiceImpl(bus); } else { return new IBusPanelServiceStubImpl(); } diff --git a/chromeos/dbus/ibus/ibus_panel_service.h b/chromeos/dbus/ibus/ibus_panel_service.h index 7b32638..5fde186 100644 --- a/chromeos/dbus/ibus/ibus_panel_service.h +++ b/chromeos/dbus/ibus/ibus_panel_service.h @@ -19,7 +19,6 @@ class ObjectPath; } // namespace dbus namespace chromeos { -class IBusInputContextClient; // TODO(nona): Remove ibus namespace after complete libibus removal. namespace ibus { @@ -55,8 +54,6 @@ class CHROMEOS_EXPORT IBusPanelCandidateWindowHandlerInterface { // Called when the IME hides the preedit text. virtual void HidePreeditText() = 0; - // TODO(nona): Introduce SetCursorLocation function. - protected: IBusPanelCandidateWindowHandlerInterface() {} }; @@ -115,12 +112,9 @@ class CHROMEOS_EXPORT IBusPanelService { // Factory function, creates a new instance and returns ownership. // For normal usage, access the singleton via DBusThreadManager::Get(). - // IBusPanelService does not take an ownership of |input_context|, so caller - // should release it. static CHROMEOS_EXPORT IBusPanelService* Create( DBusClientImplementationType type, - dbus::Bus* bus, - IBusInputContextClient* input_context); + dbus::Bus* bus); protected: // Create() should be used instead. diff --git a/chromeos/dbus/ibus/ibus_panel_service_unittest.cc b/chromeos/dbus/ibus/ibus_panel_service_unittest.cc index 43cc325..85a59e9 100644 --- a/chromeos/dbus/ibus/ibus_panel_service_unittest.cc +++ b/chromeos/dbus/ibus/ibus_panel_service_unittest.cc @@ -9,7 +9,6 @@ #include "base/message_loop.h" #include "base/values.h" #include "chromeos/dbus/ibus/ibus_constants.h" -#include "chromeos/dbus/ibus/ibus_input_context_client.h" #include "chromeos/dbus/ibus/ibus_lookup_table.h" #include "chromeos/dbus/ibus/ibus_property.h" #include "chromeos/dbus/ibus/ibus_text.h" @@ -45,8 +44,6 @@ class MockIBusPanelCandidateWindowHandler uint32 cursor_pos, bool visible) ); MOCK_METHOD0(HidePreeditText, void()); - MOCK_METHOD2(SetCursorLocation, void(const ibus::Rect& cursor_location, - const ibus::Rect& composition_head)); private: DISALLOW_COPY_AND_ASSIGN(MockIBusPanelCandidateWindowHandler); @@ -293,14 +290,10 @@ class IBusPanelServiceTest : public testing::Test { AssertOnOriginThread()) .WillRepeatedly(Return()); - stub_input_context_client_.reset(IBusInputContextClient::Create( - STUB_DBUS_CLIENT_IMPLEMENTATION)); - // Create a service service_.reset(IBusPanelService::Create( REAL_DBUS_CLIENT_IMPLEMENTATION, - mock_bus_.get(), - stub_input_context_client_.get())); + mock_bus_.get())); // Set panel handler. candidate_window_handler_.reset(new MockIBusPanelCandidateWindowHandler()); @@ -317,8 +310,6 @@ class IBusPanelServiceTest : public testing::Test { scoped_ptr<MockIBusPanelCandidateWindowHandler> candidate_window_handler_; // The mock property handler. Do not free, this is owned by IBusPanelService. scoped_ptr<MockIBusPanelPropertyHandler> property_handler_; - // The stub input context client. - scoped_ptr<IBusInputContextClient> stub_input_context_client_; // The mock bus. scoped_refptr<dbus::MockBus> mock_bus_; // The mock exported object. diff --git a/chromeos/dbus/ibus/mock_ibus_input_context_client.cc b/chromeos/dbus/ibus/mock_ibus_input_context_client.cc index 6946413..fbaebb1 100644 --- a/chromeos/dbus/ibus/mock_ibus_input_context_client.cc +++ b/chromeos/dbus/ibus/mock_ibus_input_context_client.cc @@ -31,13 +31,6 @@ void MockIBusInputContextClient::SetInputContextHandler( IBusInputContextHandlerInterface* handler) { } -void MockIBusInputContextClient::SetSetCursorLocationHandler( - const SetCursorLocationHandler& set_cursor_location_handler) { -} - -void MockIBusInputContextClient::UnsetSetCursorLocationHandler() { -} - void MockIBusInputContextClient::ResetObjectProxy() { reset_object_proxy_call_caount_++; is_initialized_ = false; @@ -67,8 +60,7 @@ void MockIBusInputContextClient::Reset() { } void MockIBusInputContextClient::SetCursorLocation( - const ibus::Rect& cursor_location, - const ibus::Rect& composition_head) { + int32 x, int32 y, int32 w, int32 h) { set_cursor_location_call_count_++; } @@ -98,11 +90,4 @@ void MockIBusInputContextClient::PropertyActivate( ibus::IBusPropertyState state) { } -bool MockIBusInputContextClient::IsXKBLayout() { - return true; -} - -void MockIBusInputContextClient::SetIsXKBLayout(bool is_xkb_layout) { -} - } // namespace chromeos diff --git a/chromeos/dbus/ibus/mock_ibus_input_context_client.h b/chromeos/dbus/ibus/mock_ibus_input_context_client.h index 5e8199e..528db41 100644 --- a/chromeos/dbus/ibus/mock_ibus_input_context_client.h +++ b/chromeos/dbus/ibus/mock_ibus_input_context_client.h @@ -28,17 +28,13 @@ class MockIBusInputContextClient : public IBusInputContextClient { const dbus::ObjectPath& object_path) OVERRIDE; virtual void SetInputContextHandler( IBusInputContextHandlerInterface* handler) OVERRIDE; - virtual void SetSetCursorLocationHandler( - const SetCursorLocationHandler& set_cursor_location_handler) OVERRIDE; - virtual void UnsetSetCursorLocationHandler() OVERRIDE; virtual void ResetObjectProxy() OVERRIDE; virtual bool IsObjectProxyReady() const OVERRIDE; virtual void SetCapabilities(uint32 capabilities) OVERRIDE; virtual void FocusIn() OVERRIDE; virtual void FocusOut() OVERRIDE; virtual void Reset() OVERRIDE; - virtual void SetCursorLocation(const ibus::Rect& cursor_location, - const ibus::Rect& composition_head) OVERRIDE; + virtual void SetCursorLocation(int32 x, int32 y, int32 w, int32 h) OVERRIDE; virtual void ProcessKeyEvent(uint32 keyval, uint32 keycode, uint32 state, @@ -49,8 +45,6 @@ class MockIBusInputContextClient : public IBusInputContextClient { uint32 anchor_pos) OVERRIDE; virtual void PropertyActivate(const std::string& key, ibus::IBusPropertyState state) OVERRIDE; - virtual bool IsXKBLayout() OVERRIDE; - virtual void SetIsXKBLayout(bool is_xkb_layout) OVERRIDE; // Call count of Initialize(). int initialize_call_count() const { return initialize_call_count_; } |