2017-10-30 22:14:38 +00:00
|
|
|
/*
|
2020-04-13 22:56:35 +00:00
|
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2017-10-30 22:14:38 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
* A copy of the License is located at
|
|
|
|
*
|
|
|
|
* http://aws.amazon.com/apache2.0/
|
|
|
|
*
|
|
|
|
* or in the "license" file accompanying this file. This file is distributed
|
|
|
|
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
|
|
* express or implied. See the License for the specific language governing
|
|
|
|
* permissions and limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
#include <future>
|
2017-10-30 22:14:38 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <set>
|
2020-04-13 22:56:35 +00:00
|
|
|
#include <vector>
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
#include <AVSCommon/AVS/Attachment/MockAttachmentManager.h>
|
2020-04-13 22:56:35 +00:00
|
|
|
#include <AVSCommon/SDKInterfaces/MockChannelVolumeInterface.h>
|
2017-10-30 22:14:38 +00:00
|
|
|
#include <AVSCommon/SDKInterfaces/MockContextManager.h>
|
|
|
|
#include <AVSCommon/SDKInterfaces/MockDirectiveHandlerResult.h>
|
|
|
|
#include <AVSCommon/SDKInterfaces/MockExceptionEncounteredSender.h>
|
|
|
|
#include <AVSCommon/SDKInterfaces/MockMessageSender.h>
|
Version 1.8 alexa-client-sdk
Changes in this update:
Enhancements
Added local stop functionality. This allows a user to stop an active function, such as an alert or timer, by uttering "Alexa, stop" when an Alexa-enabled product is offline.
Alerts in the background now stream in 10 sec intervals, rather than continuously.
Added support for France to the sample app.
friendlyName can now be updated for BlueZ implementations of BlueZBluetoothDevice and BlueZHostController.
Bug Fixes
Fixed an issue where the Bluetooth agent didn't clear user data upon reset, including paired devices and the uuidMapping table.
Fixed MediaPlayer threading issues. Now each instance has it's own glib main loop thread, rather than utilizing the default main context worker thread.
Fixed segmentation fault issues that occurred when certain static initializers needed to be initialized in a certain order, but the order wasn't defined.
Known Issues
The ACL may encounter issues if audio attachments are received but not consumed.
SpeechSynthesizerState currently uses GAINING_FOCUS and LOSING_FOCUS as a workaround for handling intermediate state. These states may be removed in a future release.
The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
When a source device is streaming silence via Bluetooth, the Alexa companion app indicates that audio content is streaming.
The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
On Raspberry Pi, when streaming audio via Bluetooth, sometimes the audio stream stutters.
On Raspberry Pi, BlueALSA must be terminated each time the device boots. See Raspberry Pi Quick Start Guide for more information.
2018-06-27 21:41:15 +00:00
|
|
|
#include <AVSCommon/SDKInterfaces/MockSpeakerInterface.h>
|
2017-10-30 22:14:38 +00:00
|
|
|
#include <AVSCommon/SDKInterfaces/SpeakerManagerObserverInterface.h>
|
|
|
|
#include <AVSCommon/Utils/Memory/Memory.h>
|
2020-06-22 23:48:22 +00:00
|
|
|
#include <AVSCommon/Utils/Metrics/MockMetricRecorder.h>
|
Version 1.8 alexa-client-sdk
Changes in this update:
Enhancements
Added local stop functionality. This allows a user to stop an active function, such as an alert or timer, by uttering "Alexa, stop" when an Alexa-enabled product is offline.
Alerts in the background now stream in 10 sec intervals, rather than continuously.
Added support for France to the sample app.
friendlyName can now be updated for BlueZ implementations of BlueZBluetoothDevice and BlueZHostController.
Bug Fixes
Fixed an issue where the Bluetooth agent didn't clear user data upon reset, including paired devices and the uuidMapping table.
Fixed MediaPlayer threading issues. Now each instance has it's own glib main loop thread, rather than utilizing the default main context worker thread.
Fixed segmentation fault issues that occurred when certain static initializers needed to be initialized in a certain order, but the order wasn't defined.
Known Issues
The ACL may encounter issues if audio attachments are received but not consumed.
SpeechSynthesizerState currently uses GAINING_FOCUS and LOSING_FOCUS as a workaround for handling intermediate state. These states may be removed in a future release.
The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
When a source device is streaming silence via Bluetooth, the Alexa companion app indicates that audio content is streaming.
The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
On Raspberry Pi, when streaming audio via Bluetooth, sometimes the audio stream stutters.
On Raspberry Pi, BlueALSA must be terminated each time the device boots. See Raspberry Pi Quick Start Guide for more information.
2018-06-27 21:41:15 +00:00
|
|
|
#include <SpeakerManager/SpeakerManagerConstants.h>
|
2017-10-30 22:14:38 +00:00
|
|
|
#include <gmock/gmock.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <rapidjson/document.h>
|
|
|
|
#include <rapidjson/stringbuffer.h>
|
|
|
|
#include <rapidjson/writer.h>
|
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
#include "SpeakerManager/SpeakerManagerStorageInterface.h"
|
2017-10-30 22:14:38 +00:00
|
|
|
#include "SpeakerManager/SpeakerManager.h"
|
|
|
|
|
|
|
|
namespace alexaClientSDK {
|
|
|
|
namespace capabilityAgents {
|
|
|
|
namespace speakerManager {
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
using namespace avsCommon::avs;
|
|
|
|
using namespace avsCommon::avs::attachment::test;
|
|
|
|
using namespace avsCommon::avs::speakerConstants;
|
|
|
|
using namespace avsCommon::sdkInterfaces;
|
|
|
|
using namespace avsCommon::sdkInterfaces::test;
|
|
|
|
using namespace avsCommon::utils::memory;
|
|
|
|
using namespace rapidjson;
|
|
|
|
using namespace ::testing;
|
|
|
|
|
|
|
|
/// Timeout when waiting for futures to be set.
|
|
|
|
static std::chrono::milliseconds TIMEOUT(1000);
|
|
|
|
|
|
|
|
/// The @c MessageId identifer.
|
|
|
|
static const std::string MESSAGE_ID("messageId");
|
|
|
|
|
|
|
|
/// A @c SetVolume/AdjustVolume payload.
|
|
|
|
static const std::string VOLUME_PAYLOAD =
|
|
|
|
"{"
|
|
|
|
"\"volume\":" +
|
|
|
|
std::to_string(AVS_SET_VOLUME_MAX) +
|
|
|
|
""
|
|
|
|
"}";
|
|
|
|
|
|
|
|
/// A @c SetMute payload.
|
|
|
|
static const std::string MUTE_PAYLOAD =
|
|
|
|
"{"
|
|
|
|
"\"mute\":" +
|
|
|
|
MUTE_STRING +
|
|
|
|
""
|
|
|
|
"}";
|
|
|
|
|
2019-05-22 23:06:18 +00:00
|
|
|
/// A @c SetMute payload to unmute.
|
|
|
|
static const std::string UNMUTE_PAYLOAD =
|
|
|
|
"{"
|
|
|
|
"\"mute\":" +
|
|
|
|
UNMUTE_STRING +
|
|
|
|
""
|
|
|
|
"}";
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
#ifdef ENABLE_MAXVOLUME_SETTING
|
|
|
|
/// A valid value to be used as maximum volume limit.
|
|
|
|
static const int8_t VALID_MAXIMUM_VOLUME_LIMIT = AVS_SET_VOLUME_MAX - 10;
|
|
|
|
|
|
|
|
/// An invalid maximum volume limit value
|
|
|
|
static const int8_t INVALID_MAXIMUM_VOLUME_LIMIT = AVS_SET_VOLUME_MAX + 10;
|
|
|
|
#endif
|
|
|
|
|
2021-03-29 19:59:51 +00:00
|
|
|
/// A valid delta to adjust the volume.
|
|
|
|
static const int8_t VALID_VOLUME_ADJUSTMENT = 10;
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
/**
|
|
|
|
* A mock object to test that the observer is being correctly notified.
|
|
|
|
*/
|
|
|
|
class MockObserver : public SpeakerManagerObserverInterface {
|
|
|
|
public:
|
|
|
|
MOCK_METHOD3(
|
|
|
|
onSpeakerSettingsChanged,
|
2020-04-13 22:56:35 +00:00
|
|
|
void(const Source&, const ChannelVolumeInterface::Type&, const SpeakerInterface::SpeakerSettings&));
|
2017-10-30 22:14:38 +00:00
|
|
|
};
|
2020-04-13 22:56:35 +00:00
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
class MockSpeakerManagerStorage : public SpeakerManagerStorageInterface {
|
|
|
|
public:
|
|
|
|
MOCK_METHOD1(loadState, bool(SpeakerManagerStorageState&));
|
|
|
|
MOCK_METHOD1(saveState, bool(const SpeakerManagerStorageState&));
|
|
|
|
|
|
|
|
MockSpeakerManagerStorage() :
|
|
|
|
m_state{.speakerChannelState = {.channelVolume = AVS_SET_VOLUME_MIN, .channelMuteStatus = UNMUTE},
|
|
|
|
.alertsChannelState = {.channelVolume = AVS_SET_VOLUME_MIN, .channelMuteStatus = UNMUTE}} {
|
|
|
|
ON_CALL(*this, loadState(_)).WillByDefault(Invoke([this](SpeakerManagerStorageState& state) {
|
|
|
|
state = this->m_state;
|
|
|
|
return true;
|
|
|
|
}));
|
|
|
|
ON_CALL(*this, saveState(_)).WillByDefault(Invoke([this](const SpeakerManagerStorageState& state) {
|
|
|
|
this->m_state = state;
|
|
|
|
return true;
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDefaults() {
|
|
|
|
m_state = {.speakerChannelState = {.channelVolume = AVS_SET_VOLUME_MIN, .channelMuteStatus = UNMUTE},
|
|
|
|
.alertsChannelState = {.channelVolume = AVS_SET_VOLUME_MIN, .channelMuteStatus = UNMUTE}};
|
|
|
|
}
|
|
|
|
|
|
|
|
void setFailureMode() {
|
|
|
|
ON_CALL(*this, loadState(_)).WillByDefault(Return(false));
|
|
|
|
ON_CALL(*this, saveState(_)).WillByDefault(Return(false));
|
|
|
|
}
|
|
|
|
|
|
|
|
SpeakerManagerStorageState m_state;
|
|
|
|
};
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
class SpeakerManagerTest : public ::testing::TestWithParam<std::vector<ChannelVolumeInterface::Type>> {
|
2017-10-30 22:14:38 +00:00
|
|
|
public:
|
|
|
|
/// SetUp before each test.
|
|
|
|
void SetUp();
|
|
|
|
|
|
|
|
/// TearDown after each test.
|
|
|
|
void TearDown();
|
|
|
|
|
|
|
|
/// CleanUp and reset the SpeakerManager.
|
|
|
|
void cleanUp();
|
|
|
|
|
|
|
|
/// Function to wait for @c m_wakeSetCompleteFuture to be set.
|
|
|
|
void wakeOnSetCompleted();
|
|
|
|
|
|
|
|
/// Helper function to get unique @c Type.
|
2020-04-13 22:56:35 +00:00
|
|
|
std::set<ChannelVolumeInterface::Type> getUniqueTypes(std::vector<std::shared_ptr<ChannelVolumeInterface>>& groups);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
#ifdef ENABLE_MAXVOLUME_SETTING
|
|
|
|
/**
|
|
|
|
* Helper function for create and sent a directive
|
|
|
|
*
|
|
|
|
* @param directiveName The directive name. One of SetVolume or AdjustVolume.
|
|
|
|
* @param volume The value of the volume files within the directive.
|
|
|
|
*/
|
|
|
|
void createAndSendVolumeDirective(const std::string directiveName, const int8_t volume);
|
|
|
|
#endif
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> createChannelVolumeInterfaces() {
|
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
|
|
|
return {channelVolumeInterface};
|
|
|
|
}
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
/// A constructor which initializes the promises and futures needed for the test class.
|
|
|
|
SpeakerManagerTest() :
|
|
|
|
m_wakeSetCompletedPromise{},
|
|
|
|
m_wakeSetCompletedFuture{m_wakeSetCompletedPromise.get_future()} {
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Promise to synchronize directive handling through setCompleted.
|
|
|
|
std::promise<void> m_wakeSetCompletedPromise;
|
|
|
|
|
|
|
|
/// Future to synchronize directive handling through setCompleted.
|
|
|
|
std::future<void> m_wakeSetCompletedFuture;
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
/// The metric recorder.
|
|
|
|
std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> m_metricRecorder;
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
/*
|
|
|
|
* Set this to a nice mock. The only instance of the mock being called is the setStateProvider member, which we
|
|
|
|
* explicitly test.
|
|
|
|
*/
|
|
|
|
std::shared_ptr<NiceMock<MockContextManager>> m_mockContextManager;
|
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
std::shared_ptr<MockSpeakerManagerStorage> m_mockStorage;
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
/// A strict mock that allows the test to strictly monitor the messages sent.
|
|
|
|
std::shared_ptr<StrictMock<MockMessageSender>> m_mockMessageSender;
|
|
|
|
|
|
|
|
/// A strict mock that allows the test to strictly monitor the exceptions being sent.
|
|
|
|
std::shared_ptr<StrictMock<MockExceptionEncounteredSender>> m_mockExceptionSender;
|
|
|
|
|
|
|
|
/// A strict mock that allows the test to strictly monitor the handling of directives.
|
|
|
|
std::unique_ptr<StrictMock<MockDirectiveHandlerResult>> m_mockDirectiveHandlerResult;
|
|
|
|
|
|
|
|
/// A mock to allow testing of the observer callback behavior.
|
|
|
|
std::shared_ptr<NiceMock<MockObserver>> m_observer;
|
|
|
|
|
|
|
|
/// A pointer to an instance of the SpeakerManager that will be instantiated per test.
|
|
|
|
std::shared_ptr<SpeakerManager> m_speakerManager;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SpeakerManagerTest::SetUp() {
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage = std::make_shared<NiceMock<MockSpeakerManagerStorage>>();
|
|
|
|
|
2020-06-22 23:48:22 +00:00
|
|
|
m_metricRecorder = std::make_shared<NiceMock<avsCommon::utils::metrics::test::MockMetricRecorder>>();
|
2017-10-30 22:14:38 +00:00
|
|
|
m_mockContextManager = std::make_shared<NiceMock<MockContextManager>>();
|
|
|
|
m_mockMessageSender = std::make_shared<StrictMock<MockMessageSender>>();
|
|
|
|
m_mockExceptionSender = std::make_shared<StrictMock<MockExceptionEncounteredSender>>();
|
|
|
|
m_mockDirectiveHandlerResult = make_unique<StrictMock<MockDirectiveHandlerResult>>();
|
|
|
|
m_observer = std::make_shared<NiceMock<MockObserver>>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpeakerManagerTest::TearDown() {
|
|
|
|
if (m_speakerManager) {
|
|
|
|
m_speakerManager->shutdown();
|
|
|
|
m_speakerManager.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpeakerManagerTest::wakeOnSetCompleted() {
|
|
|
|
m_wakeSetCompletedPromise.set_value();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to get unique @c Type from a vector of speakers.
|
|
|
|
*/
|
2020-04-13 22:56:35 +00:00
|
|
|
std::set<ChannelVolumeInterface::Type> SpeakerManagerTest::getUniqueTypes(
|
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>>& groups) {
|
|
|
|
std::set<ChannelVolumeInterface::Type> types;
|
|
|
|
for (auto item : groups) {
|
|
|
|
types.insert(item->getSpeakerType());
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
return types;
|
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
#ifdef ENABLE_MAXVOLUME_SETTING
|
|
|
|
void SpeakerManagerTest::createAndSendVolumeDirective(const std::string directiveName, const int8_t volume) {
|
|
|
|
EXPECT_CALL(*(m_mockDirectiveHandlerResult.get()), setCompleted())
|
|
|
|
.Times(1)
|
|
|
|
.WillOnce(InvokeWithoutArgs(this, &SpeakerManagerTest::wakeOnSetCompleted));
|
|
|
|
|
|
|
|
static int id = 1;
|
|
|
|
const std::string messageId = MESSAGE_ID + std::to_string(id++);
|
|
|
|
std::string payload =
|
|
|
|
"{"
|
|
|
|
"\"volume\":" +
|
|
|
|
std::to_string(volume) + "}";
|
|
|
|
|
|
|
|
// Create Directive.
|
|
|
|
auto attachmentManager = std::make_shared<StrictMock<MockAttachmentManager>>();
|
|
|
|
auto avsMessageHeader = std::make_shared<AVSMessageHeader>(SET_VOLUME.nameSpace, directiveName, messageId);
|
|
|
|
|
|
|
|
std::shared_ptr<AVSDirective> directive =
|
|
|
|
AVSDirective::create("", avsMessageHeader, payload, attachmentManager, "");
|
|
|
|
|
|
|
|
m_speakerManager->CapabilityAgent::preHandleDirective(directive, std::move(m_mockDirectiveHandlerResult));
|
|
|
|
m_speakerManager->CapabilityAgent::handleDirective(messageId);
|
|
|
|
m_wakeSetCompletedFuture.wait_for(TIMEOUT);
|
|
|
|
}
|
|
|
|
|
2020-06-22 23:48:22 +00:00
|
|
|
static int8_t getSpeakerVolume(std::shared_ptr<ChannelVolumeInterface> channelVolumeInterface) {
|
2020-02-19 18:35:26 +00:00
|
|
|
SpeakerInterface::SpeakerSettings speakerSettings;
|
2020-06-22 23:48:22 +00:00
|
|
|
channelVolumeInterface->getSpeakerSettings(&speakerSettings);
|
2020-02-19 18:35:26 +00:00
|
|
|
return speakerSettings.volume;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-12-09 00:07:37 +00:00
|
|
|
/// Helper function to generate the VolumeState in JSON for the ContextManager.
|
|
|
|
std::string generateVolumeStateJson(SpeakerInterface::SpeakerSettings settings) {
|
|
|
|
rapidjson::Document state(rapidjson::kObjectType);
|
|
|
|
state.AddMember(VOLUME_KEY, settings.volume, state.GetAllocator());
|
|
|
|
state.AddMember(MUTED_KEY, settings.mute, state.GetAllocator());
|
|
|
|
|
|
|
|
rapidjson::StringBuffer buffer;
|
|
|
|
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
|
|
|
if (!state.Accept(writer)) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return buffer.GetString();
|
|
|
|
}
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
/**
|
|
|
|
* Tests creating the SpeakerManager with a null contextManager.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_nullContextManager) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterfaces = createChannelVolumeInterfaces();
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, channelVolumeInterfaces, nullptr, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
ASSERT_EQ(m_speakerManager, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests creating the SpeakerManager with a null messageSender.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_nullMessageSender) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterfaces = createChannelVolumeInterfaces();
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, channelVolumeInterfaces, m_mockContextManager, nullptr, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
ASSERT_EQ(m_speakerManager, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests creating the SpeakerManager with a null exceptionSender.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_nullExceptionSender) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterfaces = createChannelVolumeInterfaces();
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, channelVolumeInterfaces, m_mockContextManager, m_mockMessageSender, nullptr, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
ASSERT_EQ(m_speakerManager, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-04-13 22:56:35 +00:00
|
|
|
* Tests creating the SpeakerManager with no channelVolumeInterfaces.
|
2017-10-30 22:14:38 +00:00
|
|
|
*/
|
2020-04-13 22:56:35 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_noChannelVolumeInterfaces) {
|
2021-11-15 23:35:18 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
|
|
|
m_mockStorage, {}, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
Version 1.9.0 alexa-client-sdk
Changes in this update:
Enhancements
Added Android SDK support, which includes new implementations of the MediaPlayer, audio recorder, and logger.
Added the InteractionModel interface, which enables Alexa Routines.
Optional configuration changes have been introduced. Now a network interface can be specified to connect to the SDK via curl.
Build options can be configured to support Android.
Added GUI 1.1 support. The PlaybackController has been extended to support new control functionality, and the System interface has been updated to support SoftwareInfo.
Bug Fixes
Installation script execution time has been reduced. Now a single branch clone is used, such as the master branch.
Issue 846 - Fixed a bug where audio stuttered on slow network connections.
Removed the SpeakerManager constructor check for non-zero speakers.
Issue 891 - Resolved incorrect offset in the PlaybackFinished event.
Issue 727 - Fixed an issue where the sample app behaved erratically upon network disconnection/reconnection.
Issue 910 - Fixed a GCC 8+ compilation issue. Note: issues related to -Wclass-memaccess will still trigger warnings, but won't fail compilation.
Issue 871 Issue 880 - Fixed compiler warnings.
Fixed a bug where Ted Talks would not stream via TuneIn.
Fixed an issue where the PryonLiteKeywordDetector would not restart.
Fixed an issue where PlaybackStutterStarted and PlaybackStutterFinished events were not being sent due to a missing Gstreamer queue element.
Fixed a bug where the CapabilitiesDelegate database was not being cleared upon logout.
Fixed in issue that caused the following compiler warning “class has virtual functions but non-virtual destructor”.
Fixed a bug where BlueZDeviceManager was not properly destroyed.
Fixed a bug that occurred when the initializer list was converted to std::unordered_set.
Fixed a build error that occurred when building with BUILD_TESTING=Off.
Known Issues
* The ACL may encounter issues if audio attachments are received but not consumed.
* SpeechSynthesizerState currently uses GAINING_FOCUS and LOSING_FOCUS as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa companion app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* On Raspberry Pi, when streaming audio via Bluetooth, sometimes the audio stream stutters.
* These CapabilitiesDelegateTest tests have been temporarily disabled to prevent build errors for the Android build: CapabilitiesDelegateTest.withCapabilitiesHappyCase, CapabilitiesDelegateTest.republish, CapabilitiesDelegateTest.testClearData.
* make integration is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with the any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user TTS.
* Spotify does not completely shut down when the sample app quits.
2018-08-28 21:10:18 +00:00
|
|
|
ASSERT_NE(m_speakerManager, nullptr);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-12-09 00:07:37 +00:00
|
|
|
* Tests that the SpeakerManager initially provides the state at constructor time.
|
2017-10-30 22:14:38 +00:00
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_contextManagerSetStateConstructor) {
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(DEFAULT_SETTINGS), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
auto groups = createChannelVolumeInterfaces();
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groups, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test setVolume with a value that's under the bounds. The operation should fail.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_setVolumeUnderBounds) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
2021-11-15 23:35:18 +00:00
|
|
|
|
|
|
|
// Expect call on initialization
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).Times(Exactly(1));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
{channelVolumeInterface},
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
// Expect no more calls
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).Times(Exactly(0));
|
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(0));
|
2017-10-30 22:14:38 +00:00
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
2021-11-15 23:35:18 +00:00
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
|
|
|
std::future<bool> future = m_speakerManager->setVolume(
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_SET_VOLUME_MIN - 1, properties);
|
2017-10-30 22:14:38 +00:00
|
|
|
ASSERT_FALSE(future.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test setVolume with a value that's over the bounds. The operation should fail.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_setVolumeOverBounds) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
2021-11-15 23:35:18 +00:00
|
|
|
|
|
|
|
// Expect call on initialization.
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).Times(Exactly(1));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
{channelVolumeInterface},
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
// Expect no more calls.
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).Times(Exactly(0));
|
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(0));
|
2017-10-30 22:14:38 +00:00
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
|
|
|
std::future<bool> future = m_speakerManager->setVolume(
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_SET_VOLUME_MAX + 1, properties);
|
2017-10-30 22:14:38 +00:00
|
|
|
ASSERT_FALSE(future.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test adjustVolume with a value that's under the bounds. The operation should fail.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_adjustVolumeUnderBounds) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
2021-11-15 23:35:18 +00:00
|
|
|
|
|
|
|
// Expect call on initialization.
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).Times(Exactly(1));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
{channelVolumeInterface},
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
// Expect no more calls.
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).Times(Exactly(0));
|
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(0));
|
2017-10-30 22:14:38 +00:00
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
|
|
|
std::future<bool> future = m_speakerManager->adjustVolume(
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_ADJUST_VOLUME_MIN - 1, properties);
|
2017-10-30 22:14:38 +00:00
|
|
|
ASSERT_FALSE(future.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test adjustVolume with a value that's over the bounds. The operation should fail.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_adjustVolumeOverBounds) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
2021-11-15 23:35:18 +00:00
|
|
|
// Expect call on initialization.
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).Times(Exactly(1));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
{channelVolumeInterface},
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
// Expect no more calls.
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).Times(Exactly(0));
|
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(0));
|
2017-10-30 22:14:38 +00:00
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
|
|
|
std::future<bool> future = m_speakerManager->adjustVolume(
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_ADJUST_VOLUME_MAX + 1, properties);
|
2017-10-30 22:14:38 +00:00
|
|
|
ASSERT_FALSE(future.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-03-29 19:59:51 +00:00
|
|
|
* Test if one speaker is out of sync, getSpeakingSettings should return the cached value correctly.
|
2017-10-30 22:14:38 +00:00
|
|
|
*/
|
2021-03-29 19:59:51 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_getCachedSettings) {
|
|
|
|
// Prepare two speakers with the same type AVS_SPEAKER_VOLUME
|
|
|
|
auto channelVolumeInterface1 = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterface2 = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
2021-03-29 19:59:51 +00:00
|
|
|
channelVolumeInterface1->DelegateToReal();
|
|
|
|
channelVolumeInterface2->DelegateToReal();
|
|
|
|
// Get speaker settings from the first speaker of each type during initialization.
|
|
|
|
EXPECT_CALL(*channelVolumeInterface1, getSpeakerSettings(_)).Times(Exactly(1));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
2021-03-29 19:59:51 +00:00
|
|
|
{channelVolumeInterface1, channelVolumeInterface2},
|
2020-04-13 22:56:35 +00:00
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
2020-06-22 23:48:22 +00:00
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2021-03-29 19:59:51 +00:00
|
|
|
// If a speaker changes its volume and is out of sync with the rest speakers of the same type, querying speaker
|
|
|
|
// settings from SpeakerManager should return the cached volume correctly.
|
|
|
|
channelVolumeInterface2->setUnduckedVolume(AVS_SET_VOLUME_MAX);
|
|
|
|
channelVolumeInterface2->setMute(MUTE);
|
|
|
|
SpeakerInterface::SpeakerSettings settings;
|
2018-07-09 21:07:31 +00:00
|
|
|
std::future<bool> future =
|
2021-03-29 19:59:51 +00:00
|
|
|
m_speakerManager->getSpeakerSettings(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, &settings);
|
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
ASSERT_EQ(settings.volume, DEFAULT_SETTINGS.volume);
|
|
|
|
ASSERT_EQ(settings.mute, DEFAULT_SETTINGS.mute);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2021-03-29 19:59:51 +00:00
|
|
|
ASSERT_TRUE(channelVolumeInterface2->getSpeakerSettings(&settings));
|
|
|
|
ASSERT_EQ(settings.volume, AVS_SET_VOLUME_MAX);
|
|
|
|
ASSERT_EQ(settings.mute, MUTE);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
/*
|
|
|
|
* Test adjustVolume when the adjusted volume is unchanged. Should not send an event.
|
|
|
|
*/
|
|
|
|
TEST_F(SpeakerManagerTest, test_eventNotSentWhenAdjustVolumeUnchanged) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
auto groupVec = std::vector<std::shared_ptr<ChannelVolumeInterface>>{channelVolumeInterface};
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
|
|
|
|
// The test adjusts the volume by AVS_ADJUST_VOLUME_MIN, which results in the lowest volume possible.
|
|
|
|
SpeakerInterface::SpeakerSettings expectedSettings{AVS_SET_VOLUME_MIN, UNMUTE};
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
for (auto type : getUniqueTypes(groupVec)) {
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(SpeakerManagerObserverInterface::Source::LOCAL_API, type, expectedSettings))
|
|
|
|
.Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
if (ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME == type) {
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(0));
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(0));
|
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(AnyNumber());
|
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(expectedSettings), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
std::future<bool> future = m_speakerManager->adjustVolume(type, AVS_ADJUST_VOLUME_MIN, properties);
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test setVolume when the new volume is unchanged. Should not send an event.
|
|
|
|
*/
|
|
|
|
TEST_F(SpeakerManagerTest, test_eventNotSentWhenSetVolumeUnchanged) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(AVS_SET_VOLUME_MIN)).Times(Exactly(2));
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
auto groupVec = std::vector<std::shared_ptr<ChannelVolumeInterface>>{channelVolumeInterface};
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
|
|
|
|
SpeakerInterface::SpeakerSettings expectedSettings{AVS_SET_VOLUME_MIN, UNMUTE};
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
for (auto type : getUniqueTypes(groupVec)) {
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(SpeakerManagerObserverInterface::Source::LOCAL_API, type, expectedSettings))
|
|
|
|
.Times(Exactly(1));
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(0));
|
2020-04-13 22:56:35 +00:00
|
|
|
if (ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME == type) {
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(0));
|
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(AnyNumber());
|
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(expectedSettings), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
std::future<bool> future = m_speakerManager->setVolume(type, AVS_SET_VOLUME_MIN, properties);
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
/**
|
|
|
|
* Test getConfiguration and ensure that all directives are handled.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_getConfiguration) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterfaceVec = createChannelVolumeInterfaces();
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
channelVolumeInterfaceVec,
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
auto configuration = m_speakerManager->getConfiguration();
|
2021-03-29 19:59:51 +00:00
|
|
|
auto neitherNonBlockingPolicy = BlockingPolicy(BlockingPolicy::MEDIUMS_NONE, false);
|
|
|
|
ASSERT_EQ(configuration[SET_VOLUME], neitherNonBlockingPolicy);
|
|
|
|
ASSERT_EQ(configuration[ADJUST_VOLUME], neitherNonBlockingPolicy);
|
|
|
|
ASSERT_EQ(configuration[SET_MUTE], neitherNonBlockingPolicy);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 23:09:40 +00:00
|
|
|
/**
|
|
|
|
* Test that adding duplicated ChannelVolumeInterface instances in the SpeakerManager works correctly.
|
|
|
|
*/
|
|
|
|
TEST_F(SpeakerManagerTest, test_addDuplicatedChannelVolumeInterfaces) {
|
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> channelVolumeInterfaceVec = {channelVolumeInterface,
|
|
|
|
channelVolumeInterface};
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
channelVolumeInterfaceVec,
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2020-12-08 23:09:40 +00:00
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).Times(Exactly(1));
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(1));
|
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
|
|
|
std::future<bool> future = m_speakerManager->adjustVolume(
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_ADJUST_VOLUME_MAX, properties);
|
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
}
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
/**
|
|
|
|
* Test that adding a null observer does not cause any errors in the SpeakerManager.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_addNullObserver) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterfaceVec = createChannelVolumeInterfaces();
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
channelVolumeInterfaceVec,
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
m_speakerManager->addSpeakerManagerObserver(nullptr);
|
2020-02-19 18:35:26 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(2));
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
m_speakerManager->setVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_SET_VOLUME_MAX, properties)
|
|
|
|
.wait();
|
|
|
|
m_speakerManager->adjustVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_ADJUST_VOLUME_MAX, properties)
|
|
|
|
.wait();
|
|
|
|
m_speakerManager->setMute(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, MUTE, properties).wait();
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that removing an observer works correctly.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_removeSpeakerManagerObserver) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterfaceVec = createChannelVolumeInterfaces();
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
2020-02-19 18:35:26 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(2));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
channelVolumeInterfaceVec,
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
|
|
|
m_speakerManager->removeSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
m_speakerManager->setVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_SET_VOLUME_MAX, properties)
|
|
|
|
.wait();
|
|
|
|
m_speakerManager->adjustVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_ADJUST_VOLUME_MAX, properties)
|
|
|
|
.wait();
|
|
|
|
m_speakerManager->setMute(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, MUTE, properties).wait();
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that removing a null observer does not cause any errors in the SpeakerManager.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_F(SpeakerManagerTest, test_removeNullObserver) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto channelVolumeInterfaceVec = createChannelVolumeInterfaces();
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(2));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
channelVolumeInterfaceVec,
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
m_speakerManager->removeSpeakerManagerObserver(nullptr);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
m_speakerManager->setVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_SET_VOLUME_MAX, properties)
|
|
|
|
.wait();
|
|
|
|
m_speakerManager->adjustVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_ADJUST_VOLUME_MAX, properties)
|
|
|
|
.wait();
|
|
|
|
m_speakerManager->setMute(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, MUTE, properties).wait();
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
/*
|
2021-06-04 17:47:13 +00:00
|
|
|
* Test retry logic for SetVolume on speaker type AVS_SPEAKER_VOLUME. Returning false once for speaker->setVolume()
|
2020-02-19 18:35:26 +00:00
|
|
|
* triggers retry and when successful returns the future of value true.
|
|
|
|
*/
|
|
|
|
TEST_F(SpeakerManagerTest, test_retryAndApplySettingsForSetVolume) {
|
2021-06-04 17:47:13 +00:00
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
{channelVolumeInterface},
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2020-02-19 18:35:26 +00:00
|
|
|
|
2021-06-04 17:47:13 +00:00
|
|
|
auto retryTimes = 0;
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).WillRepeatedly(InvokeWithoutArgs([&retryTimes] {
|
|
|
|
return retryTimes++ > 0;
|
|
|
|
}));
|
|
|
|
|
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
2020-02-19 18:35:26 +00:00
|
|
|
std::future<bool> future =
|
2020-04-13 22:56:35 +00:00
|
|
|
m_speakerManager->setVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, AVS_SET_VOLUME_MIN, properties);
|
2020-02-19 18:35:26 +00:00
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-06-04 17:47:13 +00:00
|
|
|
* Test retry logic for AdjustVolume on speakers of type AVS_SPEAKER_VOLUME. Return false once for the second speaker
|
2021-03-29 19:59:51 +00:00
|
|
|
* during adjustVolume() to trigger a retry. The delta should not be applied again to the first speaker during retry.
|
2020-02-19 18:35:26 +00:00
|
|
|
*/
|
|
|
|
TEST_F(SpeakerManagerTest, test_retryAndApplySettingsForAdjustVolume) {
|
2021-03-29 19:59:51 +00:00
|
|
|
auto channelVolumeInterface1 = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
auto channelVolumeInterface2 = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface1->DelegateToReal();
|
|
|
|
channelVolumeInterface2->DelegateToReal();
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
2021-03-29 19:59:51 +00:00
|
|
|
{channelVolumeInterface1, channelVolumeInterface2},
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
|
|
|
|
|
|
|
auto retryTimes = 0;
|
|
|
|
EXPECT_CALL(*channelVolumeInterface2, setUnduckedVolume(_)).WillRepeatedly(InvokeWithoutArgs([&retryTimes] {
|
2021-06-04 17:47:13 +00:00
|
|
|
return retryTimes++ > 0;
|
2021-03-29 19:59:51 +00:00
|
|
|
}));
|
2020-02-19 18:35:26 +00:00
|
|
|
|
2021-03-29 19:59:51 +00:00
|
|
|
// Expect volumeChanged event.
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
std::future<bool> future = m_speakerManager->adjustVolume(
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
2021-03-29 19:59:51 +00:00
|
|
|
VALID_VOLUME_ADJUSTMENT,
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties());
|
2020-02-19 18:35:26 +00:00
|
|
|
ASSERT_TRUE(future.get());
|
2021-03-29 19:59:51 +00:00
|
|
|
|
|
|
|
SpeakerInterface::SpeakerSettings settings1;
|
|
|
|
ASSERT_TRUE(channelVolumeInterface1->getSpeakerSettings(&settings1));
|
|
|
|
ASSERT_EQ(settings1.volume, DEFAULT_SETTINGS.volume + VALID_VOLUME_ADJUSTMENT);
|
|
|
|
|
|
|
|
SpeakerInterface::SpeakerSettings speakerSettings;
|
|
|
|
std::future<bool> settingsFuture =
|
|
|
|
m_speakerManager->getSpeakerSettings(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, &speakerSettings);
|
|
|
|
ASSERT_TRUE(settingsFuture.get());
|
|
|
|
ASSERT_EQ(speakerSettings.volume, DEFAULT_SETTINGS.volume + VALID_VOLUME_ADJUSTMENT);
|
2020-02-19 18:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-06-04 17:47:13 +00:00
|
|
|
* Test retry logic for SetMute on speaker type AVS_SPEAKER_VOLUME. Returning false once for speaker->setMute()
|
2020-02-19 18:35:26 +00:00
|
|
|
* triggers retry and when successful returns the future of value true.
|
|
|
|
*/
|
|
|
|
TEST_F(SpeakerManagerTest, test_retryAndApplySettingsForSetMute) {
|
2021-06-04 17:47:13 +00:00
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
{channelVolumeInterface},
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2021-06-04 17:47:13 +00:00
|
|
|
|
|
|
|
auto retryTimes = 0;
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setMute(_)).WillRepeatedly(InvokeWithoutArgs([&retryTimes] {
|
|
|
|
return retryTimes++ > 0;
|
|
|
|
}));
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
2020-02-19 18:35:26 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
std::future<bool> future =
|
|
|
|
m_speakerManager->setMute(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, MUTE, properties);
|
2020-02-19 18:35:26 +00:00
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
}
|
|
|
|
|
2021-06-04 17:47:13 +00:00
|
|
|
/*
|
|
|
|
* Test retryAndApplySettings() failure for setVolume, adjustVolume and setMute on speaker type AVS_SPEAKER_VOLUME.
|
|
|
|
* Repeatedly returning false for adjustVolume() and setMute() to trigger retries. After retrying maximum times,
|
|
|
|
* returning the future of false.
|
|
|
|
*/
|
|
|
|
TEST_F(SpeakerManagerTest, test_retryAndApplySettingsFails) {
|
|
|
|
auto channelVolumeInterface = std::make_shared<NiceMock<MockChannelVolumeInterface>>();
|
|
|
|
channelVolumeInterface->DelegateToReal();
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
{channelVolumeInterface},
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2021-06-04 17:47:13 +00:00
|
|
|
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setUnduckedVolume(_)).WillRepeatedly(Return(false));
|
|
|
|
EXPECT_CALL(*channelVolumeInterface, setMute(_)).WillRepeatedly(Return(false));
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(0);
|
|
|
|
|
|
|
|
std::future<bool> setVolumeResult = m_speakerManager->setVolume(
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
AVS_SET_VOLUME_MIN,
|
|
|
|
SpeakerManagerInterface::NotificationProperties());
|
|
|
|
ASSERT_FALSE(setVolumeResult.get());
|
|
|
|
|
|
|
|
std::future<bool> adjustVolumeResult = m_speakerManager->adjustVolume(
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
VALID_VOLUME_ADJUSTMENT,
|
|
|
|
SpeakerManagerInterface::NotificationProperties());
|
|
|
|
ASSERT_FALSE(adjustVolumeResult.get());
|
|
|
|
|
|
|
|
std::future<bool> setMuteResult = m_speakerManager->setMute(
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, MUTE, SpeakerManagerInterface::NotificationProperties());
|
|
|
|
ASSERT_FALSE(setMuteResult.get());
|
|
|
|
|
|
|
|
SpeakerInterface::SpeakerSettings speakerSettings;
|
|
|
|
std::future<bool> settingsFuture =
|
|
|
|
m_speakerManager->getSpeakerSettings(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, &speakerSettings);
|
|
|
|
ASSERT_TRUE(settingsFuture.get());
|
|
|
|
ASSERT_EQ(speakerSettings.volume, DEFAULT_SETTINGS.volume);
|
|
|
|
ASSERT_EQ(speakerSettings.mute, DEFAULT_SETTINGS.mute);
|
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
#ifdef ENABLE_MAXVOLUME_SETTING
|
|
|
|
/**
|
2020-04-13 22:56:35 +00:00
|
|
|
* Test that setting a maximum volume limit succeeds and a local call to setVolume or adjustVolume will
|
2020-02-19 18:35:26 +00:00
|
|
|
* completely fail.
|
|
|
|
*/
|
|
|
|
|
|
|
|
TEST_F(SpeakerManagerTest, test_setMaximumVolumeLimit) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto avsChannelVolumeInterface =
|
|
|
|
std::make_shared<NiceMock<MockChannelVolumeInterface>>(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME);
|
|
|
|
avsChannelVolumeInterface->DelegateToReal();
|
|
|
|
auto alertsChannelVolumeInterface =
|
|
|
|
std::make_shared<NiceMock<MockChannelVolumeInterface>>(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME);
|
|
|
|
alertsChannelVolumeInterface->DelegateToReal();
|
2020-02-19 18:35:26 +00:00
|
|
|
|
2020-06-22 23:48:22 +00:00
|
|
|
avsChannelVolumeInterface->setUnduckedVolume(VALID_MAXIMUM_VOLUME_LIMIT - 1);
|
|
|
|
alertsChannelVolumeInterface->setUnduckedVolume(VALID_MAXIMUM_VOLUME_LIMIT - 1);
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
// Expect volumeChanged event.
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*avsChannelVolumeInterface, setUnduckedVolume(_)).Times(AtLeast(1));
|
|
|
|
EXPECT_CALL(*alertsChannelVolumeInterface, setUnduckedVolume(_)).Times(AtLeast(1));
|
2020-02-19 18:35:26 +00:00
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(0);
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(1));
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
2020-04-13 22:56:35 +00:00
|
|
|
{avsChannelVolumeInterface, alertsChannelVolumeInterface},
|
2020-02-19 18:35:26 +00:00
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
2020-04-13 22:56:35 +00:00
|
|
|
m_mockExceptionSender,
|
2020-06-22 23:48:22 +00:00
|
|
|
m_metricRecorder);
|
|
|
|
SpeakerManagerInterface::NotificationProperties properties;
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
EXPECT_TRUE(m_speakerManager->setMaximumVolumeLimit(VALID_MAXIMUM_VOLUME_LIMIT).get());
|
|
|
|
|
|
|
|
// Local change either with setVolume will set to limit but with adjustVolume will fail
|
|
|
|
EXPECT_TRUE(
|
2020-06-22 23:48:22 +00:00
|
|
|
m_speakerManager
|
|
|
|
->setVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, VALID_MAXIMUM_VOLUME_LIMIT + 1, properties)
|
2020-04-13 22:56:35 +00:00
|
|
|
.get());
|
2020-02-19 18:35:26 +00:00
|
|
|
EXPECT_FALSE(
|
2020-06-22 23:48:22 +00:00
|
|
|
m_speakerManager
|
|
|
|
->adjustVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, VALID_MAXIMUM_VOLUME_LIMIT + 1, properties)
|
2020-02-19 18:35:26 +00:00
|
|
|
.get());
|
|
|
|
|
|
|
|
// The volume went to upper limit.
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_EQ(getSpeakerVolume(avsChannelVolumeInterface), VALID_MAXIMUM_VOLUME_LIMIT);
|
|
|
|
EXPECT_EQ(getSpeakerVolume(alertsChannelVolumeInterface), VALID_MAXIMUM_VOLUME_LIMIT);
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
// Increase the volume by 2, so end result will exceed the limit.
|
2020-06-22 23:48:22 +00:00
|
|
|
EXPECT_TRUE(m_speakerManager->adjustVolume(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME, 2, properties).get());
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
// Following the 2nd adjustVolume, the volume will change to the limit.
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_EQ(getSpeakerVolume(alertsChannelVolumeInterface), VALID_MAXIMUM_VOLUME_LIMIT);
|
2020-02-19 18:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-04-13 22:56:35 +00:00
|
|
|
* Test that if a new limit was set while the volume was higher than the new limit, operation will succeed and the
|
|
|
|
* volume will be decreased.
|
2020-02-19 18:35:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
TEST_F(SpeakerManagerTest, testSetMaximumVolumeLimitWhileVolumeIsHigher) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto avsChannelVolumeInterface =
|
|
|
|
std::make_shared<NiceMock<MockChannelVolumeInterface>>(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME);
|
|
|
|
auto alertsChannelVolumeInterface =
|
|
|
|
std::make_shared<NiceMock<MockChannelVolumeInterface>>(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME);
|
2020-02-19 18:35:26 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
avsChannelVolumeInterface->DelegateToReal();
|
|
|
|
alertsChannelVolumeInterface->DelegateToReal();
|
2020-02-19 18:35:26 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_TRUE(avsChannelVolumeInterface->setUnduckedVolume(VALID_MAXIMUM_VOLUME_LIMIT + 1));
|
|
|
|
EXPECT_TRUE(alertsChannelVolumeInterface->setUnduckedVolume(VALID_MAXIMUM_VOLUME_LIMIT + 1));
|
2020-02-19 18:35:26 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*avsChannelVolumeInterface, setUnduckedVolume(VALID_MAXIMUM_VOLUME_LIMIT)).Times(1);
|
|
|
|
EXPECT_CALL(*alertsChannelVolumeInterface, setUnduckedVolume(VALID_MAXIMUM_VOLUME_LIMIT)).Times(1);
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
// Expect volumeChanged event.
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(1));
|
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(1));
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
2020-04-13 22:56:35 +00:00
|
|
|
{avsChannelVolumeInterface, alertsChannelVolumeInterface},
|
2020-02-19 18:35:26 +00:00
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
2020-06-22 23:48:22 +00:00
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
EXPECT_TRUE(m_speakerManager->setMaximumVolumeLimit(VALID_MAXIMUM_VOLUME_LIMIT).get());
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_EQ(getSpeakerVolume(avsChannelVolumeInterface), VALID_MAXIMUM_VOLUME_LIMIT);
|
|
|
|
EXPECT_EQ(getSpeakerVolume(alertsChannelVolumeInterface), VALID_MAXIMUM_VOLUME_LIMIT);
|
2020-02-19 18:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-04-13 22:56:35 +00:00
|
|
|
* Test that SetVolume directive with volume > limit should set the volume to the limit
|
2020-02-19 18:35:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
TEST_F(SpeakerManagerTest, testAVSSetVolumeHigherThanLimit) {
|
|
|
|
avsCommon::utils::logger::getConsoleLogger()->setLevel(avsCommon::utils::logger::Level::DEBUG9);
|
2020-04-13 22:56:35 +00:00
|
|
|
auto avsChannelVolumeInterface =
|
|
|
|
std::make_shared<NiceMock<MockChannelVolumeInterface>>(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME);
|
|
|
|
auto alertsChannelVolumeInterface =
|
|
|
|
std::make_shared<NiceMock<MockChannelVolumeInterface>>(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME);
|
2020-02-19 18:35:26 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
avsChannelVolumeInterface->DelegateToReal();
|
|
|
|
alertsChannelVolumeInterface->DelegateToReal();
|
2020-02-19 18:35:26 +00:00
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(1));
|
2020-02-19 18:35:26 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(1));
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_TRUE(avsChannelVolumeInterface->setUnduckedVolume(VALID_MAXIMUM_VOLUME_LIMIT - 1));
|
|
|
|
EXPECT_TRUE(alertsChannelVolumeInterface->setUnduckedVolume(VALID_MAXIMUM_VOLUME_LIMIT - 1));
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
2020-04-13 22:56:35 +00:00
|
|
|
{avsChannelVolumeInterface, alertsChannelVolumeInterface},
|
2020-02-19 18:35:26 +00:00
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
2020-06-22 23:48:22 +00:00
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
EXPECT_TRUE(m_speakerManager->setMaximumVolumeLimit(VALID_MAXIMUM_VOLUME_LIMIT).get());
|
|
|
|
|
|
|
|
createAndSendVolumeDirective(SET_VOLUME.name, VALID_MAXIMUM_VOLUME_LIMIT + 1);
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
ASSERT_EQ(getSpeakerVolume(avsChannelVolumeInterface), VALID_MAXIMUM_VOLUME_LIMIT);
|
|
|
|
ASSERT_EQ(getSpeakerVolume(alertsChannelVolumeInterface), VALID_MAXIMUM_VOLUME_LIMIT);
|
2020-02-19 18:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that a call to @c setMaximumVolumeLimit with invalid value fails.
|
|
|
|
*/
|
|
|
|
TEST_F(SpeakerManagerTest, testSetMaximumVolumeLimitWithInvalidValue) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto avsChannelVolumeInterface = createChannelVolumeInterfaces();
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage,
|
|
|
|
avsChannelVolumeInterface,
|
|
|
|
m_mockContextManager,
|
|
|
|
m_mockMessageSender,
|
|
|
|
m_mockExceptionSender,
|
|
|
|
m_metricRecorder);
|
2020-02-19 18:35:26 +00:00
|
|
|
|
|
|
|
EXPECT_FALSE(m_speakerManager->setMaximumVolumeLimit(INVALID_MAXIMUM_VOLUME_LIMIT).get());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
/**
|
|
|
|
* Create different combinations of @c Type for parameterized tests (TEST_P).
|
|
|
|
*/
|
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
Parameterized,
|
|
|
|
SpeakerManagerTest,
|
|
|
|
// clang-format off
|
|
|
|
::testing::Values(
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<ChannelVolumeInterface::Type>{
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME
|
2017-10-30 22:14:38 +00:00
|
|
|
},
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<ChannelVolumeInterface::Type>{
|
|
|
|
ChannelVolumeInterface::Type::AVS_ALERTS_VOLUME
|
2017-10-30 22:14:38 +00:00
|
|
|
},
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<ChannelVolumeInterface::Type>{
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME
|
2017-10-30 22:14:38 +00:00
|
|
|
},
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<ChannelVolumeInterface::Type>{
|
|
|
|
ChannelVolumeInterface::Type::AVS_ALERTS_VOLUME,
|
|
|
|
ChannelVolumeInterface::Type::AVS_ALERTS_VOLUME,
|
2017-10-30 22:14:38 +00:00
|
|
|
},
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<ChannelVolumeInterface::Type>{
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
ChannelVolumeInterface::Type::AVS_ALERTS_VOLUME,
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
ChannelVolumeInterface::Type::AVS_ALERTS_VOLUME
|
2017-10-30 22:14:38 +00:00
|
|
|
}));
|
2020-04-13 22:56:35 +00:00
|
|
|
// clang-format on
|
2017-12-09 00:07:37 +00:00
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
/**
|
2018-07-09 21:07:31 +00:00
|
|
|
* Parameterized test for setVolume. One event should be sent if an AVS_SPEAKER_VOLUME typed speaker is modified.
|
2017-10-30 22:14:38 +00:00
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_P(SpeakerManagerTest, test_setVolume) {
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*group, setUnduckedVolume(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*group, setUnduckedVolume(AVS_SET_VOLUME_MAX)).Times(Exactly(1));
|
|
|
|
groupVec.push_back(group);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
SpeakerInterface::SpeakerSettings expectedSettings{AVS_SET_VOLUME_MAX, UNMUTE};
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties(SpeakerManagerObserverInterface::Source::DIRECTIVE);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
for (auto type : getUniqueTypes(groupVec)) {
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(SpeakerManagerObserverInterface::Source::DIRECTIVE, type, expectedSettings))
|
|
|
|
.Times(Exactly(1));
|
|
|
|
if (ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME == type) {
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(AnyNumber());
|
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(expectedSettings), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
2017-12-09 00:07:37 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
std::future<bool> future = m_speakerManager->setVolume(type, AVS_SET_VOLUME_MAX, properties);
|
2017-10-30 22:14:38 +00:00
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-07-09 21:07:31 +00:00
|
|
|
* Parameterized test for adjustVolume. One event should be sent if an AVS_SPEAKER_VOLUME typed speaker is modified.
|
2017-10-30 22:14:38 +00:00
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_P(SpeakerManagerTest, test_adjustVolume) {
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
|
|
|
groupVec.push_back(group);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
Version 1.14 alexa-client-sdk
Changes in this update:
**Enhancements**
* AudioPlayer can now pre-buffer audio tracks in the Pre-Handle stage.
**Bug Fixes**
* Fixed an issue in the SQLite wrapper code where a `SQLiteStatement` caused a memory corruption issue.
* Fixed a race condition in SpeechSynthesizer that caused crashes.
* Fixed a `cmake` issue that specifies a dependency for Bluetooth incorrectly.
* Fixed a bug that caused Bluetooth playback to start automatically.
* Changed `supportedOperations` from a vector to a set in `ExternalMediaAdapterInterface`.
* Corrected an issue where a `VolumeChanged` event had previously been sent when the volume was unchanged after `setVolume` or `adjustVolume` had been called locally.
* Fixed issue with `IterativePlaylistParser` that prevented live stations on TuneIn from playing on Android.
* Corrected the spelling of "UNINITIALIZED".
**Known Issues**
* Music playback history isn't being displayed in the Alexa app for certain account and device types.
* On GCC 8+, issues related to `-Wclass-memaccess` will trigger warnings. However, this won't cause the build to fail and these warnings can be ignored.
* Android error ("libDefaultClient.so" not found) can be resolved by upgrading to ADB version 1.0.40
* When network connection is lost, lost connection status is not returned via local TTS.
* `ACL` may encounter issues if audio attachments are received but not consumed.
* `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release.
* The Alexa app doesn't always indicate when a device is successfully connected via Bluetooth.
* Connecting a product to streaming media via Bluetooth will sometimes stop media playback within the source application. Resuming playback through the source application or toggling next/previous will correct playback.
* When a source device is streaming silence via Bluetooth, the Alexa app indicates that audio content is streaming.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation is not yet supported.
* On some products, interrupted Bluetooth playback may not resume if other content is locally streamed.
* `make integration` is currently not available for Android. In order to run integration tests on Android, you'll need to manually upload the test binary file along with any input file. At that point, the adb can be used to run the integration tests.
* On Raspberry Pi running Android Things with HDMI output audio, beginning of speech is truncated when Alexa responds to user text-to-speech (TTS).
* When the sample app is restarted and the network connection is lost, the Reminder TTS message does not play. Instead, the default alarm tone will play twice.
* `ServerDisconnectIntegratonTest` tests have been disabled until they can be updated to reflect new service behavior.
* Devices connected before the Bluetooth CA is initialized are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
2019-07-09 21:10:24 +00:00
|
|
|
// The test adjusts the volume by AVS_ADJUST_VOLUME_MAX, which results in the lowest volume possible.
|
|
|
|
SpeakerInterface::SpeakerSettings expectedSettings{AVS_SET_VOLUME_MAX, UNMUTE};
|
2017-10-30 22:14:38 +00:00
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties(SpeakerManagerObserverInterface::Source::DIRECTIVE);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
for (auto type : getUniqueTypes(groupVec)) {
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*m_mockStorage, saveState(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(SpeakerManagerObserverInterface::Source::DIRECTIVE, type, expectedSettings))
|
|
|
|
.Times(Exactly(1));
|
|
|
|
if (ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME == type) {
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(AnyNumber());
|
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(expectedSettings), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
2017-12-09 00:07:37 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
std::future<bool> future = m_speakerManager->adjustVolume(type, AVS_ADJUST_VOLUME_MAX, properties);
|
2017-10-30 22:14:38 +00:00
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-07-09 21:07:31 +00:00
|
|
|
* Parameterized test for setMute. One event should be sent if an AVS_SPEAKER_VOLUME typed speaker is modified.
|
2017-10-30 22:14:38 +00:00
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_P(SpeakerManagerTest, test_setMute) {
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*group, setMute(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*group, setMute(MUTE)).Times(Exactly(1));
|
|
|
|
groupVec.push_back(group);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
SpeakerInterface::SpeakerSettings expectedSettings{DEFAULT_SETTINGS.volume, MUTE};
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties(SpeakerManagerObserverInterface::Source::DIRECTIVE);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
for (auto type : getUniqueTypes(groupVec)) {
|
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(SpeakerManagerObserverInterface::Source::DIRECTIVE, type, expectedSettings))
|
|
|
|
.Times(Exactly(1));
|
|
|
|
if (ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME == type) {
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(AnyNumber());
|
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(expectedSettings), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
2017-12-09 00:07:37 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
std::future<bool> future = m_speakerManager->setMute(type, MUTE, properties);
|
2017-10-30 22:14:38 +00:00
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parameterized test for getSpeakerSettings. Operation should succeed with default speaker settings.
|
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_P(SpeakerManagerTest, test_getSpeakerSettings) {
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
2021-03-29 19:59:51 +00:00
|
|
|
std::set<ChannelVolumeInterface::Type> uniqueTypes;
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
2021-03-29 19:59:51 +00:00
|
|
|
|
|
|
|
// There should be one call to getSpeakerSettings for the first speaker of each type.
|
|
|
|
if (uniqueTypes.find(typeOfSpeaker) == uniqueTypes.end()) {
|
|
|
|
EXPECT_CALL(*group, getSpeakerSettings(_)).Times(AtLeast(1));
|
|
|
|
uniqueTypes.insert(typeOfSpeaker);
|
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
groupVec.push_back(group);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
|
|
|
|
2021-03-29 19:59:51 +00:00
|
|
|
for (auto speaker : groupVec) {
|
|
|
|
// SpeakerManager attempts to cache speaker settings initially. No getSpeakerSettings() call should be made to
|
|
|
|
// each speaker.
|
|
|
|
auto mockSpeaker = std::dynamic_pointer_cast<NiceMock<MockChannelVolumeInterface>>(speaker);
|
|
|
|
ASSERT_TRUE(mockSpeaker);
|
|
|
|
EXPECT_CALL(*mockSpeaker, getSpeakerSettings(_)).Times(0);
|
|
|
|
}
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
for (auto type : uniqueTypes) {
|
|
|
|
SpeakerInterface::SpeakerSettings settings;
|
2021-03-29 19:59:51 +00:00
|
|
|
// Query SpeakerMananger for speaker settings, value should be cached and not queried from each speaker.
|
2017-10-30 22:14:38 +00:00
|
|
|
std::future<bool> future = m_speakerManager->getSpeakerSettings(type, &settings);
|
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
ASSERT_EQ(settings.volume, DEFAULT_SETTINGS.volume);
|
|
|
|
ASSERT_EQ(settings.mute, DEFAULT_SETTINGS.mute);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests SetVolume Directive. Expect that the volume is unmuted and set, as well at most one
|
2018-07-09 21:07:31 +00:00
|
|
|
* event is sent. In the event there are no AVS_SPEAKER_VOLUME speakers registered, no event will be sent.
|
|
|
|
* In addition, only AVS_SPEAKER_VOLUME speakers should be affected.
|
2017-10-30 22:14:38 +00:00
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_P(SpeakerManagerTest, test_setVolumeDirective) {
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
2017-10-30 22:14:38 +00:00
|
|
|
int eventsSent = 0;
|
2017-12-09 00:07:37 +00:00
|
|
|
SpeakerInterface::SpeakerSettings expectedSettings{AVS_SET_VOLUME_MAX, UNMUTE};
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
// Create Speaker objects.
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
2017-10-30 22:14:38 +00:00
|
|
|
int timesCalled = 0;
|
2020-04-13 22:56:35 +00:00
|
|
|
if (typeOfSpeaker == ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME) {
|
2017-10-30 22:14:38 +00:00
|
|
|
timesCalled = 1;
|
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
SpeakerInterface::SpeakerSettings temp;
|
2020-04-13 22:56:35 +00:00
|
|
|
group->getSpeakerSettings(&temp);
|
2020-02-19 18:35:26 +00:00
|
|
|
if (temp.mute) {
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*group, setMute(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*group, setMute(UNMUTE)).Times(Exactly(timesCalled));
|
2020-02-19 18:35:26 +00:00
|
|
|
}
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*group, setUnduckedVolume(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*group, setUnduckedVolume(AVS_SET_VOLUME_MAX)).Times(Exactly(timesCalled));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
groupVec.push_back(group);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
auto uniqueTypes = getUniqueTypes(groupVec);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
// Creation expectations based on type.
|
2020-04-13 22:56:35 +00:00
|
|
|
if (uniqueTypes.count(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME)) {
|
2017-10-30 22:14:38 +00:00
|
|
|
eventsSent = 1;
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(
|
|
|
|
SpeakerManagerObserverInterface::Source::DIRECTIVE,
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
expectedSettings))
|
|
|
|
.Times(Exactly(1));
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _)).Times(AnyNumber());
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(expectedSettings), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
2017-10-30 22:14:38 +00:00
|
|
|
} else {
|
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _)).Times(Exactly(0));
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(eventsSent));
|
|
|
|
EXPECT_CALL(*(m_mockDirectiveHandlerResult.get()), setCompleted())
|
|
|
|
.Times(1)
|
|
|
|
.WillOnce(InvokeWithoutArgs(this, &SpeakerManagerTest::wakeOnSetCompleted));
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
|
|
|
|
|
|
|
// Create Directive.
|
|
|
|
auto attachmentManager = std::make_shared<StrictMock<MockAttachmentManager>>();
|
|
|
|
auto avsMessageHeader = std::make_shared<AVSMessageHeader>(SET_VOLUME.nameSpace, SET_VOLUME.name, MESSAGE_ID);
|
|
|
|
std::shared_ptr<AVSDirective> directive =
|
|
|
|
AVSDirective::create("", avsMessageHeader, VOLUME_PAYLOAD, attachmentManager, "");
|
|
|
|
|
|
|
|
m_speakerManager->CapabilityAgent::preHandleDirective(directive, std::move(m_mockDirectiveHandlerResult));
|
|
|
|
m_speakerManager->CapabilityAgent::handleDirective(MESSAGE_ID);
|
|
|
|
m_wakeSetCompletedFuture.wait_for(TIMEOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests AdjustVolume Directive. Expect that the volume is unmuted and adjusted, as well at most one
|
2018-07-09 21:07:31 +00:00
|
|
|
* event is sent. In the event there are no AVS_SPEAKER_VOLUME speakers registered, no event will be sent.
|
|
|
|
* In addition, only AVS_SPEAKER_VOLUME speakers should be affected.
|
2017-10-30 22:14:38 +00:00
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_P(SpeakerManagerTest, test_adjustVolumeDirective) {
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
2017-10-30 22:14:38 +00:00
|
|
|
int eventsSent = 0;
|
2017-12-09 00:07:37 +00:00
|
|
|
SpeakerInterface::SpeakerSettings expectedSettings{AVS_SET_VOLUME_MAX, UNMUTE};
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
// Create Speaker objects.
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
2017-10-30 22:14:38 +00:00
|
|
|
int timesCalled = 0;
|
2020-04-13 22:56:35 +00:00
|
|
|
if (typeOfSpeaker == ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME) {
|
2017-10-30 22:14:38 +00:00
|
|
|
timesCalled = 1;
|
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
SpeakerInterface::SpeakerSettings temp;
|
2020-04-13 22:56:35 +00:00
|
|
|
group->getSpeakerSettings(&temp);
|
2020-02-19 18:35:26 +00:00
|
|
|
if (temp.mute) {
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*group, setMute(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*group, setMute(UNMUTE)).Times(Exactly(timesCalled));
|
2020-02-19 18:35:26 +00:00
|
|
|
}
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*group, setUnduckedVolume(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*group, setUnduckedVolume(AVS_SET_VOLUME_MAX)).Times(Exactly(timesCalled));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
groupVec.push_back(group);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
auto uniqueTypes = getUniqueTypes(groupVec);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
// Creation expectations based on type.
|
2020-04-13 22:56:35 +00:00
|
|
|
if (uniqueTypes.count(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME)) {
|
2017-10-30 22:14:38 +00:00
|
|
|
eventsSent = 1;
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(
|
|
|
|
SpeakerManagerObserverInterface::Source::DIRECTIVE,
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
expectedSettings))
|
|
|
|
.Times(Exactly(1));
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _)).Times(AnyNumber());
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(expectedSettings), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
2017-10-30 22:14:38 +00:00
|
|
|
} else {
|
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _)).Times(Exactly(0));
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(eventsSent));
|
|
|
|
EXPECT_CALL(*(m_mockDirectiveHandlerResult.get()), setCompleted())
|
|
|
|
.Times(1)
|
|
|
|
.WillOnce(InvokeWithoutArgs(this, &SpeakerManagerTest::wakeOnSetCompleted));
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
|
|
|
|
|
|
|
// Create Directive.
|
|
|
|
auto attachmentManager = std::make_shared<StrictMock<MockAttachmentManager>>();
|
|
|
|
auto avsMessageHeader = std::make_shared<AVSMessageHeader>(ADJUST_VOLUME.nameSpace, ADJUST_VOLUME.name, MESSAGE_ID);
|
|
|
|
std::shared_ptr<AVSDirective> directive =
|
|
|
|
AVSDirective::create("", avsMessageHeader, VOLUME_PAYLOAD, attachmentManager, "");
|
|
|
|
|
|
|
|
m_speakerManager->CapabilityAgent::preHandleDirective(directive, std::move(m_mockDirectiveHandlerResult));
|
|
|
|
m_speakerManager->CapabilityAgent::handleDirective(MESSAGE_ID);
|
|
|
|
m_wakeSetCompletedFuture.wait_for(TIMEOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests SetMute Directive. Expect that the volume is muted, as well at most one
|
2018-07-09 21:07:31 +00:00
|
|
|
* event is sent. In the event there are no AVS_SPEAKER_VOLUME speakers registered, no event will be sent.
|
|
|
|
* In addition, only AVS_SPEAKER_VOLUME speakers should be affected.
|
2017-10-30 22:14:38 +00:00
|
|
|
*/
|
2019-05-22 23:06:18 +00:00
|
|
|
TEST_P(SpeakerManagerTest, test_setMuteDirective) {
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
2017-10-30 22:14:38 +00:00
|
|
|
int eventsSent = 0;
|
2017-12-09 00:07:37 +00:00
|
|
|
SpeakerInterface::SpeakerSettings expectedSettings{DEFAULT_SETTINGS.volume, MUTE};
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
// Create Speaker objects.
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
2017-10-30 22:14:38 +00:00
|
|
|
int timesCalled = 0;
|
2020-04-13 22:56:35 +00:00
|
|
|
if (typeOfSpeaker == ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME) {
|
2017-10-30 22:14:38 +00:00
|
|
|
timesCalled = 1;
|
|
|
|
}
|
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*group, setMute(_)).Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(*group, setMute(MUTE)).Times(Exactly(timesCalled));
|
2017-10-30 22:14:38 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
groupVec.push_back(group);
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
auto uniqueTypes = getUniqueTypes(groupVec);
|
2017-10-30 22:14:38 +00:00
|
|
|
|
|
|
|
// Creation expectations based on type.
|
2020-04-13 22:56:35 +00:00
|
|
|
if (uniqueTypes.count(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME)) {
|
2017-10-30 22:14:38 +00:00
|
|
|
eventsSent = 1;
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(
|
|
|
|
SpeakerManagerObserverInterface::Source::DIRECTIVE,
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
expectedSettings))
|
|
|
|
.Times(Exactly(1));
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _)).Times(AnyNumber());
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(expectedSettings), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
2017-10-30 22:14:38 +00:00
|
|
|
} else {
|
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
2017-12-09 00:07:37 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _)).Times(Exactly(0));
|
2017-10-30 22:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(Exactly(eventsSent));
|
|
|
|
EXPECT_CALL(*(m_mockDirectiveHandlerResult.get()), setCompleted())
|
|
|
|
.Times(1)
|
|
|
|
.WillOnce(InvokeWithoutArgs(this, &SpeakerManagerTest::wakeOnSetCompleted));
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
m_speakerManager = SpeakerManager::create(
|
2021-11-15 23:35:18 +00:00
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2017-10-30 22:14:38 +00:00
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
|
|
|
|
|
|
|
// Create Directive.
|
|
|
|
auto attachmentManager = std::make_shared<StrictMock<MockAttachmentManager>>();
|
|
|
|
auto avsMessageHeader = std::make_shared<AVSMessageHeader>(SET_MUTE.nameSpace, SET_MUTE.name, MESSAGE_ID);
|
|
|
|
std::shared_ptr<AVSDirective> directive =
|
|
|
|
AVSDirective::create("", avsMessageHeader, MUTE_PAYLOAD, attachmentManager, "");
|
|
|
|
|
|
|
|
m_speakerManager->CapabilityAgent::preHandleDirective(directive, std::move(m_mockDirectiveHandlerResult));
|
|
|
|
m_speakerManager->CapabilityAgent::handleDirective(MESSAGE_ID);
|
|
|
|
m_wakeSetCompletedFuture.wait_for(TIMEOUT);
|
|
|
|
}
|
|
|
|
|
2019-05-22 23:06:18 +00:00
|
|
|
/**
|
|
|
|
* Test setVolume when unmute Directive sent. Setup test by setting volume to 0 and mute to true.
|
|
|
|
* Expect that the volume is unmuted and set to MIN_UNMUTE_VOLUME, as well at most one
|
|
|
|
* event is sent. In the event there are no AVS_SPEAKER_VOLUME speakers registered, no event will be sent.
|
|
|
|
* In addition, only AVS_SPEAKER_VOLUME speakers should be affected.
|
|
|
|
*/
|
|
|
|
TEST_P(SpeakerManagerTest, test_setVolumeDirectiveWhenMuted) {
|
2020-04-13 22:56:35 +00:00
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
2019-05-22 23:06:18 +00:00
|
|
|
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
2020-04-13 22:56:35 +00:00
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
2021-11-15 23:35:18 +00:00
|
|
|
groupVec.push_back(group);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
2020-04-13 22:56:35 +00:00
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
for (auto& group : groupVec) {
|
|
|
|
auto mockGroup = std::dynamic_pointer_cast<NiceMock<MockChannelVolumeInterface>>(group);
|
|
|
|
EXPECT_CALL(*mockGroup, setUnduckedVolume(AVS_SET_VOLUME_MIN)).Times(1);
|
|
|
|
EXPECT_CALL(*mockGroup, setMute(MUTE)).Times(1);
|
|
|
|
auto typeOfSpeaker = mockGroup->getSpeakerType();
|
2020-04-13 22:56:35 +00:00
|
|
|
if (typeOfSpeaker == ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME) {
|
2021-11-15 23:35:18 +00:00
|
|
|
EXPECT_CALL(*mockGroup, setMute(UNMUTE)).Times(1);
|
|
|
|
EXPECT_CALL(*mockGroup, setUnduckedVolume(MIN_UNMUTE_VOLUME)).Times(1);
|
2019-05-22 23:06:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
2020-04-13 22:56:35 +00:00
|
|
|
SpeakerManagerInterface::NotificationProperties properties(
|
|
|
|
SpeakerManagerObserverInterface::Source::LOCAL_API, false, false);
|
2019-05-22 23:06:18 +00:00
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
for (auto type : getUniqueTypes(groupVec)) {
|
|
|
|
m_speakerManager->setVolume(type, AVS_SET_VOLUME_MIN, properties);
|
2019-05-22 23:06:18 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
for (auto type : getUniqueTypes(groupVec)) {
|
|
|
|
std::future<bool> future = m_speakerManager->setMute(type, MUTE, properties);
|
2019-05-22 23:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check to see if AVS_SPEAKER_VOLUME speakers exist and set EXPECT_CALL accordingly
|
2020-04-13 22:56:35 +00:00
|
|
|
auto uniqueTypes = getUniqueTypes(groupVec);
|
2019-05-22 23:06:18 +00:00
|
|
|
int eventsSent = 0;
|
|
|
|
SpeakerInterface::SpeakerSettings unMuteSettings{MIN_UNMUTE_VOLUME, UNMUTE};
|
|
|
|
|
2020-04-13 22:56:35 +00:00
|
|
|
if (uniqueTypes.count(ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME)) {
|
2020-06-22 23:48:22 +00:00
|
|
|
// 2 events : {MIN_UNMUTE_VOLUME, MUTE} followed by {MIN_UNMUTE_VOLUME, UNMUTE}
|
|
|
|
eventsSent = 2;
|
2019-05-22 23:06:18 +00:00
|
|
|
|
2020-06-22 23:48:22 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(
|
|
|
|
SpeakerManagerObserverInterface::Source::DIRECTIVE,
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
SpeakerInterface::SpeakerSettings{MIN_UNMUTE_VOLUME, MUTE}))
|
|
|
|
.Times(Exactly(1));
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_observer,
|
|
|
|
onSpeakerSettingsChanged(
|
|
|
|
SpeakerManagerObserverInterface::Source::DIRECTIVE,
|
|
|
|
ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME,
|
|
|
|
unMuteSettings))
|
|
|
|
.Times(Exactly(1));
|
2019-05-22 23:06:18 +00:00
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _)).Times(AnyNumber());
|
2020-04-13 22:56:35 +00:00
|
|
|
EXPECT_CALL(
|
|
|
|
*m_mockContextManager,
|
|
|
|
setState(VOLUME_STATE, generateVolumeStateJson(unMuteSettings), StateRefreshPolicy::NEVER, _))
|
|
|
|
.Times(Exactly(1));
|
2019-05-22 23:06:18 +00:00
|
|
|
} else {
|
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(0);
|
|
|
|
EXPECT_CALL(*m_mockContextManager, setState(VOLUME_STATE, _, StateRefreshPolicy::NEVER, _)).Times(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_CALL(*m_mockMessageSender, sendMessage(_)).Times(eventsSent);
|
|
|
|
EXPECT_CALL(*(m_mockDirectiveHandlerResult.get()), setCompleted())
|
|
|
|
.Times(1)
|
|
|
|
.WillOnce(InvokeWithoutArgs(this, &SpeakerManagerTest::wakeOnSetCompleted));
|
|
|
|
|
|
|
|
// Create Directive to unmute the device.
|
|
|
|
auto attachmentManager = std::make_shared<StrictMock<MockAttachmentManager>>();
|
|
|
|
auto avsMessageHeader = std::make_shared<AVSMessageHeader>(SET_MUTE.nameSpace, SET_MUTE.name, MESSAGE_ID);
|
|
|
|
std::shared_ptr<AVSDirective> directive =
|
2020-02-19 18:35:26 +00:00
|
|
|
AVSDirective::create("", avsMessageHeader, UNMUTE_PAYLOAD, attachmentManager, "");
|
2019-05-22 23:06:18 +00:00
|
|
|
|
|
|
|
m_speakerManager->CapabilityAgent::preHandleDirective(directive, std::move(m_mockDirectiveHandlerResult));
|
|
|
|
m_speakerManager->CapabilityAgent::handleDirective(MESSAGE_ID);
|
|
|
|
m_wakeSetCompletedFuture.wait_for(TIMEOUT);
|
|
|
|
}
|
|
|
|
|
2021-11-15 23:35:18 +00:00
|
|
|
/**
|
|
|
|
* Parameterized test for getSpeakerSettings. Operation should succeed with default speaker settings.
|
|
|
|
*/
|
|
|
|
TEST_P(SpeakerManagerTest, test_getSpeakerConfigDefaults) {
|
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
|
|
|
std::set<ChannelVolumeInterface::Type> uniqueTypes;
|
|
|
|
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
|
|
|
|
|
|
|
// There should be one call to getSpeakerSettings for the first speaker of each type.
|
|
|
|
if (uniqueTypes.find(typeOfSpeaker) == uniqueTypes.end()) {
|
|
|
|
EXPECT_CALL(*group, getSpeakerSettings(_)).Times(AtLeast(1));
|
|
|
|
uniqueTypes.insert(typeOfSpeaker);
|
|
|
|
}
|
|
|
|
|
|
|
|
groupVec.push_back(group);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_mockStorage->setFailureMode();
|
|
|
|
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
|
|
|
|
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
|
|
|
|
|
|
|
for (auto speaker : groupVec) {
|
|
|
|
// SpeakerManager attempts to cache speaker settings initially. No getSpeakerSettings() call should be made to
|
|
|
|
// each speaker.
|
|
|
|
auto mockSpeaker = std::dynamic_pointer_cast<NiceMock<MockChannelVolumeInterface>>(speaker);
|
|
|
|
ASSERT_TRUE(mockSpeaker);
|
|
|
|
EXPECT_CALL(*mockSpeaker, getSpeakerSettings(_)).Times(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto type : uniqueTypes) {
|
|
|
|
SpeakerInterface::SpeakerSettings settings;
|
|
|
|
// Query SpeakerMananger for speaker settings, value should be cached and not queried from each speaker.
|
|
|
|
std::future<bool> future = m_speakerManager->getSpeakerSettings(type, &settings);
|
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case avsCommon::sdkInterfaces::ChannelVolumeInterface::Type::AVS_SPEAKER_VOLUME:
|
|
|
|
EXPECT_EQ(settings.volume, alexaClientSDK::avsCommon::avs::speakerConstants::DEFAULT_SPEAKER_VOLUME);
|
|
|
|
break;
|
|
|
|
case avsCommon::sdkInterfaces::ChannelVolumeInterface::Type::AVS_ALERTS_VOLUME:
|
|
|
|
EXPECT_EQ(settings.volume, alexaClientSDK::avsCommon::avs::speakerConstants::DEFAULT_ALERTS_VOLUME);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ASSERT_EQ(settings.mute, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parameterized test for getSpeakerSettings. Operation should succeed with speaker settings from storage.
|
|
|
|
*/
|
|
|
|
TEST_P(SpeakerManagerTest, test_getSpeakerConfigFromStorage) {
|
|
|
|
std::vector<std::shared_ptr<ChannelVolumeInterface>> groupVec;
|
|
|
|
std::set<ChannelVolumeInterface::Type> uniqueTypes;
|
|
|
|
|
|
|
|
for (auto& typeOfSpeaker : GetParam()) {
|
|
|
|
auto group = std::make_shared<NiceMock<MockChannelVolumeInterface>>(typeOfSpeaker);
|
|
|
|
group->DelegateToReal();
|
|
|
|
|
|
|
|
// There should be one call to getSpeakerSettings for the first speaker of each type.
|
|
|
|
if (uniqueTypes.find(typeOfSpeaker) == uniqueTypes.end()) {
|
|
|
|
EXPECT_CALL(*group, getSpeakerSettings(_)).Times(AtLeast(1));
|
|
|
|
uniqueTypes.insert(typeOfSpeaker);
|
|
|
|
}
|
|
|
|
|
|
|
|
groupVec.push_back(group);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_mockStorage->setDefaults();
|
|
|
|
|
|
|
|
m_speakerManager = SpeakerManager::create(
|
|
|
|
m_mockStorage, groupVec, m_mockContextManager, m_mockMessageSender, m_mockExceptionSender, m_metricRecorder);
|
|
|
|
|
|
|
|
EXPECT_CALL(*m_observer, onSpeakerSettingsChanged(_, _, _)).Times(Exactly(0));
|
|
|
|
m_speakerManager->addSpeakerManagerObserver(m_observer);
|
|
|
|
|
|
|
|
for (auto speaker : groupVec) {
|
|
|
|
// SpeakerManager attempts to cache speaker settings initially. No getSpeakerSettings() call should be made to
|
|
|
|
// each speaker.
|
|
|
|
auto mockSpeaker = std::dynamic_pointer_cast<NiceMock<MockChannelVolumeInterface>>(speaker);
|
|
|
|
ASSERT_TRUE(mockSpeaker);
|
|
|
|
EXPECT_CALL(*mockSpeaker, getSpeakerSettings(_)).Times(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto type : uniqueTypes) {
|
|
|
|
SpeakerInterface::SpeakerSettings settings;
|
|
|
|
// Query SpeakerMananger for speaker settings, value should be cached and not queried from each speaker.
|
|
|
|
std::future<bool> future = m_speakerManager->getSpeakerSettings(type, &settings);
|
|
|
|
ASSERT_TRUE(future.get());
|
|
|
|
|
|
|
|
EXPECT_EQ(settings.volume, AVS_SET_VOLUME_MIN);
|
|
|
|
EXPECT_EQ(settings.mute, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-30 22:14:38 +00:00
|
|
|
} // namespace test
|
|
|
|
} // namespace speakerManager
|
|
|
|
} // namespace capabilityAgents
|
2020-12-08 23:09:40 +00:00
|
|
|
} // namespace alexaClientSDK
|