AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Public Attributes | List of all members
alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest Class Reference
Inheritance diagram for alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest:
Collaboration graph
[legend]

Public Member Functions

 AudioPlayerTest ()
 
void SetUp () override
 
void TearDown () override
 
void reSetUp (int numberOfPlayers)
 
SetStateResult wakeOnSetState ()
 
bool wakeOnAcquireChannel ()
 
std::future< bool > wakeOnReleaseChannel ()
 
void wakeOnSendMessage ()
 
void sendPlayDirective (long offsetInMilliseconds=OFFSET_IN_MILLISECONDS_TEST, long endOffsetInMilliseconds=0L)
 
void badEndOffsetDirective (long offset, long endOffset)
 
void sendStopDirective ()
 
void sendClearQueueDirective (ClearBehavior clearBehavior)
 
void sendUpdateProgressReportIntervalDirective ()
 
bool verifyPlaybackMessage (std::shared_ptr< avsCommon::avs::MessageRequest > request, std::string expectedName, bool verifyReport=false)
 
bool verifyMessage (std::shared_ptr< avsCommon::avs::MessageRequest > request, std::string expectedName)
 
void verifyMessageMap (std::shared_ptr< avsCommon::avs::MessageRequest > request, std::map< std::string, int > *expectedMessages)
 
void verifyMessageOrder2Phase (const std::vector< std::string > &orderedMessageList, size_t index, std::function< void()> trigger1, std::function< void()> trigger2)
 
void verifyState (const std::string &providedState, const std::string &expectedState)
 
void verifyTags (std::shared_ptr< avsCommon::avs::MessageRequest > request, std::map< std::string, int > *expectedMessages, bool validateBoolean=true)
 
void extractPlaybackAttributes (std::shared_ptr< avsCommon::avs::MessageRequest > request, PlaybackAttributes *actualPlaybackAttributes)
 
void extractPlaybackReports (std::shared_ptr< avsCommon::avs::MessageRequest > request, std::vector< PlaybackReport > *actualPlaybackReports)
 
bool extractMediaPlayerState (std::shared_ptr< avsCommon::avs::MessageRequest > request, const std::string &expectedState, MediaPlayerState *playerState)
 
void testPlayEnqueueFinishPlay ()
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 

Public Attributes

std::shared_ptr< avsCommon::utils::mediaPlayer::PooledMediaResourceProviderInterfacem_mockMediaResourceProvider
 PooledMediaResourceProviderInterface to provide mock media players and speakers for testing. More...
 
std::shared_ptr< AudioPlayerm_audioPlayer
 AudioPlayer to test More...
 
std::shared_ptr< TestAudioPlayerObserverm_testAudioPlayerObserver
 A test observer to wait for AudioPlayer state changes More...
 
std::shared_ptr< MockMediaPlayerm_mockMediaPlayer
 Player to send the audio to. More...
 
std::shared_ptr< MockMediaPlayerm_mockMediaPlayerTrack2
 Another Player to send the audio to. More...
 
std::shared_ptr< MockMediaPlayerm_mockMediaPlayerTrack3
 Another Player to send the audio to. More...
 
std::shared_ptr< MockChannelVolumeInterfacem_mockChannelVolume
 ChannelVolumeInterface to send the audio to. More...
 
std::shared_ptr< MockContextManagerm_mockContextManager
 ContextManager to provide state and update state. More...
 
std::shared_ptr< MockFocusManagerm_mockFocusManager
 FocusManager to request focus to the DIALOG channel. More...
 
std::unique_ptr< MockDirectiveHandlerResultm_mockDirectiveHandlerResult
 A directive handler result to send the result to. More...
 
std::shared_ptr< MockMessageSenderm_mockMessageSender
 A message sender used to send events to AVS. More...
 
std::shared_ptr< MockExceptionEncounteredSenderm_mockExceptionSender
 An exception sender used to send exception encountered events to AVS. More...
 
std::shared_ptr< MockPlaybackRouterm_mockPlaybackRouter
 A playback router to notify when AudioPlayer becomes active. More...
 
