diff options
author | Arthur Ishiguro <arthuri@google.com> | 2020-05-12 20:15:35 -0700 |
---|---|---|
committer | Arthur Ishiguro <arthuri@google.com> | 2020-05-14 19:31:21 -0700 |
commit | a9bc8946debba73e591818bd8734fdbc26545ec8 (patch) | |
tree | f30c6d9b8a18c99e1c7f1970fa6804f338ea1898 /apps | |
parent | b8153bdd5a36acd15f571571f7e8d5a12c962b5d (diff) | |
download | chre-a9bc8946debba73e591818bd8734fdbc26545ec8.tar.gz |
Audio concurrency test: verify audio resume
Bug: 156296364
Test: Run test, verify audio resumes after AP mic access
Change-Id: Ic68dd51f0d34706f90592b124104588dbdc8a24e
Diffstat (limited to 'apps')
-rw-r--r-- | apps/test/common/chre_audio_concurrency_test/inc/chre_audio_concurrency_test_manager.h | 12 | ||||
-rw-r--r-- | apps/test/common/chre_audio_concurrency_test/src/chre_audio_concurrency_test_manager.cc | 39 |
2 files changed, 38 insertions, 13 deletions
diff --git a/apps/test/common/chre_audio_concurrency_test/inc/chre_audio_concurrency_test_manager.h b/apps/test/common/chre_audio_concurrency_test/inc/chre_audio_concurrency_test_manager.h index 23a35eee..df8f825e 100644 --- a/apps/test/common/chre_audio_concurrency_test/inc/chre_audio_concurrency_test_manager.h +++ b/apps/test/common/chre_audio_concurrency_test/inc/chre_audio_concurrency_test_manager.h @@ -89,6 +89,18 @@ class Manager { void handleTimer(); /** + * @param durationSeconds The duration of the timeout timer. + * + * @return True if the timer was set successfully. + */ + bool setTimeoutTimer(size_t durationSeconds); + + /** + * Cancels the timeout timer, if pending. + */ + void cancelTimeoutTimer(); + + /** * @param data The audio data. */ void handleAudioDataEvent(const chreAudioDataEvent *data); diff --git a/apps/test/common/chre_audio_concurrency_test/src/chre_audio_concurrency_test_manager.cc b/apps/test/common/chre_audio_concurrency_test/src/chre_audio_concurrency_test_manager.cc index 18afc2a0..9e420bb2 100644 --- a/apps/test/common/chre_audio_concurrency_test/src/chre_audio_concurrency_test_manager.cc +++ b/apps/test/common/chre_audio_concurrency_test/src/chre_audio_concurrency_test_manager.cc @@ -68,6 +68,7 @@ Manager::~Manager() { chreAudioConfigureSource(kAudioHandle, false /* enable */, 0 /* bufferDuration */, 0 /* deliveryInterval */); } + cancelTimeoutTimer(); } bool Manager::handleTestCommandMessage(uint16_t hostEndpointId, TestStep step) { @@ -90,16 +91,10 @@ bool Manager::handleTestCommandMessage(uint16_t hostEndpointId, TestStep step) { // Start a timer to ensure we receive the first audio data event // quickly. Since it may take some time to load the sound model, choose // a reasonably long timeout. - mTimerHandle = chreTimerSet(10 * kOneSecondInNanoseconds, - nullptr /* cookie */, true /* oneShot */); - if (mTimerHandle == CHRE_TIMER_INVALID) { - LOGE("Failed to set audio enabled timer"); - } else { - success = true; - } + success = setTimeoutTimer(10 /* durationSeconds */); } } else if (step == TestStep::VERIFY_AUDIO_RESUME) { - // TODO: Verify audio resumes + success = setTimeoutTimer(10 /* durationSeconds */); } if (success) { @@ -165,14 +160,28 @@ void Manager::handleTimer() { // TODO: Timeout failure } +bool Manager::setTimeoutTimer(size_t durationSeconds) { + mTimerHandle = chreTimerSet(durationSeconds * kOneSecondInNanoseconds, + nullptr /* cookie */, true /* oneShot */); + if (mTimerHandle == CHRE_TIMER_INVALID) { + LOGE("Failed to set timeout timer"); + } + + return mTimerHandle != CHRE_TIMER_INVALID; +} + +void Manager::cancelTimeoutTimer() { + if (mTimerHandle != CHRE_TIMER_INVALID) { + chreTimerCancel(mTimerHandle); + mTimerHandle = CHRE_TIMER_INVALID; + } +} + void Manager::handleAudioDataEvent(const chreAudioDataEvent *data) { if (mTestSession.has_value()) { switch (mTestSession->step) { case TestStep::ENABLE_AUDIO: { - if (mTimerHandle != CHRE_TIMER_INVALID) { - chreTimerCancel(mTimerHandle); - mTimerHandle = CHRE_TIMER_INVALID; - } + cancelTimeoutTimer(); sendEmptyMessageToHost( mTestSession->hostEndpointId, chre_audio_concurrency_test_MessageType_TEST_AUDIO_ENABLED); @@ -184,7 +193,11 @@ void Manager::handleAudioDataEvent(const chreAudioDataEvent *data) { } case TestStep::VERIFY_AUDIO_RESUME: { - // TODO: + cancelTimeoutTimer(); + sendTestResultToHost(mTestSession->hostEndpointId, + kTestResultMessageType, true /* success */); + mTestSession.reset(); + break; } default: |