Version 1.17.0 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for [captions for TTS](https://developer.amazon.com/docs/avs-device-sdk/features.html#captions). This enhancement allows you to print onscreen captions for Alexa voice responses.
- Added support for [SpeechSynthesizer Interface 1.3](https://developer.amazon.com/docs/alexa-voice-service/speechsynthesizer.html). This interface supports the new `captions` parameter.
- Added support for [AudioPlayer Interface 1.3](https://developer.amazon.com/docs/alexa-voice-service/audioplayer.html). This interface supports the new `captions` parameter.
- Added support for [Interaction Model 1.2](https://developer.amazon.com/docs/alexa-voice-service/interactionmodel-interface.html).
- Added support for [System 2.0](https://developer.amazon.com/en-US/docs/alexa/alexa-voice-service/system.html).
- Added support for Alarm Volume Ramp. This feature lets you to fade in alarms for a more pleasant experience. You enable alarm volume ramp in the sample app through the settings menu.
- Added support for using certified senders for URI path extensions. This change allows you to specify the URI path extension when sending messages with [`CertifiedSender::sendJSONMessage`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1certified_sender_1_1_certified_sender.html#a4c0706d79717b226ba77d1a9c3280fe6).
- Added new [`Metrics`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1_metrics.html) interfaces and helper classes. These additions help you create and consume [`Metrics`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1_metrics.html) events.
- **Interfaces** - `MetricRecorderInterface`, `MetricSinkInterface`.
- **Helper Classes** - `DataPointStringBuilder`, `DataPointCounterBuilder`, `DataPointDurationBuilder`, `MetricEventBuilder`.
- Added support for the following AVS [endpoint](../avs-device-sdk/endpoints.html) controller capabilities:
- [Alexa.ModeController](https://developer.amazon.com/docs/alexa-voice-service/alexa-modecontroller.html)
- [Alexa.RangeController](https://developer.amazon.com/docs/alexa-voice-service/alexa-rangecontroller.html)
- [Alexa.PowerController](https://developer.amazon.com/docs/alexa-voice-service/alexa-powercontroller.html)
- [Alexa.ToggleController](https://developer.amazon.com/docs/alexa-voice-service/alexa-togglecontroller.html)
- Added `PowerResourceManagerInterface`. This interface allows the SDK to control power resource levels for components such as the `AudioInputProcessor` and `SpeechSynthesizer`.
- Added `AlexaInterfaceCapabilityAgent`. This Capability Agent handles common directives and endpoint controller capabilities support by [`Alexa.AlexaInterface`](../alexa-voice-service/alexa.html).
- Added `AlexaInterfaceMessageSenderInterface`. This interface is required to send common events defined by the `Alexa.AlexaInterface` interface.
- Added `BufferingComplete` to [`MediaPlayerObserverInterface`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_observer_interface.html). This method helps improve performance in poor networking conditions by making sure `MediaPlayer` pre-buffers correctly.
- Added `SendDTMF` to `CallManagerInterface`. This method allows you to send DTMF tones during calls.
**New build options**
- CAPTIONS
- **ADDED** [`CAPTIONS`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#captions)
- **ADDED** [`LIBWEBVTT_LIB_PATH`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#captions)
- **ADDED** [`LIBWEBVTT_INCLUDE_DIR`](https://developer.amazon.com/docs//avs-device-sdk/cmake-parameters.html#captions)
- METRICS
- **ADDED** [`METRICS`](https://developer.amazon.com/docs//avs-device-sdk/cmake-parameters.html#metrics)
- ENDPONTS
- **ADDED** [`ENABLE_ALL_ENDPOINT_CONTROLLERS`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
- **ADDED** [`ENABLE_POWER_CONTROLLER`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
- **ADDED** [`ENABLE_TOGGLE_CONTROLLER`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
- **ADDED** [`ENABLE_RANGE_CONTROLLER`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
- **ADDED** [`ENABLE_MODE_CONTROLLER`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
**New dependencies**
- To use captions, you must install a [new dependency](https://developer.amazon.com/docs/avs-device-sdk/dependencies) – the [libwebvtt parsing library](https://github.com/alexa/webvtt). Webvtt is a C/C++ library for interpreting and authoring conformant WebVTT content. WebVTT is a caption and subtitle format designed for use with HTML5 audio and video elements.
**Bug fixes**
- Fixed [`MimeResponseSink::onReceiveNonMimeData`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1acl_1_1_mime_response_sink.html) [data issue](https://github.com/alexa/avs-device-sdk/issues/1519) that returned invalid data.
- Fixed [data type issue](https://github.com/alexa/avs-device-sdk/issues/1519) that incorrectly used `finalResponseCode` instead of [`FinalResponseCodeId`](https://github.com/alexa/avs-device-sdk/blob/master/AVSCommon/Utils/src/LibcurlUtils/LibCurlHttpContentFetcher.cpp#L370).
- Fixed [`UrlContentToAttachmentConverter`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1playlist_parser_1_1_url_content_to_attachment_converter.html) issue that used the incorrect range parameter.
- Fixed `FinallyGuard` [linking issue](https://github.com/alexa/avs-device-sdk/issues/1517) that caused problems compiling the SDK on iOS.
- Fixed a [Bluetooth Capability Agent](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1bluetooth_1_1_bluetooth.html) bug that prevented devices from initializing.
**Known Issues**
* The WebVTT dependency required for `captions` isn't supported for Windows/Android.
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the settings menu doesn't provide a message to indicate that you're back in the main menu.
2019-12-10 21:02:09 +00:00
|
|
|
/*
|
2020-04-13 22:56:35 +00:00
|
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
Version 1.17.0 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for [captions for TTS](https://developer.amazon.com/docs/avs-device-sdk/features.html#captions). This enhancement allows you to print onscreen captions for Alexa voice responses.
- Added support for [SpeechSynthesizer Interface 1.3](https://developer.amazon.com/docs/alexa-voice-service/speechsynthesizer.html). This interface supports the new `captions` parameter.
- Added support for [AudioPlayer Interface 1.3](https://developer.amazon.com/docs/alexa-voice-service/audioplayer.html). This interface supports the new `captions` parameter.
- Added support for [Interaction Model 1.2](https://developer.amazon.com/docs/alexa-voice-service/interactionmodel-interface.html).
- Added support for [System 2.0](https://developer.amazon.com/en-US/docs/alexa/alexa-voice-service/system.html).
- Added support for Alarm Volume Ramp. This feature lets you to fade in alarms for a more pleasant experience. You enable alarm volume ramp in the sample app through the settings menu.
- Added support for using certified senders for URI path extensions. This change allows you to specify the URI path extension when sending messages with [`CertifiedSender::sendJSONMessage`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1certified_sender_1_1_certified_sender.html#a4c0706d79717b226ba77d1a9c3280fe6).
- Added new [`Metrics`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1_metrics.html) interfaces and helper classes. These additions help you create and consume [`Metrics`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1_metrics.html) events.
- **Interfaces** - `MetricRecorderInterface`, `MetricSinkInterface`.
- **Helper Classes** - `DataPointStringBuilder`, `DataPointCounterBuilder`, `DataPointDurationBuilder`, `MetricEventBuilder`.
- Added support for the following AVS [endpoint](../avs-device-sdk/endpoints.html) controller capabilities:
- [Alexa.ModeController](https://developer.amazon.com/docs/alexa-voice-service/alexa-modecontroller.html)
- [Alexa.RangeController](https://developer.amazon.com/docs/alexa-voice-service/alexa-rangecontroller.html)
- [Alexa.PowerController](https://developer.amazon.com/docs/alexa-voice-service/alexa-powercontroller.html)
- [Alexa.ToggleController](https://developer.amazon.com/docs/alexa-voice-service/alexa-togglecontroller.html)
- Added `PowerResourceManagerInterface`. This interface allows the SDK to control power resource levels for components such as the `AudioInputProcessor` and `SpeechSynthesizer`.
- Added `AlexaInterfaceCapabilityAgent`. This Capability Agent handles common directives and endpoint controller capabilities support by [`Alexa.AlexaInterface`](../alexa-voice-service/alexa.html).
- Added `AlexaInterfaceMessageSenderInterface`. This interface is required to send common events defined by the `Alexa.AlexaInterface` interface.
- Added `BufferingComplete` to [`MediaPlayerObserverInterface`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_observer_interface.html). This method helps improve performance in poor networking conditions by making sure `MediaPlayer` pre-buffers correctly.
- Added `SendDTMF` to `CallManagerInterface`. This method allows you to send DTMF tones during calls.
**New build options**
- CAPTIONS
- **ADDED** [`CAPTIONS`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#captions)
- **ADDED** [`LIBWEBVTT_LIB_PATH`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#captions)
- **ADDED** [`LIBWEBVTT_INCLUDE_DIR`](https://developer.amazon.com/docs//avs-device-sdk/cmake-parameters.html#captions)
- METRICS
- **ADDED** [`METRICS`](https://developer.amazon.com/docs//avs-device-sdk/cmake-parameters.html#metrics)
- ENDPONTS
- **ADDED** [`ENABLE_ALL_ENDPOINT_CONTROLLERS`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
- **ADDED** [`ENABLE_POWER_CONTROLLER`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
- **ADDED** [`ENABLE_TOGGLE_CONTROLLER`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
- **ADDED** [`ENABLE_RANGE_CONTROLLER`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
- **ADDED** [`ENABLE_MODE_CONTROLLER`](https://developer.amazon.com/docs/avs-device-sdk/cmake-parameters.html#endpoints)
**New dependencies**
- To use captions, you must install a [new dependency](https://developer.amazon.com/docs/avs-device-sdk/dependencies) – the [libwebvtt parsing library](https://github.com/alexa/webvtt). Webvtt is a C/C++ library for interpreting and authoring conformant WebVTT content. WebVTT is a caption and subtitle format designed for use with HTML5 audio and video elements.
**Bug fixes**
- Fixed [`MimeResponseSink::onReceiveNonMimeData`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1acl_1_1_mime_response_sink.html) [data issue](https://github.com/alexa/avs-device-sdk/issues/1519) that returned invalid data.
- Fixed [data type issue](https://github.com/alexa/avs-device-sdk/issues/1519) that incorrectly used `finalResponseCode` instead of [`FinalResponseCodeId`](https://github.com/alexa/avs-device-sdk/blob/master/AVSCommon/Utils/src/LibcurlUtils/LibCurlHttpContentFetcher.cpp#L370).
- Fixed [`UrlContentToAttachmentConverter`](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1playlist_parser_1_1_url_content_to_attachment_converter.html) issue that used the incorrect range parameter.
- Fixed `FinallyGuard` [linking issue](https://github.com/alexa/avs-device-sdk/issues/1517) that caused problems compiling the SDK on iOS.
- Fixed a [Bluetooth Capability Agent](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1bluetooth_1_1_bluetooth.html) bug that prevented devices from initializing.
**Known Issues**
* The WebVTT dependency required for `captions` isn't supported for Windows/Android.
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the settings menu doesn't provide a message to indicate that you're back in the main menu.
2019-12-10 21:02:09 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <gmock/gmock.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "MockPostConnectObserver.h"
|
|
|
|
#include "MockPostConnectOperation.h"
|
|
|
|
#include <ACL/Transport/PostConnectSequencer.h>
|
|
|
|
#include <AVSCommon/SDKInterfaces/MockPostConnectSendMessage.h>
|
|
|
|
#include <AVSCommon/Utils/PromiseFuturePair.h>
|
|
|
|
|
|
|
|
namespace alexaClientSDK {
|
|
|
|
namespace acl {
|
|
|
|
namespace transport {
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
using namespace avsCommon::sdkInterfaces;
|
|
|
|
using namespace avsCommon::sdkInterfaces::test;
|
|
|
|
using namespace avsCommon::utils;
|
|
|
|
using namespace ::testing;
|
|
|
|
|
|
|
|
/// A short delay used in tests.
|
|
|
|
static const auto SHORT_DELAY = std::chrono::seconds(1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test harness for @c PostConnectSequencer class.
|
|
|
|
*/
|
|
|
|
class PostConnectSequencerTest : public Test {
|
|
|
|
public:
|
|
|
|
/// initialization for tests.
|
|
|
|
void SetUp() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/// The mock @c PostConnectObserverInterface.
|
|
|
|
std::shared_ptr<MockPostConnectObserver> m_mockPostConnectObserver;
|
|
|
|
|
|
|
|
/// The mock @c PostConnectSendMessageInterface.
|
|
|
|
std::shared_ptr<MockPostConnectSendMessage> m_mockPostConnectMessageSender;
|
|
|
|
};
|
|
|
|
|
|
|
|
void PostConnectSequencerTest::SetUp() {
|
|
|
|
m_mockPostConnectObserver = std::make_shared<NiceMock<MockPostConnectObserver>>();
|
|
|
|
m_mockPostConnectMessageSender = std::make_shared<NiceMock<MockPostConnectSendMessage>>();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the PostConnectOperationsSet sequences operations based on priority.
|
|
|
|
*/
|
|
|
|
TEST_F(PostConnectSequencerTest, test_postConnectOperationsSet) {
|
|
|
|
auto operation1 = std::make_shared<NiceMock<MockPostConnectOperation>>();
|
|
|
|
auto operation2 = std::make_shared<NiceMock<MockPostConnectOperation>>();
|
|
|
|
auto operation3 = std::make_shared<NiceMock<MockPostConnectOperation>>();
|
|
|
|
|
|
|
|
EXPECT_CALL(*operation1, getOperationPriority()).WillRepeatedly(Return(3));
|
|
|
|
EXPECT_CALL(*operation2, getOperationPriority()).WillRepeatedly(Return(2));
|
|
|
|
EXPECT_CALL(*operation3, getOperationPriority()).WillRepeatedly(Return(1));
|
|
|
|
|
|
|
|
PostConnectSequencer::PostConnectOperationsSet operationsSet;
|
|
|
|
operationsSet.insert(operation1);
|
|
|
|
operationsSet.insert(operation2);
|
|
|
|
operationsSet.insert(operation3);
|
|
|
|
|
|
|
|
auto it = operationsSet.begin();
|
|
|
|
ASSERT_EQ(*it, operation3);
|
|
|
|
it++;
|
|
|
|
ASSERT_EQ(*it, operation2);
|
|
|
|
it++;
|
|
|
|
ASSERT_EQ(*it, operation1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the PostConnectOperationsSet keeps only one instance with the same priority.
|
|
|
|
*/
|
|
|
|
TEST_F(PostConnectSequencerTest, test_postConnectOperationsSetRemovesDuplicates) {
|
|
|
|
auto operation1 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
auto operation2 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
|
|
|
|
EXPECT_CALL(*operation1, getOperationPriority()).WillRepeatedly(Return(3));
|
|
|
|
EXPECT_CALL(*operation2, getOperationPriority()).WillRepeatedly(Return(3));
|
|
|
|
|
|
|
|
PostConnectSequencer::PostConnectOperationsSet operationsSet;
|
|
|
|
operationsSet.insert(operation1);
|
|
|
|
operationsSet.insert(operation2);
|
|
|
|
|
|
|
|
ASSERT_EQ(operationsSet.size(), 1U);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if all PostConnectOperations are executed in sequence and the PostConnectObserver will be notified.
|
|
|
|
*/
|
|
|
|
TEST_F(PostConnectSequencerTest, test_happyPathAndPostConnectObserverGetsNotified) {
|
|
|
|
auto operation1 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
auto operation2 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
auto operation3 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
|
|
|
|
EXPECT_CALL(*operation1, getOperationPriority()).WillRepeatedly(Return(3));
|
|
|
|
EXPECT_CALL(*operation2, getOperationPriority()).WillRepeatedly(Return(2));
|
|
|
|
EXPECT_CALL(*operation3, getOperationPriority()).WillRepeatedly(Return(1));
|
|
|
|
|
|
|
|
PostConnectSequencer::PostConnectOperationsSet operationsSet;
|
|
|
|
operationsSet.insert(operation1);
|
|
|
|
operationsSet.insert(operation2);
|
|
|
|
operationsSet.insert(operation3);
|
|
|
|
|
|
|
|
auto postConnectSequencer = PostConnectSequencer::create(operationsSet);
|
|
|
|
ASSERT_NE(postConnectSequencer, nullptr);
|
|
|
|
|
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
EXPECT_CALL(*operation3, performOperation(_)).WillOnce(Return(true));
|
|
|
|
EXPECT_CALL(*operation2, performOperation(_)).WillOnce(Return(true));
|
|
|
|
EXPECT_CALL(*operation1, performOperation(_)).WillOnce(Return(true));
|
|
|
|
}
|
|
|
|
|
|
|
|
PromiseFuturePair<bool> promiseFuturePair;
|
|
|
|
EXPECT_CALL(*m_mockPostConnectObserver, onPostConnected()).WillOnce(Invoke([&promiseFuturePair] {
|
|
|
|
promiseFuturePair.setValue(true);
|
|
|
|
}));
|
|
|
|
|
|
|
|
postConnectSequencer->doPostConnect(m_mockPostConnectMessageSender, m_mockPostConnectObserver);
|
|
|
|
|
|
|
|
promiseFuturePair.waitFor(SHORT_DELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if doPostConnect() gets called twice in a row, the method returns false..
|
|
|
|
*/
|
|
|
|
TEST_F(PostConnectSequencerTest, test_doPostConnectReturnFalseOnSecondCall) {
|
|
|
|
auto operation1 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
|
|
|
|
EXPECT_CALL(*operation1, getOperationPriority()).WillRepeatedly(Return(1));
|
|
|
|
|
|
|
|
PostConnectSequencer::PostConnectOperationsSet operationsSet;
|
|
|
|
operationsSet.insert(operation1);
|
|
|
|
|
|
|
|
auto postConnectSequencer = PostConnectSequencer::create(operationsSet);
|
|
|
|
ASSERT_NE(postConnectSequencer, nullptr);
|
|
|
|
|
|
|
|
EXPECT_CALL(*operation1, performOperation(_)).WillOnce(Return(true));
|
|
|
|
|
|
|
|
PromiseFuturePair<bool> promiseFuturePair;
|
|
|
|
EXPECT_CALL(*m_mockPostConnectObserver, onPostConnected()).WillOnce(Invoke([&promiseFuturePair] {
|
|
|
|
promiseFuturePair.setValue(true);
|
|
|
|
}));
|
|
|
|
|
|
|
|
ASSERT_TRUE(postConnectSequencer->doPostConnect(m_mockPostConnectMessageSender, m_mockPostConnectObserver));
|
|
|
|
ASSERT_FALSE(postConnectSequencer->doPostConnect(m_mockPostConnectMessageSender, m_mockPostConnectObserver));
|
|
|
|
|
|
|
|
promiseFuturePair.waitFor(SHORT_DELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if PostConnectSequencer stops execution of PostConnectOperations if the performOperation() fails on one of
|
|
|
|
* them.
|
|
|
|
*/
|
|
|
|
TEST_F(PostConnectSequencerTest, test_subsequentOperationsDontExecute) {
|
|
|
|
auto operation1 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
auto operation2 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
auto operation3 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
|
|
|
|
EXPECT_CALL(*operation1, getOperationPriority()).WillRepeatedly(Return(3));
|
|
|
|
EXPECT_CALL(*operation2, getOperationPriority()).WillRepeatedly(Return(2));
|
|
|
|
EXPECT_CALL(*operation3, getOperationPriority()).WillRepeatedly(Return(1));
|
|
|
|
|
|
|
|
PostConnectSequencer::PostConnectOperationsSet operationsSet;
|
|
|
|
operationsSet.insert(operation1);
|
|
|
|
operationsSet.insert(operation2);
|
|
|
|
operationsSet.insert(operation3);
|
|
|
|
|
|
|
|
auto postConnectSequencer = PostConnectSequencer::create(operationsSet);
|
|
|
|
ASSERT_NE(postConnectSequencer, nullptr);
|
|
|
|
|
|
|
|
EXPECT_CALL(*operation3, performOperation(_)).WillOnce(Return(false));
|
|
|
|
|
|
|
|
PromiseFuturePair<bool> promiseFuturePair;
|
|
|
|
EXPECT_CALL(*m_mockPostConnectObserver, onUnRecoverablePostConnectFailure()).WillOnce(Invoke([&promiseFuturePair] {
|
|
|
|
promiseFuturePair.setValue(true);
|
|
|
|
}));
|
|
|
|
|
|
|
|
postConnectSequencer->doPostConnect(m_mockPostConnectMessageSender, m_mockPostConnectObserver);
|
|
|
|
|
|
|
|
/// It is possible that the destructor gets called first which initiates an abortOperation before the mainLoopThread
|
|
|
|
/// exits.
|
|
|
|
EXPECT_CALL(*operation3, abortOperation()).Times(AtMost(1));
|
|
|
|
|
|
|
|
promiseFuturePair.waitFor(SHORT_DELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if onDisconnect() stops execution of PostConnectOperations.
|
|
|
|
*/
|
|
|
|
TEST_F(PostConnectSequencerTest, test_onDisconnectStopsExecution) {
|
|
|
|
auto operation1 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
auto operation2 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
auto operation3 = std::make_shared<StrictMock<MockPostConnectOperation>>();
|
|
|
|
|
|
|
|
EXPECT_CALL(*operation1, getOperationPriority()).WillRepeatedly(Return(3));
|
|
|
|
EXPECT_CALL(*operation2, getOperationPriority()).WillRepeatedly(Return(2));
|
|
|
|
EXPECT_CALL(*operation3, getOperationPriority()).WillRepeatedly(Return(1));
|
|
|
|
|
|
|
|
PostConnectSequencer::PostConnectOperationsSet operationsSet;
|
|
|
|
operationsSet.insert(operation1);
|
|
|
|
operationsSet.insert(operation2);
|
|
|
|
operationsSet.insert(operation3);
|
|
|
|
|
|
|
|
auto postConnectSequencer = PostConnectSequencer::create(operationsSet);
|
|
|
|
ASSERT_NE(postConnectSequencer, nullptr);
|
|
|
|
|
|
|
|
PromiseFuturePair<bool> notifyOnPerfromOperation, notifyOnAbortOperation;
|
|
|
|
EXPECT_CALL(*operation3, performOperation(_))
|
|
|
|
.WillOnce(Invoke([¬ifyOnAbortOperation, ¬ifyOnPerfromOperation](
|
|
|
|
const std::shared_ptr<PostConnectSendMessageInterface>& postConnectSender) {
|
|
|
|
notifyOnPerfromOperation.setValue(true);
|
|
|
|
notifyOnAbortOperation.waitFor(SHORT_DELAY);
|
|
|
|
return true;
|
|
|
|
}));
|
|
|
|
EXPECT_CALL(*operation3, abortOperation()).WillOnce(Invoke([¬ifyOnAbortOperation] {
|
|
|
|
notifyOnAbortOperation.setValue(true);
|
|
|
|
}));
|
|
|
|
|
|
|
|
postConnectSequencer->doPostConnect(m_mockPostConnectMessageSender, m_mockPostConnectObserver);
|
|
|
|
notifyOnPerfromOperation.waitFor(SHORT_DELAY);
|
|
|
|
postConnectSequencer->onDisconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
} // namespace transport
|
|
|
|
} // namespace acl
|
|
|
|
} // namespace alexaClientSDK
|