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

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

Issue 541203002: fix for high resolution timer on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits fixes Created 6 years, 3 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
« no previous file with comments | « base/message_loop/message_loop.cc ('k') | base/time/time_win.cc » ('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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 TEST(MessageLoopTest, IOHandler) { 719 TEST(MessageLoopTest, IOHandler) {
720 RunTest_IOHandler(); 720 RunTest_IOHandler();
721 } 721 }
722 722
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 Time::EnableHighResolutionTimer(true);
729 730
730 const TimeDelta kFastTimer = TimeDelta::FromMilliseconds(5); 731 const TimeDelta kFastTimer = TimeDelta::FromMilliseconds(5);
731 const TimeDelta kSlowTimer = TimeDelta::FromMilliseconds(100); 732 const TimeDelta kSlowTimer = TimeDelta::FromMilliseconds(100);
732 733
733 EXPECT_FALSE(loop.HasHighResolutionTasks()); 734 EXPECT_FALSE(loop.HasHighResolutionTasks());
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 EXPECT_TRUE(loop.HasHighResolutionTasks());
738 loop.Run(); 739 loop.Run();
739 EXPECT_FALSE(loop.HasHighResolutionTasks()); 740 EXPECT_FALSE(loop.HasHighResolutionTasks());
740 EXPECT_FALSE(Time::IsHighResolutionTimerInUse()); 741 EXPECT_FALSE(Time::IsHighResolutionTimerInUse());
741 // Check that a slow task does not trigger the high resolution logic. 742 // Check that a slow task does not trigger the high resolution logic.
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 EXPECT_FALSE(loop.HasHighResolutionTasks());
745 loop.Run(); 746 loop.Run();
746 EXPECT_FALSE(loop.HasHighResolutionTasks()); 747 EXPECT_FALSE(loop.HasHighResolutionTasks());
748 Time::EnableHighResolutionTimer(false);
747 } 749 }
748 750
749 #endif // defined(OS_WIN) 751 #endif // defined(OS_WIN)
750 752
751 #if defined(OS_POSIX) && !defined(OS_NACL) 753 #if defined(OS_POSIX) && !defined(OS_NACL)
752 754
753 namespace { 755 namespace {
754 756
755 class QuitDelegate : public MessageLoopForIO::Watcher { 757 class QuitDelegate : public MessageLoopForIO::Watcher {
756 public: 758 public:
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 1007
1006 ASSERT_TRUE(PostMessage(message_hwnd, kSignalMsg, 0, 1)); 1008 ASSERT_TRUE(PostMessage(message_hwnd, kSignalMsg, 0, 1));
1007 1009
1008 loop.Run(); 1010 loop.Run();
1009 1011
1010 ASSERT_TRUE(UnregisterClass(MAKEINTATOM(atom), instance)); 1012 ASSERT_TRUE(UnregisterClass(MAKEINTATOM(atom), instance));
1011 } 1013 }
1012 #endif // defined(OS_WIN) 1014 #endif // defined(OS_WIN)
1013 1015
1014 } // namespace base 1016 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop.cc ('k') | base/time/time_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698