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

Side by Side Diff: base/message_loop/message_loop_unittest.cc

Issue 407073004: Revert of High resolution timer fix for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « base/message_loop/message_loop.cc ('k') | base/message_loop/message_pump.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 TEST(MessageLoopTest, WaitForIO) { 723 TEST(MessageLoopTest, WaitForIO) {
724 RunTest_WaitForIO(); 724 RunTest_WaitForIO();
725 } 725 }
726 726
727 TEST(MessageLoopTest, HighResolutionTimer) { 727 TEST(MessageLoopTest, HighResolutionTimer) {
728 MessageLoop loop; 728 MessageLoop loop;
729 729
730 const TimeDelta kFastTimer = TimeDelta::FromMilliseconds(5); 730 const TimeDelta kFastTimer = TimeDelta::FromMilliseconds(5);
731 const TimeDelta kSlowTimer = TimeDelta::FromMilliseconds(100); 731 const TimeDelta kSlowTimer = TimeDelta::FromMilliseconds(100);
732 732
733 EXPECT_FALSE(loop.HasHighResolutionTasks()); 733 EXPECT_FALSE(loop.IsHighResolutionTimerEnabledForTesting());
734
734 // Post a fast task to enable the high resolution timers. 735 // Post a fast task to enable the high resolution timers.
735 loop.PostDelayedTask(FROM_HERE, Bind(&PostNTasksThenQuit, 1), 736 loop.PostDelayedTask(FROM_HERE, Bind(&PostNTasksThenQuit, 1),
736 kFastTimer); 737 kFastTimer);
737 EXPECT_TRUE(loop.HasHighResolutionTasks());
738 loop.Run(); 738 loop.Run();
739 EXPECT_FALSE(loop.HasHighResolutionTasks()); 739 EXPECT_TRUE(loop.IsHighResolutionTimerEnabledForTesting());
740 EXPECT_FALSE(Time::IsHighResolutionTimerInUse()); 740
741 // Check that a slow task does not trigger the high resolution logic. 741 // Post a slow task and verify high resolution timers
742 // are still enabled.
742 loop.PostDelayedTask(FROM_HERE, Bind(&PostNTasksThenQuit, 1), 743 loop.PostDelayedTask(FROM_HERE, Bind(&PostNTasksThenQuit, 1),
743 kSlowTimer); 744 kSlowTimer);
744 EXPECT_FALSE(loop.HasHighResolutionTasks());
745 loop.Run(); 745 loop.Run();
746 EXPECT_FALSE(loop.HasHighResolutionTasks()); 746 EXPECT_TRUE(loop.IsHighResolutionTimerEnabledForTesting());
747
748 // Wait for a while so that high-resolution mode elapses.
749 PlatformThread::Sleep(TimeDelta::FromMilliseconds(
750 MessageLoop::kHighResolutionTimerModeLeaseTimeMs));
751
752 // Post a slow task to disable the high resolution timers.
753 loop.PostDelayedTask(FROM_HERE, Bind(&PostNTasksThenQuit, 1),
754 kSlowTimer);
755 loop.Run();
756 EXPECT_FALSE(loop.IsHighResolutionTimerEnabledForTesting());
747 } 757 }
748 758
749 #endif // defined(OS_WIN) 759 #endif // defined(OS_WIN)
750 760
751 #if defined(OS_POSIX) && !defined(OS_NACL) 761 #if defined(OS_POSIX) && !defined(OS_NACL)
752 762
753 namespace { 763 namespace {
754 764
755 class QuitDelegate : public MessageLoopForIO::Watcher { 765 class QuitDelegate : public MessageLoopForIO::Watcher {
756 public: 766 public:
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 1015
1006 ASSERT_TRUE(PostMessage(message_hwnd, kSignalMsg, 0, 1)); 1016 ASSERT_TRUE(PostMessage(message_hwnd, kSignalMsg, 0, 1));
1007 1017
1008 loop.Run(); 1018 loop.Run();
1009 1019
1010 ASSERT_TRUE(UnregisterClass(MAKEINTATOM(atom), instance)); 1020 ASSERT_TRUE(UnregisterClass(MAKEINTATOM(atom), instance));
1011 } 1021 }
1012 #endif // defined(OS_WIN) 1022 #endif // defined(OS_WIN)
1013 1023
1014 } // namespace base 1024 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop.cc ('k') | base/message_loop/message_pump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698