std::shared_ptr< MockCaptionManagerm_mockCaptionManager
 A mock CaptionManager instance to handle captions parsing. More...
 
std::shared_ptr< AttachmentManagerm_attachmentManager
 Attachment manager used to create a reader. More...
 
std::map< std::string, int > m_expectedMessages
 Map for expected messages testing. More...
 
MediaPlayerInterface::SourceId m_sourceId
 Identifier for the currently selected audio source. More...
 
std::shared_ptr< MockMetricRecorderm_mockMetricRecorder
 The mock MetricRecorderInterface. More...
 
std::shared_ptr< MockCryptoFactorym_cryptoFactory
 The mock MockCryptoFactory. More...
 
std::promise< void > m_wakeSetStatePromise
 Promise to be fulfilled when setState is called. More...
 
std::future< void > m_wakeSetStateFuture
 Future to notify when setState is called. More...
 
std::promise< void > m_wakeAcquireChannelPromise
 Promise to be fulfilled when acquireChannel is called. More...
 
std::future< void > m_wakeAcquireChannelFuture
 Future to notify when acquireChannel is called. More...
 
std::promise< void > m_wakeReleaseChannelPromise
 Promise to be fulfilled when acquireChannel is called. More...
 
std::future< void > m_wakeReleaseChannelFuture
 Future to notify when releaseChannel is called. More...
 
std::promise< void > m_wakeSendMessagePromise
 Promise to be fulfilled when sendMessage is called. More...
 
std::future< void > m_wakeSendMessageFuture
 Future to notify when sendMessage is called. More...
 
std::mutex m_mutex
 General purpose mutex. More...
 
std::condition_variable m_messageSentTrigger
 Condition variable to wake on a message being sent. More...
 
std::condition_variable m_mediaPlayerCallTrigger
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
- Protected Member Functions inherited from testing::Test
 Test ()
 

Constructor & Destructor Documentation

◆ AudioPlayerTest()

alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::AudioPlayerTest ( )

Member Function Documentation

◆ badEndOffsetDirective()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::badEndOffsetDirective ( long  offset,
long  endOffset 
)

Consolidate code with bad end offset in a play directive. endOffset <= offset

Parameters
offset"start" offset in the directive
endOffsetendOffset in the directive

◆ extractMediaPlayerState()

bool alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::extractMediaPlayerState ( std::shared_ptr< avsCommon::avs::MessageRequest request,
const std::string &  expectedState,
MediaPlayerState playerState 
)

Extracts mediaPlayerState from playback event for verification.

Parameters
requestThe MessageRequest to extract.
actualPlaybackAttributesThe PlaybackAttributes extracted.

◆ extractPlaybackAttributes()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::extractPlaybackAttributes ( std::shared_ptr< avsCommon::avs::MessageRequest request,
PlaybackAttributes actualPlaybackAttributes 
)

Extracts playback attributes from message for verification.

Parameters
requestThe MessageRequest to extract.
actualPlaybackAttributesThe PlaybackAttributes extracted.

◆ extractPlaybackReports()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::extractPlaybackReports ( std::shared_ptr< avsCommon::avs::MessageRequest request,
std::vector< PlaybackReport > *  actualPlaybackReports 
)

Extracts playback reports from message for verification.

Parameters
requestThe MessageRequest to extract.
actualPlaybackReportsPointer to list of PlaybackReport extracted.

◆ reSetUp()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::reSetUp ( int  numberOfPlayers)

◆ sendClearQueueDirective()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::sendClearQueueDirective ( ClearBehavior  clearBehavior)

Consolidate code to send ClearQueue directive

◆ sendPlayDirective()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::sendPlayDirective ( long  offsetInMilliseconds = OFFSET_IN_MILLISECONDS_TEST,
long  endOffsetInMilliseconds = 0L 
)

Consolidate code to send Play directive.

Parameters
offsetInMillisecondsThe offset to use in the directive.

◆ sendStopDirective()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::sendStopDirective ( )

Consolidate code to send Stop directive.

