16 #ifndef ALEXA_CLIENT_SDK_ADSL_TEST_COMMON_MOCKDIRECTIVEHANDLER_H_ 17 #define ALEXA_CLIENT_SDK_ADSL_TEST_COMMON_MOCKDIRECTIVEHANDLER_H_ 38 std::shared_ptr<avsCommon::avs::AVSDirective> directive,
39 std::unique_ptr<avsCommon::sdkInterfaces::DirectiveHandlerResultInterface> result)
override;
48 std::shared_ptr<avsCommon::avs::AVSDirective> directive,
49 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerResultInterface> result) = 0;
71 static std::shared_ptr<testing::NiceMock<MockDirectiveHandler>> create(
73 std::chrono::milliseconds handlingTimeMs = DEFAULT_HANDLING_TIME_MS);
82 std::chrono::milliseconds handlingTimeMs);
92 void mockHandleDirectiveImmediately(std::shared_ptr<avsCommon::avs::AVSDirective> directive);
100 void mockPreHandleDirective(
101 std::shared_ptr<avsCommon::avs::AVSDirective> directive,
102 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerResultInterface> result);
110 bool mockHandleDirective(
const std::string& messageId);
117 void mockCancelDirective(
const std::string& messageId);
122 void mockOnDeregistered();
130 void doHandleDirective(
const std::string& messageId);
138 void doPreHandlingFailed(
139 std::shared_ptr<avsCommon::avs::AVSDirective> directive,
140 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerResultInterface> result);
145 void doHandlingCompleted();
152 bool doHandlingFailed(
const std::string& messageId);
162 bool waitUntilPreHandling(std::chrono::milliseconds timeout = DEFAULT_DONE_TIMEOUT_MS);
170 bool waitUntilHandling(std::chrono::milliseconds timeout = DEFAULT_DONE_TIMEOUT_MS);
178 bool waitUntilCanceling(std::chrono::milliseconds timeout = DEFAULT_DONE_TIMEOUT_MS);
186 bool waitUntilCompleted(std::chrono::milliseconds timeout = DEFAULT_DONE_TIMEOUT_MS);
192 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerResultInterface>
m_result;
240 std::shared_ptr<avsCommon::avs::AVSDirective>,
241 std::shared_ptr<avsCommon::sdkInterfaces::DirectiveHandlerResultInterface>));
258 #endif // ALEXA_CLIENT_SDK_ADSL_TEST_COMMON_MOCKDIRECTIVEHANDLER_H_ std::chrono::milliseconds m_handlingTimeMs
The amount of time (in milliseconds) handling a directive will take.
Definition: MockDirectiveHandler.h:189
virtual void handleDirectiveImmediately(std::shared_ptr< avsCommon::avs::AVSDirective > directive)=0
Definition: AmdMetricWrapperTest.cpp:24
::std::string string
Definition: gtest-port.h:1097
std::promise< void > m_handlingPromise
Promise fulfilled when handleDirective() begins.
Definition: MockDirectiveHandler.h:219
std::thread m_doHandleDirectiveThread
Thread to perform handleDirective() asynchronously.
Definition: MockDirectiveHandler.h:198
#define MOCK_METHOD2(m,...)
Definition: gmock-generated-function-mockers.h:677
std::mutex m_mutex
Mutex to protect m_isShuttingDown.
Definition: MockDirectiveHandler.h:201
static const std::chrono::milliseconds DEFAULT_DONE_TIMEOUT_MS
Timeout used when waiting for tests to complete (we should not reach this).
Definition: MockDirectiveHandler.h:251
Definition: MockDirectiveHandler.h:35
std::shared_ptr< avsCommon::sdkInterfaces::DirectiveHandlerResultInterface > m_result
Object used to specify the result of handling a directive.
Definition: MockDirectiveHandler.h:192
std::shared_future< void > m_cancelingFuture
Future to notify when cancelDirective() begins.
Definition: MockDirectiveHandler.h:228
std::promise< void > m_preHandlingPromise
Promise fulfilled when preHandleDirective() begins.
Definition: MockDirectiveHandler.h:213
std::condition_variable m_wakeNotifier
condition_variable use to wake doHandlingDirectiveThread.
Definition: MockDirectiveHandler.h:204
std::shared_ptr< avsCommon::avs::AVSDirective > m_directive
The AVSDirective (if any) being handled.
Definition: MockDirectiveHandler.h:195
std::promise< void > m_cancelingPromise
Promise fulfilled when cancelDirective() begins.
Definition: MockDirectiveHandler.h:225
virtual avs::DirectiveHandlerConfiguration getConfiguration() const =0
std::unordered_map< directiveRoutingRule::DirectiveRoutingRule, BlockingPolicy > DirectiveHandlerConfiguration
Definition: DirectiveHandlerConfiguration.h:32
std::future< void > m_handlingFuture
Future to notify when handleDirective() begins.
Definition: MockDirectiveHandler.h:222
bool m_isShuttingDown
Whether or not this handler is shutting down.
Definition: MockDirectiveHandler.h:210
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void preHandleDirective(std::shared_ptr< avsCommon::avs::AVSDirective > directive, std::unique_ptr< avsCommon::sdkInterfaces::DirectiveHandlerResultInterface > result) override
std::future< void > m_completedFuture
Future to notify when a completed result is reported.
Definition: MockDirectiveHandler.h:234
Definition: MockDirectiveHandler.h:62
virtual bool handleDirective(const std::string &messageId)=0
Definition: DirectiveHandlerInterface.h:39
#define MOCK_METHOD0(m,...)
Definition: gmock-generated-function-mockers.h:675
#define MOCK_METHOD1(m,...)
Definition: gmock-generated-function-mockers.h:676
std::future< void > m_preHandlingFuture
Future to notify when preHandleDirective() begins.
Definition: MockDirectiveHandler.h:216
#define MOCK_CONST_METHOD0(m,...)
Definition: gmock-generated-function-mockers.h:687
virtual void onDeregistered()=0
static const std::chrono::milliseconds DEFAULT_HANDLING_TIME_MS
Default amount of time taken to handle a directive (0).
Definition: MockDirectiveHandler.h:248
virtual void cancelDirective(const std::string &messageId)=0
std::promise< void > m_completedPromise
Promise fulfilled when a completed result is reported.
Definition: MockDirectiveHandler.h:231
bool m_isCompleted
Whether or not handling completed.
Definition: MockDirectiveHandler.h:207