| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 OverscrollMode current_mode_; | 154 OverscrollMode current_mode_; |
| 155 OverscrollMode completed_mode_; | 155 OverscrollMode completed_mode_; |
| 156 float delta_x_; | 156 float delta_x_; |
| 157 float delta_y_; | 157 float delta_y_; |
| 158 | 158 |
| 159 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); | 159 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { | 162 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
| 163 public: | 163 public: |
| 164 MockRenderWidgetHostDelegate() : rwh_(nullptr), is_fullscreen_(false) {} | 164 MockRenderWidgetHostDelegate() |
| 165 : rwh_(nullptr), is_fullscreen_(false), last_device_scale_factor_(0.0) {} |
| 165 ~MockRenderWidgetHostDelegate() override {} | 166 ~MockRenderWidgetHostDelegate() override {} |
| 166 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } | 167 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } |
| 167 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; } | 168 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; } |
| 168 void set_is_fullscreen(bool is_fullscreen) { is_fullscreen_ = is_fullscreen; } | 169 void set_is_fullscreen(bool is_fullscreen) { is_fullscreen_ = is_fullscreen; } |
| 169 TextInputManager* GetTextInputManager() override { | 170 TextInputManager* GetTextInputManager() override { |
| 170 return &text_input_manager_; | 171 return &text_input_manager_; |
| 171 } | 172 } |
| 172 | 173 |
| 174 double get_last_device_scale_factor() { return last_device_scale_factor_; } |
| 175 void UpdateDeviceScaleFactor(double device_scale_factor) override { |
| 176 last_device_scale_factor_ = device_scale_factor; |
| 177 } |
| 178 |
| 173 protected: | 179 protected: |
| 174 // RenderWidgetHostDelegate: | 180 // RenderWidgetHostDelegate: |
| 175 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 181 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 176 bool* is_keyboard_shortcut) override { | 182 bool* is_keyboard_shortcut) override { |
| 177 last_event_.reset(new NativeWebKeyboardEvent(event)); | 183 last_event_.reset(new NativeWebKeyboardEvent(event)); |
| 178 return true; | 184 return true; |
| 179 } | 185 } |
| 180 void Cut() override {} | 186 void Cut() override {} |
| 181 void Copy() override {} | 187 void Copy() override {} |
| 182 void Paste() override {} | 188 void Paste() override {} |
| 183 void SelectAll() override {} | 189 void SelectAll() override {} |
| 184 void SendScreenRects() override { | 190 void SendScreenRects() override { |
| 185 if (rwh_) | 191 if (rwh_) |
| 186 rwh_->SendScreenRects(); | 192 rwh_->SendScreenRects(); |
| 187 } | 193 } |
| 188 bool IsFullscreenForCurrentTab() const override { return is_fullscreen_; } | 194 bool IsFullscreenForCurrentTab() const override { return is_fullscreen_; } |
| 189 | 195 |
| 190 private: | 196 private: |
| 191 std::unique_ptr<NativeWebKeyboardEvent> last_event_; | 197 std::unique_ptr<NativeWebKeyboardEvent> last_event_; |
| 192 RenderWidgetHostImpl* rwh_; | 198 RenderWidgetHostImpl* rwh_; |
| 193 bool is_fullscreen_; | 199 bool is_fullscreen_; |
| 194 TextInputManager text_input_manager_; | 200 TextInputManager text_input_manager_; |
| 201 double last_device_scale_factor_; |
| 195 | 202 |
| 196 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); | 203 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); |
| 197 }; | 204 }; |
| 198 | 205 |
| 199 // Simple observer that keeps track of changes to a window for tests. | 206 // Simple observer that keeps track of changes to a window for tests. |
| 200 class TestWindowObserver : public aura::WindowObserver { | 207 class TestWindowObserver : public aura::WindowObserver { |
| 201 public: | 208 public: |
| 202 explicit TestWindowObserver(aura::Window* window_to_observe) | 209 explicit TestWindowObserver(aura::Window* window_to_observe) |
| 203 : window_(window_to_observe) { | 210 : window_(window_to_observe) { |
| 204 window_->AddObserver(this); | 211 window_->AddObserver(this); |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 "100x100", | 1425 "100x100", |
| 1419 std::get<0>(params).physical_backing_size.ToString()); // backing size | 1426 std::get<0>(params).physical_backing_size.ToString()); // backing size |
| 1420 } | 1427 } |
| 1421 | 1428 |
| 1422 widget_host_->ResetSizeAndRepaintPendingFlags(); | 1429 widget_host_->ResetSizeAndRepaintPendingFlags(); |
| 1423 sink_->ClearMessages(); | 1430 sink_->ClearMessages(); |
| 1424 | 1431 |
| 1425 aura_test_helper_->test_screen()->SetDeviceScaleFactor(2.0f); | 1432 aura_test_helper_->test_screen()->SetDeviceScaleFactor(2.0f); |
| 1426 EXPECT_EQ("200x200", view_->GetPhysicalBackingSize().ToString()); | 1433 EXPECT_EQ("200x200", view_->GetPhysicalBackingSize().ToString()); |
| 1427 // Extra ScreenInfoChanged message for |parent_view_|. | 1434 // Extra ScreenInfoChanged message for |parent_view_|. |
| 1428 EXPECT_EQ(1u, sink_->message_count()); | 1435 EXPECT_EQ(0u, sink_->message_count()); |
| 1429 { | 1436 auto view_delegate = static_cast<MockRenderWidgetHostDelegate*>( |
| 1430 const IPC::Message* msg = sink_->GetMessageAt(0); | 1437 static_cast<RenderWidgetHostImpl*>(view_->GetRenderWidgetHost()) |
| 1431 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); | 1438 ->delegate()); |
| 1432 ViewMsg_Resize::Param params; | 1439 EXPECT_EQ(2.0f, view_delegate->get_last_device_scale_factor()); |
| 1433 ViewMsg_Resize::Read(msg, ¶ms); | |
| 1434 EXPECT_EQ(2.0f, std::get<0>(params).screen_info.deviceScaleFactor); | |
| 1435 EXPECT_EQ("100x100", std::get<0>(params).new_size.ToString()); // dip size | |
| 1436 EXPECT_EQ( | |
| 1437 "200x200", | |
| 1438 std::get<0>(params).physical_backing_size.ToString()); // backing size | |
| 1439 } | |
| 1440 | 1440 |
| 1441 widget_host_->ResetSizeAndRepaintPendingFlags(); | 1441 widget_host_->ResetSizeAndRepaintPendingFlags(); |
| 1442 sink_->ClearMessages(); | 1442 sink_->ClearMessages(); |
| 1443 | 1443 |
| 1444 aura_test_helper_->test_screen()->SetDeviceScaleFactor(1.0f); | 1444 aura_test_helper_->test_screen()->SetDeviceScaleFactor(1.0f); |
| 1445 // Extra ScreenInfoChanged message for |parent_view_|. | 1445 // Extra ScreenInfoChanged message for |parent_view_|. |
| 1446 EXPECT_EQ(1u, sink_->message_count()); | 1446 EXPECT_EQ(0u, sink_->message_count()); |
| 1447 EXPECT_EQ(1.0f, view_delegate->get_last_device_scale_factor()); |
| 1447 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); | 1448 EXPECT_EQ("100x100", view_->GetPhysicalBackingSize().ToString()); |
| 1448 { | |
| 1449 const IPC::Message* msg = sink_->GetMessageAt(0); | |
| 1450 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); | |
| 1451 ViewMsg_Resize::Param params; | |
| 1452 ViewMsg_Resize::Read(msg, ¶ms); | |
| 1453 EXPECT_EQ(1.0f, std::get<0>(params).screen_info.deviceScaleFactor); | |
| 1454 EXPECT_EQ("100x100", std::get<0>(params).new_size.ToString()); // dip size | |
| 1455 EXPECT_EQ( | |
| 1456 "100x100", | |
| 1457 std::get<0>(params).physical_backing_size.ToString()); // backing size | |
| 1458 } | |
| 1459 } | 1449 } |
| 1460 | 1450 |
| 1461 // Checks that InputMsg_CursorVisibilityChange IPC messages are dispatched | 1451 // Checks that InputMsg_CursorVisibilityChange IPC messages are dispatched |
| 1462 // to the renderer at the correct times. | 1452 // to the renderer at the correct times. |
| 1463 TEST_F(RenderWidgetHostViewAuraTest, CursorVisibilityChange) { | 1453 TEST_F(RenderWidgetHostViewAuraTest, CursorVisibilityChange) { |
| 1464 view_->InitAsChild(NULL); | 1454 view_->InitAsChild(NULL); |
| 1465 aura::client::ParentWindowWithContext( | 1455 aura::client::ParentWindowWithContext( |
| 1466 view_->GetNativeView(), | 1456 view_->GetNativeView(), |
| 1467 parent_view_->GetNativeView()->GetRootWindow(), | 1457 parent_view_->GetNativeView()->GetRootWindow(), |
| 1468 gfx::Rect()); | 1458 gfx::Rect()); |
| (...skipping 2759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4228 for (auto index : active_view_sequence_) { | 4218 for (auto index : active_view_sequence_) { |
| 4229 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); | 4219 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); |
| 4230 SetHasCompositionTextToTrue(); | 4220 SetHasCompositionTextToTrue(); |
| 4231 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_finish_session_call, | 4221 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_finish_session_call, |
| 4232 processes_[index], | 4222 processes_[index], |
| 4233 InputMsg_ImeConfirmComposition::ID)); | 4223 InputMsg_ImeConfirmComposition::ID)); |
| 4234 } | 4224 } |
| 4235 } | 4225 } |
| 4236 | 4226 |
| 4237 } // namespace content | 4227 } // namespace content |
| OLD | NEW |