AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MockTransport.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_MOCKTRANSPORT_H_
17 #define ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_MOCKTRANSPORT_H_
18 
20 
22 
23 #include <gmock/gmock.h>
24 
25 #include <memory>
26 
27 namespace alexaClientSDK {
28 namespace acl {
29 namespace transport {
30 namespace test {
31 
33 
35 public:
36  MockTransport() : m_id{sNewId++} {};
37 
38  MOCK_METHOD0(doShutdown, void());
39  MOCK_METHOD0(connect, bool());
40  MOCK_METHOD0(disconnect, void());
41  MOCK_METHOD0(isConnected, bool());
42  MOCK_METHOD0(isPendingDisconnected, bool());
46  MOCK_METHOD1(sendMessage, void(std::shared_ptr<avsCommon::avs::MessageRequest>));
47  MOCK_METHOD2(onAttachmentReceived, void(const std::string& contextId, const std::string& message));
48 
49  const int m_id;
50 
51 private:
52  static int sNewId;
53 };
54 
55 int MockTransport::sNewId = 0;
56 
61  ON_CALL(*transport, connect()).WillByDefault(Return(true));
62  ON_CALL(*transport, isConnected()).WillByDefault(Return(false));
63 }
64 
69  initializeMockTransport(transport);
70  ON_CALL(*transport, isConnected()).WillByDefault(Return(true));
71 }
72 
77  ON_CALL(*transport, isConnected()).WillByDefault(Return(false));
78 }
79 
80 } // namespace test
81 } // namespace transport
82 } // namespace acl
83 } // namespace alexaClientSDK
84 
85 #endif // ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_MOCKTRANSPORT_H_
Definition: AmdMetricWrapperTest.cpp:24
::std::string string
Definition: gtest-port.h:1097
#define ON_CALL(obj, call)
Definition: gmock-spec-builders.h:1841
MOCK_METHOD2(onAttachmentReceived, void(const std::string &contextId, const std::string &message))
void disconnectMockTransport(MockTransport *transport)
Definition: MockTransport.h:76
MOCK_METHOD1(sendMessage, void(std::shared_ptr< avsCommon::avs::MessageRequest >))
void connectMockTransport(MockTransport *transport)
Definition: MockTransport.h:68
void initializeMockTransport(MockTransport *transport)
Definition: MockTransport.h:60
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
internal::ReturnAction< R > Return(R value)
Definition: gmock-actions.h:1061
MockTransport()
Definition: MockTransport.h:36
tuple message
Definition: gtest_output_test.py:331
const int m_id
Definition: MockTransport.h:49
Definition: TransportInterface.h:31

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