AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MockExternalMediaPlayerAdapter.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef AVS_CAPABILITIES_EXTERNALMEDIAPLAYER_ACSDKEXTERNALMEDIAPLAYERINTERFACES_TEST_ACSDKEXTERNALMEDIAPLAYERINTERFACES_MOCKEXTERNALMEDIAPLAYERADAPTER_H_
17 #define AVS_CAPABILITIES_EXTERNALMEDIAPLAYER_ACSDKEXTERNALMEDIAPLAYERINTERFACES_TEST_ACSDKEXTERNALMEDIAPLAYERINTERFACES_MOCKEXTERNALMEDIAPLAYERADAPTER_H_
18 
21 
29 
30 #include <gmock/gmock.h>
31 
32 namespace alexaClientSDK {
33 namespace acsdkExternalMediaPlayerInterfaces {
34 namespace test {
35 
38 public:
39  /*
40  * Method that adheres to the AdapterCreateFunc interface to create an
41  * adapter. This method create a mock instances and assigns it to a class
42  * static to keep the mock class simple.
43  *
44  * @param metricRecorder The metricRecorder instance to be used to record
45  * metrics
46  * @param mediaPlayer The mediaPlayer instance to be used to play Spotify
47  * content.
48  * @param speakerManager A @c SpeakerManagerInterface to perform volume
49  * changes requested by ESDK.
50  * @param messageSender The object to use for sending events.
51  * @param focusManager The focusManager used to acquire/release channel.
52  * @param contextManager The AVS Context manager used to generate system
53  * context for events.
54  * @param externalMediaPlayer The instance of the @c ExternalMediaPlayer
55  * managing the adapter.
56  * @return A @c std::shared_ptr to the new @c ExternalMediaAdapter instance.
57  */
58  static std::shared_ptr<acsdkExternalMediaPlayerInterfaces::ExternalMediaAdapterInterface> getInstance(
59  std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder,
60  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> mediaPlayer,
61  std::shared_ptr<avsCommon::sdkInterfaces::ChannelVolumeInterface> speaker,
62  std::shared_ptr<avsCommon::sdkInterfaces::SpeakerManagerInterface> speakerManager,
63  std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> messageSender,
64  std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> focusManager,
65  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
66  std::shared_ptr<acsdkExternalMediaPlayerInterfaces::ExternalMediaPlayerInterface> externalMediaPlayer);
67 
70 
71  static std::shared_ptr<MockExternalMediaPlayerAdapter> m_currentActiveMediaPlayerAdapter;
72 
73  MOCK_METHOD0(doShutdown, void());
74  MOCK_METHOD0(init, void());
75  MOCK_METHOD0(deInit, void());
78  void(
79  const std::string& accessToken,
80  const std::string& userName,
81  bool forceLogin,
82  std::chrono::milliseconds tokenRefreshInterval));
83  MOCK_METHOD0(handleLogout, void());
84  MOCK_METHOD1(handlePlay, void(const HandlePlayParams& params));
85  MOCK_METHOD2(handlePlayControl, void(RequestType requestType, const std::string& playbackTarget));
86  MOCK_METHOD1(handleSeek, void(std::chrono::milliseconds offset));
87  MOCK_METHOD1(handleAdjustSeek, void(std::chrono::milliseconds deltaOffset));
90  void(bool authorized, const std::string& playerId, const std::string& defaultSkillToken));
91  MOCK_METHOD1(handleSetVolume, void(int8_t volume));
92  MOCK_METHOD1(handleSetMute, void(bool));
94  MOCK_METHOD0(getOffset, std::chrono::milliseconds());
95 };
96 
98 std::shared_ptr<MockExternalMediaPlayerAdapter> MockExternalMediaPlayerAdapter::m_currentActiveMediaPlayerAdapter;
99 
101  RequiresShutdown("MockExternalMediaPlayerAdapter"),
102  ExternalMediaAdapterInterface("MockExternalMediaPlayerAdapter") {
103 }
104 
105 std::shared_ptr<acsdkExternalMediaPlayerInterfaces::ExternalMediaAdapterInterface> MockExternalMediaPlayerAdapter::
107  std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder,
108  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> mediaPlayer,
109  std::shared_ptr<avsCommon::sdkInterfaces::ChannelVolumeInterface> speaker,
110  std::shared_ptr<avsCommon::sdkInterfaces::SpeakerManagerInterface> speakerManager,
111  std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> messageSender,
112  std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> focusManager,
113  std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager,
114  std::shared_ptr<acsdkExternalMediaPlayerInterfaces::ExternalMediaPlayerInterface> externalMediaPlayer) {
115  MockExternalMediaPlayerAdapter::m_currentActiveMediaPlayerAdapter =
116  std::shared_ptr<MockExternalMediaPlayerAdapter>(new MockExternalMediaPlayerAdapter());
118 }
119 } // namespace test
120 } // namespace acsdkExternalMediaPlayerInterfaces
121 } // namespace alexaClientSDK
122 
123 #endif // AVS_CAPABILITIES_EXTERNALMEDIAPLAYER_ACSDKEXTERNALMEDIAPLAYERINTERFACES_TEST_ACSDKEXTERNALMEDIAPLAYERINTERFACES_MOCKEXTERNALMEDIAPLAYERADAPTER_H_
virtual void handleAdjustSeek(std::chrono::milliseconds deltaOffset)=0
Definition: AmdMetricWrapperTest.cpp:24
RequestType
Definition: ExternalMediaAdapterInterface.h:32
::std::string string
Definition: gtest-port.h:1097
virtual void handleAuthorized(bool authorized, const std::string &playerId, const std::string &defaultSkillToken)=0
MOCK_METHOD3(handleAuthorized, void(bool authorized, const std::string &playerId, const std::string &defaultSkillToken))
Definition: ExternalMediaAdapterInterface.h:495
virtual void init()=0
Method to initialize a third party library.
static std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder
Metric recorder shared ptr.
Definition: BaseAPLCapabilityAgentTest.cpp:261
virtual void deInit()=0
Method to de-initialize a third party library.
MockExternalMediaPlayerAdapter()
MockExternalMediaPlayerAdapter private constructor.
Definition: MockExternalMediaPlayerAdapter.h:100
MOCK_METHOD4(handleLogin, void(const std::string &accessToken, const std::string &userName, bool forceLogin, std::chrono::milliseconds tokenRefreshInterval))
virtual void handleLogin(const std::string &accessToken, const std::string &userName, bool forceLogin, std::chrono::milliseconds tokenRefreshInterval)=0
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
static std::shared_ptr< acsdkExternalMediaPlayerInterfaces::ExternalMediaAdapterInterface > getInstance(std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder, std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface > mediaPlayer, std::shared_ptr< avsCommon::sdkInterfaces::ChannelVolumeInterface > speaker, std::shared_ptr< avsCommon::sdkInterfaces::SpeakerManagerInterface > speakerManager, std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > messageSender, std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface > focusManager, std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > contextManager, std::shared_ptr< acsdkExternalMediaPlayerInterfaces::ExternalMediaPlayerInterface > externalMediaPlayer)
Definition: MockExternalMediaPlayerAdapter.h:106
static std::shared_ptr< MockExternalMediaPlayerAdapter > m_currentActiveMediaPlayerAdapter
Static instance of MockMediaPlayerAdapter.
Definition: MockExternalMediaPlayerAdapter.h:71
virtual void handlePlayControl(RequestType requestType, const std::string &playbackTarget)=0
virtual AdapterState getState()=0
Method to fetch the state(session state and playback state) of an adapter.
MOCK_METHOD2(handlePlayControl, void(RequestType requestType, const std::string &playbackTarget))
Mock class of ExternalMediaAdapterInterface.
Definition: MockExternalMediaPlayerAdapter.h:37

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