◆ sendUpdateProgressReportIntervalDirective()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::sendUpdateProgressReportIntervalDirective ( )

Sends UpdateProgressReportInterval directive.

◆ SetUp()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::SetUp ( )
overridevirtual

Reimplemented from testing::Test.

◆ TearDown()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::TearDown ( )
overridevirtual

Reimplemented from testing::Test.

◆ testPlayEnqueueFinishPlay()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::testPlayEnqueueFinishPlay ( )

Run through test of playing, enqueuing, finish, play

This test sets up a sequence of 1 REPLACE track, followed by 3 ENQUEUE tracks, then tests that they are all played in sequence. It is called from tests that set up different numbers of MediaPlayers in a Factory Pool to ensure everything works smoothly.

◆ verifyMessage()

bool alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::verifyMessage ( std::shared_ptr< avsCommon::avs::MessageRequest request,
std::string  expectedName 
)

Verify that the message name matches the expected name

Parameters
requestThe MessageRequest to verify
expectedNameThe expected name to find in the json header

◆ verifyMessageMap()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::verifyMessageMap ( std::shared_ptr< avsCommon::avs::MessageRequest request,
std::map< std::string, int > *  expectedMessages 
)

Verify that the sent request matches one in a Map of expectedMessages

Parameters
requestThe MessageRequest to verify
expectedMessagesThe map of expected messages and a count of how many are seen

◆ verifyMessageOrder2Phase()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::verifyMessageOrder2Phase ( const std::vector< std::string > &  orderedMessageList,
size_t  index,
std::function< void()>  trigger1,
std::function< void()>  trigger2 
)

verify that the sent request matches the indexed message in the list

Parameters
orderedMessageListThe list of expected messages, in order expected
indexThe expected message to match

◆ verifyPlaybackMessage()

bool alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::verifyPlaybackMessage ( std::shared_ptr< avsCommon::avs::MessageRequest request,
std::string  expectedName,
bool  verifyReport = false 
)

Verify that the message name matches the expected name, and contains fields common to PlaybackEvents

Parameters
requestThe MessageRequest to verify
expectedNameThe expected name to find in the json header
verifyReportTrue to look for PlaybackReport

◆ verifyState()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::verifyState ( const std::string &  providedState,
const std::string &  expectedState 
)

Verify that the provided state matches the expected state

Parameters
jsonStateThe state to verify
expectedStateThe expected state

◆ verifyTags()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::verifyTags ( std::shared_ptr< avsCommon::avs::MessageRequest request,
std::map< std::string, int > *  expectedMessages,
bool  validateBoolean = true 
)

Verify that the message name matches the expected name and also verify expected tags.

Parameters
requestThe MessageRequest to verify
expectedMessagesMap of expected tags and count of how many are seen.

◆ wakeOnAcquireChannel()

bool alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::wakeOnAcquireChannel ( )

This is invoked in response to a acquireChannel call.

Returns
true

◆ wakeOnReleaseChannel()

std::future< bool > alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::wakeOnReleaseChannel ( )

This is invoked in response to a releaseChannel call.

Returns
true

◆ wakeOnSendMessage()

void alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::wakeOnSendMessage ( )

Fulfills the m_wakeSendMessagePromise. This is invoked in response to a sendMessage call.

◆ wakeOnSetState()

SetStateResult alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::wakeOnSetState ( )

This is invoked in response to a setState call.

Returns
SUCCESS.

Member Data Documentation

◆ m_attachmentManager

std::shared_ptr<AttachmentManager> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_attachmentManager

Attachment manager used to create a reader.

◆ m_audioPlayer

std::shared_ptr<AudioPlayer> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_audioPlayer

AudioPlayer to test

◆ m_cryptoFactory

std::shared_ptr<MockCryptoFactory> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_cryptoFactory

The mock MockCryptoFactory.

◆ m_expectedMessages

std::map<std::string, int> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_expectedMessages

Map for expected messages testing.

◆ m_mediaPlayerCallTrigger

std::condition_variable alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mediaPlayerCallTrigger

