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

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

Issue 938123003: Prevent hang monitor restarts when hidden (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 "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/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 985
986 // Wait long enough for the second timeout and see if it fired. 986 // Wait long enough for the second timeout and see if it fired.
987 base::MessageLoop::current()->PostDelayedTask( 987 base::MessageLoop::current()->PostDelayedTask(
988 FROM_HERE, 988 FROM_HERE,
989 base::MessageLoop::QuitClosure(), 989 base::MessageLoop::QuitClosure(),
990 TimeDelta::FromMilliseconds(25)); 990 TimeDelta::FromMilliseconds(25));
991 base::MessageLoop::current()->Run(); 991 base::MessageLoop::current()->Run();
992 EXPECT_TRUE(host_->unresponsive_timer_fired()); 992 EXPECT_TRUE(host_->unresponsive_timer_fired());
993 } 993 }
994 994
995 // Test that the hang monitor timer is effectively disabled when the widget is
996 // hidden.
997 TEST_F(RenderWidgetHostTest, HangMonitorTimeoutDisabledWhenHidden) {
998 host_->StartHangMonitorTimeout(TimeDelta::FromMicroseconds(1));
999
1000 // Hiding the widget should deactivate the timeout.
1001 host_->WasHidden();
1002
1003 // The timeout should not fire.
1004 EXPECT_FALSE(host_->unresponsive_timer_fired());
1005 base::MessageLoop::current()->PostDelayedTask(
1006 FROM_HERE,
1007 base::MessageLoop::QuitClosure(),
1008 TimeDelta::FromMicroseconds(2));
1009 base::MessageLoop::current()->Run();
1010 EXPECT_FALSE(host_->unresponsive_timer_fired());
1011
1012 // The timeout should never reactivate while hidden.
1013 host_->StartHangMonitorTimeout(TimeDelta::FromMicroseconds(1));
1014 base::MessageLoop::current()->PostDelayedTask(
1015 FROM_HERE,
1016 base::MessageLoop::QuitClosure(),
1017 TimeDelta::FromMicroseconds(2));
1018 base::MessageLoop::current()->Run();
1019 EXPECT_FALSE(host_->unresponsive_timer_fired());
1020
1021 // Showing the widget should restore normal timeout behavior.
1022 host_->WasShown(ui::LatencyInfo());
1023 host_->StartHangMonitorTimeout(TimeDelta::FromMicroseconds(1));
1024 base::MessageLoop::current()->PostDelayedTask(
1025 FROM_HERE,
1026 base::MessageLoop::QuitClosure(),
1027 TimeDelta::FromMicroseconds(2));
1028 base::MessageLoop::current()->Run();
1029 EXPECT_TRUE(host_->unresponsive_timer_fired());
1030 }
1031
995 // Test that the hang monitor catches two input events but only one ack. 1032 // Test that the hang monitor catches two input events but only one ack.
996 // This can happen if the second input event causes the renderer to hang. 1033 // This can happen if the second input event causes the renderer to hang.
997 // This test will catch a regression of crbug.com/111185. 1034 // This test will catch a regression of crbug.com/111185.
998 TEST_F(RenderWidgetHostTest, MultipleInputEvents) { 1035 TEST_F(RenderWidgetHostTest, MultipleInputEvents) {
999 // Configure the host to wait 10ms before considering 1036 // Configure the host to wait 10ms before considering
1000 // the renderer hung. 1037 // the renderer hung.
1001 host_->set_hung_renderer_delay_ms(10); 1038 host_->set_hung_renderer_delay_ms(10);
1002 1039
1003 // Send two events but only one ack. 1040 // Send two events but only one ack.
1004 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); 1041 SimulateKeyboardEvent(WebInputEvent::RawKeyDown);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 // Having an initial size set means that the size information had been sent 1506 // Having an initial size set means that the size information had been sent
1470 // with the reqiest to new up the RenderView and so subsequent WasResized 1507 // with the reqiest to new up the RenderView and so subsequent WasResized
1471 // calls should not result in new IPC (unless the size has actually changed). 1508 // calls should not result in new IPC (unless the size has actually changed).
1472 host_->WasResized(); 1509 host_->WasResized();
1473 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 1510 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
1474 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); 1511 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size);
1475 EXPECT_TRUE(host_->resize_ack_pending_); 1512 EXPECT_TRUE(host_->resize_ack_pending_);
1476 } 1513 }
1477 1514
1478 } // namespace content 1515 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698