Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Version 1.20.1 alexa-client-sdk
Browse files Browse the repository at this point in the history
Changes in this update:

Feature enhancements, updates, and resolved issues from all releases are available on the [Amazon developer portal](https://developer.amazon.com/docs/alexa/avs-device-sdk/release-notes.html).
  • Loading branch information
mvelegon-amzn committed Aug 6, 2020
1 parent f82767c commit 4bb0d23
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 122 deletions.
4 changes: 2 additions & 2 deletions AVSCommon/Utils/include/AVSCommon/Utils/SDKVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace utils {
namespace sdkVersion {

inline static std::string getCurrentVersion() {
return "1.20.0";
return "1.20.1";
}

inline static int getMajorVersion() {
Expand All @@ -41,7 +41,7 @@ inline static int getMinorVersion() {
}

inline static int getPatchVersion() {
return 0;
return 1;
}

} // namespace sdkVersion
Expand Down
2 changes: 1 addition & 1 deletion ApplicationUtilities/SDKComponent/src/SDKComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace SDKComponent {
using namespace avsCommon::utils::logger;

// Name of the Component to add to ComponentReporter
static const std::string SDK_COMPONENT_NAME = "com.amazon.sdk";
static const std::string SDK_COMPONENT_NAME = "com.amazon.alexa.deviceSDK";

/// String to identify log entries originating from this file.
static const std::string TAG("SDKComponent");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace ::testing;
using namespace avsCommon::avs;

// Name of the SDK Component Added to Component Reporter
static const std::string SDK_COMPONENT_NAME = "com.amazon.sdk";
static const std::string SDK_COMPONENT_NAME = "com.amazon.alexa.deviceSDK";

/**
* Test SDKComponent correctly returns sdk version in SDKVersion.h
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## ChangeLog

### Version 1.20.1 - August 6 2020
Feature enhancements, updates, and resolved issues from all releases are available on the [Amazon developer portal](https://developer.amazon.com/docs/alexa/avs-device-sdk/release-notes.html)

### Version 1.20.0 - June 22 2020
Feature enhancements, updates, and resolved issues from all releases are available on the [Amazon developer portal](https://developer.amazon.com/docs/alexa/avs-device-sdk/release-notes.html)

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)

# Set project information
project(AlexaClientSDK VERSION 1.20.0 LANGUAGES CXX)
project(AlexaClientSDK VERSION 1.20.1 LANGUAGES CXX)
set(PROJECT_BRIEF "A cross-platform, modular SDK for interacting with the Alexa Voice Service")

# This variable should be used by extension packages to include cmake files from this project.
Expand Down
2 changes: 1 addition & 1 deletion CapabilityAgents/TemplateRuntime/src/TemplateRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void TemplateRuntime::doShutdown() {
m_activeRenderPlayerInfoCardsProvider.reset();
m_audioItemsInExecution.clear();
m_audioPlayerInfo.clear();
for (const auto renderPlayerInfoCardsInterface : m_renderPlayerInfoCardsInterfaces) {
for (const auto& renderPlayerInfoCardsInterface : m_renderPlayerInfoCardsInterfaces) {
renderPlayerInfoCardsInterface->setObserver(nullptr);
}
m_renderPlayerInfoCardsInterfaces.clear();
Expand Down
20 changes: 1 addition & 19 deletions CertifiedSender/src/CertifiedSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@

#include <AVSCommon/AVS/MessageRequest.h>
#include <AVSCommon/Utils/Logger/Logger.h>
#include <AVSCommon/Utils/Configuration/ConfigurationNode.h>
#include <RegistrationManager/CustomerDataManager.h>

#include <queue>

namespace alexaClientSDK {
namespace certifiedSender {

Expand Down Expand Up @@ -168,23 +167,6 @@ bool CertifiedSender::init() {
}
}

/// Load stored messages from storage.
std::queue<MessageStorageInterface::StoredMessage> storedMessages;
if (!m_storage->load(&storedMessages)) {
ACSDK_ERROR(LX("initFailed").m("Could not load messages from database file."));
return false;
}

while (!storedMessages.empty()) {
auto storedMessage = storedMessages.front();
{
std::lock_guard<std::mutex> lock{m_mutex};
m_messagesToSend.push_back(std::make_shared<CertifiedMessageRequest>(
storedMessage.message, storedMessage.id, storedMessage.uriPathExtension));
}
storedMessages.pop();
}

m_workerThread = std::thread(&CertifiedSender::mainloop, this);

return true;
Expand Down
105 changes: 8 additions & 97 deletions CertifiedSender/test/CertifiedSenderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/

#include <chrono>
#include <future>
#include <memory>
#include <queue>

#include <gtest/gtest.h>

Expand Down Expand Up @@ -85,22 +85,20 @@ class CertifiedSenderTest : public ::testing::Test {
(*configuration) << CONFIGURATION;
ASSERT_TRUE(avsCommon::avs::initialization::AlexaClientSDKInit::initialize({configuration}));

m_customerDataManager = std::make_shared<registrationManager::CustomerDataManager>();
auto customerDataManager = std::make_shared<registrationManager::CustomerDataManager>();
m_mockMessageSender = std::make_shared<avsCommon::sdkInterfaces::test::MockMessageSender>();
m_connection = std::make_shared<MockConnection>();
m_storage = std::make_shared<MockMessageStorage>();

EXPECT_CALL(*m_storage, open()).Times(1).WillOnce(Return(true));
EXPECT_CALL(*m_storage, load(_)).Times(1).WillOnce(Return(true));
m_certifiedSender =
CertifiedSender::create(m_mockMessageSender, m_connection, m_storage, m_customerDataManager);
m_certifiedSender = CertifiedSender::create(m_mockMessageSender, m_connection, m_storage, customerDataManager);
}

void TearDown() override {
if (avsCommon::avs::initialization::AlexaClientSDKInit::isInitialized()) {
avsCommon::avs::initialization::AlexaClientSDKInit::uninitialize();
}
m_certifiedSender->shutdown();
m_connection->removeConnectionStatusObserver(m_certifiedSender);
}

/// Class under test.
Expand All @@ -113,9 +111,6 @@ class CertifiedSenderTest : public ::testing::Test {
/// be deleted.
std::shared_ptr<MockConnection> m_connection;

/// The pointer to the customer data manager
std::shared_ptr<registrationManager::CustomerDataManager> m_customerDataManager;

/// The mock message sender instance.
std::shared_ptr<avsCommon::sdkInterfaces::test::MockMessageSender> m_mockMessageSender;
};
Expand All @@ -128,101 +123,17 @@ TEST_F(CertifiedSenderTest, test_clearData) {
m_certifiedSender->clearData();
}

/**
* Tests various failure scenarios for the init method.
*/
TEST_F(CertifiedSenderTest, test_initFailsWhenStorageMethodsFail) {
/// Test if the init method fails when createDatabase on storage fails.
{
EXPECT_CALL(*m_storage, open()).Times(1).WillOnce(Return(false));
EXPECT_CALL(*m_storage, createDatabase()).Times(1).WillOnce(Return(false));
EXPECT_CALL(*m_storage, load(_)).Times(0);
auto certifiedSender =
CertifiedSender::create(m_mockMessageSender, m_connection, m_storage, m_customerDataManager);
ASSERT_EQ(certifiedSender, nullptr);
}

/// Test if the init method fails when load from storage fails.
{
EXPECT_CALL(*m_storage, open()).Times(1).WillOnce(Return(true));
EXPECT_CALL(*m_storage, load(_)).Times(1).WillOnce(Return(false));
auto certifiedSender =
CertifiedSender::create(m_mockMessageSender, m_connection, m_storage, m_customerDataManager);
ASSERT_EQ(certifiedSender, nullptr);
}
}

/**
* Tests if the stored messages get sent when a connection is established.
*/
TEST_F(CertifiedSenderTest, testTimer_storedMessagesGetSent) {
EXPECT_CALL(*m_storage, open()).Times(1).WillOnce(Return(true));

/// Return messages from storage.
EXPECT_CALL(*m_storage, load(_))
.Times(1)
.WillOnce(Invoke([](std::queue<MessageStorageInterface::StoredMessage>* storedMessages) {
storedMessages->push(MessageStorageInterface::StoredMessage(1, "testMessage_1"));
storedMessages->push(MessageStorageInterface::StoredMessage(2, "testMessage_2"));
return true;
}));

avsCommon::utils::PromiseFuturePair<bool> allRequestsSent;
{
InSequence s;

EXPECT_CALL(*m_mockMessageSender, sendMessage(_))
.Times(1)
.WillOnce(Invoke([](std::shared_ptr<avsCommon::avs::MessageRequest> request) {
ASSERT_EQ(request->getJsonContent(), "testMessage_1");
request->sendCompleted(avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status::SUCCESS);
}));
EXPECT_CALL(*m_storage, erase(1)).WillOnce(Return(true));

EXPECT_CALL(*m_mockMessageSender, sendMessage(_))
.Times(1)
.WillOnce(Invoke([](std::shared_ptr<avsCommon::avs::MessageRequest> request) {
ASSERT_EQ(request->getJsonContent(), "testMessage_2");
request->sendCompleted(avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status::SUCCESS);
}));
EXPECT_CALL(*m_storage, erase(2)).WillOnce(Invoke([&allRequestsSent](int messageId) {
allRequestsSent.setValue(true);
return true;
}));
}

auto certifiedSender = CertifiedSender::create(m_mockMessageSender, m_connection, m_storage, m_customerDataManager);

std::static_pointer_cast<avsCommon::sdkInterfaces::ConnectionStatusObserverInterface>(certifiedSender)
->onConnectionStatusChanged(
avsCommon::sdkInterfaces::ConnectionStatusObserverInterface::Status::CONNECTED,
avsCommon::sdkInterfaces::ConnectionStatusObserverInterface::ChangedReason::SUCCESS);

/// wait for requests to get sent out.
EXPECT_TRUE(allRequestsSent.waitFor(TEST_TIMEOUT));

/// Cleanup
certifiedSender->shutdown();
}

/**
* Verify that a message with a URI specified will be sent out by the sender with the URI.
*/
TEST_F(CertifiedSenderTest, testTimer_SendMessageWithURI) {
avsCommon::utils::PromiseFuturePair<std::shared_ptr<avsCommon::avs::MessageRequest>> requestSent;

EXPECT_CALL(*m_mockMessageSender, sendMessage(_))
.WillOnce(Invoke([&requestSent](std::shared_ptr<avsCommon::avs::MessageRequest> request) {
requestSent.setValue(request);
}));
EXPECT_CALL(*m_storage, store(_, TEST_URI, _)).WillOnce(Return(true));

{
InSequence s;
EXPECT_CALL(*m_mockMessageSender, sendMessage(_))
.WillOnce(Invoke([&requestSent](std::shared_ptr<avsCommon::avs::MessageRequest> request) {
requestSent.setValue(request);
request->sendCompleted(avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status::SUCCESS);
}));
EXPECT_CALL(*m_storage, erase(_)).WillOnce(Return(true));
}

std::static_pointer_cast<avsCommon::sdkInterfaces::ConnectionStatusObserverInterface>(m_certifiedSender)
->onConnectionStatusChanged(
avsCommon::sdkInterfaces::ConnectionStatusObserverInterface::Status::CONNECTED,
Expand Down

0 comments on commit 4bb0d23

Please sign in to comment.