diff options
author | Kozoriz <kozorizandriy@gmail.com> | 2016-03-24 08:43:04 +0200 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-03-31 17:54:33 +0300 |
commit | 49824bec909d34b9dc8b327a5fefaf58afd8a486 (patch) | |
tree | 18c5ad79da2b8f0f0913804ca397ec9dec016595 /src/components | |
parent | e318daf2b631593e21ce4c518c89d4069ac39428 (diff) | |
download | sdl_core-49824bec909d34b9dc8b327a5fefaf58afd8a486.tar.gz |
ProtocolHandler test correctives
Diffstat (limited to 'src/components')
4 files changed, 11 insertions, 139 deletions
diff --git a/src/components/include/test/protocol_handler/mock_protocol_handler.h b/src/components/include/test/protocol_handler/mock_protocol_handler.h index 36dd61baa8..413852f8da 100644 --- a/src/components/include/test/protocol_handler/mock_protocol_handler.h +++ b/src/components/include/test/protocol_handler/mock_protocol_handler.h @@ -36,6 +36,7 @@ #include "protocol_handler/protocol_packet.h" #include "protocol_handler/protocol_handler.h" #include "protocol_handler/protocol_handler_settings.h" +#include "protocol_handler/session_observer.h" namespace test { namespace components { @@ -57,7 +58,9 @@ class MockProtocolHandler : public ::protocol_handler::ProtocolHandler { MOCK_METHOD3(SendEndService, void(int32_t connection_id, uint8_t session_id, uint8_t service_type)); MOCK_CONST_METHOD0(get_settings, - protocol_handler::ProtocolHandlerSettings &()); + const ::protocol_handler::ProtocolHandlerSettings&()); + MOCK_METHOD0(get_session_observer, + protocol_handler::SessionObserver&()); }; } // namespace protocol_handler_test } // namespace components diff --git a/src/components/protocol_handler/test/CMakeLists.txt b/src/components/protocol_handler/test/CMakeLists.txt index 44b609edb9..08640f802a 100644 --- a/src/components/protocol_handler/test/CMakeLists.txt +++ b/src/components/protocol_handler/test/CMakeLists.txt @@ -32,10 +32,12 @@ if(BUILD_TESTS) include_directories( include + ${COMPONENTS_DIR}/resumption/include ${GMOCK_INCLUDE_DIRECTORY} ${COMPONENTS_DIR}/protocol_handler/include ${COMPONENTS_DIR}/protocol_handler/test/include ${COMPONENTS_DIR}/include/protocol + ${JSONCPP_INCLUDE_DIRECTORY} ) set(LIBRARIES diff --git a/src/components/protocol_handler/test/include/protocol_handler/protocol_handler_mock.h b/src/components/protocol_handler/test/include/protocol_handler/protocol_handler_mock.h deleted file mode 100644 index 575e82514a..0000000000 --- a/src/components/protocol_handler/test/include/protocol_handler/protocol_handler_mock.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2014, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef SRC_COMPONENTS_PROTOCOL_HANDLER_TEST_INCLUDE_PROTOCOL_HANDLER_MOCK_H_ -#define SRC_COMPONENTS_PROTOCOL_HANDLER_TEST_INCLUDE_PROTOCOL_HANDLER_MOCK_H_ - -#include <gmock/gmock.h> -#include "transport_manager/transport_manager.h" -#include "protocol_handler/session_observer.h" -#include "protocol_handler/protocol_handler.h" -#include "protocol_handler/protocol_handler_settings.h" - -namespace test { -namespace components { -namespace protocol_handler_test { - -using namespace protocol_handler; -using namespace transport_manager; - -/* - * MOCK implementation of ::protocol_handler::ProtocolObserver interface - */ - -class ProtocolHandlerMock : public protocol_handler::ProtocolHandler { - public: - MOCK_METHOD2(SendMessageToMobileApp, - void(const ::protocol_handler::RawMessagePtr message, - bool final_message)); - MOCK_METHOD1(AddProtocolObserver, - void(::protocol_handler::ProtocolObserver *observer)); - MOCK_METHOD1(RemoveProtocolObserver, - void(::protocol_handler::ProtocolObserver *observer)); - MOCK_METHOD2(SendFramesNumber, - void(uint32_t connection_key, int32_t number_of_frames)); - MOCK_METHOD2(SendHeartBeat, void(int32_t connection_id, uint8_t session_id)); - MOCK_METHOD2(SendEndSession, void(int32_t connection_id, uint8_t session_id)); - MOCK_METHOD3(SendEndService, - void(int32_t connection_id, uint8_t session_id, uint8_t service_type)); - MOCK_CONST_METHOD0(get_settings, - const ::protocol_handler::ProtocolHandlerSettings&()); -}; - -#ifdef ENABLE_SECURITY -/* - * MOCK implementation of security_manager::SecurityManager - */ -class SecurityManagerMock : public security_manager::SecurityManager { - public: - MOCK_METHOD1(AddListener, - void(security_manager::SecurityManagerListener *)); - MOCK_METHOD1(CreateSSLContext, - security_manager::SSLContext*(const uint32_t &)); - MOCK_METHOD1(StartHandshake, - void(uint32_t)); - MOCK_METHOD4(SendInternalError, - void(const uint32_t , - const uint8_t&, - const std::string&, - const uint32_t )); - - MOCK_METHOD1(set_session_observer, - void(::protocol_handler::SessionObserver *)); - MOCK_METHOD1(set_protocol_handler, - void(::protocol_handler::ProtocolHandler *)); - MOCK_METHOD1(set_crypto_manager, - void(::security_manager::CryptoManager *)); - MOCK_METHOD1(RemoveListener, - void(::security_manager::SecurityManagerListener *)); - // protocol_handler::ProtocolObserver part - MOCK_METHOD1(OnMessageReceived, - void(const ::protocol_handler::RawMessagePtr)); - MOCK_METHOD1(OnMobileMessageSent, - void(const ::protocol_handler::RawMessagePtr)); -}; - -class SSLContextMock : public security_manager::SSLContext { - public: - MOCK_CONST_METHOD0(mode, int ()); - MOCK_METHOD2(StartHandshake, - security_manager::SSLContext::HandshakeResult ( - const uint8_t** const, size_t*)); - MOCK_METHOD4(DoHandshakeStep, - security_manager::SSLContext::HandshakeResult ( - const uint8_t* const, size_t, - const uint8_t** const, size_t*)); - MOCK_METHOD4(Encrypt, - bool (const uint8_t* const, size_t, - const uint8_t** const, size_t*)); - MOCK_METHOD4(Decrypt, - bool (const uint8_t* const, size_t, - const uint8_t** const, size_t*)); - MOCK_CONST_METHOD1(get_max_block_size, size_t (size_t)); - MOCK_CONST_METHOD0(IsInitCompleted, bool()); - MOCK_CONST_METHOD0(IsHandshakePending, bool()); - MOCK_CONST_METHOD0(LastError, - std::string()); - MOCK_METHOD0(ResetConnection, - void()); - MOCK_METHOD1(SetHandshakeContext, void (const HandshakeContext& hsh_ctx)); -}; -#endif // ENABLE_SECURITY -} - // namespace test -} // namespace components -} // namespace protocol_handler_test -#endif // SRC_COMPONENTS_PROTOCOL_HANDLER_TEST_INCLUDE_PROTOCOL_HANDLER_MOCK_H_ - diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc index 3f04ea5564..9543f93360 100644 --- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc +++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc @@ -35,12 +35,14 @@ #include "protocol_handler/protocol_handler_impl.h" #include "protocol/common.h" #include "protocol_handler/control_message_matcher.h" -#include "protocol_handler/protocol_handler_mock.h" +#include "protocol_handler/mock_protocol_handler.h" #include "protocol_handler/protocol_observer_mock.h" #include "protocol_handler/mock_protocol_handler_settings.h" #include "protocol_handler/mock_session_observer.h" #include "connection_handler/mock_connection_handler.h" #include "transport_manager/transport_manager_mock.h" +#include "security_manager/mock_security_manager.h" +#include "security_manager/mock_ssl_context.h" #include "utils/make_shared.h" @@ -196,8 +198,8 @@ class ProtocolHandlerImplTest : public ::testing::Test { testing::StrictMock<transport_manager_test::MockTransportManager> transport_manager_mock; testing::StrictMock<protocol_handler_test::MockSessionObserver> session_observer_mock; #ifdef ENABLE_SECURITY - testing::NiceMock<protocol_handler_test::SecurityManagerMock> security_manager_mock; - testing::NiceMock<protocol_handler_test::SSLContextMock> ssl_context_mock; + testing::NiceMock<security_manager_test::MockSecurityManager> security_manager_mock; + testing::NiceMock<security_manager_test::MockSSLContext> ssl_context_mock; #endif // ENABLE_SECURITY }; |