avs-device-sdk/RegistrationManager/test/CustomerDataManagerTest.cpp

80 lines
2.4 KiB
C++
Raw Normal View History

Verison 1.6 of the avs-device-sdk Changes in this update: **Enhancements** * `rapidJson` is now included with "make install". * Updated the `TemplateRuntimeObserverInterface` to support clearing of `displayCards`. * Added Windows SDK support, along with an installation script (MinGW-w64). * Updated `ContextManager` to ignore context reported by a state provider. * The `SharedDataStream` object is now associated by playlist, rather than by URL. * Added the `RegistrationManager` component. Now, when a user logs out all persistent user-specific data is cleared from the SDK. The log out functionality can be exercised in the sample app with the new command: `k`. **Bug Fixes** * [Issue 400](https://github.com/alexa/avs-device-sdk/issues/400) Fixed a bug where the alert reminder did not iterate as intended after loss of network connection. * [Issue 477](https://github.com/alexa/avs-device-sdk/issues/477) Fixed a bug in which Alexa's weather response was being truncated. * Fixed an issue in which there were reports of instability related to the Sensory engine. To correct this, the `portAudio` [`suggestedLatency`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L62) value can now be configured. **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. * Music playback doesn't immediately stop when a user barges-in on iHeartRadio. * The Windows sample app sometimes hangs on exit. * GDP receives a `SIGPIPE` when troubleshooting the Windows sample app.
2018-03-09 00:55:39 +00:00
/*
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* 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 <gmock/gmock.h>
#include <gtest/gtest.h>
#include <memory>
#include "RegistrationManager/CustomerDataHandler.h"
#include "RegistrationManager/CustomerDataManager.h"
namespace alexaClientSDK {
namespace registrationManager {
namespace test {
class MockCustomerDataHandler : public CustomerDataHandler {
public:
MockCustomerDataHandler(std::shared_ptr<CustomerDataManager> dataManager) : CustomerDataHandler(dataManager) {
}
MOCK_METHOD0(clearData, void());
};
class CustomerDataManagerTest : public ::testing::Test {
protected:
void SetUp() override {
m_dataManager = std::make_shared<CustomerDataManager>();
}
void TearDown() override {
m_dataManager.reset();
}
std::shared_ptr<CustomerDataManager> m_dataManager;
};
TEST_F(CustomerDataManagerTest, testEmptyManager) {
m_dataManager->clearData();
}
/**
* Test that all data handlers are cleared.
*/
TEST_F(CustomerDataManagerTest, testClearData) {
MockCustomerDataHandler handler1{m_dataManager};
MockCustomerDataHandler handler2{m_dataManager};
EXPECT_CALL(handler1, clearData()).Times(1);
EXPECT_CALL(handler2, clearData()).Times(1);
m_dataManager->clearData();
}
/**
* Test that removing a data handler does not leave any dangling reference inside @c CustomerDataManager.
*/
TEST_F(CustomerDataManagerTest, testClearDataAfterHandlerDeletion) {
{
// CustomerDataHandler will register and deregister with CustomerDataManager during ctor and dtor, respectively.
MockCustomerDataHandler handler1{m_dataManager};
EXPECT_CALL(handler1, clearData()).Times(0);
}
MockCustomerDataHandler handler2{m_dataManager};
EXPECT_CALL(handler2, clearData()).Times(1);
m_dataManager->clearData();
}
} // namespace test
} // namespace registrationManager
} // namespace alexaClientSDK