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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/timer.h" | 8 #include "base/timer.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/renderer_host/backing_store.h" | 10 #include "content/browser/renderer_host/backing_store.h" |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 763 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
764 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 764 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
765 | 765 |
766 // Wait long enough for first timeout and see if it fired. | 766 // Wait long enough for first timeout and see if it fired. |
767 MessageLoop::current()->PostDelayedTask( | 767 MessageLoop::current()->PostDelayedTask( |
768 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); | 768 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); |
769 MessageLoop::current()->Run(); | 769 MessageLoop::current()->Run(); |
770 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 770 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
771 } | 771 } |
772 | 772 |
| 773 // Test that the hang monitor timer expires properly if it is started, then |
| 774 // updated to a shorter duration. |
| 775 TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) { |
| 776 // Start with a timeout. |
| 777 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(100)); |
| 778 |
| 779 // Start it again with shorter delay. |
| 780 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
| 781 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(20)); |
| 782 |
| 783 // Wait long enough for first timeout and see if it fired. |
| 784 MessageLoop::current()->PostDelayedTask( |
| 785 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(25)); |
| 786 MessageLoop::current()->Run(); |
| 787 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
| 788 } |
| 789 |
773 // Test that the hang monitor catches two input events but only one ack. | 790 // Test that the hang monitor catches two input events but only one ack. |
774 // This can happen if the second input event causes the renderer to hang. | 791 // This can happen if the second input event causes the renderer to hang. |
775 // This test will catch a regression of crbug.com/111185. | 792 // This test will catch a regression of crbug.com/111185. |
776 TEST_F(RenderWidgetHostTest, MultipleInputEvents) { | 793 TEST_F(RenderWidgetHostTest, MultipleInputEvents) { |
777 // Configure the host to wait 10ms before considering | 794 // Configure the host to wait 10ms before considering |
778 // the renderer hung. | 795 // the renderer hung. |
779 host_->set_hung_renderer_delay_ms(10); | 796 host_->set_hung_renderer_delay_ms(10); |
780 | 797 |
781 // Send two events but only one ack. | 798 // Send two events but only one ack. |
782 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 799 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
783 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 800 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
784 SendInputEventACK(WebInputEvent::RawKeyDown, true); | 801 SendInputEventACK(WebInputEvent::RawKeyDown, true); |
785 | 802 |
786 // Wait long enough for first timeout and see if it fired. | 803 // Wait long enough for first timeout and see if it fired. |
787 MessageLoop::current()->PostDelayedTask( | 804 MessageLoop::current()->PostDelayedTask( |
788 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); | 805 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); |
789 MessageLoop::current()->Run(); | 806 MessageLoop::current()->Run(); |
790 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 807 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
791 } | 808 } |
OLD | NEW |