16 #ifndef ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_MESSAGEROUTERTEST_H_ 17 #define ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_MESSAGEROUTERTEST_H_ 40 using namespace transport;
41 using namespace transport::test;
42 using namespace avsCommon::avs::attachment;
43 using namespace avsCommon::utils::threading;
44 using namespace avsCommon::utils::memory;
46 using namespace avsCommon::utils;
47 using namespace avsCommon::utils::observer::test;
54 std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> authDelegate,
55 std::shared_ptr<AttachmentManagerInterface> attachmentManager,
56 std::shared_ptr<TransportFactoryInterface> factory,
64 SHORT_SERVER_SIDE_DISCONNECT_GRACE_PERIOD) {
74 auto future = m_executor.submit([]() { ; });
75 auto status = future.wait_for(millisecondsToWait);
76 return status == std::future_status::ready;
80 return !m_executor.isShutdown();
93 m_mockTransport = transport;
97 std::shared_ptr<TransportInterface> createTransport(
98 std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> authDelegate,
99 std::shared_ptr<AttachmentManagerInterface> attachmentManager,
101 std::shared_ptr<MessageConsumerInterface> messageConsumerInterface,
102 std::shared_ptr<TransportObserverInterface> transportObserverInterface,
103 std::shared_ptr<SynchronizedMessageRequestQueue> sharedMessageRequestQueue)
override {
104 return m_mockTransport;
107 std::shared_ptr<MockTransport> m_mockTransport;
115 m_mockMessageRouterObserver{std::make_shared<MockMessageRouterObserver>()},
116 m_mockAuthDelegate{std::make_shared<MockAuthDelegate>()},
117 m_attachmentManager{std::make_shared<AttachmentManager>(AttachmentManager::AttachmentType::IN_PROCESS)},
118 m_mockTransport{std::make_shared<NiceMock<MockTransport>>()},
119 m_transportFactory{std::make_shared<MockTransportFactory>(m_mockTransport)},
120 m_router{std::make_shared<TestableMessageRouter>(
125 m_router->setObserver(m_mockMessageRouterObserver);
129 if (m_router->isExecutorActive()) {
136 return std::make_shared<avsCommon::avs::MessageRequest>(MESSAGE);
140 return std::make_shared<TestMessageRequestObserver>();
144 auto status = m_router->isExecutorReady(millisecondsToWait);
154 setupStateToPending();
155 m_router->onConnected(m_mockTransport);
184 #endif // ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_MESSAGEROUTERTEST_H_ Definition: gmock-actions.h:53
std::shared_ptr< TestMessageRequestObserver > createObserver()
Definition: MessageRouterTest.h:139
std::shared_ptr< MockMessageRouterObserver > m_mockMessageRouterObserver
Definition: MessageRouterTest.h:165
std::shared_ptr< TestableMessageRouter > m_router
Definition: MessageRouterTest.h:170
std::shared_ptr< avsCommon::avs::MessageRequest > createMessageRequest()
Definition: MessageRouterTest.h:135
Definition: AmdMetricWrapperTest.cpp:24
::std::string string
Definition: gtest-port.h:1097
std::shared_ptr< MockAuthDelegate > m_mockAuthDelegate
Definition: MessageRouterTest.h:166
static const int MESSAGE_LENGTH
Definition: MessageRouterTest.h:161
Definition: AlexaEventProcessedObserverInterface.h:23
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
std::shared_ptr< NiceMock< MockTransport > > m_mockTransport
Definition: MessageRouterTest.h:168
bool isExecutorReady(std::chrono::milliseconds millisecondsToWait)
Definition: MessageRouterTest.h:73
void TearDown()
Definition: MessageRouterTest.h:128
void setMockTransport(std::shared_ptr< MockTransport > transport)
Definition: MessageRouterTest.h:92
void setupStateToConnected()
Definition: MessageRouterTest.h:153
static const std::chrono::milliseconds SHORT_TIMEOUT_MS
Definition: MessageRouterTest.h:162
static const std::string MESSAGE
Definition: MessageRouterTest.h:160
void connectMockTransport(MockTransport *transport)
Definition: MockTransport.h:68
void setupStateToPending()
Definition: MessageRouterTest.h:148
Definition: TransportFactoryInterface.h:36
Definition: MessageRouter.h:47
void waitOnMessageRouter(std::chrono::milliseconds millisecondsToWait)
Definition: MessageRouterTest.h:143
Definition: MessageRouterTest.h:51
void initializeMockTransport(MockTransport *transport)
Definition: MockTransport.h:60
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
MockTransportFactory(std::shared_ptr< MockTransport > transport)
Definition: MessageRouterTest.h:89
Definition: MessageRouterTest.h:87
Definition: MessageRouterTest.h:110
std::shared_ptr< MockTransportFactory > m_transportFactory
Definition: MessageRouterTest.h:169
static const std::string CONTEXT_ID
Definition: MessageRouterTest.h:163
static const std::chrono::milliseconds SHORT_TIMEOUT_MS
Timeout to sleep before asking for provideState().
Definition: AudioActivityTrackerTest.cpp:80
bool isExecutorActive()
Definition: MessageRouterTest.h:79
std::shared_ptr< AttachmentManagerInterface > m_attachmentManager
Definition: MessageRouterTest.h:167
TestableMessageRouter(std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > authDelegate, std::shared_ptr< AttachmentManagerInterface > attachmentManager, std::shared_ptr< TransportFactoryInterface > factory, const std::string &avsGateway)
Definition: MessageRouterTest.h:53
MessageRouterTest()
Definition: MessageRouterTest.h:114
static const std::chrono::milliseconds SHORT_SERVER_SIDE_DISCONNECT_GRACE_PERIOD
Short amount of time to allow for an automatic reconnect before notifying of a server side disconnect...
Definition: MessageRouterTest.h:84
static const int ENGINE_TYPE_ALEXA_VOICE_SERVICES
Definition: ConnectionStatusObserverInterface.h:26