2017-05-26 23:06:14 +00:00
|
|
|
/*
|
2018-02-12 23:31:53 +00:00
|
|
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2017-05-26 23:06:14 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// @file HTTP2StreamTest.cpp
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <random>
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <ACL/Transport/HTTP2Stream.h>
|
2017-08-08 00:04:43 +00:00
|
|
|
#include <AVSCommon/AVS/Initialization/AlexaClientSDKInit.h>
|
|
|
|
#include <AVSCommon/Utils/SDS/InProcessSDS.h>
|
|
|
|
#include <AVSCommon/AVS/Attachment/InProcessAttachmentReader.h>
|
2017-05-26 23:06:14 +00:00
|
|
|
#include "TestableConsumer.h"
|
|
|
|
#include "MockMessageRequest.h"
|
|
|
|
#include "Common/Common.h"
|
|
|
|
|
|
|
|
namespace alexaClientSDK {
|
|
|
|
namespace acl {
|
2017-06-09 23:23:31 +00:00
|
|
|
namespace test {
|
2017-05-26 23:06:14 +00:00
|
|
|
|
2017-08-08 00:04:43 +00:00
|
|
|
using namespace ::testing;
|
|
|
|
using namespace avsCommon::avs;
|
|
|
|
using namespace avsCommon::avs::attachment;
|
|
|
|
using namespace avsCommon::utils::sds;
|
|
|
|
using namespace alexaClientSDK::avsCommon::avs::initialization;
|
|
|
|
|
2017-05-26 23:06:14 +00:00
|
|
|
/// A test url with which to initialize our test stream object.
|
|
|
|
static const std::string LIBCURL_TEST_URL = "http://example.com";
|
|
|
|
/// A test auth string with which to initialize our test stream object.
|
|
|
|
static const std::string LIBCURL_TEST_AUTH_STRING = "test_auth_string";
|
2017-08-08 00:04:43 +00:00
|
|
|
/// The length of the string we will test for the exception message.
|
2017-05-26 23:06:14 +00:00
|
|
|
static const int TEST_EXCEPTION_STRING_LENGTH = 200;
|
|
|
|
/// The number of iterations the multi-write test will perform.
|
|
|
|
static const int TEST_EXCEPTION_PARTITIONS = 7;
|
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
|
|
|
/// The maximum length of the exception message allowed. Must be same as EXCEPTION_MESSAGE_MAX_SIZE.
|
|
|
|
static const size_t TEST_EXCEPTION_STRING_MAX_SIZE = 4096;
|
|
|
|
/// The length of the string we will test for the exception message that exceeded the maximum length.
|
|
|
|
static const size_t TEST_EXCEPTION_STRING_EXCEED_MAX_LENGTH = TEST_EXCEPTION_STRING_MAX_SIZE + 1024;
|
2017-08-08 00:04:43 +00:00
|
|
|
/// Number of bytes per word in the SDS circular buffer.
|
|
|
|
static const size_t SDS_WORDSIZE = 1;
|
|
|
|
/// Maximum number of readers to support in the SDS circular buffer.
|
|
|
|
static const size_t SDS_MAXREADERS = 1;
|
|
|
|
/// Number of words to hold in the SDS circular buffer.
|
|
|
|
static const size_t SDS_WORDS = 300;
|
|
|
|
/// Number of strings to read/write for the test
|
|
|
|
static const size_t NUMBER_OF_STRINGS = 1;
|
Version 1.7.0 of the avs-device-sdk
Changes in this update:
**Enhancements**
* `AuthDelegate` and `AuthServer.py` have been replaced by `CBLAUthDelegate`, which provides a more straightforward path to authorization.
* Added a new configuration property called [`cblAuthDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L2). This object specifies parameters for `CBLAuthDelegate`.
* Added a new configuration property called [`miscDatabase`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L34), which is a generic key/value database to be used by various components.
* Added a new configuration property called [`dcfDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L17) This object specifies parameters for `DCFDelegate`. Within this object, values were added for the 'endpoint' and `overridenDcfPublishMessageBody`. 'endpoint' is the endpoint to connect to in order to send device capabilities. `overridenDcfPublishMessageBody`is the message that will get sent out to the Capabilities API. Note: values within the `dcfDelegate` object will only work in `DEBUG` builds.
* Added a new configuration property called [`deviceInfo`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L9) which specifies device-identifying information for use by the Device Capability Framework (DCF), and for authorization (CBLAuthDelegate).
* Updated the Directive Sequencer to support wildcard directive handlers. This allows a handler for a given AVS interface to register at the namespace level, rather than specifying the names of all directives within that namespace.
* Updated the Raspberry Pi installation script to include `alsasink` in the configuration file.
* Added `audioSink` as a configuration option. This allows users to override the audio sink element used in `Gstreamer`.
* Added an interface for monitoring internet connection status: `InternetConnectionMonitorInterface.h`.
* The Alexa Communications Library (ACL) is no longer required to wait until authorization has succeeded before attempting to connect to AVS. Instead, `HTTP2Transport` handles waiting for authorization to complete.
* Added the Device Capabilities Framework (DCF) delegate. Device capabilities can now be sent for each capability interface using DCF publish messages.
* The sample app has been updated to send DCF publish messages, which will automatically occur when the sample app starts. Note: a DCF publish message must be successfully sent in order for communication with AVS to occur.
* The SDK now supports HTTP PUT messages.
* Added support for opt-arg style arguments and multiple configuration files. Now, the sample app can be invoked by either of these commands: `SampleApp <configfile> <debuglevel>` OR `SampleApp -C file1 -C file2 ... -L loglevel`.
**Bug Fixes**
* Issues [447](https://github.com/alexa/avs-device-sdk/issues/447) and [553](https://github.com/alexa/avs-device-sdk/issues/553) Fixed the `AttachmentRenderSource`'s handling of `BLOCKING` `AttachmentReaders`.
* Updated the `Logger` implementation to be more resilient to `nullptr` string inputs.
* Fixed a `TimeUtils` utility-related compile issue.
* Fixed a bug in which alerts failed to activate if the system was restarted without network connection.
* Fixed Android 64-bit build failure issue.
**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.
* Some ERROR messages may be printed during start-up event if initialization proceeds normally and successfully.
* If an unrecoverable authorization error or an unrecoverable DCF error is encountered, the sample app may crash on shutdown.
* If a non-CBL `clientId` is included in the `deviceInfo` section of `AlexaClientSDKConfig.json`, the error will be reported as an unrecoverable authorization error, rather than a more specific error.
2018-04-18 22:17:28 +00:00
|
|
|
|
|
|
|
/// The field name for the user voice attachment
|
|
|
|
static const std::string AUDIO_ATTACHMENT_FIELD_NAME = "audio";
|
|
|
|
|
|
|
|
/// The field name for the wake word engine metadata
|
|
|
|
static const std::string KWD_METADATA_ATTACHMENT_FIELD_NAME = "WakwWordEngineMetadata";
|
|
|
|
|
2017-05-26 23:06:14 +00:00
|
|
|
/**
|
|
|
|
* Our GTest class.
|
|
|
|
*/
|
|
|
|
class HTTP2StreamTest : public ::testing::Test {
|
|
|
|
public:
|
2017-08-08 00:04:43 +00:00
|
|
|
void SetUp() override;
|
2017-05-26 23:06:14 +00:00
|
|
|
|
2017-08-08 00:04:43 +00:00
|
|
|
void TearDown() override;
|
2017-05-26 23:06:14 +00:00
|
|
|
|
2017-08-08 00:04:43 +00:00
|
|
|
/// A message request to initiate @c m_readTestableStream with
|
|
|
|
std::shared_ptr<MessageRequest> m_MessageRequest;
|
2017-05-26 23:06:14 +00:00
|
|
|
/// A mock message request object.
|
|
|
|
std::shared_ptr<MockMessageRequest> m_mockMessageRequest;
|
|
|
|
/// An object that is required for constructing a stream.
|
2017-10-02 22:59:05 +00:00
|
|
|
std::shared_ptr<TestableConsumer> m_testableConsumer;
|
2017-05-26 23:06:14 +00:00
|
|
|
/// The actual stream we will be testing.
|
|
|
|
std::shared_ptr<HTTP2Stream> m_testableStream;
|
2017-08-08 00:04:43 +00:00
|
|
|
/// The stream to test @c readCallback function
|
|
|
|
std::shared_ptr<HTTP2Stream> m_readTestableStream;
|
|
|
|
/// The attachment manager for the stream
|
|
|
|
std::shared_ptr<AttachmentManager> m_attachmentManager;
|
|
|
|
/// A Writer to write data to SDS buffer.
|
|
|
|
std::unique_ptr<avsCommon::utils::sds::InProcessSDS::Writer> m_writer;
|
|
|
|
/// The attachment reader for message request of @c m_readTestableStream
|
Version 1.7.0 of the avs-device-sdk
Changes in this update:
**Enhancements**
* `AuthDelegate` and `AuthServer.py` have been replaced by `CBLAUthDelegate`, which provides a more straightforward path to authorization.
* Added a new configuration property called [`cblAuthDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L2). This object specifies parameters for `CBLAuthDelegate`.
* Added a new configuration property called [`miscDatabase`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L34), which is a generic key/value database to be used by various components.
* Added a new configuration property called [`dcfDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L17) This object specifies parameters for `DCFDelegate`. Within this object, values were added for the 'endpoint' and `overridenDcfPublishMessageBody`. 'endpoint' is the endpoint to connect to in order to send device capabilities. `overridenDcfPublishMessageBody`is the message that will get sent out to the Capabilities API. Note: values within the `dcfDelegate` object will only work in `DEBUG` builds.
* Added a new configuration property called [`deviceInfo`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L9) which specifies device-identifying information for use by the Device Capability Framework (DCF), and for authorization (CBLAuthDelegate).
* Updated the Directive Sequencer to support wildcard directive handlers. This allows a handler for a given AVS interface to register at the namespace level, rather than specifying the names of all directives within that namespace.
* Updated the Raspberry Pi installation script to include `alsasink` in the configuration file.
* Added `audioSink` as a configuration option. This allows users to override the audio sink element used in `Gstreamer`.
* Added an interface for monitoring internet connection status: `InternetConnectionMonitorInterface.h`.
* The Alexa Communications Library (ACL) is no longer required to wait until authorization has succeeded before attempting to connect to AVS. Instead, `HTTP2Transport` handles waiting for authorization to complete.
* Added the Device Capabilities Framework (DCF) delegate. Device capabilities can now be sent for each capability interface using DCF publish messages.
* The sample app has been updated to send DCF publish messages, which will automatically occur when the sample app starts. Note: a DCF publish message must be successfully sent in order for communication with AVS to occur.
* The SDK now supports HTTP PUT messages.
* Added support for opt-arg style arguments and multiple configuration files. Now, the sample app can be invoked by either of these commands: `SampleApp <configfile> <debuglevel>` OR `SampleApp -C file1 -C file2 ... -L loglevel`.
**Bug Fixes**
* Issues [447](https://github.com/alexa/avs-device-sdk/issues/447) and [553](https://github.com/alexa/avs-device-sdk/issues/553) Fixed the `AttachmentRenderSource`'s handling of `BLOCKING` `AttachmentReaders`.
* Updated the `Logger` implementation to be more resilient to `nullptr` string inputs.
* Fixed a `TimeUtils` utility-related compile issue.
* Fixed a bug in which alerts failed to activate if the system was restarted without network connection.
* Fixed Android 64-bit build failure issue.
**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.
* Some ERROR messages may be printed during start-up event if initialization proceeds normally and successfully.
* If an unrecoverable authorization error or an unrecoverable DCF error is encountered, the sample app may crash on shutdown.
* If a non-CBL `clientId` is included in the `deviceInfo` section of `AlexaClientSDKConfig.json`, the error will be reported as an unrecoverable authorization error, rather than a more specific error.
2018-04-18 22:17:28 +00:00
|
|
|
std::shared_ptr<InProcessAttachmentReader> m_attachmentReader;
|
2017-08-08 00:04:43 +00:00
|
|
|
/// A char pointer to data buffer to read or write from callbacks
|
|
|
|
char* m_dataBegin;
|
|
|
|
/// A string to which @c m_dataBegin is pointing to
|
|
|
|
std::string m_testString;
|
2017-05-26 23:06:14 +00:00
|
|
|
};
|
|
|
|
|
2017-08-08 00:04:43 +00:00
|
|
|
void HTTP2StreamTest::SetUp() {
|
Version 1.7.0 of the avs-device-sdk
Changes in this update:
**Enhancements**
* `AuthDelegate` and `AuthServer.py` have been replaced by `CBLAUthDelegate`, which provides a more straightforward path to authorization.
* Added a new configuration property called [`cblAuthDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L2). This object specifies parameters for `CBLAuthDelegate`.
* Added a new configuration property called [`miscDatabase`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L34), which is a generic key/value database to be used by various components.
* Added a new configuration property called [`dcfDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L17) This object specifies parameters for `DCFDelegate`. Within this object, values were added for the 'endpoint' and `overridenDcfPublishMessageBody`. 'endpoint' is the endpoint to connect to in order to send device capabilities. `overridenDcfPublishMessageBody`is the message that will get sent out to the Capabilities API. Note: values within the `dcfDelegate` object will only work in `DEBUG` builds.
* Added a new configuration property called [`deviceInfo`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L9) which specifies device-identifying information for use by the Device Capability Framework (DCF), and for authorization (CBLAuthDelegate).
* Updated the Directive Sequencer to support wildcard directive handlers. This allows a handler for a given AVS interface to register at the namespace level, rather than specifying the names of all directives within that namespace.
* Updated the Raspberry Pi installation script to include `alsasink` in the configuration file.
* Added `audioSink` as a configuration option. This allows users to override the audio sink element used in `Gstreamer`.
* Added an interface for monitoring internet connection status: `InternetConnectionMonitorInterface.h`.
* The Alexa Communications Library (ACL) is no longer required to wait until authorization has succeeded before attempting to connect to AVS. Instead, `HTTP2Transport` handles waiting for authorization to complete.
* Added the Device Capabilities Framework (DCF) delegate. Device capabilities can now be sent for each capability interface using DCF publish messages.
* The sample app has been updated to send DCF publish messages, which will automatically occur when the sample app starts. Note: a DCF publish message must be successfully sent in order for communication with AVS to occur.
* The SDK now supports HTTP PUT messages.
* Added support for opt-arg style arguments and multiple configuration files. Now, the sample app can be invoked by either of these commands: `SampleApp <configfile> <debuglevel>` OR `SampleApp -C file1 -C file2 ... -L loglevel`.
**Bug Fixes**
* Issues [447](https://github.com/alexa/avs-device-sdk/issues/447) and [553](https://github.com/alexa/avs-device-sdk/issues/553) Fixed the `AttachmentRenderSource`'s handling of `BLOCKING` `AttachmentReaders`.
* Updated the `Logger` implementation to be more resilient to `nullptr` string inputs.
* Fixed a `TimeUtils` utility-related compile issue.
* Fixed a bug in which alerts failed to activate if the system was restarted without network connection.
* Fixed Android 64-bit build failure issue.
**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.
* Some ERROR messages may be printed during start-up event if initialization proceeds normally and successfully.
* If an unrecoverable authorization error or an unrecoverable DCF error is encountered, the sample app may crash on shutdown.
* If a non-CBL `clientId` is included in the `deviceInfo` section of `AlexaClientSDKConfig.json`, the error will be reported as an unrecoverable authorization error, rather than a more specific error.
2018-04-18 22:17:28 +00:00
|
|
|
AlexaClientSDKInit::initialize(std::vector<std::shared_ptr<std::istream>>());
|
2017-10-02 22:59:05 +00:00
|
|
|
m_testableConsumer = std::make_shared<TestableConsumer>();
|
|
|
|
|
|
|
|
m_testString = createRandomAlphabetString(TEST_EXCEPTION_STRING_LENGTH);
|
|
|
|
m_dataBegin = const_cast<char*>(m_testString.c_str());
|
|
|
|
|
|
|
|
/// Create a SDS buffer and using a @c Writer, write a string into the buffer
|
|
|
|
size_t bufferSize = InProcessSDS::calculateBufferSize(SDS_WORDS, SDS_WORDSIZE, SDS_MAXREADERS);
|
|
|
|
auto buffer = std::make_shared<avsCommon::utils::sds::InProcessSDS::Buffer>(bufferSize);
|
|
|
|
std::shared_ptr<InProcessSDS> stream = InProcessSDS::create(buffer, SDS_WORDSIZE, SDS_MAXREADERS);
|
|
|
|
ASSERT_NE(stream, nullptr);
|
|
|
|
|
|
|
|
m_writer = stream->createWriter(InProcessSDS::Writer::Policy::NONBLOCKABLE);
|
|
|
|
ASSERT_NE(m_writer, nullptr);
|
|
|
|
ASSERT_EQ(TEST_EXCEPTION_STRING_LENGTH, m_writer->write(m_dataBegin, TEST_EXCEPTION_STRING_LENGTH));
|
|
|
|
|
|
|
|
/// Create an attachment Reader for @c m_MessageRequest
|
2018-02-12 23:31:53 +00:00
|
|
|
m_attachmentReader = InProcessAttachmentReader::create(InProcessSDS::Reader::Policy::NONBLOCKING, stream);
|
Version 1.7.0 of the avs-device-sdk
Changes in this update:
**Enhancements**
* `AuthDelegate` and `AuthServer.py` have been replaced by `CBLAUthDelegate`, which provides a more straightforward path to authorization.
* Added a new configuration property called [`cblAuthDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L2). This object specifies parameters for `CBLAuthDelegate`.
* Added a new configuration property called [`miscDatabase`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L34), which is a generic key/value database to be used by various components.
* Added a new configuration property called [`dcfDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L17) This object specifies parameters for `DCFDelegate`. Within this object, values were added for the 'endpoint' and `overridenDcfPublishMessageBody`. 'endpoint' is the endpoint to connect to in order to send device capabilities. `overridenDcfPublishMessageBody`is the message that will get sent out to the Capabilities API. Note: values within the `dcfDelegate` object will only work in `DEBUG` builds.
* Added a new configuration property called [`deviceInfo`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L9) which specifies device-identifying information for use by the Device Capability Framework (DCF), and for authorization (CBLAuthDelegate).
* Updated the Directive Sequencer to support wildcard directive handlers. This allows a handler for a given AVS interface to register at the namespace level, rather than specifying the names of all directives within that namespace.
* Updated the Raspberry Pi installation script to include `alsasink` in the configuration file.
* Added `audioSink` as a configuration option. This allows users to override the audio sink element used in `Gstreamer`.
* Added an interface for monitoring internet connection status: `InternetConnectionMonitorInterface.h`.
* The Alexa Communications Library (ACL) is no longer required to wait until authorization has succeeded before attempting to connect to AVS. Instead, `HTTP2Transport` handles waiting for authorization to complete.
* Added the Device Capabilities Framework (DCF) delegate. Device capabilities can now be sent for each capability interface using DCF publish messages.
* The sample app has been updated to send DCF publish messages, which will automatically occur when the sample app starts. Note: a DCF publish message must be successfully sent in order for communication with AVS to occur.
* The SDK now supports HTTP PUT messages.
* Added support for opt-arg style arguments and multiple configuration files. Now, the sample app can be invoked by either of these commands: `SampleApp <configfile> <debuglevel>` OR `SampleApp -C file1 -C file2 ... -L loglevel`.
**Bug Fixes**
* Issues [447](https://github.com/alexa/avs-device-sdk/issues/447) and [553](https://github.com/alexa/avs-device-sdk/issues/553) Fixed the `AttachmentRenderSource`'s handling of `BLOCKING` `AttachmentReaders`.
* Updated the `Logger` implementation to be more resilient to `nullptr` string inputs.
* Fixed a `TimeUtils` utility-related compile issue.
* Fixed a bug in which alerts failed to activate if the system was restarted without network connection.
* Fixed Android 64-bit build failure issue.
**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.
* Some ERROR messages may be printed during start-up event if initialization proceeds normally and successfully.
* If an unrecoverable authorization error or an unrecoverable DCF error is encountered, the sample app may crash on shutdown.
* If a non-CBL `clientId` is included in the `deviceInfo` section of `AlexaClientSDKConfig.json`, the error will be reported as an unrecoverable authorization error, rather than a more specific error.
2018-04-18 22:17:28 +00:00
|
|
|
m_MessageRequest = std::make_shared<MessageRequest>("");
|
|
|
|
m_MessageRequest->addAttachmentReader(AUDIO_ATTACHMENT_FIELD_NAME, m_attachmentReader);
|
|
|
|
m_MessageRequest->addAttachmentReader(KWD_METADATA_ATTACHMENT_FIELD_NAME, m_attachmentReader);
|
|
|
|
|
2017-10-02 22:59:05 +00:00
|
|
|
ASSERT_NE(m_MessageRequest, nullptr);
|
|
|
|
|
|
|
|
m_mockMessageRequest = std::make_shared<MockMessageRequest>();
|
|
|
|
ASSERT_NE(m_mockMessageRequest, nullptr);
|
|
|
|
m_attachmentManager = std::make_shared<AttachmentManager>(AttachmentManager::AttachmentType::IN_PROCESS);
|
|
|
|
|
|
|
|
m_testableStream = std::make_shared<HTTP2Stream>(m_testableConsumer, m_attachmentManager);
|
|
|
|
ASSERT_NE(m_testableStream, nullptr);
|
|
|
|
ASSERT_TRUE(m_testableStream->initPost(LIBCURL_TEST_URL, LIBCURL_TEST_AUTH_STRING, m_mockMessageRequest));
|
|
|
|
|
|
|
|
m_readTestableStream = std::make_shared<HTTP2Stream>(m_testableConsumer, m_attachmentManager);
|
|
|
|
ASSERT_NE(m_readTestableStream, nullptr);
|
|
|
|
ASSERT_TRUE(m_readTestableStream->initPost(LIBCURL_TEST_URL, LIBCURL_TEST_AUTH_STRING, m_MessageRequest));
|
|
|
|
}
|
2017-08-08 00:04:43 +00:00
|
|
|
|
|
|
|
void HTTP2StreamTest::TearDown() {
|
2017-10-02 22:59:05 +00:00
|
|
|
AlexaClientSDKInit::uninitialize();
|
|
|
|
}
|
2017-05-26 23:06:14 +00:00
|
|
|
/**
|
|
|
|
* Let's simulate that AVSConnectionManager->send() has been invoked, and the messageRequest object is
|
|
|
|
* waiting to be notified on the response from AVS. We will invoke the stream writeCallbacks directly to
|
|
|
|
* simulate exception data returning from AVS, and verify that the stream passes the correct data back to
|
|
|
|
* the request object.
|
|
|
|
*/
|
|
|
|
TEST_F(HTTP2StreamTest, testExceptionReceivedSingleWrite) {
|
2017-08-08 00:04:43 +00:00
|
|
|
HTTP2Stream::writeCallback(m_dataBegin, TEST_EXCEPTION_STRING_LENGTH, NUMBER_OF_STRINGS, m_testableStream.get());
|
2017-05-26 23:06:14 +00:00
|
|
|
|
2017-10-02 22:59:05 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageRequest, exceptionReceived(_)).Times(1);
|
|
|
|
EXPECT_CALL(*m_mockMessageRequest, sendCompleted(_)).Times(1);
|
2017-05-26 23:06:14 +00:00
|
|
|
// This simulates stream cleanup, which flushes out the parsed exception message.
|
|
|
|
m_testableStream->notifyRequestObserver();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The same test as above, but now with multiple writes (simulating either a small buffer from libcurl, or a very
|
|
|
|
* long exception message).
|
|
|
|
*/
|
|
|
|
TEST_F(HTTP2StreamTest, testExceptionReceivedMultiWrite) {
|
|
|
|
int writeQuantum = TEST_EXCEPTION_STRING_LENGTH;
|
|
|
|
if (TEST_EXCEPTION_PARTITIONS > 0) {
|
|
|
|
writeQuantum = TEST_EXCEPTION_STRING_LENGTH / TEST_EXCEPTION_PARTITIONS;
|
|
|
|
}
|
|
|
|
int numberBytesWritten = 0;
|
|
|
|
|
2017-08-08 00:04:43 +00:00
|
|
|
char* currBuffPosition = m_dataBegin;
|
2017-05-26 23:06:14 +00:00
|
|
|
while (numberBytesWritten < TEST_EXCEPTION_STRING_LENGTH) {
|
2017-08-08 00:04:43 +00:00
|
|
|
int bytesRemaining = TEST_EXCEPTION_STRING_LENGTH - numberBytesWritten;
|
2017-05-26 23:06:14 +00:00
|
|
|
int bytesToWrite = bytesRemaining < writeQuantum ? bytesRemaining : writeQuantum;
|
|
|
|
|
2017-08-08 00:04:43 +00:00
|
|
|
HTTP2Stream::writeCallback(currBuffPosition, bytesToWrite, NUMBER_OF_STRINGS, m_testableStream.get());
|
2017-05-26 23:06:14 +00:00
|
|
|
currBuffPosition += bytesToWrite;
|
|
|
|
numberBytesWritten += bytesToWrite;
|
|
|
|
}
|
|
|
|
|
2017-10-02 22:59:05 +00:00
|
|
|
EXPECT_CALL(*m_mockMessageRequest, exceptionReceived(_)).Times(1);
|
|
|
|
EXPECT_CALL(*m_mockMessageRequest, sendCompleted(_)).Times(1);
|
2017-05-26 23:06:14 +00:00
|
|
|
|
|
|
|
// This simulates stream cleanup, which flushes out the parsed exception message.
|
|
|
|
m_testableStream->notifyRequestObserver();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* We will invoke the stream writeCallbacks directly to simulate exception data that exceeded maximum length allowed
|
|
|
|
* returning from AVS, and verify that the stream passes up the correct data up to the maximum length back to the
|
|
|
|
* request object.
|
|
|
|
*/
|
|
|
|
TEST_F(HTTP2StreamTest, testExceptionExceededMaximum) {
|
|
|
|
HTTP2Stream::writeCallback(
|
|
|
|
m_dataBegin, TEST_EXCEPTION_STRING_EXCEED_MAX_LENGTH, NUMBER_OF_STRINGS, m_testableStream.get());
|
|
|
|
|
|
|
|
EXPECT_CALL(*m_mockMessageRequest, exceptionReceived(_)).WillOnce(Invoke([](const std::string& exceptionMessage) {
|
|
|
|
EXPECT_EQ(exceptionMessage.size(), TEST_EXCEPTION_STRING_MAX_SIZE);
|
|
|
|
}));
|
|
|
|
EXPECT_CALL(*m_mockMessageRequest, sendCompleted(_)).Times(1);
|
|
|
|
// This simulates stream cleanup, which flushes out the parsed exception message.
|
|
|
|
m_testableStream->notifyRequestObserver();
|
|
|
|
}
|
|
|
|
|
2017-08-08 00:04:43 +00:00
|
|
|
TEST_F(HTTP2StreamTest, testHeaderCallback) {
|
|
|
|
// Check if the length returned is as expected
|
|
|
|
int headerLength = TEST_EXCEPTION_STRING_LENGTH * NUMBER_OF_STRINGS;
|
|
|
|
int returnHeaderLength = HTTP2Stream::headerCallback(
|
2017-10-02 22:59:05 +00:00
|
|
|
m_dataBegin, TEST_EXCEPTION_STRING_LENGTH, NUMBER_OF_STRINGS, m_testableStream.get());
|
2017-08-08 00:04:43 +00:00
|
|
|
ASSERT_EQ(headerLength, returnHeaderLength);
|
|
|
|
// Call the function with NULL HTTP2Stream and check if it fails
|
2017-10-02 22:59:05 +00:00
|
|
|
returnHeaderLength =
|
|
|
|
HTTP2Stream::headerCallback(m_dataBegin, TEST_EXCEPTION_STRING_LENGTH, NUMBER_OF_STRINGS, nullptr);
|
2017-08-08 00:04:43 +00:00
|
|
|
ASSERT_EQ(0, returnHeaderLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(HTTP2StreamTest, testReadCallBack) {
|
2017-10-02 22:59:05 +00:00
|
|
|
// Check if the bytesRead are equal to length of data written in SDS buffer
|
Version 1.7.0 of the avs-device-sdk
Changes in this update:
**Enhancements**
* `AuthDelegate` and `AuthServer.py` have been replaced by `CBLAUthDelegate`, which provides a more straightforward path to authorization.
* Added a new configuration property called [`cblAuthDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L2). This object specifies parameters for `CBLAuthDelegate`.
* Added a new configuration property called [`miscDatabase`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L34), which is a generic key/value database to be used by various components.
* Added a new configuration property called [`dcfDelegate`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L17) This object specifies parameters for `DCFDelegate`. Within this object, values were added for the 'endpoint' and `overridenDcfPublishMessageBody`. 'endpoint' is the endpoint to connect to in order to send device capabilities. `overridenDcfPublishMessageBody`is the message that will get sent out to the Capabilities API. Note: values within the `dcfDelegate` object will only work in `DEBUG` builds.
* Added a new configuration property called [`deviceInfo`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L9) which specifies device-identifying information for use by the Device Capability Framework (DCF), and for authorization (CBLAuthDelegate).
* Updated the Directive Sequencer to support wildcard directive handlers. This allows a handler for a given AVS interface to register at the namespace level, rather than specifying the names of all directives within that namespace.
* Updated the Raspberry Pi installation script to include `alsasink` in the configuration file.
* Added `audioSink` as a configuration option. This allows users to override the audio sink element used in `Gstreamer`.
* Added an interface for monitoring internet connection status: `InternetConnectionMonitorInterface.h`.
* The Alexa Communications Library (ACL) is no longer required to wait until authorization has succeeded before attempting to connect to AVS. Instead, `HTTP2Transport` handles waiting for authorization to complete.
* Added the Device Capabilities Framework (DCF) delegate. Device capabilities can now be sent for each capability interface using DCF publish messages.
* The sample app has been updated to send DCF publish messages, which will automatically occur when the sample app starts. Note: a DCF publish message must be successfully sent in order for communication with AVS to occur.
* The SDK now supports HTTP PUT messages.
* Added support for opt-arg style arguments and multiple configuration files. Now, the sample app can be invoked by either of these commands: `SampleApp <configfile> <debuglevel>` OR `SampleApp -C file1 -C file2 ... -L loglevel`.
**Bug Fixes**
* Issues [447](https://github.com/alexa/avs-device-sdk/issues/447) and [553](https://github.com/alexa/avs-device-sdk/issues/553) Fixed the `AttachmentRenderSource`'s handling of `BLOCKING` `AttachmentReaders`.
* Updated the `Logger` implementation to be more resilient to `nullptr` string inputs.
* Fixed a `TimeUtils` utility-related compile issue.
* Fixed a bug in which alerts failed to activate if the system was restarted without network connection.
* Fixed Android 64-bit build failure issue.
**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.
* Some ERROR messages may be printed during start-up event if initialization proceeds normally and successfully.
* If an unrecoverable authorization error or an unrecoverable DCF error is encountered, the sample app may crash on shutdown.
* If a non-CBL `clientId` is included in the `deviceInfo` section of `AlexaClientSDKConfig.json`, the error will be reported as an unrecoverable authorization error, rather than a more specific error.
2018-04-18 22:17:28 +00:00
|
|
|
auto indexAndStream = std::make_pair<size_t, HTTP2Stream*>(0, m_readTestableStream.get());
|
|
|
|
int bytesRead =
|
|
|
|
HTTP2Stream::readCallback(m_dataBegin, TEST_EXCEPTION_STRING_LENGTH, NUMBER_OF_STRINGS, &indexAndStream);
|
2017-08-08 00:04:43 +00:00
|
|
|
ASSERT_EQ(TEST_EXCEPTION_STRING_LENGTH, bytesRead);
|
|
|
|
// Call the function with NULL HTTP2Stream and check if it fails
|
|
|
|
bytesRead = HTTP2Stream::readCallback(m_dataBegin, TEST_EXCEPTION_STRING_LENGTH, NUMBER_OF_STRINGS, nullptr);
|
|
|
|
ASSERT_EQ(0, bytesRead);
|
|
|
|
}
|
2017-10-02 22:59:05 +00:00
|
|
|
} // namespace test
|
|
|
|
} // namespace acl
|
|
|
|
} // namespace alexaClientSDK
|
2017-05-26 23:06:14 +00:00
|
|
|
|
2017-10-02 22:59:05 +00:00
|
|
|
int main(int argc, char** argv) {
|
2017-05-26 23:06:14 +00:00
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
2017-10-02 22:59:05 +00:00
|
|
|
}
|