src/media/audio/audio_core/audio_clock_unittest.cc
// Clock type (and domain, for Device clocks) can be set after construction, and chained.
Clock type (and domain, for Device clocks) can be set after construction, and chained.
Clock type ( and domain for Device clocks ) can be set after construction and chained .
TEST(AudioClockTest, CreateAs) {
  AudioClock audio_clock;
  audio_clock = AudioClock::CreateAsOptimal(clock::AdjustableCloneOfMonotonic());
  EXPECT_TRUE(audio_clock.is_adjustable());
  EXPECT_FALSE(audio_clock.is_device_clock());
  EXPECT_TRUE(audio_clock.is_client_clock());
  EXPECT_FALSE(audio_clock.controls_hardware_clock());
  EXPECT_FALSE(audio_clock.SetAsHardwareControlling(true));
  EXPECT_FALSE(audio_clock.controls_hardware_clock());
  audio_clock = AudioClock::CreateAsCustom(clock::AdjustableCloneOfMonotonic());
  EXPECT_FALSE(audio_clock.is_adjustable());
  EXPECT_FALSE(audio_clock.is_device_clock());
  EXPECT_TRUE(audio_clock.is_client_clock());
  EXPECT_FALSE(audio_clock.controls_hardware_clock());
  EXPECT_TRUE(audio_clock.SetAsHardwareControlling(true));
  EXPECT_TRUE(audio_clock.controls_hardware_clock());
  constexpr uint32_t kCustomDomain = 42;
  audio_clock = AudioClock::CreateAsDeviceAdjustable(clock::CloneOfMonotonic(), kCustomDomain);
  EXPECT_TRUE(audio_clock.is_adjustable());
  EXPECT_TRUE(audio_clock.is_device_clock());
  EXPECT_FALSE(audio_clock.is_client_clock());
  EXPECT_EQ(audio_clock.domain(), kCustomDomain);
  EXPECT_FALSE(audio_clock.controls_hardware_clock());
  EXPECT_FALSE(audio_clock.SetAsHardwareControlling(true));
  EXPECT_FALSE(audio_clock.controls_hardware_clock());
  constexpr uint32_t kCustomDomain2 = 68;
  audio_clock = AudioClock::CreateAsDeviceStatic(clock::CloneOfMonotonic(), kCustomDomain2);
  EXPECT_FALSE(audio_clock.is_adjustable());
  EXPECT_TRUE(audio_clock.is_device_clock());
  EXPECT_FALSE(audio_clock.is_client_clock());
  EXPECT_EQ(audio_clock.domain(), kCustomDomain2);
  EXPECT_FALSE(audio_clock.controls_hardware_clock());
  EXPECT_FALSE(audio_clock.SetAsHardwareControlling(true));
  EXPECT_FALSE(audio_clock.controls_hardware_clock());
}
TEST ( AudioClockTest , CreateAs ) { AudioClock audio_clock ; audio_clock = AudioClock :: CreateAsOptimal ( clock :: AdjustableCloneOfMonotonic ( ) ) ; EXPECT_TRUE ( audio_clock . is_adjustable ( ) ) ; EXPECT_FALSE ( audio_clock . is_device_clock ( ) ) ; EXPECT_TRUE ( audio_clock . is_client_clock ( ) ) ; EXPECT_FALSE ( audio_clock . controls_hardware_clock ( ) ) ; EXPECT_FALSE ( audio_clock . SetAsHardwareControlling ( true ) ) ; EXPECT_FALSE ( audio_clock . controls_hardware_clock ( ) ) ; audio_clock = AudioClock :: CreateAsCustom ( clock :: AdjustableCloneOfMonotonic ( ) ) ; EXPECT_FALSE ( audio_clock . is_adjustable ( ) ) ; EXPECT_FALSE ( audio_clock . is_device_clock ( ) ) ; EXPECT_TRUE ( audio_clock . is_client_clock ( ) ) ; EXPECT_FALSE ( audio_clock . controls_hardware_clock ( ) ) ; EXPECT_TRUE ( audio_clock . SetAsHardwareControlling ( true ) ) ; EXPECT_TRUE ( audio_clock . controls_hardware_clock ( ) ) ; constexpr uint32_t kCustomDomain = 42 ; audio_clock = AudioClock :: CreateAsDeviceAdjustable ( clock :: CloneOfMonotonic ( ) , kCustomDomain ) ; EXPECT_TRUE ( audio_clock . is_adjustable ( ) ) ; EXPECT_TRUE ( audio_clock . is_device_clock ( ) ) ; EXPECT_FALSE ( audio_clock . is_client_clock ( ) ) ; EXPECT_EQ ( audio_clock . domain ( ) , kCustomDomain ) ; EXPECT_FALSE ( audio_clock . controls_hardware_clock ( ) ) ; EXPECT_FALSE ( audio_clock . SetAsHardwareControlling ( true ) ) ; EXPECT_FALSE ( audio_clock . controls_hardware_clock ( ) ) ; constexpr uint32_t kCustomDomain2 = 68 ; audio_clock = AudioClock :: CreateAsDeviceStatic ( clock :: CloneOfMonotonic ( ) , kCustomDomain2 ) ; EXPECT_FALSE ( audio_clock . is_adjustable ( ) ) ; EXPECT_TRUE ( audio_clock . is_device_clock ( ) ) ; EXPECT_FALSE ( audio_clock . is_client_clock ( ) ) ; EXPECT_EQ ( audio_clock . domain ( ) , kCustomDomain2 ) ; EXPECT_FALSE ( audio_clock . controls_hardware_clock ( ) ) ; EXPECT_FALSE ( audio_clock . SetAsHardwareControlling ( true ) ) ; EXPECT_FALSE ( audio_clock . controls_hardware_clock ( ) ) ; }
Clock type (and domain, for Device clocks) can be set after construction, and chained.
Clock type ( and domain for Device clocks ) can be set after construction and chained .