| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <tuple> | 9 #include <tuple> |
| 10 | 10 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override { | 406 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override { |
| 407 unhandled_keyboard_event_type_ = event.type(); | 407 unhandled_keyboard_event_type_ = event.type(); |
| 408 unhandled_keyboard_event_called_ = true; | 408 unhandled_keyboard_event_called_ = true; |
| 409 } | 409 } |
| 410 | 410 |
| 411 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override { | 411 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override { |
| 412 handle_wheel_event_called_ = true; | 412 handle_wheel_event_called_ = true; |
| 413 return handle_wheel_event_; | 413 return handle_wheel_event_; |
| 414 } | 414 } |
| 415 | 415 |
| 416 void RendererUnresponsive(RenderWidgetHostImpl* render_widget_host, | 416 void RendererUnresponsive(RenderWidgetHostImpl* render_widget_host) override { |
| 417 RendererUnresponsiveType type) override { | |
| 418 unresponsive_timer_fired_ = true; | 417 unresponsive_timer_fired_ = true; |
| 419 } | 418 } |
| 420 | 419 |
| 421 void Cut() override {} | 420 void Cut() override {} |
| 422 void Copy() override {} | 421 void Copy() override {} |
| 423 void Paste() override {} | 422 void Paste() override {} |
| 424 void SelectAll() override {} | 423 void SelectAll() override {} |
| 425 | 424 |
| 426 private: | 425 private: |
| 427 bool prehandle_keyboard_event_; | 426 bool prehandle_keyboard_event_; |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 SendInputEventACK(WebInputEvent::GestureTwoFingerTap, | 1112 SendInputEventACK(WebInputEvent::GestureTwoFingerTap, |
| 1114 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1113 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1115 EXPECT_EQ(WebInputEvent::GestureTwoFingerTap, view_->gesture_event_type()); | 1114 EXPECT_EQ(WebInputEvent::GestureTwoFingerTap, view_->gesture_event_type()); |
| 1116 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, view_->ack_result()); | 1115 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, view_->ack_result()); |
| 1117 } | 1116 } |
| 1118 | 1117 |
| 1119 // Test that the hang monitor timer expires properly if a new timer is started | 1118 // Test that the hang monitor timer expires properly if a new timer is started |
| 1120 // while one is in progress (see crbug.com/11007). | 1119 // while one is in progress (see crbug.com/11007). |
| 1121 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { | 1120 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { |
| 1122 // Start with a short timeout. | 1121 // Start with a short timeout. |
| 1123 host_->StartHangMonitorTimeout( | 1122 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10), |
| 1124 TimeDelta::FromMilliseconds(10), WebInputEvent::Undefined, | 1123 WebInputEvent::Undefined); |
| 1125 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN); | |
| 1126 | 1124 |
| 1127 // Immediately try to add a long 30 second timeout. | 1125 // Immediately try to add a long 30 second timeout. |
| 1128 EXPECT_FALSE(delegate_->unresponsive_timer_fired()); | 1126 EXPECT_FALSE(delegate_->unresponsive_timer_fired()); |
| 1129 host_->StartHangMonitorTimeout( | 1127 host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30), |
| 1130 TimeDelta::FromSeconds(30), WebInputEvent::Undefined, | 1128 WebInputEvent::Undefined); |
| 1131 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN); | |
| 1132 | 1129 |
| 1133 // Wait long enough for first timeout and see if it fired. | 1130 // Wait long enough for first timeout and see if it fired. |
| 1134 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1131 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1135 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 1132 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 1136 TimeDelta::FromMilliseconds(10)); | 1133 TimeDelta::FromMilliseconds(10)); |
| 1137 base::RunLoop().Run(); | 1134 base::RunLoop().Run(); |
| 1138 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); | 1135 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); |
| 1139 } | 1136 } |
| 1140 | 1137 |
| 1141 // Test that the hang monitor timer expires properly if it is started, stopped, | 1138 // Test that the hang monitor timer expires properly if it is started, stopped, |
| 1142 // and then started again. | 1139 // and then started again. |
| 1143 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) { | 1140 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) { |
| 1144 // Start with a short timeout, then stop it. | 1141 // Start with a short timeout, then stop it. |
| 1145 host_->StartHangMonitorTimeout( | 1142 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10), |
| 1146 TimeDelta::FromMilliseconds(10), WebInputEvent::Undefined, | 1143 WebInputEvent::Undefined); |
| 1147 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN); | |
| 1148 host_->StopHangMonitorTimeout(); | 1144 host_->StopHangMonitorTimeout(); |
| 1149 | 1145 |
| 1150 // Start it again to ensure it still works. | 1146 // Start it again to ensure it still works. |
| 1151 EXPECT_FALSE(delegate_->unresponsive_timer_fired()); | 1147 EXPECT_FALSE(delegate_->unresponsive_timer_fired()); |
| 1152 host_->StartHangMonitorTimeout( | 1148 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10), |
| 1153 TimeDelta::FromMilliseconds(10), WebInputEvent::Undefined, | 1149 WebInputEvent::Undefined); |
| 1154 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN); | |
| 1155 | 1150 |
| 1156 // Wait long enough for first timeout and see if it fired. | 1151 // Wait long enough for first timeout and see if it fired. |
| 1157 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1152 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1158 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 1153 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 1159 TimeDelta::FromMilliseconds(40)); | 1154 TimeDelta::FromMilliseconds(40)); |
| 1160 base::RunLoop().Run(); | 1155 base::RunLoop().Run(); |
| 1161 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); | 1156 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); |
| 1162 } | 1157 } |
| 1163 | 1158 |
| 1164 // Test that the hang monitor timer expires properly if it is started, then | 1159 // Test that the hang monitor timer expires properly if it is started, then |
| 1165 // updated to a shorter duration. | 1160 // updated to a shorter duration. |
| 1166 TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) { | 1161 TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) { |
| 1167 // Start with a timeout. | 1162 // Start with a timeout. |
| 1168 host_->StartHangMonitorTimeout( | 1163 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(100), |
| 1169 TimeDelta::FromMilliseconds(100), WebInputEvent::Undefined, | 1164 WebInputEvent::Undefined); |
| 1170 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN); | |
| 1171 | 1165 |
| 1172 // Start it again with shorter delay. | 1166 // Start it again with shorter delay. |
| 1173 EXPECT_FALSE(delegate_->unresponsive_timer_fired()); | 1167 EXPECT_FALSE(delegate_->unresponsive_timer_fired()); |
| 1174 host_->StartHangMonitorTimeout( | 1168 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(20), |
| 1175 TimeDelta::FromMilliseconds(20), WebInputEvent::Undefined, | 1169 WebInputEvent::Undefined); |
| 1176 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN); | |
| 1177 | 1170 |
| 1178 // Wait long enough for the second timeout and see if it fired. | 1171 // Wait long enough for the second timeout and see if it fired. |
| 1179 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1172 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1180 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 1173 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 1181 TimeDelta::FromMilliseconds(25)); | 1174 TimeDelta::FromMilliseconds(25)); |
| 1182 base::RunLoop().Run(); | 1175 base::RunLoop().Run(); |
| 1183 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); | 1176 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); |
| 1184 } | 1177 } |
| 1185 | 1178 |
| 1186 // Test that the hang monitor timer is effectively disabled when the widget is | 1179 // Test that the hang monitor timer is effectively disabled when the widget is |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 ui::LatencyInfo()); | 1794 ui::LatencyInfo()); |
| 1802 | 1795 |
| 1803 | 1796 |
| 1804 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1797 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
| 1805 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1798 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
| 1806 | 1799 |
| 1807 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1800 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
| 1808 } | 1801 } |
| 1809 | 1802 |
| 1810 } // namespace content | 1803 } // namespace content |
| OLD | NEW |