| OLD | NEW |
| 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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "content/browser/gpu/compositor_util.h" | 35 #include "content/browser/gpu/compositor_util.h" |
| 36 #include "content/browser/renderer_host/input/input_router.h" | 36 #include "content/browser/renderer_host/input/input_router.h" |
| 37 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" | 37 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" |
| 38 #include "content/browser/renderer_host/input/web_input_event_util.h" | 38 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 39 #include "content/browser/renderer_host/overscroll_controller.h" | 39 #include "content/browser/renderer_host/overscroll_controller.h" |
| 40 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 40 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
| 41 #include "content/browser/renderer_host/render_view_host_factory.h" | 41 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 42 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 42 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 43 #include "content/browser/renderer_host/render_widget_host_impl.h" | 43 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 44 #include "content/browser/renderer_host/resize_lock.h" | 44 #include "content/browser/renderer_host/resize_lock.h" |
| 45 #include "content/browser/renderer_host/text_input_manager.h" | |
| 46 #include "content/browser/web_contents/web_contents_view_aura.h" | 45 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 47 #include "content/common/host_shared_bitmap_manager.h" | 46 #include "content/common/host_shared_bitmap_manager.h" |
| 48 #include "content/common/input/synthetic_web_input_event_builders.h" | 47 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 49 #include "content/common/input_messages.h" | 48 #include "content/common/input_messages.h" |
| 50 #include "content/common/text_input_state.h" | |
| 51 #include "content/common/view_messages.h" | 49 #include "content/common/view_messages.h" |
| 52 #include "content/public/browser/render_widget_host_view.h" | 50 #include "content/public/browser/render_widget_host_view.h" |
| 53 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 51 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 54 #include "content/public/browser/web_contents_view_delegate.h" | 52 #include "content/public/browser/web_contents_view_delegate.h" |
| 55 #include "content/public/common/context_menu_params.h" | 53 #include "content/public/common/context_menu_params.h" |
| 56 #include "content/public/test/mock_render_process_host.h" | 54 #include "content/public/test/mock_render_process_host.h" |
| 57 #include "content/public/test/test_browser_context.h" | 55 #include "content/public/test/test_browser_context.h" |
| 58 #include "content/test/test_render_view_host.h" | 56 #include "content/test/test_render_view_host.h" |
| 59 #include "content/test/test_web_contents.h" | 57 #include "content/test/test_web_contents.h" |
| 60 #include "ipc/ipc_message.h" | |
| 61 #include "ipc/ipc_test_sink.h" | 58 #include "ipc/ipc_test_sink.h" |
| 62 #include "media/base/video_frame.h" | 59 #include "media/base/video_frame.h" |
| 63 #include "testing/gmock/include/gmock/gmock.h" | 60 #include "testing/gmock/include/gmock/gmock.h" |
| 64 #include "testing/gtest/include/gtest/gtest.h" | 61 #include "testing/gtest/include/gtest/gtest.h" |
| 65 #include "ui/aura/client/aura_constants.h" | 62 #include "ui/aura/client/aura_constants.h" |
| 66 #include "ui/aura/client/screen_position_client.h" | 63 #include "ui/aura/client/screen_position_client.h" |
| 67 #include "ui/aura/client/window_tree_client.h" | 64 #include "ui/aura/client/window_tree_client.h" |
| 68 #include "ui/aura/env.h" | 65 #include "ui/aura/env.h" |
| 69 #include "ui/aura/layout_manager.h" | 66 #include "ui/aura/layout_manager.h" |
| 70 #include "ui/aura/test/aura_test_helper.h" | 67 #include "ui/aura/test/aura_test_helper.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); | 155 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); |
| 159 }; | 156 }; |
| 160 | 157 |
| 161 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { | 158 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
| 162 public: | 159 public: |
| 163 MockRenderWidgetHostDelegate() : rwh_(nullptr), is_fullscreen_(false) {} | 160 MockRenderWidgetHostDelegate() : rwh_(nullptr), is_fullscreen_(false) {} |
| 164 ~MockRenderWidgetHostDelegate() override {} | 161 ~MockRenderWidgetHostDelegate() override {} |
| 165 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } | 162 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } |
| 166 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; } | 163 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; } |
| 167 void set_is_fullscreen(bool is_fullscreen) { is_fullscreen_ = is_fullscreen; } | 164 void set_is_fullscreen(bool is_fullscreen) { is_fullscreen_ = is_fullscreen; } |
| 168 TextInputManager* GetTextInputManager() override { | |
| 169 return &text_input_manager_; | |
| 170 } | |
| 171 | 165 |
| 172 protected: | 166 protected: |
| 173 // RenderWidgetHostDelegate: | 167 // RenderWidgetHostDelegate: |
| 174 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 168 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 175 bool* is_keyboard_shortcut) override { | 169 bool* is_keyboard_shortcut) override { |
| 176 last_event_.reset(new NativeWebKeyboardEvent(event)); | 170 last_event_.reset(new NativeWebKeyboardEvent(event)); |
| 177 return true; | 171 return true; |
| 178 } | 172 } |
| 179 void Cut() override {} | 173 void Cut() override {} |
| 180 void Copy() override {} | 174 void Copy() override {} |
| 181 void Paste() override {} | 175 void Paste() override {} |
| 182 void SelectAll() override {} | 176 void SelectAll() override {} |
| 183 void SendScreenRects() override { | 177 void SendScreenRects() override { |
| 184 if (rwh_) | 178 if (rwh_) |
| 185 rwh_->SendScreenRects(); | 179 rwh_->SendScreenRects(); |
| 186 } | 180 } |
| 187 bool IsFullscreenForCurrentTab() const override { return is_fullscreen_; } | 181 bool IsFullscreenForCurrentTab() const override { return is_fullscreen_; } |
| 188 | 182 |
| 189 private: | 183 private: |
| 190 std::unique_ptr<NativeWebKeyboardEvent> last_event_; | 184 std::unique_ptr<NativeWebKeyboardEvent> last_event_; |
| 191 RenderWidgetHostImpl* rwh_; | 185 RenderWidgetHostImpl* rwh_; |
| 192 bool is_fullscreen_; | 186 bool is_fullscreen_; |
| 193 TextInputManager text_input_manager_; | |
| 194 | 187 |
| 195 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); | 188 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); |
| 196 }; | 189 }; |
| 197 | 190 |
| 198 // Simple observer that keeps track of changes to a window for tests. | 191 // Simple observer that keeps track of changes to a window for tests. |
| 199 class TestWindowObserver : public aura::WindowObserver { | 192 class TestWindowObserver : public aura::WindowObserver { |
| 200 public: | 193 public: |
| 201 explicit TestWindowObserver(aura::Window* window_to_observe) | 194 explicit TestWindowObserver(aura::Window* window_to_observe) |
| 202 : window_(window_to_observe) { | 195 : window_(window_to_observe) { |
| 203 window_->AddObserver(this); | 196 window_->AddObserver(this); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 const blink::WebInputEvent* event = std::get<0>(params); | 536 const blink::WebInputEvent* event = std::get<0>(params); |
| 544 SendTouchEventACK(event->type, ack_result, | 537 SendTouchEventACK(event->type, ack_result, |
| 545 WebInputEventTraits::GetUniqueTouchEventId(*event)); | 538 WebInputEventTraits::GetUniqueTouchEventId(*event)); |
| 546 } | 539 } |
| 547 | 540 |
| 548 const ui::MotionEventAura& pointer_state() { | 541 const ui::MotionEventAura& pointer_state() { |
| 549 return view_->pointer_state_for_test(); | 542 return view_->pointer_state_for_test(); |
| 550 } | 543 } |
| 551 | 544 |
| 552 protected: | 545 protected: |
| 553 BrowserContext* browser_context() { return browser_context_.get(); } | |
| 554 | |
| 555 // Sets the |view| active in TextInputManager with the given |type|. |type| | |
| 556 // cannot be ui::TEXT_INPUT_TYPE_NONE. | |
| 557 void ActivateViewForTextInputManager(RenderWidgetHostViewBase* view, | |
| 558 ui::TextInputType type) { | |
| 559 DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, type); | |
| 560 TextInputManager* manager = | |
| 561 static_cast<RenderWidgetHostImpl*>(view->GetRenderWidgetHost()) | |
| 562 ->delegate() | |
| 563 ->GetTextInputManager(); | |
| 564 if (manager->GetActiveWidget()) { | |
| 565 manager->active_view_for_testing()->TextInputStateChanged( | |
| 566 TextInputState()); | |
| 567 } | |
| 568 | |
| 569 if (!view) | |
| 570 return; | |
| 571 | |
| 572 TextInputState state_with_type_text; | |
| 573 state_with_type_text.type = type; | |
| 574 view->TextInputStateChanged(state_with_type_text); | |
| 575 } | |
| 576 | |
| 577 // If true, then calls RWH::Shutdown() instead of deleting RWH. | 546 // If true, then calls RWH::Shutdown() instead of deleting RWH. |
| 578 bool widget_host_uses_shutdown_to_destroy_; | 547 bool widget_host_uses_shutdown_to_destroy_; |
| 579 | 548 |
| 580 bool is_guest_view_hack_; | 549 bool is_guest_view_hack_; |
| 581 | 550 |
| 582 base::MessageLoopForUI message_loop_; | 551 base::MessageLoopForUI message_loop_; |
| 583 BrowserThreadImpl browser_thread_for_ui_; | 552 BrowserThreadImpl browser_thread_for_ui_; |
| 584 std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 553 std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
| 585 std::unique_ptr<BrowserContext> browser_context_; | 554 std::unique_ptr<BrowserContext> browser_context_; |
| 586 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; | 555 std::vector<std::unique_ptr<MockRenderWidgetHostDelegate>> delegates_; |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 EXPECT_TRUE(observer.destroyed()); | 1058 EXPECT_TRUE(observer.destroyed()); |
| 1090 | 1059 |
| 1091 widget_host_ = NULL; | 1060 widget_host_ = NULL; |
| 1092 view_ = NULL; | 1061 view_ = NULL; |
| 1093 } | 1062 } |
| 1094 | 1063 |
| 1095 // Checks that IME-composition-event state is maintained correctly. | 1064 // Checks that IME-composition-event state is maintained correctly. |
| 1096 TEST_F(RenderWidgetHostViewAuraTest, SetCompositionText) { | 1065 TEST_F(RenderWidgetHostViewAuraTest, SetCompositionText) { |
| 1097 view_->InitAsChild(NULL); | 1066 view_->InitAsChild(NULL); |
| 1098 view_->Show(); | 1067 view_->Show(); |
| 1099 ActivateViewForTextInputManager(view_, ui::TEXT_INPUT_TYPE_TEXT); | |
| 1100 | 1068 |
| 1101 ui::CompositionText composition_text; | 1069 ui::CompositionText composition_text; |
| 1102 composition_text.text = base::ASCIIToUTF16("|a|b"); | 1070 composition_text.text = base::ASCIIToUTF16("|a|b"); |
| 1103 | 1071 |
| 1104 // Focused segment | 1072 // Focused segment |
| 1105 composition_text.underlines.push_back( | 1073 composition_text.underlines.push_back( |
| 1106 ui::CompositionUnderline(0, 3, 0xff000000, true, 0x78563412)); | 1074 ui::CompositionUnderline(0, 3, 0xff000000, true, 0x78563412)); |
| 1107 | 1075 |
| 1108 // Non-focused segment, with different background color. | 1076 // Non-focused segment, with different background color. |
| 1109 composition_text.underlines.push_back( | 1077 composition_text.underlines.push_back( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 | 1112 |
| 1145 view_->ImeCancelComposition(); | 1113 view_->ImeCancelComposition(); |
| 1146 EXPECT_FALSE(view_->has_composition_text_); | 1114 EXPECT_FALSE(view_->has_composition_text_); |
| 1147 } | 1115 } |
| 1148 | 1116 |
| 1149 // Checks that sequence of IME-composition-event and mouse-event when mouse | 1117 // Checks that sequence of IME-composition-event and mouse-event when mouse |
| 1150 // clicking to cancel the composition. | 1118 // clicking to cancel the composition. |
| 1151 TEST_F(RenderWidgetHostViewAuraTest, FinishCompositionByMouse) { | 1119 TEST_F(RenderWidgetHostViewAuraTest, FinishCompositionByMouse) { |
| 1152 view_->InitAsChild(NULL); | 1120 view_->InitAsChild(NULL); |
| 1153 view_->Show(); | 1121 view_->Show(); |
| 1154 ActivateViewForTextInputManager(view_, ui::TEXT_INPUT_TYPE_TEXT); | |
| 1155 | 1122 |
| 1156 ui::CompositionText composition_text; | 1123 ui::CompositionText composition_text; |
| 1157 composition_text.text = base::ASCIIToUTF16("|a|b"); | 1124 composition_text.text = base::ASCIIToUTF16("|a|b"); |
| 1158 | 1125 |
| 1159 // Focused segment | 1126 // Focused segment |
| 1160 composition_text.underlines.push_back( | 1127 composition_text.underlines.push_back( |
| 1161 ui::CompositionUnderline(0, 3, 0xff000000, true, 0x78563412)); | 1128 ui::CompositionUnderline(0, 3, 0xff000000, true, 0x78563412)); |
| 1162 | 1129 |
| 1163 // Non-focused segment, with different background color. | 1130 // Non-focused segment, with different background color. |
| 1164 composition_text.underlines.push_back( | 1131 composition_text.underlines.push_back( |
| (...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4020 100, 100, 0, ui::EventTimeForNow(), event_details); | 3987 100, 100, 0, ui::EventTimeForNow(), event_details); |
| 4021 view()->OnGestureEvent(&gesture_event); | 3988 view()->OnGestureEvent(&gesture_event); |
| 4022 | 3989 |
| 4023 EXPECT_TRUE(delegate->context_menu_request_received()); | 3990 EXPECT_TRUE(delegate->context_menu_request_received()); |
| 4024 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); | 3991 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); |
| 4025 #endif | 3992 #endif |
| 4026 | 3993 |
| 4027 RenderViewHostFactory::set_is_real_render_view_host(false); | 3994 RenderViewHostFactory::set_is_real_render_view_host(false); |
| 4028 } | 3995 } |
| 4029 | 3996 |
| 4030 // ---------------------------------------------------------------------------- | |
| 4031 // TextInputManager and IME-Related Tests | |
| 4032 | |
| 4033 // A group of tests which verify that the IME method results are routed to the | |
| 4034 // right RenderWidget in the OOPIF structure. | |
| 4035 // In each test, 3 views are created where one is in process with main frame and | |
| 4036 // the other two are in distinct processes (this makes a total of 4 RWHVs). Then | |
| 4037 // each test will verify the correctness of routing for one of the IME result | |
| 4038 // methods. The method is called on ui::TextInputClient (i.e., RWHV for the tab | |
| 4039 // in aura) and then the test verifies that the IPC is routed to the | |
| 4040 // RenderWidget corresponding to the active view (i.e., the RenderWidget | |
| 4041 // with focused <input>). | |
| 4042 class InputMethodResultAuraTest : public RenderWidgetHostViewAuraTest { | |
| 4043 public: | |
| 4044 InputMethodResultAuraTest() {} | |
| 4045 ~InputMethodResultAuraTest() override {} | |
| 4046 | |
| 4047 void SetUp() override { | |
| 4048 RenderWidgetHostViewAuraTest::SetUp(); | |
| 4049 InitializeAura(); | |
| 4050 | |
| 4051 view_for_first_process_ = CreateViewForProcess(tab_process()); | |
| 4052 | |
| 4053 second_process_host_ = CreateNewProcessHost(); | |
| 4054 view_for_second_process_ = CreateViewForProcess(second_process_host_); | |
| 4055 | |
| 4056 third_process_host_ = CreateNewProcessHost(); | |
| 4057 view_for_third_process_ = CreateViewForProcess(third_process_host_); | |
| 4058 | |
| 4059 views_.insert(views_.begin(), | |
| 4060 {tab_view(), view_for_first_process_, | |
| 4061 view_for_second_process_, view_for_third_process_}); | |
| 4062 processes_.insert(processes_.begin(), | |
| 4063 {tab_process(), tab_process(), second_process_host_, | |
| 4064 third_process_host_}); | |
| 4065 active_view_sequence_.insert(active_view_sequence_.begin(), | |
| 4066 {0, 1, 2, 1, 1, 3, 0, 3, 1}); | |
| 4067 } | |
| 4068 | |
| 4069 void TearDown() override { | |
| 4070 RenderWidgetHost* host_for_second_process = | |
| 4071 view_for_second_process_->GetRenderWidgetHost(); | |
| 4072 view_for_second_process_->Destroy(); | |
| 4073 delete host_for_second_process; | |
| 4074 | |
| 4075 RenderWidgetHost* host_for_third_process = | |
| 4076 view_for_third_process_->GetRenderWidgetHost(); | |
| 4077 view_for_third_process_->Destroy(); | |
| 4078 delete host_for_third_process; | |
| 4079 | |
| 4080 // This one is in-process with tab. The base class will clean the widget. | |
| 4081 view_for_first_process_->Destroy(); | |
| 4082 | |
| 4083 RenderWidgetHostViewAuraTest::TearDown(); | |
| 4084 } | |
| 4085 | |
| 4086 protected: | |
| 4087 const IPC::Message* RunAndReturnIPCSent(const base::Closure closure, | |
| 4088 MockRenderProcessHost* process, | |
| 4089 int32_t message_id) { | |
| 4090 process->sink().ClearMessages(); | |
| 4091 closure.Run(); | |
| 4092 return process->sink().GetFirstMessageMatching(message_id); | |
| 4093 } | |
| 4094 | |
| 4095 MockRenderWidgetHostDelegate* render_widget_host_delegate() const { | |
| 4096 return delegates_.back().get(); | |
| 4097 } | |
| 4098 | |
| 4099 ui::TextInputClient* text_input_client() const { return view_; } | |
| 4100 | |
| 4101 bool has_composition_text() const { | |
| 4102 return tab_view()->has_composition_text_; | |
| 4103 } | |
| 4104 | |
| 4105 MockRenderProcessHost* CreateNewProcessHost() { | |
| 4106 MockRenderProcessHost* process_host = | |
| 4107 new MockRenderProcessHost(browser_context()); | |
| 4108 return process_host; | |
| 4109 } | |
| 4110 | |
| 4111 RenderWidgetHostImpl* CreateRenderWidgetHostForProcess( | |
| 4112 MockRenderProcessHost* process_host) { | |
| 4113 return new RenderWidgetHostImpl(render_widget_host_delegate(), process_host, | |
| 4114 process_host->GetNextRoutingID(), false); | |
| 4115 } | |
| 4116 | |
| 4117 TestRenderWidgetHostView* CreateViewForProcess( | |
| 4118 MockRenderProcessHost* process_host) { | |
| 4119 RenderWidgetHostImpl* host = CreateRenderWidgetHostForProcess(process_host); | |
| 4120 TestRenderWidgetHostView* view = new TestRenderWidgetHostView(host); | |
| 4121 host->SetView(view); | |
| 4122 return view; | |
| 4123 } | |
| 4124 | |
| 4125 void SetHasCompositionTextToTrue() { | |
| 4126 ui::CompositionText composition_text; | |
| 4127 composition_text.text = base::ASCIIToUTF16("text"); | |
| 4128 tab_view()->SetCompositionText(composition_text); | |
| 4129 EXPECT_TRUE(has_composition_text()); | |
| 4130 } | |
| 4131 | |
| 4132 MockRenderProcessHost* tab_process() const { return process_host_; } | |
| 4133 | |
| 4134 RenderWidgetHostViewAura* tab_view() const { return view_; } | |
| 4135 | |
| 4136 std::vector<RenderWidgetHostViewBase*> views_; | |
| 4137 std::vector<MockRenderProcessHost*> processes_; | |
| 4138 // A sequence of indices in [0, 3] which determines the index of a RWHV in | |
| 4139 // |views_|. This sequence is used in the tests to sequentially make a RWHV | |
| 4140 // active for a subsequent IME result method call. | |
| 4141 std::vector<size_t> active_view_sequence_; | |
| 4142 | |
| 4143 private: | |
| 4144 // This will initialize |window_| in RenderWidgetHostViewAura. It is needed | |
| 4145 // for RenderWidgetHostViewAura::GetInputMethod() to work. | |
| 4146 void InitializeAura() { | |
| 4147 view_->InitAsChild(nullptr); | |
| 4148 view_->Show(); | |
| 4149 } | |
| 4150 | |
| 4151 TestRenderWidgetHostView* view_for_first_process_; | |
| 4152 MockRenderProcessHost* second_process_host_; | |
| 4153 TestRenderWidgetHostView* view_for_second_process_; | |
| 4154 MockRenderProcessHost* third_process_host_; | |
| 4155 TestRenderWidgetHostView* view_for_third_process_; | |
| 4156 | |
| 4157 DISALLOW_COPY_AND_ASSIGN(InputMethodResultAuraTest); | |
| 4158 }; | |
| 4159 | |
| 4160 // This test verifies that ui::TextInputClient::SetCompositionText call leads to | |
| 4161 // IPC message InputMsg_ImeSetComposition being sent to the right renderer | |
| 4162 // process. | |
| 4163 TEST_F(InputMethodResultAuraTest, SetCompositionText) { | |
| 4164 base::Closure ime_call = | |
| 4165 base::Bind(&ui::TextInputClient::SetCompositionText, | |
| 4166 base::Unretained(text_input_client()), ui::CompositionText()); | |
| 4167 for (auto index : active_view_sequence_) { | |
| 4168 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); | |
| 4169 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], | |
| 4170 InputMsg_ImeSetComposition::ID)); | |
| 4171 } | |
| 4172 } | |
| 4173 | |
| 4174 // This test verifies that ui::TextInputClient::ConfirmCompositionText call | |
| 4175 // leads to IPC message InputMsg_ImeConfirmComposition being sent to the right | |
| 4176 // renderer process. | |
| 4177 TEST_F(InputMethodResultAuraTest, ConfirmCompositionText) { | |
| 4178 base::Closure ime_call = | |
| 4179 base::Bind(&ui::TextInputClient::ConfirmCompositionText, | |
| 4180 base::Unretained(text_input_client())); | |
| 4181 for (auto index : active_view_sequence_) { | |
| 4182 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); | |
| 4183 SetHasCompositionTextToTrue(); | |
| 4184 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], | |
| 4185 InputMsg_ImeConfirmComposition::ID)); | |
| 4186 } | |
| 4187 } | |
| 4188 | |
| 4189 // This test verifies that ui::TextInputClient::ConfirmCompositionText call | |
| 4190 // leads to IPC message InputMsg_ImeSetComposition being sent to the right | |
| 4191 // renderer process. | |
| 4192 TEST_F(InputMethodResultAuraTest, ClearCompositionText) { | |
| 4193 base::Closure ime_call = | |
| 4194 base::Bind(&ui::TextInputClient::ClearCompositionText, | |
| 4195 base::Unretained(text_input_client())); | |
| 4196 for (auto index : active_view_sequence_) { | |
| 4197 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); | |
| 4198 SetHasCompositionTextToTrue(); | |
| 4199 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], | |
| 4200 InputMsg_ImeSetComposition::ID)); | |
| 4201 } | |
| 4202 } | |
| 4203 | |
| 4204 // This test verifies that ui::TextInputClient::InsertText call leads to IPC | |
| 4205 // message InputMsg_ImeSetComposition being sent to the right renderer process. | |
| 4206 TEST_F(InputMethodResultAuraTest, InsertText) { | |
| 4207 base::Closure ime_call = | |
| 4208 base::Bind(&ui::TextInputClient::InsertText, | |
| 4209 base::Unretained(text_input_client()), base::string16()); | |
| 4210 for (auto index : active_view_sequence_) { | |
| 4211 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); | |
| 4212 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], | |
| 4213 InputMsg_ImeConfirmComposition::ID)); | |
| 4214 } | |
| 4215 } | |
| 4216 | |
| 4217 } // namespace content | 3997 } // namespace content |
| OLD | NEW |