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

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

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