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

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 1410313006: Separate RenderViewHost from RenderWidgetHost, part 5: move calls to the RenderWidgetHostDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 1 month 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
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 class MockRenderWidgetHost : public RenderWidgetHostImpl { 145 class MockRenderWidgetHost : public RenderWidgetHostImpl {
146 public: 146 public:
147 MockRenderWidgetHost(RenderWidgetHostDelegate* delegate, 147 MockRenderWidgetHost(RenderWidgetHostDelegate* delegate,
148 RenderProcessHost* process, 148 RenderProcessHost* process,
149 int routing_id) 149 int routing_id)
150 : RenderWidgetHostImpl( 150 : RenderWidgetHostImpl(
151 delegate, 151 delegate,
152 process, 152 process,
153 routing_id, 153 routing_id,
154 false), 154 false),
155 unresponsive_timer_fired_(false),
156 new_content_rendering_timeout_fired_(false) { 155 new_content_rendering_timeout_fired_(false) {
157 acked_touch_event_type_ = blink::WebInputEvent::Undefined; 156 acked_touch_event_type_ = blink::WebInputEvent::Undefined;
158 } 157 }
159 158
160 // Allow poking at a few private members. 159 // Allow poking at a few private members.
161 using RenderWidgetHostImpl::GetResizeParams; 160 using RenderWidgetHostImpl::GetResizeParams;
162 using RenderWidgetHostImpl::OnUpdateRect; 161 using RenderWidgetHostImpl::OnUpdateRect;
163 using RenderWidgetHostImpl::RendererExited; 162 using RenderWidgetHostImpl::RendererExited;
164 using RenderWidgetHostImpl::SetInitialRenderSizeParams; 163 using RenderWidgetHostImpl::SetInitialRenderSizeParams;
165 using RenderWidgetHostImpl::old_resize_params_; 164 using RenderWidgetHostImpl::old_resize_params_;
166 using RenderWidgetHostImpl::is_hidden_; 165 using RenderWidgetHostImpl::is_hidden_;
167 using RenderWidgetHostImpl::resize_ack_pending_; 166 using RenderWidgetHostImpl::resize_ack_pending_;
168 using RenderWidgetHostImpl::input_router_; 167 using RenderWidgetHostImpl::input_router_;
169 168
170 void OnTouchEventAck(const TouchEventWithLatencyInfo& event, 169 void OnTouchEventAck(const TouchEventWithLatencyInfo& event,
171 InputEventAckState ack_result) override { 170 InputEventAckState ack_result) override {
172 // Sniff touch acks. 171 // Sniff touch acks.
173 acked_touch_event_type_ = event.event.type; 172 acked_touch_event_type_ = event.event.type;
174 RenderWidgetHostImpl::OnTouchEventAck(event, ack_result); 173 RenderWidgetHostImpl::OnTouchEventAck(event, ack_result);
175 } 174 }
176 175
177 bool unresponsive_timer_fired() const {
178 return unresponsive_timer_fired_;
179 }
180
181 bool new_content_rendering_timeout_fired() const { 176 bool new_content_rendering_timeout_fired() const {
182 return new_content_rendering_timeout_fired_; 177 return new_content_rendering_timeout_fired_;
183 } 178 }
184 179
185 void DisableGestureDebounce() { 180 void DisableGestureDebounce() {
186 input_router_.reset(new InputRouterImpl( 181 input_router_.reset(new InputRouterImpl(
187 process_, this, this, routing_id_, InputRouterImpl::Config())); 182 process_, this, this, routing_id_, InputRouterImpl::Config()));
188 } 183 }
189 184
190 WebInputEvent::Type acked_touch_event_type() const { 185 WebInputEvent::Type acked_touch_event_type() const {
191 return acked_touch_event_type_; 186 return acked_touch_event_type_;
192 } 187 }
193 188
194 void SetupForInputRouterTest() { 189 void SetupForInputRouterTest() {
195 input_router_.reset(new MockInputRouter(this)); 190 input_router_.reset(new MockInputRouter(this));
196 } 191 }
197 192
198 MockInputRouter* mock_input_router() { 193 MockInputRouter* mock_input_router() {
199 return static_cast<MockInputRouter*>(input_router_.get()); 194 return static_cast<MockInputRouter*>(input_router_.get());
200 } 195 }
201 196
202 protected: 197 protected:
203 void NotifyRendererUnresponsive() override {
204 unresponsive_timer_fired_ = true;
205 }
206
207 void NotifyNewContentRenderingTimeoutForTesting() override { 198 void NotifyNewContentRenderingTimeoutForTesting() override {
208 new_content_rendering_timeout_fired_ = true; 199 new_content_rendering_timeout_fired_ = true;
209 } 200 }
210 201
211 bool unresponsive_timer_fired_;
212 bool new_content_rendering_timeout_fired_; 202 bool new_content_rendering_timeout_fired_;
213 WebInputEvent::Type acked_touch_event_type_; 203 WebInputEvent::Type acked_touch_event_type_;
214 204
215 private: 205 private:
216 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost); 206 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost);
217 }; 207 };
218 208
219 namespace { 209 namespace {
220 210
221 // RenderWidgetHostProcess ----------------------------------------------------- 211 // RenderWidgetHostProcess -----------------------------------------------------
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { 332 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate {
343 public: 333 public:
344 MockRenderWidgetHostDelegate() 334 MockRenderWidgetHostDelegate()
345 : prehandle_keyboard_event_(false), 335 : prehandle_keyboard_event_(false),
346 prehandle_keyboard_event_is_shortcut_(false), 336 prehandle_keyboard_event_is_shortcut_(false),
347 prehandle_keyboard_event_called_(false), 337 prehandle_keyboard_event_called_(false),
348 prehandle_keyboard_event_type_(WebInputEvent::Undefined), 338 prehandle_keyboard_event_type_(WebInputEvent::Undefined),
349 unhandled_keyboard_event_called_(false), 339 unhandled_keyboard_event_called_(false),
350 unhandled_keyboard_event_type_(WebInputEvent::Undefined), 340 unhandled_keyboard_event_type_(WebInputEvent::Undefined),
351 handle_wheel_event_(false), 341 handle_wheel_event_(false),
352 handle_wheel_event_called_(false) {} 342 handle_wheel_event_called_(false),
343 unresponsive_timer_fired_(false) {}
353 ~MockRenderWidgetHostDelegate() override {} 344 ~MockRenderWidgetHostDelegate() override {}
354 345
355 // Tests that make sure we ignore keyboard event acknowledgments to events we 346 // Tests that make sure we ignore keyboard event acknowledgments to events we
356 // didn't send work by making sure we didn't call UnhandledKeyboardEvent(). 347 // didn't send work by making sure we didn't call UnhandledKeyboardEvent().
357 bool unhandled_keyboard_event_called() const { 348 bool unhandled_keyboard_event_called() const {
358 return unhandled_keyboard_event_called_; 349 return unhandled_keyboard_event_called_;
359 } 350 }
360 351
361 WebInputEvent::Type unhandled_keyboard_event_type() const { 352 WebInputEvent::Type unhandled_keyboard_event_type() const {
362 return unhandled_keyboard_event_type_; 353 return unhandled_keyboard_event_type_;
(...skipping 14 matching lines...) Expand all
377 void set_handle_wheel_event(bool handle) { 368 void set_handle_wheel_event(bool handle) {
378 handle_wheel_event_ = handle; 369 handle_wheel_event_ = handle;
379 } 370 }
380 371
381 void set_prehandle_keyboard_event_is_shortcut(bool is_shortcut) { 372 void set_prehandle_keyboard_event_is_shortcut(bool is_shortcut) {
382 prehandle_keyboard_event_is_shortcut_ = is_shortcut; 373 prehandle_keyboard_event_is_shortcut_ = is_shortcut;
383 } 374 }
384 375
385 bool handle_wheel_event_called() const { return handle_wheel_event_called_; } 376 bool handle_wheel_event_called() const { return handle_wheel_event_called_; }
386 377
378 bool unresponsive_timer_fired() const { return unresponsive_timer_fired_; }
379
387 protected: 380 protected:
388 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 381 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
389 bool* is_keyboard_shortcut) override { 382 bool* is_keyboard_shortcut) override {
390 prehandle_keyboard_event_type_ = event.type; 383 prehandle_keyboard_event_type_ = event.type;
391 prehandle_keyboard_event_called_ = true; 384 prehandle_keyboard_event_called_ = true;
392 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_; 385 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_;
393 return prehandle_keyboard_event_; 386 return prehandle_keyboard_event_;
394 } 387 }
395 388
396 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override { 389 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override {
397 unhandled_keyboard_event_type_ = event.type; 390 unhandled_keyboard_event_type_ = event.type;
398 unhandled_keyboard_event_called_ = true; 391 unhandled_keyboard_event_called_ = true;
399 } 392 }
400 393
401 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override { 394 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override {
402 handle_wheel_event_called_ = true; 395 handle_wheel_event_called_ = true;
403 return handle_wheel_event_; 396 return handle_wheel_event_;
404 } 397 }
405 398
399 void RendererUnresponsive(RenderWidgetHostImpl* render_widget_host) override {
400 unresponsive_timer_fired_ = true;
401 }
402
406 void Cut() override {} 403 void Cut() override {}
407 void Copy() override {} 404 void Copy() override {}
408 void Paste() override {} 405 void Paste() override {}
409 void SelectAll() override {} 406 void SelectAll() override {}
410 407
411 private: 408 private:
412 bool prehandle_keyboard_event_; 409 bool prehandle_keyboard_event_;
413 bool prehandle_keyboard_event_is_shortcut_; 410 bool prehandle_keyboard_event_is_shortcut_;
414 bool prehandle_keyboard_event_called_; 411 bool prehandle_keyboard_event_called_;
415 WebInputEvent::Type prehandle_keyboard_event_type_; 412 WebInputEvent::Type prehandle_keyboard_event_type_;
416 413
417 bool unhandled_keyboard_event_called_; 414 bool unhandled_keyboard_event_called_;
418 WebInputEvent::Type unhandled_keyboard_event_type_; 415 WebInputEvent::Type unhandled_keyboard_event_type_;
419 416
420 bool handle_wheel_event_; 417 bool handle_wheel_event_;
421 bool handle_wheel_event_called_; 418 bool handle_wheel_event_called_;
419
420 bool unresponsive_timer_fired_;
422 }; 421 };
423 422
424 // RenderWidgetHostTest -------------------------------------------------------- 423 // RenderWidgetHostTest --------------------------------------------------------
425 424
426 class RenderWidgetHostTest : public testing::Test { 425 class RenderWidgetHostTest : public testing::Test {
427 public: 426 public:
428 RenderWidgetHostTest() 427 RenderWidgetHostTest()
429 : process_(NULL), 428 : process_(NULL),
430 handle_key_press_event_(false), 429 handle_key_press_event_(false),
431 handle_mouse_event_(false), 430 handle_mouse_event_(false),
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, view_->ack_result()); 1058 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, view_->ack_result());
1060 } 1059 }
1061 1060
1062 // Test that the hang monitor timer expires properly if a new timer is started 1061 // Test that the hang monitor timer expires properly if a new timer is started
1063 // while one is in progress (see crbug.com/11007). 1062 // while one is in progress (see crbug.com/11007).
1064 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { 1063 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) {
1065 // Start with a short timeout. 1064 // Start with a short timeout.
1066 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 1065 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
1067 1066
1068 // Immediately try to add a long 30 second timeout. 1067 // Immediately try to add a long 30 second timeout.
1069 EXPECT_FALSE(host_->unresponsive_timer_fired()); 1068 EXPECT_FALSE(delegate_->unresponsive_timer_fired());
1070 host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30)); 1069 host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30));
1071 1070
1072 // Wait long enough for first timeout and see if it fired. 1071 // Wait long enough for first timeout and see if it fired.
1073 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1072 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1074 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1073 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1075 TimeDelta::FromMilliseconds(10)); 1074 TimeDelta::FromMilliseconds(10));
1076 base::MessageLoop::current()->Run(); 1075 base::MessageLoop::current()->Run();
1077 EXPECT_TRUE(host_->unresponsive_timer_fired()); 1076 EXPECT_TRUE(delegate_->unresponsive_timer_fired());
1078 } 1077 }
1079 1078
1080 // Test that the hang monitor timer expires properly if it is started, stopped, 1079 // Test that the hang monitor timer expires properly if it is started, stopped,
1081 // and then started again. 1080 // and then started again.
1082 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) { 1081 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) {
1083 // Start with a short timeout, then stop it. 1082 // Start with a short timeout, then stop it.
1084 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 1083 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
1085 host_->StopHangMonitorTimeout(); 1084 host_->StopHangMonitorTimeout();
1086 1085
1087 // Start it again to ensure it still works. 1086 // Start it again to ensure it still works.
1088 EXPECT_FALSE(host_->unresponsive_timer_fired()); 1087 EXPECT_FALSE(delegate_->unresponsive_timer_fired());
1089 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 1088 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
1090 1089
1091 // Wait long enough for first timeout and see if it fired. 1090 // Wait long enough for first timeout and see if it fired.
1092 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1091 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1093 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1092 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1094 TimeDelta::FromMilliseconds(40)); 1093 TimeDelta::FromMilliseconds(40));
1095 base::MessageLoop::current()->Run(); 1094 base::MessageLoop::current()->Run();
1096 EXPECT_TRUE(host_->unresponsive_timer_fired()); 1095 EXPECT_TRUE(delegate_->unresponsive_timer_fired());
1097 } 1096 }
1098 1097
1099 // Test that the hang monitor timer expires properly if it is started, then 1098 // Test that the hang monitor timer expires properly if it is started, then
1100 // updated to a shorter duration. 1099 // updated to a shorter duration.
1101 TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) { 1100 TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) {
1102 // Start with a timeout. 1101 // Start with a timeout.
1103 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(100)); 1102 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(100));
1104 1103
1105 // Start it again with shorter delay. 1104 // Start it again with shorter delay.
1106 EXPECT_FALSE(host_->unresponsive_timer_fired()); 1105 EXPECT_FALSE(delegate_->unresponsive_timer_fired());
1107 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(20)); 1106 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(20));
1108 1107
1109 // Wait long enough for the second timeout and see if it fired. 1108 // Wait long enough for the second timeout and see if it fired.
1110 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1109 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1111 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1110 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1112 TimeDelta::FromMilliseconds(25)); 1111 TimeDelta::FromMilliseconds(25));
1113 base::MessageLoop::current()->Run(); 1112 base::MessageLoop::current()->Run();
1114 EXPECT_TRUE(host_->unresponsive_timer_fired()); 1113 EXPECT_TRUE(delegate_->unresponsive_timer_fired());
1115 } 1114 }
1116 1115
1117 // Test that the hang monitor timer is effectively disabled when the widget is 1116 // Test that the hang monitor timer is effectively disabled when the widget is
1118 // hidden. 1117 // hidden.
1119 TEST_F(RenderWidgetHostTest, HangMonitorTimeoutDisabledForInputWhenHidden) { 1118 TEST_F(RenderWidgetHostTest, HangMonitorTimeoutDisabledForInputWhenHidden) {
1120 host_->set_hung_renderer_delay(base::TimeDelta::FromMicroseconds(1)); 1119 host_->set_hung_renderer_delay(base::TimeDelta::FromMicroseconds(1));
1121 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); 1120 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false);
1122 1121
1123 // Hiding the widget should deactivate the timeout. 1122 // Hiding the widget should deactivate the timeout.
1124 host_->WasHidden(); 1123 host_->WasHidden();
1125 1124
1126 // The timeout should not fire. 1125 // The timeout should not fire.
1127 EXPECT_FALSE(host_->unresponsive_timer_fired()); 1126 EXPECT_FALSE(delegate_->unresponsive_timer_fired());
1128 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1127 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1129 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1128 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1130 TimeDelta::FromMicroseconds(2)); 1129 TimeDelta::FromMicroseconds(2));
1131 base::MessageLoop::current()->Run(); 1130 base::MessageLoop::current()->Run();
1132 EXPECT_FALSE(host_->unresponsive_timer_fired()); 1131 EXPECT_FALSE(delegate_->unresponsive_timer_fired());
1133 1132
1134 // The timeout should never reactivate while hidden. 1133 // The timeout should never reactivate while hidden.
1135 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); 1134 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false);
1136 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1135 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1137 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1136 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1138 TimeDelta::FromMicroseconds(2)); 1137 TimeDelta::FromMicroseconds(2));
1139 base::MessageLoop::current()->Run(); 1138 base::MessageLoop::current()->Run();
1140 EXPECT_FALSE(host_->unresponsive_timer_fired()); 1139 EXPECT_FALSE(delegate_->unresponsive_timer_fired());
1141 1140
1142 // Showing the widget should restore the timeout, as the events have 1141 // Showing the widget should restore the timeout, as the events have
1143 // not yet been ack'ed. 1142 // not yet been ack'ed.
1144 host_->WasShown(ui::LatencyInfo()); 1143 host_->WasShown(ui::LatencyInfo());
1145 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1144 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1146 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1145 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1147 TimeDelta::FromMicroseconds(2)); 1146 TimeDelta::FromMicroseconds(2));
1148 base::MessageLoop::current()->Run(); 1147 base::MessageLoop::current()->Run();
1149 EXPECT_TRUE(host_->unresponsive_timer_fired()); 1148 EXPECT_TRUE(delegate_->unresponsive_timer_fired());
1150 } 1149 }
1151 1150
1152 // Test that the hang monitor catches two input events but only one ack. 1151 // Test that the hang monitor catches two input events but only one ack.
1153 // This can happen if the second input event causes the renderer to hang. 1152 // This can happen if the second input event causes the renderer to hang.
1154 // This test will catch a regression of crbug.com/111185. 1153 // This test will catch a regression of crbug.com/111185.
1155 TEST_F(RenderWidgetHostTest, MultipleInputEvents) { 1154 TEST_F(RenderWidgetHostTest, MultipleInputEvents) {
1156 // Configure the host to wait 10ms before considering 1155 // Configure the host to wait 10ms before considering
1157 // the renderer hung. 1156 // the renderer hung.
1158 host_->set_hung_renderer_delay(base::TimeDelta::FromMicroseconds(10)); 1157 host_->set_hung_renderer_delay(base::TimeDelta::FromMicroseconds(10));
1159 1158
1160 // Send two events but only one ack. 1159 // Send two events but only one ack.
1161 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); 1160 SimulateKeyboardEvent(WebInputEvent::RawKeyDown);
1162 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); 1161 SimulateKeyboardEvent(WebInputEvent::RawKeyDown);
1163 SendInputEventACK(WebInputEvent::RawKeyDown, 1162 SendInputEventACK(WebInputEvent::RawKeyDown,
1164 INPUT_EVENT_ACK_STATE_CONSUMED); 1163 INPUT_EVENT_ACK_STATE_CONSUMED);
1165 1164
1166 // Wait long enough for first timeout and see if it fired. 1165 // Wait long enough for first timeout and see if it fired.
1167 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1166 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1168 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1167 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1169 TimeDelta::FromMicroseconds(20)); 1168 TimeDelta::FromMicroseconds(20));
1170 base::MessageLoop::current()->Run(); 1169 base::MessageLoop::current()->Run();
1171 EXPECT_TRUE(host_->unresponsive_timer_fired()); 1170 EXPECT_TRUE(delegate_->unresponsive_timer_fired());
1172 } 1171 }
1173 1172
1174 // Test that the rendering timeout for newly loaded content fires 1173 // Test that the rendering timeout for newly loaded content fires
1175 // when enough time passes without receiving a new compositor frame. 1174 // when enough time passes without receiving a new compositor frame.
1176 TEST_F(RenderWidgetHostTest, NewContentRenderingTimeout) { 1175 TEST_F(RenderWidgetHostTest, NewContentRenderingTimeout) {
1177 host_->set_new_content_rendering_delay_for_testing( 1176 host_->set_new_content_rendering_delay_for_testing(
1178 base::TimeDelta::FromMicroseconds(10)); 1177 base::TimeDelta::FromMicroseconds(10));
1179 1178
1180 // Test immediate start and stop, ensuring that the timeout doesn't fire. 1179 // Test immediate start and stop, ensuring that the timeout doesn't fire.
1181 host_->StartNewContentRenderingTimeout(); 1180 host_->StartNewContentRenderingTimeout();
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 // Having an initial size set means that the size information had been sent 1646 // Having an initial size set means that the size information had been sent
1648 // with the reqiest to new up the RenderView and so subsequent WasResized 1647 // with the reqiest to new up the RenderView and so subsequent WasResized
1649 // calls should not result in new IPC (unless the size has actually changed). 1648 // calls should not result in new IPC (unless the size has actually changed).
1650 host_->WasResized(); 1649 host_->WasResized();
1651 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 1650 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
1652 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); 1651 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size);
1653 EXPECT_TRUE(host_->resize_ack_pending_); 1652 EXPECT_TRUE(host_->resize_ack_pending_);
1654 } 1653 }
1655 1654
1656 } // namespace content 1655 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698