| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Tests for Watchdog class. | 5 // Tests for Watchdog class. |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/watchdog.h" | 8 #include "base/watchdog.h" |
| 9 #include "base/spin_wait.h" | 9 #include "base/spin_wait.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 using base::TimeDelta; |
| 14 |
| 13 namespace { | 15 namespace { |
| 14 | 16 |
| 15 //------------------------------------------------------------------------------ | 17 //------------------------------------------------------------------------------ |
| 16 // Provide a derived class to facilitate testing. | 18 // Provide a derived class to facilitate testing. |
| 17 | 19 |
| 18 // TODO(JAR): Remove default argument from constructor, and make mandatory. | 20 // TODO(JAR): Remove default argument from constructor, and make mandatory. |
| 19 class WatchdogCounter : public Watchdog { | 21 class WatchdogCounter : public Watchdog { |
| 20 public: | 22 public: |
| 21 WatchdogCounter(const TimeDelta& duration, | 23 WatchdogCounter(const TimeDelta& duration, |
| 22 const std::wstring& thread_watched_name, | 24 const std::wstring& thread_watched_name, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 watchdog.ArmSomeTimeDeltaAgo(TimeDelta::FromSeconds(2)); | 122 watchdog.ArmSomeTimeDeltaAgo(TimeDelta::FromSeconds(2)); |
| 121 // It should almost instantly go off, but certainly in less than a second. | 123 // It should almost instantly go off, but certainly in less than a second. |
| 122 SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(TimeDelta::FromSeconds(1), | 124 SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(TimeDelta::FromSeconds(1), |
| 123 watchdog.alarm_counter() > 0); | 125 watchdog.alarm_counter() > 0); |
| 124 | 126 |
| 125 EXPECT_EQ(1, watchdog.alarm_counter()); | 127 EXPECT_EQ(1, watchdog.alarm_counter()); |
| 126 } | 128 } |
| 127 | 129 |
| 128 } // namespace | 130 } // namespace |
| 129 | 131 |
| OLD | NEW |