AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
Classes | |
class | CapabilitiesDelegateTest |
class | DiscoveryEventSenderTest |
struct | EventData |
class | MockAuthDelegate |
class | MockCapabilitiesDelegateObserver |
class | MockCapabilitiesDelegateStorage |
class | MockDiscoveryEventSender |
class | MockDiscoveryStatusObserver |
class | PostConnectCapabilitiesPublisherTest |
Functions | |
AVSDiscoveryEndpointAttributes | createEndpointAttributes (const std::string endpointId="TEST_ENDPOINT_ID") |
AVSDiscoveryEndpointAttributes::Registration | createEndpointRegistration (const std::string productID=TEST_PRODUCT_ID, const std::string serialNumber=TEST_SERIAL_NUMBER, const std::string registrationKey=TEST_REGISTRATION_KEY, const std::string productIdKey=TEST_PRODUCT_ID_KEY) |
CapabilityConfiguration | createCapabilityConfiguration (const CapabilityConfiguration::AdditionalConfigurations &additionalConfigurationsIn=CapabilityConfiguration::AdditionalConfigurations()) |
TEST_F (CapabilitiesDelegateTest, test_createMethodWithInvalidParameters) | |
TEST_F (CapabilitiesDelegateTest, test_init) | |
TEST_F (CapabilitiesDelegateTest, test_invalidateCapabilities) | |
TEST_F (CapabilitiesDelegateTest, test_clearData) | |
TEST_F (CapabilitiesDelegateTest, test_shutdown) | |
TEST_F (CapabilitiesDelegateTest, test_addCapabilitiesObserver) | |
TEST_F (CapabilitiesDelegateTest, test_onDiscoveryCompleted) | |
TEST_F (CapabilitiesDelegateTest, test_onDiscoveryCompletedButStorageFails) | |
TEST_F (CapabilitiesDelegateTest, test_onDiscoveryFailure) | |
TEST_F (CapabilitiesDelegateTest, test_addOrUpdateEndpointReturnsFalseWithInvalidInput) | |
TEST_F (CapabilitiesDelegateTest, test_dynamicAddOrUpdateEndpoint) | |
TEST_F (CapabilitiesDelegateTest, test_deleteEndpointReturnsFalseWithInvalidInput) | |
TEST_F (CapabilitiesDelegateTest, test_dynamicDeleteEndpoint) | |
TEST_F (CapabilitiesDelegateTest, test_dynamicDeleteEndpointWhenEndpointNotRegisteredShouldFail) | |
TEST_F (CapabilitiesDelegateTest, test_createPostConnectOperationWithDifferentEndpointConfigs) | |
TEST_F (CapabilitiesDelegateTest, test_createPostConnectOperationWithPendingEndpointsWithSameEndpointConfigs) | |
TEST_F (CapabilitiesDelegateTest, test_createPostConnectOperationWithoutPendingEndpointsAndSameEndpointConfigs) | |
TEST_F (CapabilitiesDelegateTest, test_createPostConnectOperationCachesEndpoints) | |
TEST_F (CapabilitiesDelegateTest, test_createPostConnectOperationWithStaleEndpointAndWithoutPendingEndpointsAndSameEndpointConfigs) | |
TEST_F (CapabilitiesDelegateTest, test_createPostConnectOperationWithStaleEndpoint) | |
TEST_F (CapabilitiesDelegateTest, test_createPostConnectOperationWithStaleEndpointAndPendingEndpointsWithSameEndpointConfigs) | |
TEST_F (CapabilitiesDelegateTest, test_createPostConnectOperationWithNewEndpointAndPendingEndpointsWithSameEndpointConfigs) | |
TEST_F (CapabilitiesDelegateTest, test_createTwoPostConnectOperationWithStaleEndpointAndPendingEndpointsWithSameEndpointConfigs) | |
TEST_F (CapabilitiesDelegateTest, test_createPostConnectOperationWithReconnects) | |
TEST_F (CapabilitiesDelegateTest, test_setDiscoveryEventSenderStopsPreviousDiscoveryEventSender) | |
TEST_F (CapabilitiesDelegateTest, test_onAVSGatewayChangedNotification) | |
TEST_F (CapabilitiesDelegateTest, test_reconnectWhenStorageIsEmpty) | |
TEST_F (CapabilitiesDelegateTest, test_deferSendDiscoveryEventsWhileDiscoveryEventSenderInFlight) | |
TEST_F (CapabilitiesDelegateTest, test_observerCallingIntoCapabilitiesDelegateOnSuccessNotificationSucceeds) | |
TEST_F (CapabilitiesDelegateTest, test_doNotSendEndpointsWhileDisconnected) | |
TEST_F (CapabilitiesDelegateTest, test_reconnectTriggersSendPendingEndpoints) | |
TEST_F (CapabilitiesDelegateTest, test_duplicateEndpointInPendingAddOrUpdateAndDeleteShouldFail) | |
TEST_F (CapabilitiesDelegateTest, test_registration) | |
TEST_F (CapabilitiesDelegateTest, test_addAndUpdateOfDeduplicatedEndpoints) | |
TEST_F (CapabilitiesDelegateTest, test_deduplictedDeletionFailure) | |
TEST_F (CapabilitiesDelegateTest, test_SplitMessagePendingDeduplicatedEndpoints) | |
TEST_F (CapabilitiesDelegateTest, test_endpointLimits) | |
TEST_F (CapabilitiesDelegateTest, test_updateDeduplicatedEndpointWhenInflight) | |
TEST_F (CapabilitiesDelegateTest, test_addDeduplicatedEndpointWhenOtherInflight) | |
bool | parseAuthToken (const std::string &payloadString, EventData *eventData) |
bool | parseEndpointsIds (const std::string &payloadString, EventData *eventData) |
bool | parseEventJson (const std::string &eventJson, EventData *eventData) |
void | validateDiscoveryEvent (const EventData &eventData, const std::string &eventName, const std::vector< std::string > &endpointIds=std::vector< std::string >()) |
TEST_F (DiscoveryEventSenderTest, test_createWithInvalidParams) | |
TEST_F (DiscoveryEventSenderTest, test_sendsDiscoveryEvents) | |
TEST_F (DiscoveryEventSenderTest, test_sendsDiscoveryEventsNotWaitForEventProcessed) | |
TEST_F (DiscoveryEventSenderTest, test_sendDiscoveryEventsFailsWithNullMessageSender) | |
static int | getExpectedNumberOfDiscoveryEventsFromEndpointNum (int numEndpoints) |
static int | getExpectedNumberOfDiscoveryEventFromPayloadSize (int endpointPayloadSize) |
TEST_F (DiscoveryEventSenderTest, test_sendDiscoveryEventsSplitsEventsWithMaxEndpoints) | |
TEST_F (DiscoveryEventSenderTest, test_sendDiscoveryEventsSplitsEventsWhenMaxPayloadSizeIsReached) | |
TEST_F (DiscoveryEventSenderTest, test_deleteReportEventReceives4xxResponse) | |
TEST_F (DiscoveryEventSenderTest, test_sendDiscoveryEventsWhenAuthTokenIsEmpty) | |
TEST_F (DiscoveryEventSenderTest, test_addOrUpdateReportReceives4xxResponse) | |
TEST_F (DiscoveryEventSenderTest, test_retriesWhenAddOrUpdateReportReceives5xxResponse) | |
TEST_F (DiscoveryEventSenderTest, test_addOrUpdateRetriesThenSuccessfulResponse) | |
TEST_F (DiscoveryEventSenderTest, test_deleteReportRetriesThenSuccessfulResponse) | |
TEST_F (DiscoveryEventSenderTest, test_retriesWhenEventProcessedDirectiveIsNotReceived) | |
TEST_F (DiscoveryEventSenderTest, test_retriesWhenInvalidEventProcessedDirectiveIsReceived) | |
TEST_F (DiscoveryEventSenderTest, test_stopWhenWaitingOnEventProcessedDirective) | |
TEST_F (DiscoveryEventSenderTest, test_stopWhenAuthTokenIsRequested) | |
TEST_F (DiscoveryEventSenderTest, test_sendDiscoveryEventsFailsWhenCalledTwice) | |
TEST_F (PostConnectCapabilitiesPublisherTest, test_createWithInvalidParams) | |
TEST_F (PostConnectCapabilitiesPublisherTest, test_getPostConnectOperationPriority) | |
TEST_F (PostConnectCapabilitiesPublisherTest, test_performOperationWithInvalidPostConnectSender) | |
TEST_F (PostConnectCapabilitiesPublisherTest, test_performOperationSendsDiscoveryEvents) | |
TEST_F (PostConnectCapabilitiesPublisherTest, test_performOperationFailsWhenCalledTwice) | |
TEST_F (PostConnectCapabilitiesPublisherTest, test_performOperationFailsWhenSendDiscoveryEventsFails) | |
TEST_F (PostConnectCapabilitiesPublisherTest, test_abortStopsSendDiscoveryEvents) | |
Variables | |
static const std::string | TEST_AUTH_TOKEN = "TEST_AUTH_TOKEN" |
Test string for auth token. More... | |
static const std::string | EVENT_KEY = "event" |
The event key in the discovery event. More... | |
static const std::string | HEADER_KEY = "header" |
The header key in the discovery event. More... | |
static const std::string | EVENT_CORRELATION_TOKEN_KEY = "eventCorrelationToken" |
The eventCorrelationToken key in the discovery event. More... | |
static const std::chrono::seconds | MY_WAIT_TIMEOUT {5} |
static const std::string | TEST_CLIENT_ID = "TEST_CLIENT_ID" |
A Test client Id. More... | |
static const std::string | TEST_PRODUCT_ID = "TEST_PRODUCT_ID" |
A Test product Id. More... | |
static const std::string | TEST_SERIAL_NUMBER = "TEST_SERIAL_NUMBER" |
A Test serial number. More... | |
static const std::string | TEST_REGISTRATION_KEY = "TEST_REGISTRATION_KEY" |
A Test product Id. More... | |
static const std::string | TEST_PRODUCT_ID_KEY = "TEST_PRODUCT_ID_KEY" |
A Test product Id Key. More... | |
static const std::string | TEST_MANUFACTURER_NAME = "TEST_MANUFACTURER_NAME" |
A Test manufacturer name. More... | |
static const std::string | TEST_DESCRIPTION = "TEST_DESCRIPTION" |
A Test description. More... | |
static const std::string | TEST_DISPLAY_CATEGORY = "TEST_DISPLAY_CATEGORY" |
A Test display category. More... | |
static const std::string | DISCOVERY_NAMESPACE = "Alexa.Discovery" |
The Discovery event Namsepace. More... | |
static const std::string | ADD_OR_UPDATE_REPORT_NAME = "AddOrUpdateReport" |
The AddOrUpdateReport Namespace. More... | |
static const std::string | DELETE_REPORT_NAME = "DeleteReport" |
The DeleteReport Namespace. More... | |
static const std::string | DISCOVERY_PAYLOAD_VERSION = "3" |
The payload version of the discovery event. More... | |
static const std::string | ENDPOINTS_KEY = "endpoints" |
The scope key in the discovery event. More... | |
static const std::string | ENDPOINTID_KEY = "endpointId" |
The scope key in the discovery event. More... | |
static const std::string | EVENT_KEY = "event" |
The event key in the discovery event. More... | |
static const std::string | HEADER_KEY = "header" |
The header key in the discovery event. More... | |
static const std::string | NAMESPACE_KEY = "namespace" |
The namespace key in the discovery event. More... | |
static const std::string | NAME_KEY = "name" |
The name key in the discovery event. More... | |
static const std::string | PAYLOAD_VERSION_KEY = "payloadVersion" |
The payload version key in the discovery event. More... | |
static const std::string | EVENT_CORRELATION_TOKEN_KEY = "eventCorrelationToken" |
The eventCorrelationToken key in the discovery event. More... | |
static const std::string | PAYLOAD_KEY = "payload" |
The payload key in the discovery event. More... | |
static const std::string | TEST_AUTH_TOKEN = "TEST_AUTH_TOKEN" |
Test string for auth token. More... | |
static const std::string | TEST_ENDPOINT_ID_1 = "1" |
Test string for endpointID 1. More... | |
static const std::string | TEST_ENDPOINT_ID_2 = "2" |
Test string for endpointId 2. More... | |
static const std::unordered_map< std::string, std::string > | TEST_ADD_OR_UPDATE_ENDPOINTS |
The test endpointId to endpointConfig map AddOrUpdateReport event endpoints. More... | |
static const std::unordered_map< std::string, std::string > | TEST_DELETE_ENDPOINTS |
The test endpointId to endpointConfig map DeleteReport event endpoints. More... | |
static const std::vector< std::string > | EXPECTED_ADD_OR_UPDATE_ENDPOINT_IDS = {TEST_ENDPOINT_ID_1} |
The expected AddOrUpdateReport endpoint Ids. More... | |
static const std::vector< std::string > | EXPECTED_DELETE_ENDPOINT_IDS = {TEST_ENDPOINT_ID_2} |
The expected DeleteReport endpoint Ids. More... | |
static const std::string | TEST_EVENT_CORRELATION_TOKEN = "TEST_EVENT_CORRELATION_TOKEN" |
The test string for eventCorrelationToken sent in headers. More... | |
static constexpr int | TEST_RETRY_COUNT = 2 |
The test retry count. More... | |
static constexpr int | MAX_ENDPOINTS_PER_ADD_OR_UPDATE_REPORT_EVENT = 300 |
Maximum number of endpoints that can be sent in a Discovery.AddOrUpdateReport event. More... | |
static constexpr int | MAX_ENDPOINTS_SIZE_IN_PAYLOAD = 246 * 1024 |
Maximum size of Discovery event (246KB) More... | |
CapabilityConfiguration alexaClientSDK::capabilitiesDelegate::test::createCapabilityConfiguration | ( | const CapabilityConfiguration::AdditionalConfigurations & | additionalConfigurationsIn = CapabilityConfiguration::AdditionalConfigurations() | ) |
Creates a test CapabilityConfiguration
.
CapabilityConfiguration
structure. AVSDiscoveryEndpointAttributes alexaClientSDK::capabilitiesDelegate::test::createEndpointAttributes | ( | const std::string | endpointId = "TEST_ENDPOINT_ID" | ) |
Create a test AVSDiscoveryEndpointAttributes
.
endpointId | Optional endpointId to use in these attributes. Default "TEST_ENDPOINT_ID". |
AVSDiscoveryEndpointAttributes
structure. AVSDiscoveryEndpointAttributes::Registration alexaClientSDK::capabilitiesDelegate::test::createEndpointRegistration | ( | const std::string | productID = TEST_PRODUCT_ID , |
const std::string | serialNumber = TEST_SERIAL_NUMBER , |
||
const std::string | registrationKey = TEST_REGISTRATION_KEY , |
||
const std::string | productIdKey = TEST_PRODUCT_ID_KEY |
||
) |
Create a test AVSDiscoveryEndpointAttributes::Registration
object.
productId | Optional product Id to use in these attributes. |
serialNumber | Optional device serial number to use in these attributes. |
registrationKey | Optional registration key to use in these attributes. |
productIdKey | Optional product Id Key to use in these attributes. |
AVSDiscoveryEndpointAttributes::Registration
structure.
|
inlinestatic |
This method returns the number of Discovery Events the given endpoints will be spit into based on the endpoint payload size.
endpointPayloadSize | The total size of the endpoint payload. |
|
inlinestatic |
This method returns the number of Discovery Events the given endpoints will be split into.
numEndpoints | The total number of endpoints. |
bool alexaClientSDK::capabilitiesDelegate::test::parseAuthToken | ( | const std::string & | payloadString, |
EventData * | eventData | ||
) |
bool alexaClientSDK::capabilitiesDelegate::test::parseEndpointsIds | ( | const std::string & | payloadString, |
EventData * | eventData | ||
) |
bool alexaClientSDK::capabilitiesDelegate::test::parseEventJson | ( | const std::string & | eventJson, |
EventData * | eventData | ||
) |
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | PostConnectCapabilitiesPublisherTest | , |
test_createWithInvalidParams | |||
) |
Test create fails with invalid parameters.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | PostConnectCapabilitiesPublisherTest | , |
test_getPostConnectOperationPriority | |||
) |
Test getPriority method returns expected value.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | PostConnectCapabilitiesPublisherTest | , |
test_performOperationWithInvalidPostConnectSender | |||
) |
Test that performOperation fails if the PostConnectSendMessage is invalid.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | PostConnectCapabilitiesPublisherTest | , |
test_performOperationSendsDiscoveryEvents | |||
) |
Test performOperation sends Discovery events.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | PostConnectCapabilitiesPublisherTest | , |
test_performOperationFailsWhenCalledTwice | |||
) |
Test second call to performOperation fails when executed twice.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | PostConnectCapabilitiesPublisherTest | , |
test_performOperationFailsWhenSendDiscoveryEventsFails | |||
) |
Test when sending Discovery events fails.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | PostConnectCapabilitiesPublisherTest | , |
test_abortStopsSendDiscoveryEvents | |||
) |
Test abortOperation stops DiscoveryEventSender.
Stop is called on destruction as well as abort.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createMethodWithInvalidParameters | |||
) |
Tests the create method with various configurations.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_createWithInvalidParams | |||
) |
Test create fails with invalid parameters
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_init | |||
) |
Tests the init method and if the open(), createDatabase() and load() methods get called on storage.
Test if creteDatabase fails create method return nullptr.
Happy path.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_sendsDiscoveryEvents | |||
) |
Test Happy Path, if AddOrUpdateReport event and DeleteReport event get sent out.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_invalidateCapabilities | |||
) |
Tests if the invalidateCapabilities method triggers a database cleanup.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_clearData | |||
) |
Tests if the clearData method triggers a database cleanup.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_shutdown | |||
) |
Test if the addDiscoveryObserver method gets triggered when the setDiscoveryEventSender method is called. Test if DiscoveryEventSender is stopped when the shutdown method is called. Test if the removeDiscoveryObserver method gets triggered when the shutdown method is called.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_sendsDiscoveryEventsNotWaitForEventProcessed | |||
) |
Test Happy Path, if AddOrUpdateReport event and DeleteReport event get sent out without wait for EventProcessed.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_addCapabilitiesObserver | |||
) |
Tests the addCapabilitiesObserver() method.
Adding null observer doesn't fail.
Add a new observer and it receives notifications of the current capabilities state.
Add existing observer and it does not get any notifications (strict mock would catch any extra notifications)
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_sendDiscoveryEventsFailsWithNullMessageSender | |||
) |
Test sendDiscoveryEvents fails with null message sender.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_onDiscoveryCompleted | |||
) |
Tests for onDiscoveryCompleted() method.
Check if store and erase is triggered and if observer gets notified.
Check removing observer does not send notifications to the observer.
Only store and erase is triggered, observer does not get notified (should fail as we use strict mock for observer).
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_sendDiscoveryEventsSplitsEventsWithMaxEndpoints | |||
) |
Test if multiple discovery events are sent if the number of endpoints is greater than MAX endpoints.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_onDiscoveryCompletedButStorageFails | |||
) |
Check onDiscoveryCompleted() but storage to device fails.
Check if store and erase is triggered and if observer gets notified.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_onDiscoveryFailure | |||
) |
Check notifications when onDiscoveryFailure() method is called.
validate retriable error response
validate invalid auth error response
validate bad request error response
other responses
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_sendDiscoveryEventsSplitsEventsWhenMaxPayloadSizeIsReached | |||
) |
Test if multiple discovery events are sent if the max payload size is reached.
Create a large endpointConfig string (2KB)
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_addOrUpdateEndpointReturnsFalseWithInvalidInput | |||
) |
Tests if addOrUpdateEndpoint returns false for invalid input.
Invalid AVSDiscoveryEndpointAttributes.
Empty Capabilities.
Invalid CapabilityConfiguration.
EndpointAttributes does not have endpointID which is required.
EndpointConfiguration too big
Return false if endpoint is a duplicate in pending list.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_dynamicAddOrUpdateEndpoint | |||
) |
Tests dynamic addOrUpdateEndpoint happy path.
Set-up.
Expect calls to MessageSender.
Expect call to storage.
Expect callback to CapabilitiesObserver.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_deleteReportEventReceives4xxResponse | |||
) |
Test when AddOrUpdateReport response is 202 and DeleteReport response is 4xx.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_sendDiscoveryEventsWhenAuthTokenIsEmpty | |||
) |
Test auth token is empty.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_addOrUpdateReportReceives4xxResponse | |||
) |
Test when AddOrUpdateReport response is 4xx, DeleteReport event is not sent.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_deleteEndpointReturnsFalseWithInvalidInput | |||
) |
Tests if deleteEndpoint returns false for invalid input.
Invalid AVSDiscoveryEndpointAttributes.
Empty Capabilities.
Invalid CapabilityConfiguration.
EndpointAttributes does not have endpointID which is required.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_dynamicDeleteEndpoint | |||
) |
Tests dynamic deleteEndpoint happy path.
Set-up.
Add endpoint (so we can delete it).
Expect calls to MessageSender.
Expect call to storage.
Expect callback to CapabilitiesObserver.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_retriesWhenAddOrUpdateReportReceives5xxResponse | |||
) |
Test when AddOrUpdateReport response is 5xx, there are retries and deleteReport is not sent.
wait until 3 retries and exit.
spin a thread to initiate abort.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_addOrUpdateRetriesThenSuccessfulResponse | |||
) |
Test when AddOrUpdateReport response is 5xx, there are retries. If its successful after two retries, deleteReport event also gets sent out.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_dynamicDeleteEndpointWhenEndpointNotRegisteredShouldFail | |||
) |
Tests dynamic deleteEndpoint should fail if endpoint is unregistered.
Set-up.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createPostConnectOperationWithDifferentEndpointConfigs | |||
) |
Endpoint config is different from the endpoint config created with the test endpoint attributes so a post connect operation is created.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_deleteReportRetriesThenSuccessfulResponse | |||
) |
Test when DeleteReport response is 5xx, there are retries. If its successful after two retries, Discovery is completed.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createPostConnectOperationWithPendingEndpointsWithSameEndpointConfigs | |||
) |
Tests if the createPostConnectOperation() does not create a new PostConnectCapabilitiesPublisher
when registered pending endpoint configurations are same as the ones in storage. Tests if CapabilitiesDelegate reports this as a success to observers as there are pending endpoints.
Endpoint config is same as the endpoint config created with the test endpoint attributes so a post connect operation is not created. However, we do expect an observer callback as there were pending endpoints.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_retriesWhenEventProcessedDirectiveIsNotReceived | |||
) |
Test when EventProcessed directive is not received, the AddOrUpdateReport event is retried and deleteReport event does not get sent.
wait until 3 retries and exit.
spin a thread to initiate abort.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createPostConnectOperationWithoutPendingEndpointsAndSameEndpointConfigs | |||
) |
Tests if the createPostConnectOperation() does not create a new PostConnectCapabilitiesPublisher
when registered pending endpoint configurations are same as the ones in storage. Tests that CapabilitiesDelegate does not notify observers on re-connect, as there were no changes and no pending endpoints expecting to be registered. This ensures observers are not notified unnecessarily during re-connects.
Set-up.
Add the endpoint here before creating the initial post-connect, which forces the endpoint to be cached in CapabilitiesDelegate. Here we do expect an observer callback because there is a pending endpoint. This is test set-up.s
Test.
Create another post-connect operation; this simulates the re-connect. There are no pending endpoints to send in CapabilitiesDelegate, and the cached endpoint in CapabilitiesDelegate matches what is stored in the database, so expect no observer callback as well as a null post connect operation. Strict mocks will catch the observer callback if it happens incorrectly.
Endpoint config is same as the endpoint config created with the test endpoint attributes so a post connect operation is not created.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_retriesWhenInvalidEventProcessedDirectiveIsReceived | |||
) |
Test when EventProcessed directive is received with a wrong event correlation token, the AddOrUpdateReport event is retried and deleteReport event does not get sent.
wait until 3 retries and exit.
spin a thread to initiate abort.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_stopWhenWaitingOnEventProcessedDirective | |||
) |
Test when stop gets called while waiting on the EventProcessed directive.
spin a thread to initiate abort.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createPostConnectOperationCachesEndpoints | |||
) |
Tests if the createPostConnectOperation() caches pending endpoints even when it does not create a new post-connect operation as capabilities have not change.
Returning a stored endpoint here is necessary to force CapabilitiesDelegate to cache the endpoint on the first call to createPostConnectOperation().
This represents an empty database, so that when createPostConnectOperation() is called a second time, we can verify that it creates a non-null post-connect publisher to send the cached endpoint.
Endpoint config is same as the endpoint config created with the test endpoint attributes so a post connect operation is not created, but we add the endpoint here so that it is cached in CapabilitiesDelegate for testing later. Expect an observer callback here, since there is a pending endpoint.
Test. Create another post-connect operation; this simulates a re-connect. We can verify whether the endpoint from the first createPostConnectOperation() was cached.
The database is empty, but because there should be a cached endpoint, we expect a non-null post-connect publisher to send that endpoint to AVS.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_stopWhenAuthTokenIsRequested | |||
) |
Test stop when requesting auth token.
Since the state is uninitialized performOperation() will be waiting in getAuthToken() method.
give a short time
spin a thread to initiate abort.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | DiscoveryEventSenderTest | , |
test_sendDiscoveryEventsFailsWhenCalledTwice | |||
) |
Test second call to sendDiscoveryEvents fails when executed twice.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createPostConnectOperationWithStaleEndpointAndWithoutPendingEndpointsAndSameEndpointConfigs | |||
) |
Tests if the createPostConnectOperation() creates a new PostConnectCapabilitiesPublisher
when registered endpoint configurations are same as the ones in storage, but there is one additional stored endpoint that is not registered (and needs to be deleted). Tests observers are NOT notified of added endpoints since there are no pending endpoints.s Tests if CapabilitiesDelegate returns a non-null post connect operation, since there is a stale endpoint to delete.
Stale endpoint is in the database but not registered.
Endpoint config is same as the endpoint config created with the test endpoint attributes so a post connect operation is not created, but add it here so that it is cached in CapabilitiesDelegate.
Create another post-connect operation; this simulates a re-connect. There is a stale endpoint to be sent, so we expect a non-null post connect publisher. However, there is no pending endpoint to register, so we expect no immediate observer notification.
Endpoint config is same as the endpoint config created with the test endpoint attributes so a post connect operation is not created.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createPostConnectOperationWithStaleEndpoint | |||
) |
Tests if the createPostConnectOperation() creates a new PostConnectCapabilitiesPublisher
when there is an endpoint in storage that is not registered (that is, a stale endpoint in the database). Tests if CapabilitiesDelegate returns a non-null post connect operation, since there is a stale endpoint to delete.
There is a stale endpoint to be deleted, so we expect a non-null post connect publisher.
Endpoint config is same as the endpoint config created with the test endpoint attributes so a post connect operation is not created.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createPostConnectOperationWithStaleEndpointAndPendingEndpointsWithSameEndpointConfigs | |||
) |
Tests if the createPostConnectOperation() creates a new PostConnectCapabilitiesPublisher
when registered endpoint configurations are same as the ones in storage, but there is one additional stored endpoint that is not registered (and needs to be deleted). Tests CapabilitiesObservers are notified of added endpoints even though they were not published in an event. Tests if CapabilitiesDelegate returns a non-null post connect operation, since there is a stale endpoint to delete.
Observer callback should only contain the pending endpoint to add (since that is already registered), but not the stale endpoint to delete (since that still needs to be sent to AVS).
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createPostConnectOperationWithNewEndpointAndPendingEndpointsWithSameEndpointConfigs | |||
) |
Tests if the createPostConnectOperation() creates a new PostConnectCapabilitiesPublisher
when registered endpoint configurations are same as the ones in storage, but there is one additional stored endpoint that is not registered (and needs to be deleted). Tests CapabilitiesObservers are notified of added endpoints even though they were not published in an event. Tests if CapabilitiesDelegate returns a non-null post connect operation, since there is a stale endpoint to delete.
Observer callback should only contain the pending endpoint to add (since that is already registered), but not the stale endpoint to delete (since that still needs to be sent to AVS).
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createTwoPostConnectOperationWithStaleEndpointAndPendingEndpointsWithSameEndpointConfigs | |||
) |
Tests if before the stale endpoint is deleted and the stale endpoint is added, that the first createPostConnectOperation will create a deleteReport for the stale endpoint, but the second createPostConnectOperation will return a nullptr operation because the stale endpoint has been added, and this results in no change in capabilities.
Observer callback should only contain the pending endpoint to add (since that is already registered), but not the stale endpoint to delete (since that still needs to be sent to AVS).
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_createPostConnectOperationWithReconnects | |||
) |
Tests if the createPostConnectOperation() creates a new PostConnectCapabilitiesPublisher
when storage is empty. When the capabilities are successfully published, a subsequent call to createPostConnectOperation() results in a nullptr.
Endpoint config in storage is empty, create a new post connect operation.
Expect the successfully published endpoint configuration to be stored and erase.
Notify that discovery has successfully completed.
Expect call to load endpoint configuration
PostConnectOperation after reconnection
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_setDiscoveryEventSenderStopsPreviousDiscoveryEventSender | |||
) |
Tests if setDiscoveryEventSender always stops the previous DiscoveryEventSender. This is critical because even though an individual DiscoveryEventSender contains exponential backoff and timeout logic to avoid spamming the backend service, if many DiscoveryEventSender objects are created (e.g. in a re-connect loop with many post-connect operations) and any of these are failed to be stopped before creating the next one, there is a real risk of throttling.
This test creates and adds many DiscoveryEventSenders asynchronously. We verify that every DiscoveryEventSender is stopped.
Set up the CapabilitiesDelegate.
Create the mock DiscoveryEventSenders.
The last DES to be added will only have stop() called on it in CapabilitiesDelegate's own shutdown method. Non-mock DiscoveryEventSenders also call stop() on themselves in their own dtor, but that is not the case here as we're using mocks.
Spin up the threads that will all call setDiscoveryEventSender(...).
Wait for the threads.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_onAVSGatewayChangedNotification | |||
) |
Test if the CapabilitiesDelegate calls the clearDatabase() method when the onAVSGatewayChanged() method is called.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_reconnectWhenStorageIsEmpty | |||
) |
Test if post-connect operation will send all registered and pending endpoints if database is empty (eg after onAVSGatewayChanged). Test if pending delete for a registered endpoint will mean that endpoint is not sent in addOrUpdateReport.
Set-up.
Add a test endpoint.
Add another test endpoint.
Add a third test endpoint. Get the capability json to test pending delete.
Expect calls to MessageSender.
Expect calls to storage.
Expect calls to CapabilitiesObserver.
Disconnect to force a pending delete.
Test post-connect with an empty database.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_deferSendDiscoveryEventsWhileDiscoveryEventSenderInFlight | |||
) |
Test if the CapabilitiesDelegate defers dynamically adding or deleting endpoints while there is a Discovery event in-flight.
Set-up.
Add a second test endpoint. Get the capability json for the last endpoint to test pending delete.
Add a DiscoveryEventSender to simulate Discovery event in-flight.
Expect no callback to CapabilitiesObserver, since these endpoints remain in pending.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_observerCallingIntoCapabilitiesDelegateOnSuccessNotificationSucceeds | |||
) |
Tests that CapabilitiesDelegate is in the correct state before notifying its observers.
Set-up.
Add an endpoint.
On the first successful capabilities change, call from observer back into CapabilitiesDelegate.
If the below is false with "endpoint not registered", this means that the CapabilitiesDelegate state is not correct when it notifies its observers.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_doNotSendEndpointsWhileDisconnected | |||
) |
Test if pending endpoints are not sent while disconnected.
Set-up.
Strict mock will catch unexpected calls.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_reconnectTriggersSendPendingEndpoints | |||
) |
Test if pending endpoints are sent on re-connect.
Set-up.
Add a third test endpoint. Get the capability json for the last endpoint to test pending delete.
Expect calls to MessageSender.
Expect calls to storage.
Expect calls to CapabilitiesObserver.
Test.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_duplicateEndpointInPendingAddOrUpdateAndDeleteShouldFail | |||
) |
Test if trying to delete an endpoint that is pending in addOrUpdate (and vice versa) results in failure.
Set-up.
Add an endpoint now so we can test pending delete.
Disconnect to force all endpoints into pending.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_registration | |||
) |
Test endpoint registrations. Confirm that changing the registration of an endpoint results in a failure. Also confirm that adding an endpoint with a different registration results in a failure.
Configure endpointId1 attributes with a non-empty registration.
Try endpointId1 with empty registration.
Configure endpointId2 attributes with a non-empty registration.
Try endpointId2 with non-empty registration.
Try endpointId3 with different and non-empty registration.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_addAndUpdateOfDeduplicatedEndpoints | |||
) |
Test adding 3 endpoints that share registration information (i.e. they are de-duplicated in the cloud). Verify that other endpoints are sent in the discovery message whenever an endpoint is added. Finally, update the first endpoint that was sent and confirm that all endpoints are sent in the discovery message.
Set-up.
endpointId1 is being registered first. The Discovery message should only contain it. Expect calls to MessageSender.
Expect call to storage.
Expect callback to CapabilitiesObserver.
endpointId1 has already been registered. Confirm that it is added when endpointId2 is added. Expect calls to MessageSender.
Expect call to storage.
Expect callback to CapabilitiesObserver.
endpointId1 and endpointId2 have already been registered. Confirm that they are added when endpointId3 is added. Expect calls to MessageSender.
Expect call to storage.
Expect callback to CapabilitiesObserver.
Update the configuration
endpointId1, endpointId2 and endpointId3 have already been registered. Confirm that they are added when endpointId1 is updated. Expect calls to MessageSender.
Expect call to storage.
Expect callback to CapabilitiesObserver.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_deduplictedDeletionFailure | |||
) |
Test that deleting a de-duplicated endpoint fails.
endpointId1 is being registered first. The Discovery message should only contain it. Expect calls to MessageSender.
Expect call to storage.
Expect callback to CapabilitiesObserver.
Deleting endpoint 1 should fail.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_SplitMessagePendingDeduplicatedEndpoints | |||
) |
Test adding two pairs of 3 endpoints that share registration information (i.e. they are de-duplicated in the cloud). For this test, endpointid3 and endpointId6 have large configurations, preventing them from being sent in the same message. Verify that the endpoints are split into two messages, each containing 3 endpoints.
Set-up the first set of deduplicated endpoints.
Set-up the second set of endpoints.
Create a large capability configuration for endpoint3 and endpoint6.
Create a default capability configuration for the other endpoints.
Upon connect, expect two messages to be sent. One with endpoints 1,2 and 3, and the other with endpoints 4, 5 and 6. Expect calls to MessageSender.
Expect call to storage.
Expect callback to CapabilitiesObserver.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_endpointLimits | |||
) |
Test limits of the Alexa.Discovery interface. Specifically test :
Add a deduplicated endpoint with more than MAX_CAPABILITIES_PER_ENDPOINT capabilities.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_updateDeduplicatedEndpointWhenInflight | |||
) |
Test updating a deduplicated endpoint when it is in flight.
Set-up.
Add a DiscoveryEventSender to simulate Discovery event in-flight.
Create an updated capability configuration for the update to endpoint1.
Expect no callback to CapabilitiesObserver, since the update remains in pending.
endpointId1 is inflight. Should be able to add it again to the pending update set.
alexaClientSDK::capabilitiesDelegate::test::TEST_F | ( | CapabilitiesDelegateTest | , |
test_addDeduplicatedEndpointWhenOtherInflight | |||
) |
Test adding a deduplicated endpoint when another one is in flight. Verify that the first endpoint is also sent in the discovery message when the second endpoint is added.
Set-up.
Add a DiscoveryEventSender to simulate Discovery event in-flight.
Expect no callback to CapabilitiesObserver, since the add of endpoint2 remains in pending.
Endpoint1 is in flight. Confirm that Endpoint2 is added to the pending endpoints.
void alexaClientSDK::capabilitiesDelegate::test::validateDiscoveryEvent | ( | const EventData & | eventData, |
const std::string & | eventName, | ||
const std::vector< std::string > & | endpointIds = std::vector<std::string>() |
||
) |
Validates if the event data structure contains expected discovery event fields.
eventData | The EventData containing the parsed discovery fields |
eventName | The name of the discovery event to validate against. |
endpointIds | The optional endpointIds list to be validated against the payload. |
|
static |
The AddOrUpdateReport Namespace.
|
static |
The DeleteReport Namespace.
|
static |
The Discovery event Namsepace.
|
static |
The payload version of the discovery event.
|
static |
The scope key in the discovery event.
|
static |
The scope key in the discovery event.
|
static |
The eventCorrelationToken key in the discovery event.
|
static |
The eventCorrelationToken key in the discovery event.
|
static |
The event key in the discovery event.
|
static |
The event key in the discovery event.
|
static |
The expected AddOrUpdateReport endpoint Ids.
|
static |
The expected DeleteReport endpoint Ids.
|
static |
The header key in the discovery event.
|
static |
The header key in the discovery event.
|
static |
Maximum number of endpoints that can be sent in a Discovery.AddOrUpdateReport event.
|
static |
Maximum size of Discovery event (246KB)
|
static |
Constant representing the timeout for test events.
|
static |
The name key in the discovery event.
|
static |
The namespace key in the discovery event.
|
static |
The payload key in the discovery event.
|
static |
The payload version key in the discovery event.
|
static |
The test endpointId to endpointConfig map AddOrUpdateReport event endpoints.
|
static |
Test string for auth token.
|
static |
Test string for auth token.
|
static |
A Test client Id.
|
static |
The test endpointId to endpointConfig map DeleteReport event endpoints.
|
static |
A Test description.
|
static |
A Test display category.
|
static |
Test string for endpointID 1.
|
static |
Test string for endpointId 2.
|
static |
The test string for eventCorrelationToken sent in headers.
|
static |
A Test manufacturer name.
|
static |
A Test product Id.
|
static |
A Test product Id Key.
|
static |
A Test product Id.
|
static |
The test retry count.
|
static |
A Test serial number.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0