![]() |
AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
Classes | |
class | MockSpeechSynthesizerObserver |
struct | SpeakTestInfo |
class | SpeechSynthesizerTest |
Typedefs | |
using | MediaPlayerState = avsCommon::utils::mediaPlayer::MediaPlayerState |
using | PowerResourceLevel = PowerResourceManagerInterface::PowerResourceLevel |
Functions | |
static const std::chrono::milliseconds | MY_WAIT_TIMEOUT (1000) |
Plenty of time for a test to complete. More... | |
static const std::chrono::milliseconds | STATE_CHANGE_TIMEOUT (10000) |
static const std::string | CHANNEL_NAME (avsCommon::sdkInterfaces::FocusManagerInterface::DIALOG_CHANNEL_NAME) |
The name of the FocusManager channel used by the SpeechSynthesizer . More... | |
static const std::string | NAMESPACE_SPEECH_SYNTHESIZER ("SpeechSynthesizer") |
Namespace for SpeechSynthesizer. More... | |
static const std::string | NAME_SPEAK ("Speak") |
Name for SpeechSynthesizer directive. More... | |
static const std::string | NAME_RECOGNIZE ("Recognize") |
Wrong name for testing. More... | |
static const std::string | MESSAGE_ID_TEST ("MessageId_Test") |
Message Id for testing. More... | |
static const std::string | MESSAGE_ID_TEST_2 ("MessageId_Test_2") |
Message Id for testing. More... | |
static const std::string | DIALOG_REQUEST_ID_TEST ("DialogRequestId_Test") |
DialogRequestId for testing. More... | |
static const std::string | TOKEN_TEST ("Token_Test") |
Token for testing. More... | |
static const std::string | FORMAT_TEST ("AUDIO_MPEG") |
Format of the audio. More... | |
static const std::string | URL_TEST ("cid:Test") |
URL for testing. More... | |
static const std::string | CONTEXT_ID_TEST ("ContextId_Test") |
Context ID for testing. More... | |
static const std::string | CONTEXT_ID_TEST_2 ("ContextId_Test_2") |
Context ID for testing. More... | |
static const std::string | FINISHED_STATE ("FINISHED") |
The FINISHED state of the SpeechSynthesizer . More... | |
static const std::string | COMPONENT_NAME ("SpeechSynthesizer") |
Component name for power resource management. More... | |
static SpeakTestInfo | generateSpeakInfo (PlayBehavior playBehavior) |
static std::string | generatePlayingState (const SpeakTestInfo &info) |
static std::string | generateFinishedState (const SpeakTestInfo &info) |
static std::string | generateInterruptedState (const SpeakTestInfo &info) |
static bool | matchEvent (std::shared_ptr< MessageRequest > request, const std::string &expectedContent) |
MATCHER (IsStartedEvent, "") | |
MATCHER (IsFinishedEvent, "") | |
MATCHER (IsInterruptedEvent, "") | |
TEST_F (SpeechSynthesizerTest, test_createWithNullAudioPipelineFactoryFails) | |
TEST_F (SpeechSynthesizerTest, test_callingHandleImmediately) | |
TEST_F (SpeechSynthesizerTest, test_callingHandle) | |
TEST_F (SpeechSynthesizerTest, test_callingCancel) | |
TEST_F (SpeechSynthesizerTest, test_callingCancelAfterHandle) | |
TEST_F (SpeechSynthesizerTest, test_callingProvideStateWhenNotPlaying) | |
TEST_F (SpeechSynthesizerTest, test_callingProvideStateWhenPlaying) | |
TEST_F (SpeechSynthesizerTest, testTimer_bargeInWhilePlaying) | |
TEST_F (SpeechSynthesizerTest, testTimer_notCallStopTwice) | |
TEST_F (SpeechSynthesizerTest, testSlow_callingCancelBeforeOnFocusChanged) | |
TEST_F (SpeechSynthesizerTest, test_callingCancelBeforeOnExecuteStateChanged) | |
TEST_F (SpeechSynthesizerTest, test_mediaPlayerFailedToStop) | |
TEST_F (SpeechSynthesizerTest, testTimer_mediaPlayerAlwaysFailToStop) | |
TEST_F (SpeechSynthesizerTest, testSlow_setStateTimeout) | |
TEST_F (SpeechSynthesizerTest, test_givenPlayingStateFocusBecomesNone) | |
TEST_F (SpeechSynthesizerTest, testTimer_onPlayedStopped) | |
TEST_F (SpeechSynthesizerTest, test_replaceAllWithEmptyQueue) | |
TEST_F (SpeechSynthesizerTest, test_replaceAllWithNonEmptyQueue) | |
TEST_F (SpeechSynthesizerTest, test_replaceAllStopActiveSpeech) | |
TEST_F (SpeechSynthesizerTest, test_enqueueWithActiveSpeech) | |
TEST_F (SpeechSynthesizerTest, test_replaceEnqueuedWithAnotherEnqueuedItem) | |
TEST_F (SpeechSynthesizerTest, test_parsingSingleAnalyzerConfig) | |
TEST_F (SpeechSynthesizerTest, test_parsingMultipleAnalyzerConfig) | |
TEST_F (SpeechSynthesizerTest, test_handleDirectiveWithEmptyAttachment) | |
Variables | |
static const MediaPlayerState | DEFAULT_MEDIA_PLAYER_STATE = {std::chrono::milliseconds(0)} |
Default media player state for all playback events. More... | |
static std::string | SPEECH_STARTED_EVENT_NAME {"SpeechStarted"} |
The name of the event to send to the AVS server once audio starting playing. More... | |
static std::string | SPEECH_FINISHED_EVENT_NAME {"SpeechFinished"} |
The name of the event to send to the AVS server once audio finishes playing. More... | |
static std::string | SPEECH_INTERRUPTED_EVENT_NAME {"SpeechInterrupted"} |
The name of the event to send to the AVS server once audio playing has been interrupted. More... | |
static const NamespaceAndName | NAMESPACE_AND_NAME_SPEECH_STATE {NAMESPACE_SPEECH_SYNTHESIZER, "SpeechState"} |
The NamespaceAndName to send to the ContextManager . More... | |
static const std::string | CAPTION_CONTENT_SAMPLE |
static const std::string | PAYLOAD_TEST |
A payload for testing. More... | |
static const std::string | PAYLOAD_TEST_SINGLE_ANALYZER |
A payload for testing with single audio analyzer entry. More... | |
static const std::string | PAYLOAD_TEST_MULTIPLE_ANALYZER |
A payload for testing with multiple audio analyzer entry. More... | |
static const std::string | UNPARSED_DIRECTIVE_TEST |
A complete unparsed JSON directive for creating a directive without an attachment manager. More... | |
static const std::string | PLAYING_STATE {"PLAYING"} |
The PLAYING state of the SpeechSynthesizer . More... | |
static const std::string | INTERRUPTED_STATE {"INTERRUPTED"} |
The INTERRUPTED state of the SpeechSynthesizer . More... | |
static const long | OFFSET_IN_MILLISECONDS_TEST {100} |
The offset in milliseconds returned by the mock media player. More... | |
static const std::chrono::milliseconds | OFFSET_IN_CHRONO_MILLISECONDS_TEST {100} |
An std::chrono::milliseconds representation of the offset. More... | |
static const std::string | PLAYING_STATE_TEST |
The expected state when the SpeechSynthesizer is in PLAYING state. More... | |
static const std::string | FINISHED_STATE_TEST |
The expected state when the SpeechSynthesizer is in FINISHED state. More... | |
static const std::string | INTERRUPTED_STATE_TEST |
The expected state when the SpeechSynthesizer is in INTERRUPTED state. More... | |
static const std::string | IDLE_STATE_TEST |
The expected state when the SpeechSynthesizer is not handling any directive. More... | |
static const unsigned int | PROVIDE_STATE_TOKEN_TEST {1} |
Provide State Token for testing. More... | |
using alexaClientSDK::capabilityAgents::speechSynthesizer::test::MediaPlayerState = typedef avsCommon::utils::mediaPlayer::MediaPlayerState |
using alexaClientSDK::capabilityAgents::speechSynthesizer::test::PowerResourceLevel = typedef PowerResourceManagerInterface::PowerResourceLevel |
|
static |
The name of the FocusManager
channel used by the SpeechSynthesizer
.
|
static |
Component name for power resource management.
|
static |
Context ID for testing.
|
static |
Context ID for testing.
|
static |
DialogRequestId for testing.
|
static |
The FINISHED
state of the SpeechSynthesizer
.
|
static |
Format of the audio.
|
static |
|
static |
|
static |
|
static |
alexaClientSDK::capabilityAgents::speechSynthesizer::test::MATCHER | ( | IsStartedEvent | , |
"" | |||
) |
alexaClientSDK::capabilityAgents::speechSynthesizer::test::MATCHER | ( | IsFinishedEvent | , |
"" | |||
) |
alexaClientSDK::capabilityAgents::speechSynthesizer::test::MATCHER | ( | IsInterruptedEvent | , |
"" | |||
) |
|
static |
Match request by the event content. This does a simple string search.
request | The request to be checked. |
expectedContent | The content that should be included in the request. |
|
static |
Message Id for testing.
|
static |
Message Id for testing.
|
static |
Plenty of time for a test to complete.
|
static |
Wrong name for testing.
|
static |
Name for SpeechSynthesizer directive.
|
static |
Namespace for SpeechSynthesizer.
|
static |
Time to wait for state change timeout. This should be set to be longer than STATE_CHANGE_TIMEOUT in SpeechSynthesizer.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_createWithNullAudioPipelineFactoryFails | |||
) |
Test creating SpeechSynthesizer fails with null audio pipeline factory.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_callingHandleImmediately | |||
) |
Test call to handleDirectiveImmediately. Expected result is that acquireChannel
is called with the correct channel. On focus changed FOREGROUND
, audio should play. Expect the ContextManager
setState
is called when state changes to PLAYING
.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_callingHandle | |||
) |
Tests preHandleDirective and HandleDirective Call preHandle with a valid SPEAK directive. Then call handleDirective. Expected result is that acquireChannel
is called with the correct channel. On focus changed FOREGROUND
, audio should play. Expect the ContextManager
setState
is called when state changes to PLAYING
.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_callingCancel | |||
) |
Tests cancelDirective. Call preHandle with a valid SPEAK directive. Then call cancelDirective. Expect that neither setState
nor sendMessage
are called since handle was never called to start playing audio.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_callingCancelAfterHandle | |||
) |
Testing cancelDirective after calling Call preHandle with a valid SPEAK directive. Then call handleDirective. Expected result is that acquireChannel
is called once. On Focus Changed to foreground, audio should play. Call cancel directive. Expect the ContextManager
setState
is called when the state changes to PLAYING
and then to INTERRUPTED
. Expect sendMessage
is called twice (SpeechStarted and SpeechInterrupted). Expect setFailed()
is never called.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_callingProvideStateWhenNotPlaying | |||
) |
Testing provideState. Call provideState
and expect that setState is called.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_callingProvideStateWhenPlaying | |||
) |
Testing provideState when playing. Call provideState
after the state of the SpeechSynthesizer
has changed to PLAYING
. Expect getOffset
is called. Expect setState
is called when state changes and when state is requested via provideState
.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
testTimer_bargeInWhilePlaying | |||
) |
Testing barge-in via handleDirectiveImmediately
when audio is playing back. Call handleDirective
. Once playback started notification is received, call handleDirectiveImmediately
.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
testTimer_notCallStopTwice | |||
) |
Testing SpeechSynthesizer won't be calling stop() in MediaPlayer
twice. Call preHandle with a valid SPEAK directive. Then call handleDirective. Expected result is that acquireChannel
is called once. On Focus Changed to foreground, audio should play. Call cancel directive. Expect the stop() to be called once. Call onFocusChanged, expect the stop() to not be called again. Expect when handleDirectiveImmediately with a valid SPEAK directive is called, SpeechSynthesizer
will react correctly.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
testSlow_callingCancelBeforeOnFocusChanged | |||
) |
Testing executeCancel() completes execution before onFocusChanged() is called.
The directive that was cancelled should never play. The second speech should play without any problem.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_callingCancelBeforeOnExecuteStateChanged | |||
) |
Testing executeCancel() completes execution before executeStateChange() is called.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_mediaPlayerFailedToStop | |||
) |
Testing SpeechSynthesizer will continue to function properly if stop() in MediaPlayer
returned with an error. Call preHandle with a valid SPEAK directive. Then call handleDirective. Expected result is that acquireChannel
is called once. On Focus Changed to foreground, audio should play. Call cancel directive. Expect the stop() to be called once, and we force MediaPlayer to return an error. Expect when handleDirectiveImmediately with a valid SPEAK directive is called, SpeechSynthesizer
will react correctly.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
testTimer_mediaPlayerAlwaysFailToStop | |||
) |
Test SpeechSynthesizer shutdown when speech is playing and MediaPlayerInterface.stop()
fails (ACSDK-1859).
Expected result is that shutdown should succeeded no matter the stop
return.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
testSlow_setStateTimeout | |||
) |
Testing SpeechSynthesizer will call stop() if the SpeechSynthesizer experienced a state change timeout to PLAYING state.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_givenPlayingStateFocusBecomesNone | |||
) |
Testing changing focus state to NONE (local stop) during a speak. Expect setFailed
to be called so any subsequent directives with the same dialogRequestId will be dropped.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
testTimer_onPlayedStopped | |||
) |
Testing SpeechSynthesizer will call setFailed() if the SpeechSynthesizer got a onPlaybackStopped() callback while it is in PLAYING state.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_replaceAllWithEmptyQueue | |||
) |
Test SpeechSynthesizer REPLACE_ALL when there is no active directive.
Expect the speech synthesizer to play the new speech and go to idle after.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_replaceAllWithNonEmptyQueue | |||
) |
Test SpeechSynthesizer REPLACE_ALL when the queue has one speak directive that hasn't started yet.
Expect the speech synthesizer to cancel the enqueued directive and play the new speech.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_replaceAllStopActiveSpeech | |||
) |
Test SpeechSynthesizer REPLACE_ALL when there is an ongoing speech.
Expect the speech synthesizer to cancel the active speech, send a completed event and play the new speech.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_enqueueWithActiveSpeech | |||
) |
Test SpeechSynthesizer ENQUEUE play behavior when there is already an active directive.
Expect the speech synthesizer to finish playing the first directive and play the enqueued directive right after.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_replaceEnqueuedWithAnotherEnqueuedItem | |||
) |
Test SpeechSynthesizer REPLACE_ENQUEUED play behavior when there is one directive playing and one in the queue.
Expect the speech synthesizer to finish playing the first directive, skip the second and play the third directive.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_parsingSingleAnalyzerConfig | |||
) |
Test call to test audio analyzer config parsing logic.
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_parsingMultipleAnalyzerConfig | |||
) |
alexaClientSDK::capabilityAgents::speechSynthesizer::test::TEST_F | ( | SpeechSynthesizerTest | , |
test_handleDirectiveWithEmptyAttachment | |||
) |
|
static |
Token for testing.
|
static |
URL for testing.
|
static |
|
static |
Default media player state for all playback events.
|
static |
The expected state when the SpeechSynthesizer
is in FINISHED
state.
|
static |
The expected state when the SpeechSynthesizer
is not handling any directive.
|
static |
The INTERRUPTED
state of the SpeechSynthesizer
.
|
static |
The expected state when the SpeechSynthesizer
is in INTERRUPTED
state.
|
static |
The NamespaceAndName
to send to the ContextManager
.
|
static |
An std::chrono::milliseconds representation of the offset.
|
static |
The offset in milliseconds returned by the mock media player.
|
static |
A payload for testing.
|
static |
A payload for testing with multiple audio analyzer entry.
|
static |
A payload for testing with single audio analyzer entry.
|
static |
The PLAYING
state of the SpeechSynthesizer
.
|
static |
The expected state when the SpeechSynthesizer
is in PLAYING
state.
|
static |
Provide State Token for testing.
|
static |
The name of the event to send to the AVS server once audio finishes playing.
|
static |
The name of the event to send to the AVS server once audio playing has been interrupted.
|
static |
The name of the event to send to the AVS server once audio starting playing.
|
static |
A complete unparsed JSON directive for creating a directive without an attachment manager.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0