#include "media/audio/audio_thread_hang_monitor.h"
#include <optional>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
ElementsAre;
Test;
HangAction;
namespace media {
namespace {
constexpr int kStarted = …;
constexpr int kHung = …;
constexpr int kRecovered = …;
constexpr base::TimeDelta kShortHangDeadline = …;
constexpr base::TimeDelta kLongHangDeadline = …;
}
class AudioThreadHangMonitorTest : public Test { … };
TEST_F(AudioThreadHangMonitorTest, LogsThreadStarted) { … }
TEST_F(AudioThreadHangMonitorTest, DoesNotLogThreadHungWhenOk) { … }
TEST_F(AudioThreadHangMonitorTest, LogsHungWhenAudioThreadIsBlocked) { … }
TEST_F(AudioThreadHangMonitorTest, DoesNotLogThreadHungWithShortDeadline) { … }
TEST_F(AudioThreadHangMonitorTest, LogsThreadHungWithShortDeadline) { … }
TEST_F(AudioThreadHangMonitorTest, DoesNotLogThreadHungWithLongDeadline) { … }
TEST_F(AudioThreadHangMonitorTest, LogsThreadHungWithLongDeadline) { … }
TEST_F(AudioThreadHangMonitorTest, ZeroDeadlineMeansDefaultDeadline) { … }
TEST_F(AudioThreadHangMonitorTest,
LogsRecoveredWhenAudioThreadIsBlockedThenRecovers) { … }
TEST_F(AudioThreadHangMonitorTest, NoHangActionWhenOk) { … }
TEST_F(AudioThreadHangMonitorTest, DumpsWhenAudioThreadIsBlocked) { … }
TEST_F(AudioThreadHangMonitorTest, TerminatesProcessWhenAudioThreadIsBlocked) { … }
TEST_F(AudioThreadHangMonitorTest,
DumpsAndTerminatesProcessWhenAudioThreadIsBlocked) { … }
}