// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <memory> #include <utility> #include "base/functional/bind.h" #include "base/memory/raw_ptr.h" #include "base/synchronization/waitable_event.h" #include "base/task/sequenced_task_runner.h" #include "base/test/task_environment.h" #include "base/threading/thread.h" #include "base/time/time.h" #include "media/audio/alive_checker.h" #include "testing/gtest/include/gtest/gtest.h" namespace media { namespace { int kCheckIntervalMs = …; int kTimeoutMs = …; } // namespace class MockPowerObserverHelper : public PowerObserverHelper { … }; class AliveCheckerTest : public testing::Test { … }; // Start the checker, don't send alive notifications, and run until it detects // dead. Verify that it only detects once. Repeat once. TEST_F(AliveCheckerTest, NoAliveNotificationsDetectTwice) { … } // Setup the checker to stop at first alive notification. Start it and notify // that the client is alive once. Verify that we get no dead detection. TEST_F(AliveCheckerTest, StopAtFirstAliveNotification_DoNotify) { … } // Setup the checker to stop at first alive notification. Start it and run until // it detects dead. TEST_F(AliveCheckerTest, StopAtFirstAliveNotification_DontNotify) { … } // Setup the checker to pause checking when suspended. Suspend and verify that // it doesn't detect dead. Start the checker, don't send alive notifications, // and and verify that it doesn't detect dead. Resume and run until it detects // dead. TEST_F(AliveCheckerTest, SuspendResume_StartBetweenSuspendAndResume) { … } // Setup the checker to stop at first alive notification and pause checking when // suspended. Start the checker, send one alive notifications, and verify it // doesn't detect dead. Suspend and verify that it doesn't detect dead. Resume // and and verify that it doesn't detect dead. TEST_F(AliveCheckerTest, SuspendResumeWithAutoStop_NotifyBeforeSuspend) { … } // Setup the checker to stop at first alive notification and pause checking when // suspended. Start the checker, send one alive notifications, and verify it // doesn't detect dead. Start it again, suspend and verify that it doesn't // detect dead. Resume and run until detected dead. TEST_F(AliveCheckerTest, SuspendResumeWithAutoStop_NotifyBeforeSuspendAndRestart) { … } // Setup the checker to stop at first alive notification and pause checking when // suspended. Start the checker, suspend. Send one alive notification and // verify it doesn't detected dead. Resume and verify it doesn't detected dead. TEST_F(AliveCheckerTest, SuspendResumeWithAutoStop_NotifyBetweenSuspendAndResume) { … } // Setup the checker to stop at first alive notification and pause checking when // suspended. Start the checker, suspend, resume, send one alive notification // and verify it doesn't detected dead. TEST_F(AliveCheckerTest, SuspendResumeWithAutoStop_NotifyAfterResume) { … } // Setup the checker to stop at first alive notification and pause checking when // suspended. Start the checker suspend, and and verify it doesn't detected // dead. Resume and run until it detects dead. TEST_F(AliveCheckerTest, SuspendResumeWithAutoStop_DontNotify) { … } } // namespace media