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

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

Issue 2155383002: Add an histogram to differentiate between hang types of the renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 months 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 <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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override { 398 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override {
399 unhandled_keyboard_event_type_ = event.type; 399 unhandled_keyboard_event_type_ = event.type;
400 unhandled_keyboard_event_called_ = true; 400 unhandled_keyboard_event_called_ = true;
401 } 401 }
402 402
403 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override { 403 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override {
404 handle_wheel_event_called_ = true; 404 handle_wheel_event_called_ = true;
405 return handle_wheel_event_; 405 return handle_wheel_event_;
406 } 406 }
407 407
408 void RendererUnresponsive(RenderWidgetHostImpl* render_widget_host) override { 408 void RendererUnresponsive(RenderWidgetHostImpl* render_widget_host,
409 RendererUnresponsiveType type) override {
409 unresponsive_timer_fired_ = true; 410 unresponsive_timer_fired_ = true;
410 } 411 }
411 412
412 void Cut() override {} 413 void Cut() override {}
413 void Copy() override {} 414 void Copy() override {}
414 void Paste() override {} 415 void Paste() override {}
415 void SelectAll() override {} 416 void SelectAll() override {}
416 417
417 private: 418 private:
418 bool prehandle_keyboard_event_; 419 bool prehandle_keyboard_event_;
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 SendInputEventACK(WebInputEvent::GestureTwoFingerTap, 1064 SendInputEventACK(WebInputEvent::GestureTwoFingerTap,
1064 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1065 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1065 EXPECT_EQ(WebInputEvent::GestureTwoFingerTap, view_->gesture_event_type()); 1066 EXPECT_EQ(WebInputEvent::GestureTwoFingerTap, view_->gesture_event_type());
1066 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, view_->ack_result()); 1067 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, view_->ack_result());
1067 } 1068 }
1068 1069
1069 // Test that the hang monitor timer expires properly if a new timer is started 1070 // Test that the hang monitor timer expires properly if a new timer is started
1070 // while one is in progress (see crbug.com/11007). 1071 // while one is in progress (see crbug.com/11007).
1071 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { 1072 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) {
1072 // Start with a short timeout. 1073 // Start with a short timeout.
1073 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 1074 host_->StartHangMonitorTimeout(
1075 TimeDelta::FromMilliseconds(10),
1076 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN);
1074 1077
1075 // Immediately try to add a long 30 second timeout. 1078 // Immediately try to add a long 30 second timeout.
1076 EXPECT_FALSE(delegate_->unresponsive_timer_fired()); 1079 EXPECT_FALSE(delegate_->unresponsive_timer_fired());
1077 host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30)); 1080 host_->StartHangMonitorTimeout(
1081 TimeDelta::FromSeconds(30),
1082 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN);
1078 1083
1079 // Wait long enough for first timeout and see if it fired. 1084 // Wait long enough for first timeout and see if it fired.
1080 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1085 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1081 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1086 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1082 TimeDelta::FromMilliseconds(10)); 1087 TimeDelta::FromMilliseconds(10));
1083 base::MessageLoop::current()->Run(); 1088 base::MessageLoop::current()->Run();
1084 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); 1089 EXPECT_TRUE(delegate_->unresponsive_timer_fired());
1085 } 1090 }
1086 1091
1087 // Test that the hang monitor timer expires properly if it is started, stopped, 1092 // Test that the hang monitor timer expires properly if it is started, stopped,
1088 // and then started again. 1093 // and then started again.
1089 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) { 1094 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) {
1090 // Start with a short timeout, then stop it. 1095 // Start with a short timeout, then stop it.
1091 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 1096 host_->StartHangMonitorTimeout(
1097 TimeDelta::FromMilliseconds(10),
1098 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN);
1092 host_->StopHangMonitorTimeout(); 1099 host_->StopHangMonitorTimeout();
1093 1100
1094 // Start it again to ensure it still works. 1101 // Start it again to ensure it still works.
1095 EXPECT_FALSE(delegate_->unresponsive_timer_fired()); 1102 EXPECT_FALSE(delegate_->unresponsive_timer_fired());
1096 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 1103 host_->StartHangMonitorTimeout(
1104 TimeDelta::FromMilliseconds(10),
1105 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN);
1097 1106
1098 // Wait long enough for first timeout and see if it fired. 1107 // Wait long enough for first timeout and see if it fired.
1099 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1108 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1100 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1109 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1101 TimeDelta::FromMilliseconds(40)); 1110 TimeDelta::FromMilliseconds(40));
1102 base::MessageLoop::current()->Run(); 1111 base::MessageLoop::current()->Run();
1103 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); 1112 EXPECT_TRUE(delegate_->unresponsive_timer_fired());
1104 } 1113 }
1105 1114
1106 // Test that the hang monitor timer expires properly if it is started, then 1115 // Test that the hang monitor timer expires properly if it is started, then
1107 // updated to a shorter duration. 1116 // updated to a shorter duration.
1108 TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) { 1117 TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) {
1109 // Start with a timeout. 1118 // Start with a timeout.
1110 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(100)); 1119 host_->StartHangMonitorTimeout(
1120 TimeDelta::FromMilliseconds(100),
1121 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN);
1111 1122
1112 // Start it again with shorter delay. 1123 // Start it again with shorter delay.
1113 EXPECT_FALSE(delegate_->unresponsive_timer_fired()); 1124 EXPECT_FALSE(delegate_->unresponsive_timer_fired());
1114 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(20)); 1125 host_->StartHangMonitorTimeout(
1126 TimeDelta::FromMilliseconds(20),
1127 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN);
1115 1128
1116 // Wait long enough for the second timeout and see if it fired. 1129 // Wait long enough for the second timeout and see if it fired.
1117 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 1130 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1118 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 1131 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
1119 TimeDelta::FromMilliseconds(25)); 1132 TimeDelta::FromMilliseconds(25));
1120 base::MessageLoop::current()->Run(); 1133 base::MessageLoop::current()->Run();
1121 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); 1134 EXPECT_TRUE(delegate_->unresponsive_timer_fired());
1122 } 1135 }
1123 1136
1124 // Test that the hang monitor timer is effectively disabled when the widget is 1137 // Test that the hang monitor timer is effectively disabled when the widget is
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 ui::LatencyInfo()); 1687 ui::LatencyInfo());
1675 1688
1676 1689
1677 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). 1690 // Tests RWHI::ForwardWheelEventWithLatencyInfo().
1678 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); 1691 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo());
1679 1692
1680 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); 1693 ASSERT_FALSE(host_->input_router()->HasPendingEvents());
1681 } 1694 }
1682 1695
1683 } // namespace content 1696 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698