src/media/audio/audio_core/test/api/audio_capturer_test.cc
// inadequate ZX_RIGHTS -- if no TRANSFER, the SetReferenceClock silently does nothing.
// The reference clock should remain the unique recognizable reference clock from before the call.
inadequate ZX_RIGHTS -- if no TRANSFER, the SetReferenceClock silently does nothing.
The reference clock should remain the unique recognizable reference clock from before the call.
inadequate ZX_RIGHTS -- if no TRANSFER the SetReferenceClock silently does nothing . The reference clock should remain the unique recognizable reference clock from before the call .
TEST_F(AudioCapturerClockTest, SetRefClock_NoTransferNoChange) {
  zx::clock dupe_clock, retained_clock, orig_clock = clock::AdjustableCloneOfMonotonic();
  ASSERT_EQ(orig_clock.duplicate(kClockRights, &dupe_clock), ZX_OK);
  ASSERT_EQ(orig_clock.duplicate(kClockRights, &retained_clock), ZX_OK);
  zx::clock::update_args args;
  args.reset().set_rate_adjust(-100);
  ASSERT_EQ(orig_clock.update(args), ZX_OK) << "clock.update with rate_adjust failed";
  audio_capturer_->SetReferenceClock(std::move(dupe_clock));
  zx::clock received_clock = GetAndValidateReferenceClock();
  clock::testing::VerifyIsNotSystemMonotonic(received_clock);
   Now create another clock without transfer rights...
  zx::clock no_transfer_clock = clock::CloneOfMonotonic();
  ASSERT_TRUE(no_transfer_clock.is_valid());
  ASSERT_EQ(no_transfer_clock.replace(kClockRights & ~ZX_RIGHT_TRANSFER, &no_transfer_clock),
            ZX_OK);
  clock::testing::VerifyIsSystemMonotonic(no_transfer_clock);
   ... and try to set it as our reference clock...
  audio_capturer_->SetReferenceClock(std::move(no_transfer_clock));
  zx::clock received_clock2 = GetAndValidateReferenceClock();
   ... but this should not result in any change.
  clock::testing::VerifyReadOnlyRights(received_clock2);
  clock::testing::VerifyIsNotSystemMonotonic(received_clock2);
}
TEST_F ( AudioCapturerClockTest , SetRefClock_NoTransferNoChange ) { zx :: clock dupe_clock , retained_clock , orig_clock = clock :: AdjustableCloneOfMonotonic ( ) ; ASSERT_EQ ( orig_clock . duplicate ( kClockRights , & dupe_clock ) , ZX_OK ) ; ASSERT_EQ ( orig_clock . duplicate ( kClockRights , & retained_clock ) , ZX_OK ) ; zx :: clock :: update_args args ; args . reset ( ) . set_rate_adjust ( -100 ) ; ASSERT_EQ ( orig_clock . update ( args ) , ZX_OK ) << " " ; audio_capturer_ -> SetReferenceClock ( std :: move ( dupe_clock ) ) ; zx :: clock received_clock = GetAndValidateReferenceClock ( ) ; clock :: testing :: VerifyIsNotSystemMonotonic ( received_clock ) ; zx :: clock no_transfer_clock = clock :: CloneOfMonotonic ( ) ; ASSERT_TRUE ( no_transfer_clock . is_valid ( ) ) ; ASSERT_EQ ( no_transfer_clock . replace ( kClockRights & ~ ZX_RIGHT_TRANSFER , & no_transfer_clock ) , ZX_OK ) ; clock :: testing :: VerifyIsSystemMonotonic ( no_transfer_clock ) ; audio_capturer_ -> SetReferenceClock ( std :: move ( no_transfer_clock ) ) ; zx :: clock received_clock2 = GetAndValidateReferenceClock ( ) ; clock :: testing :: VerifyReadOnlyRights ( received_clock2 ) ; clock :: testing :: VerifyIsNotSystemMonotonic ( received_clock2 ) ; }
inadequate ZX_RIGHTS -- if no TRANSFER, the SetReferenceClock silently does nothing.
inadequate ZX_RIGHTS -- if no TRANSFER the SetReferenceClock silently does nothing .
// First create a unique custom clock that we will recognize... // ... and set it on this capturer. // // Now create another clock without transfer rights... // ... and try to set it as our reference clock... // ... but this should not result in any change.