зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1656438 - Do output verification in the gtest body. r=padenot
Depends on D89753 Differential Revision: https://phabricator.services.mozilla.com/D89754
This commit is contained in:
Родитель
9962c2e6af
Коммит
d85a980ee9
|
@ -191,18 +191,26 @@ class MockCubebStream {
|
|||
return CUBEB_OK;
|
||||
}
|
||||
|
||||
cubeb_devid GetInputDeviceID() { return mInputDeviceID; }
|
||||
cubeb_devid GetOutputDeviceID() { return mOutputDeviceID; }
|
||||
cubeb_devid GetInputDeviceID() const { return mInputDeviceID; }
|
||||
cubeb_devid GetOutputDeviceID() const { return mOutputDeviceID; }
|
||||
|
||||
uint32_t InputChannels() const { return mAudioGenerator.mChannels; }
|
||||
uint32_t InputSampleRate() const { return mAudioGenerator.mSampleRate; }
|
||||
uint32_t InputFrequency() const { return mAudioGenerator.mFrequency; }
|
||||
|
||||
void GoFaster() { mFastMode = true; }
|
||||
void DontGoFaster() { mFastMode = false; }
|
||||
void ForceError() { mForceErrorState = true; }
|
||||
void VerifyOutput() { mVerifyOutput = true; }
|
||||
|
||||
MediaEventSource<uint32_t>& FramesProcessedEvent() {
|
||||
return mFramesProcessedEvent;
|
||||
}
|
||||
|
||||
MediaEventSource<Tuple<uint64_t, uint32_t, uint32_t>>&
|
||||
OutputVerificationEvent() {
|
||||
return mOutputVerificationEvent;
|
||||
}
|
||||
|
||||
MediaEventSource<void>& ErrorForcedEvent() { return mErrorForcedEvent; }
|
||||
|
||||
private:
|
||||
|
@ -244,17 +252,9 @@ class MockCubebStream {
|
|||
std::this_thread::sleep_for(std::chrono::milliseconds(
|
||||
mFastMode ? 0 : NUM_OF_FRAMES * 1000 / sampleRate));
|
||||
}
|
||||
if (mVerifyOutput) {
|
||||
// This is an async, in case of failure the result will appear in the
|
||||
// next test. TODO: make it wait till the results are in place.
|
||||
EXPECT_EQ(mAudioVerifier.EstimatedFreq(), mAudioGenerator.mFrequency);
|
||||
EXPECT_GE(mAudioVerifier.PreSilenceSamples(),
|
||||
static_cast<uint32_t>(NUM_OF_FRAMES));
|
||||
// Waveform may start after the beginning. In this case, there is a gap
|
||||
// at the beginning and the end which is counted as discontinuity.
|
||||
EXPECT_GE(mAudioVerifier.CountDiscontinuities(), 0U);
|
||||
EXPECT_LE(mAudioVerifier.CountDiscontinuities(), 2U);
|
||||
}
|
||||
mOutputVerificationEvent.Notify(MakeTuple(
|
||||
mAudioVerifier.PreSilenceSamples(), mAudioVerifier.EstimatedFreq(),
|
||||
mAudioVerifier.CountDiscontinuities()));
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -286,11 +286,12 @@ class MockCubebStream {
|
|||
|
||||
std::atomic_bool mFastMode{false};
|
||||
std::atomic_bool mForceErrorState{false};
|
||||
std::atomic_bool mVerifyOutput{false};
|
||||
AudioGenerator<AudioDataValue> mAudioGenerator;
|
||||
AudioVerifier<AudioDataValue> mAudioVerifier;
|
||||
|
||||
MediaEventProducer<uint32_t> mFramesProcessedEvent;
|
||||
MediaEventProducer<Tuple<uint64_t, uint32_t, uint32_t>>
|
||||
mOutputVerificationEvent;
|
||||
MediaEventProducer<void> mErrorForcedEvent;
|
||||
};
|
||||
|
||||
|
|
|
@ -310,7 +310,6 @@ TEST(TestAudioTrackGraph, SourceTrack)
|
|||
auto p = Invoke([&] { return graph->NotifyWhenDeviceStarted(sourceTrack); });
|
||||
MockCubebStream* stream = WaitFor(cubeb->StreamInitEvent());
|
||||
EXPECT_TRUE(stream->mHasInput);
|
||||
stream->VerifyOutput();
|
||||
Unused << WaitFor(p);
|
||||
|
||||
// Wait for a second worth of audio data.
|
||||
|
@ -337,7 +336,19 @@ TEST(TestAudioTrackGraph, SourceTrack)
|
|||
sourceTrack->Destroy();
|
||||
});
|
||||
|
||||
WaitFor(cubeb->StreamDestroyEvent());
|
||||
uint32_t inputFrequency = stream->InputFrequency();
|
||||
uint64_t preSilenceSamples;
|
||||
uint32_t estimatedFreq;
|
||||
uint32_t nrDiscontinuities;
|
||||
Tie(preSilenceSamples, estimatedFreq, nrDiscontinuities) =
|
||||
WaitFor(stream->OutputVerificationEvent());
|
||||
|
||||
EXPECT_EQ(estimatedFreq, inputFrequency);
|
||||
EXPECT_GE(preSilenceSamples, static_cast<uint32_t>(NUM_OF_FRAMES));
|
||||
// Waveform may start after the beginning. In this case, there is a gap
|
||||
// at the beginning and the end which is counted as discontinuity.
|
||||
EXPECT_GE(nrDiscontinuities, 0U);
|
||||
EXPECT_LE(nrDiscontinuities, 2U);
|
||||
}
|
||||
|
||||
TEST(TestAudioTrackGraph, CrossGraphPort)
|
||||
|
|
Загрузка…
Ссылка в новой задаче