AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MockChannelVolumeInterface.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 ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_TEST_AVSCOMMON_SDKINTERFACES_MOCKCHANNELVOLUMEINTERFACE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_TEST_AVSCOMMON_SDKINTERFACES_MOCKCHANNELVOLUMEINTERFACE_H_
18 
19 #include <gmock/gmock.h>
22 
23 namespace alexaClientSDK {
24 namespace avsCommon {
25 namespace sdkInterfaces {
26 namespace test {
27 using namespace ::testing;
28 
30 public:
32  return m_type;
33  }
34  size_t getId() const {
35  return (size_t)m_speaker.get();
36  }
37  bool startDucking() {
38  return true;
39  }
40  bool stopDucking() {
41  return true;
42  }
43  bool setUnduckedVolume(int8_t volume) {
44  m_settings.volume = volume;
45  return true;
46  }
47  bool setMute(bool mute) {
48  m_settings.mute = mute;
49  return true;
50  }
52  if (!settings) {
53  return false;
54  }
55  settings->volume = m_settings.volume;
56  settings->mute = m_settings.mute;
57  return true;
58  }
61  std::shared_ptr<avsCommon::sdkInterfaces::SpeakerInterface> speaker) :
64  m_type{type},
65  m_speaker{speaker} {
66  }
67 
68 private:
71  const std::shared_ptr<avsCommon::sdkInterfaces::SpeakerInterface> m_speaker;
72 };
73 
75 public:
77  MOCK_CONST_METHOD0(getId, size_t());
78  MOCK_METHOD0(startDucking, bool());
79  MOCK_METHOD0(stopDucking, bool());
80  MOCK_METHOD1(setUnduckedVolume, bool(int8_t));
81  MOCK_METHOD1(setMute, bool(bool));
83  void DelegateToReal();
87  std::shared_ptr<avsCommon::sdkInterfaces::SpeakerInterface> speaker =
88  std::make_shared<NiceMock<MockSpeakerInterface>>()) :
90  m_manager{type, speaker} {
91  }
92 
93 private:
94  MockChannelVolumeManager m_manager;
95 };
96 
98  ON_CALL(*this, getSpeakerType()).WillByDefault(Invoke(&m_manager, &ChannelVolumeInterface::getSpeakerType));
99  ON_CALL(*this, getId()).WillByDefault(Invoke(&m_manager, &ChannelVolumeInterface::getId));
100  ON_CALL(*this, startDucking()).WillByDefault(Invoke(&m_manager, &ChannelVolumeInterface::startDucking));
101  ON_CALL(*this, stopDucking()).WillByDefault(Invoke(&m_manager, &ChannelVolumeInterface::stopDucking));
102  ON_CALL(*this, setUnduckedVolume(_)).WillByDefault(Invoke(&m_manager, &ChannelVolumeInterface::setUnduckedVolume));
103  ON_CALL(*this, setMute(_)).WillByDefault(Invoke(&m_manager, &ChannelVolumeInterface::setMute));
104  ON_CALL(*this, getSpeakerSettings(_))
105  .WillByDefault(Invoke(&m_manager, &ChannelVolumeInterface::getSpeakerSettings));
106 }
107 
108 } // namespace test
109 } // namespace sdkInterfaces
110 } // namespace avsCommon
111 } // namespace alexaClientSDK
112 
113 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_TEST_AVSCOMMON_SDKINTERFACES_MOCKCHANNELVOLUMEINTERFACE_H_
virtual std::size_t getId() const
Definition: ChannelVolumeInterface.h:117
Definition: gmock-actions.h:53
virtual bool getSpeakerSettings(avsCommon::sdkInterfaces::SpeakerInterface::SpeakerSettings *settings) const =0
avsCommon::sdkInterfaces::ChannelVolumeInterface::Type getSpeakerType() const
Definition: MockChannelVolumeInterface.h:31
Definition: AmdMetricWrapperTest.cpp:24
#define ON_CALL(obj, call)
Definition: gmock-spec-builders.h:1841
bool startDucking()
Definition: MockChannelVolumeInterface.h:37
size_t getId() const
Definition: MockChannelVolumeInterface.h:34
bool mute
True means muted, false means unmuted.
Definition: SpeakerInterface.h:46
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
Definition: gmock-more-actions.h:114
bool setMute(bool mute)
Definition: MockChannelVolumeInterface.h:47
MockChannelVolumeManager(avsCommon::sdkInterfaces::ChannelVolumeInterface::Type type, std::shared_ptr< avsCommon::sdkInterfaces::SpeakerInterface > speaker)
Definition: MockChannelVolumeInterface.h:59
const int8_t AVS_SET_VOLUME_MIN
AVS setVolume Minimum.
Definition: SpeakerConstants.h:30
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
MockChannelVolumeInterface(avsCommon::sdkInterfaces::ChannelVolumeInterface::Type type=avsCommon::sdkInterfaces::ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, std::shared_ptr< avsCommon::sdkInterfaces::SpeakerInterface > speaker=std::make_shared< NiceMock< MockSpeakerInterface >>())
Definition: MockChannelVolumeInterface.h:84
int8_t volume
Must be within [AVS_SET_VOLUME_MIN, AVS_SET_VOLUME_MAX].
Definition: SpeakerInterface.h:44
bool stopDucking()
Definition: MockChannelVolumeInterface.h:40
type
Definition: upload.py:443
void DelegateToReal()
Definition: MockChannelVolumeInterface.h:97
bool getSpeakerSettings(avsCommon::sdkInterfaces::SpeakerInterface::SpeakerSettings *settings) const
Definition: MockChannelVolumeInterface.h:51
const internal::AnythingMatcher _
Definition: gmock-matchers.h:3729
#define MOCK_CONST_METHOD1(m,...)
Definition: gmock-generated-function-mockers.h:688
#define MOCK_METHOD0(m,...)
Definition: gmock-generated-function-mockers.h:675
#define MOCK_METHOD1(m,...)
Definition: gmock-generated-function-mockers.h:676
#define MOCK_CONST_METHOD0(m,...)
Definition: gmock-generated-function-mockers.h:687
bool setUnduckedVolume(int8_t volume)
Definition: MockChannelVolumeInterface.h:43

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