OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |