AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | List of all members
alexaClientSDK::settings::test::MockSettingProtocol Class Reference

#include <MockSettingProtocol.h>

Inheritance diagram for alexaClientSDK::settings::test::MockSettingProtocol:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::settings::test::MockSettingProtocol:
Collaboration graph
[legend]

Public Member Functions

 MockSettingProtocol (const std::string &initialValue, bool applyChange, bool revertChange)
 
bool isDataCleared ()
 
SettingProtocolInterface methods
SetSettingResult localChange (ApplyChangeFunction applyChange, RevertChangeFunction revertChange, SettingNotificationFunction notifyObservers) override
 
bool avsChange (ApplyChangeFunction applyChange, RevertChangeFunction revertChange, SettingNotificationFunction notifyObservers) override
 
bool restoreValue (ApplyDbChangeFunction applyChange, SettingNotificationFunction notifyObservers) override
 
bool clearData () override
 
- Public Member Functions inherited from alexaClientSDK::settings::SettingProtocolInterface
virtual ~SettingProtocolInterface ()=default
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::settings::SettingProtocolInterface
using ApplyChangeFunction = std::function< std::pair< bool, std::string >()>
 
using ApplyDbChangeFunction = std::function< std::pair< bool, std::string >(const std::string &dbValue)>
 
using SettingNotificationFunction = std::function< void(SettingNotifications notification)>
 
using RevertChangeFunction = std::function< std::string()>
 

Detailed Description

Mock class that implements SettingProtocolInterface.

Note
This is not thread safe and it runs the protocol synchronously to keep tests simple.

Constructor & Destructor Documentation

◆ MockSettingProtocol()

alexaClientSDK::settings::test::MockSettingProtocol::MockSettingProtocol ( const std::string &  initialValue,
bool  applyChange,
bool  revertChange 
)

Member Function Documentation

◆ avsChange()

bool alexaClientSDK::settings::test::MockSettingProtocol::avsChange ( ApplyChangeFunction  applyChange,
RevertChangeFunction  revertChange,
SettingNotificationFunction  notifyObservers 
)
overridevirtual

Implements the protocol for changing a setting value triggered by an AVS directive.

Parameters
applyChangeFunction that can be used to apply the new value.
revertChangeFunction that can be used to revert the change. This function should only be called if the apply change succeeded but some other part of the protocol has failed.
notifyObserversFunction used to notify the observers of the protocol result.
Returns
true if the directive was enqueued correctly; false otherwise.

Implements alexaClientSDK::settings::SettingProtocolInterface.

◆ clearData()

bool alexaClientSDK::settings::test::MockSettingProtocol::clearData ( )
overridevirtual

Clear the data for this setting.

Returns
true if it data is cleared; otherwise.

Implements alexaClientSDK::settings::SettingProtocolInterface.

◆ isDataCleared()

bool alexaClientSDK::settings::test::MockSettingProtocol::isDataCleared ( )

Check if clearData() is called or not.

Returns
true if clearData() is called; false otherwise.

◆ localChange()

SetSettingResult alexaClientSDK::settings::test::MockSettingProtocol::localChange ( ApplyChangeFunction  applyChange,
RevertChangeFunction  revertChange,
SettingNotificationFunction  notifyObservers 
)
overridevirtual

Implements the protocol for changing a setting value through local UI.

Parameters
applyChangeFunction that can be used to apply the new value.
revertChangeFunction that can be used to revert the change. This function should only be called if the apply change succeeded but some other part of the protocol has failed.
notifyObserversFunction used to notify the observers of the protocol result.
Returns
Returns what was the set result.

Implements alexaClientSDK::settings::SettingProtocolInterface.

◆ restoreValue()

bool alexaClientSDK::settings::test::MockSettingProtocol::restoreValue ( ApplyDbChangeFunction  applyChange,
SettingNotificationFunction  notifyObservers 
)
overridevirtual

Implements the protocol for restoring a value from the storage.

Parameters
applyChangeFunction that can be used to apply the value restored from the storage. This function will be called with empty string if no value was found in the database.
notifyObserversFunction used to notify the observers of the protocol result.
Returns
true if the directive was enqueued correctly; false otherwise.

Implements alexaClientSDK::settings::SettingProtocolInterface.


The documentation for this class was generated from the following file:

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0