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

Side by Side Diff: base/threading/watchdog_unittest.cc

Issue 10004001: Add virtual and OVERRIDE to base/ implementation files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback from chromium-dev Created 8 years, 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/threading/watchdog.h" 5 #include "base/threading/watchdog.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/synchronization/spin_wait.h" 8 #include "base/synchronization/spin_wait.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.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 namespace base { 13 namespace base {
14 14
15 namespace { 15 namespace {
16 16
17 //------------------------------------------------------------------------------ 17 //------------------------------------------------------------------------------
18 // Provide a derived class to facilitate testing. 18 // Provide a derived class to facilitate testing.
19 19
20 class WatchdogCounter : public Watchdog { 20 class WatchdogCounter : public Watchdog {
21 public: 21 public:
22 WatchdogCounter(const TimeDelta& duration, 22 WatchdogCounter(const TimeDelta& duration,
23 const std::string& thread_watched_name, 23 const std::string& thread_watched_name,
24 bool enabled) 24 bool enabled)
25 : Watchdog(duration, thread_watched_name, enabled), alarm_counter_(0) { 25 : Watchdog(duration, thread_watched_name, enabled), alarm_counter_(0) {
jar (doing other things) 2012/04/05 21:11:30 nit: one init per line.
26 } 26 }
27 27
28 virtual ~WatchdogCounter() {} 28 virtual ~WatchdogCounter() {}
29 29
30 virtual void Alarm() { 30 virtual void Alarm() OVERRIDE {
31 alarm_counter_++; 31 alarm_counter_++;
32 Watchdog::Alarm(); 32 Watchdog::Alarm();
33 } 33 }
34 34
35 int alarm_counter() { return alarm_counter_; } 35 int alarm_counter() { return alarm_counter_; }
36 36
37 private: 37 private:
38 int alarm_counter_; 38 int alarm_counter_;
39 39
40 DISALLOW_COPY_AND_ASSIGN(WatchdogCounter); 40 DISALLOW_COPY_AND_ASSIGN(WatchdogCounter);
41 }; 41 };
42 42
43 class WatchdogTest : public testing::Test { 43 class WatchdogTest : public testing::Test {
44 public: 44 public:
45 void SetUp() { 45 virtual void SetUp() OVERRIDE {
46 Watchdog::ResetStaticData(); 46 Watchdog::ResetStaticData();
47 } 47 }
48 }; 48 };
49 49
50 } // namespace 50 } // namespace
51 51
52 //------------------------------------------------------------------------------ 52 //------------------------------------------------------------------------------
53 // Actual tests 53 // Actual tests
54 54
55 // Minimal constructor/destructor test. 55 // Minimal constructor/destructor test.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Set a time greater than the timeout into the past. 132 // Set a time greater than the timeout into the past.
133 watchdog.ArmSomeTimeDeltaAgo(TimeDelta::FromSeconds(10)); 133 watchdog.ArmSomeTimeDeltaAgo(TimeDelta::FromSeconds(10));
134 // It should almost instantly go off, but certainly in less than 5 minutes. 134 // It should almost instantly go off, but certainly in less than 5 minutes.
135 SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(TimeDelta::FromMinutes(5), 135 SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(TimeDelta::FromMinutes(5),
136 watchdog.alarm_counter() > 0); 136 watchdog.alarm_counter() > 0);
137 137
138 EXPECT_EQ(1, watchdog.alarm_counter()); 138 EXPECT_EQ(1, watchdog.alarm_counter());
139 } 139 }
140 140
141 } // namespace base 141 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698