// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/threading/watchdog.h" #include <atomic> #include "base/logging.h" #include "base/test/spin_wait.h" #include "base/threading/platform_thread.h" #include "base/time/time.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { namespace { //------------------------------------------------------------------------------ // Provide a derived class to facilitate testing. class WatchdogCounter : public Watchdog::Delegate { … }; class WatchdogTest : public testing::Test { … }; } // namespace //------------------------------------------------------------------------------ // Actual tests // Minimal constructor/destructor test. TEST_F(WatchdogTest, StartupShutdownTest) { … } // Test ability to call Arm and Disarm repeatedly. TEST_F(WatchdogTest, ArmDisarmTest) { … } // Make sure a basic alarm fires when the time has expired. TEST_F(WatchdogTest, AlarmTest) { … } // Make sure a basic alarm fires when the time has expired. TEST_F(WatchdogTest, AlarmPriorTimeTest) { … } // Make sure a disable alarm does nothing, even if we arm it. TEST_F(WatchdogTest, ConstructorDisabledTest) { … } // Make sure Disarming will prevent firing, even after Arming. TEST_F(WatchdogTest, DisarmTest) { … } } // namespace base