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

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

Issue 9572035: Convert uses of int ms to TimeDelta in content/browser, ipc, and webkit/plugins. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 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/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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 718 }
719 719
720 // Test that the hang monitor timer expires properly if a new timer is started 720 // Test that the hang monitor timer expires properly if a new timer is started
721 // while one is in progress (see crbug.com/11007). 721 // while one is in progress (see crbug.com/11007).
722 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { 722 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) {
723 // Start with a short timeout. 723 // Start with a short timeout.
724 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 724 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
725 725
726 // Immediately try to add a long 30 second timeout. 726 // Immediately try to add a long 30 second timeout.
727 EXPECT_FALSE(host_->unresponsive_timer_fired()); 727 EXPECT_FALSE(host_->unresponsive_timer_fired());
728 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(30000)); 728 host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30));
729 729
730 // Wait long enough for first timeout and see if it fired. 730 // Wait long enough for first timeout and see if it fired.
731 MessageLoop::current()->PostDelayedTask(FROM_HERE, 731 MessageLoop::current()->PostDelayedTask(
732 MessageLoop::QuitClosure(), 10); 732 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10));
733 MessageLoop::current()->Run(); 733 MessageLoop::current()->Run();
734 EXPECT_TRUE(host_->unresponsive_timer_fired()); 734 EXPECT_TRUE(host_->unresponsive_timer_fired());
735 } 735 }
736 736
737 // Test that the hang monitor timer expires properly if it is started, stopped, 737 // Test that the hang monitor timer expires properly if it is started, stopped,
738 // and then started again. 738 // and then started again.
739 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) { 739 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) {
740 // Start with a short timeout, then stop it. 740 // Start with a short timeout, then stop it.
741 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 741 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
742 host_->StopHangMonitorTimeout(); 742 host_->StopHangMonitorTimeout();
743 743
744 // Start it again to ensure it still works. 744 // Start it again to ensure it still works.
745 EXPECT_FALSE(host_->unresponsive_timer_fired()); 745 EXPECT_FALSE(host_->unresponsive_timer_fired());
746 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 746 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
747 747
748 // Wait long enough for first timeout and see if it fired. 748 // Wait long enough for first timeout and see if it fired.
749 MessageLoop::current()->PostDelayedTask(FROM_HERE, 749 MessageLoop::current()->PostDelayedTask(
750 MessageLoop::QuitClosure(), 40); 750 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40));
751 MessageLoop::current()->Run(); 751 MessageLoop::current()->Run();
752 EXPECT_TRUE(host_->unresponsive_timer_fired()); 752 EXPECT_TRUE(host_->unresponsive_timer_fired());
753 } 753 }
754 754
755 // Test that the hang monitor catches two input events but only one ack. 755 // Test that the hang monitor catches two input events but only one ack.
756 // This can happen if the second input event causes the renderer to hang. 756 // This can happen if the second input event causes the renderer to hang.
757 // This test will catch a regression of crbug.com/111185. 757 // This test will catch a regression of crbug.com/111185.
758 TEST_F(RenderWidgetHostTest, MultipleInputEvents) { 758 TEST_F(RenderWidgetHostTest, MultipleInputEvents) {
759 // Configure the host to wait 10ms before considering 759 // Configure the host to wait 10ms before considering
760 // the renderer hung. 760 // the renderer hung.
761 host_->set_hung_renderer_delay_ms(10); 761 host_->set_hung_renderer_delay_ms(10);
762 762
763 // Send two events but only one ack. 763 // Send two events but only one ack.
764 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); 764 SimulateKeyboardEvent(WebInputEvent::RawKeyDown);
765 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); 765 SimulateKeyboardEvent(WebInputEvent::RawKeyDown);
766 SendInputEventACK(WebInputEvent::RawKeyDown, true); 766 SendInputEventACK(WebInputEvent::RawKeyDown, true);
767 767
768 // Wait long enough for first timeout and see if it fired. 768 // Wait long enough for first timeout and see if it fired.
769 MessageLoop::current()->PostDelayedTask(FROM_HERE, 769 MessageLoop::current()->PostDelayedTask(
770 MessageLoop::QuitClosure(), 40); 770 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40));
771 MessageLoop::current()->Run(); 771 MessageLoop::current()->Run();
772 EXPECT_TRUE(host_->unresponsive_timer_fired()); 772 EXPECT_TRUE(host_->unresponsive_timer_fired());
773 } 773 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/database_message_filter.cc ('k') | content/browser/trace_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698