Condition variable to wake on MediaPlayer calls. This is used when a MediaPlayer call is expected to occur without a corresponding change in PlayerActivity.

◆ m_messageSentTrigger

std::condition_variable alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_messageSentTrigger

Condition variable to wake on a message being sent.

◆ m_mockCaptionManager

std::shared_ptr<MockCaptionManager> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockCaptionManager

A mock CaptionManager instance to handle captions parsing.

◆ m_mockChannelVolume

std::shared_ptr<MockChannelVolumeInterface> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockChannelVolume

ChannelVolumeInterface to send the audio to.

◆ m_mockContextManager

std::shared_ptr<MockContextManager> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockContextManager

ContextManager to provide state and update state.

◆ m_mockDirectiveHandlerResult

std::unique_ptr<MockDirectiveHandlerResult> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockDirectiveHandlerResult

A directive handler result to send the result to.

◆ m_mockExceptionSender

std::shared_ptr<MockExceptionEncounteredSender> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockExceptionSender

An exception sender used to send exception encountered events to AVS.

◆ m_mockFocusManager

std::shared_ptr<MockFocusManager> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockFocusManager

FocusManager to request focus to the DIALOG channel.

◆ m_mockMediaPlayer

std::shared_ptr<MockMediaPlayer> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockMediaPlayer

Player to send the audio to.

◆ m_mockMediaPlayerTrack2

std::shared_ptr<MockMediaPlayer> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockMediaPlayerTrack2

Another Player to send the audio to.

◆ m_mockMediaPlayerTrack3

std::shared_ptr<MockMediaPlayer> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockMediaPlayerTrack3

Another Player to send the audio to.

◆ m_mockMediaResourceProvider

std::shared_ptr<avsCommon::utils::mediaPlayer::PooledMediaResourceProviderInterface> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockMediaResourceProvider

PooledMediaResourceProviderInterface to provide mock media players and speakers for testing.

◆ m_mockMessageSender

std::shared_ptr<MockMessageSender> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockMessageSender

A message sender used to send events to AVS.

◆ m_mockMetricRecorder

std::shared_ptr<MockMetricRecorder> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockMetricRecorder

The mock MetricRecorderInterface.

◆ m_mockPlaybackRouter

std::shared_ptr<MockPlaybackRouter> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mockPlaybackRouter

A playback router to notify when AudioPlayer becomes active.

◆ m_mutex

std::mutex alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_mutex

General purpose mutex.

◆ m_sourceId

MediaPlayerInterface::SourceId alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_sourceId

Identifier for the currently selected audio source.

◆ m_testAudioPlayerObserver

std::shared_ptr<TestAudioPlayerObserver> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_testAudioPlayerObserver

A test observer to wait for AudioPlayer state changes

◆ m_wakeAcquireChannelFuture

std::future<void> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_wakeAcquireChannelFuture

Future to notify when acquireChannel is called.

◆ m_wakeAcquireChannelPromise

std::promise<void> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_wakeAcquireChannelPromise

Promise to be fulfilled when acquireChannel is called.

◆ m_wakeReleaseChannelFuture

std::future<void> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_wakeReleaseChannelFuture

Future to notify when releaseChannel is called.

◆ m_wakeReleaseChannelPromise

std::promise<void> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_wakeReleaseChannelPromise

Promise to be fulfilled when acquireChannel is called.

◆ m_wakeSendMessageFuture

std::future<void> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_wakeSendMessageFuture

Future to notify when sendMessage is called.

◆ m_wakeSendMessagePromise

std::promise<void> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_wakeSendMessagePromise

Promise to be fulfilled when sendMessage is called.

◆ m_wakeSetStateFuture

std::future<void> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_wakeSetStateFuture

Future to notify when setState is called.

◆ m_wakeSetStatePromise

std::promise<void> alexaClientSDK::acsdkAudioPlayer::test::AudioPlayerTest::m_wakeSetStatePromise

Promise to be fulfilled when setState is called.


The documentation for this class was generated from the following file:

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0