diff options
Diffstat (limited to 'src/components/protocol_handler/test/protocol_handler_tm_test.cc')
-rw-r--r-- | src/components/protocol_handler/test/protocol_handler_tm_test.cc | 63 |
1 files changed, 46 insertions, 17 deletions
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 e1149fefb2..07b562f3a2 100644 --- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc +++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc @@ -39,6 +39,7 @@ #include "protocol_handler/mock_protocol_handler.h" #include "protocol_handler/mock_protocol_handler_settings.h" #include "protocol_handler/mock_protocol_observer.h" +#include "protocol_handler/mock_service_status_update_handler_listener.h" #include "protocol_handler/mock_session_observer.h" #include "protocol_handler/protocol_handler.h" #include "protocol_handler/protocol_handler_impl.h" @@ -108,6 +109,7 @@ using protocol_handler::PROTOCOL_VERSION_MAX; using protocol_handler::ProtocolHandlerImpl; using protocol_handler::RawMessage; using protocol_handler::RawMessagePtr; +using protocol_handler::ServiceStatusUpdateHandler; using protocol_handler::ServiceType; // For TM states using test::components::security_manager_test::MockSystemTimeHandler; @@ -139,6 +141,9 @@ using ::testing::SetArgPointee; using ::testing::SetArgReferee; typedef std::vector<uint8_t> UCharDataVector; +typedef std::shared_ptr< + testing::NiceMock<MockServiceStatusUpdateHandlerListener> > + MockServiceStatusUpdateHandlerListenerPtr; // custom action to call a member function with 6 arguments ACTION_P4(InvokeMemberFuncWithArg2, ptr, memberFunc, a, b) { @@ -186,10 +191,17 @@ class ProtocolHandlerImplTest : public ::testing::Test { session_observer_mock, connection_handler_mock, transport_manager_mock)); + std::unique_ptr<ServiceStatusUpdateHandler> service_status_update_handler_( + new ServiceStatusUpdateHandler( + &(*mock_service_status_update_handler_listener_))); + protocol_handler_impl->set_service_status_update_handler( + std::move(service_status_update_handler_)); tm_listener = protocol_handler_impl.get(); } void SetUp() OVERRIDE { + mock_service_status_update_handler_listener_ = std::make_shared< + testing::NiceMock<MockServiceStatusUpdateHandlerListener> >(); InitProtocolHandlerImpl(0u, 0u); connection_id = 0xAu; session_id = 0xFFu; @@ -214,9 +226,11 @@ class ProtocolHandlerImplTest : public ::testing::Test { void TearDown() OVERRIDE { const_cast<protocol_handler::impl::FromMobileQueue&>( - protocol_handler_impl->get_from_mobile_queue()).WaitDumpQueue(); + protocol_handler_impl->get_from_mobile_queue()) + .WaitDumpQueue(); const_cast<protocol_handler::impl::ToMobileQueue&>( - protocol_handler_impl->get_to_mobile_queue()).WaitDumpQueue(); + protocol_handler_impl->get_to_mobile_queue()) + .WaitDumpQueue(); } // Emulate connection establish @@ -388,6 +402,8 @@ class ProtocolHandlerImplTest : public ::testing::Test { testing::NiceMock<MockProtocolHandlerSettings> protocol_handler_settings_mock; std::shared_ptr<ProtocolHandlerImpl> protocol_handler_impl; + MockServiceStatusUpdateHandlerListenerPtr + mock_service_status_update_handler_listener_; TransportManagerListener* tm_listener; // Uniq connection ::transport_manager::ConnectionUID connection_id; @@ -730,13 +746,12 @@ TEST_F(ProtocolHandlerImplTest, const uint8_t session_id1 = 1u; const ::transport_manager::ConnectionUID connection_id2 = 0xBu; const uint8_t session_id2 = 2u; + EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id2, session_id2)) + .WillRepeatedly(Return(connection_key)); #ifdef ENABLE_SECURITY AddSecurityManager(); - EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id2, session_id2)) - .WillOnce(Return(connection_key)); - EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, start_service)) .Times(2) @@ -1414,7 +1429,7 @@ TEST_F(ProtocolHandlerImplTest, services.push_back(0x0A); services.push_back(0x0B); EXPECT_CALL(protocol_handler_settings_mock, force_protected_service()) - .WillOnce(ReturnRefOfCopy(services)); + .WillRepeatedly(ReturnRefOfCopy(services)); // call new SSLContext creation EXPECT_CALL(security_manager_mock, CreateSSLContext(connection_key, _)) @@ -3638,7 +3653,8 @@ TEST_F(ProtocolHandlerImplTest, SendMessageToDevice(ExpectedMessage(FRAME_TYPE_CONTROL, FRAME_DATA_HEART_BEAT_ACK, PROTECTION_OFF, - kControl))).Times(0); + kControl))) + .Times(0); // Act SendControlMessage( PROTECTION_OFF, kControl, session_id, FRAME_DATA_HEART_BEAT); @@ -3659,8 +3675,12 @@ TEST_F(ProtocolHandlerImplTest, const bool is_final = true; const uint32_t total_data_size = 1; UCharDataVector data(total_data_size); - RawMessagePtr message = std::make_shared<RawMessage>( - connection_key, PROTOCOL_VERSION_3, &data[0], total_data_size, kControl); + RawMessagePtr message = std::make_shared<RawMessage>(connection_key, + PROTOCOL_VERSION_3, + &data[0], + total_data_size, + false, + kControl); // Expect getting pair from key from session observer EXPECT_CALL(session_observer_mock, PairFromKey(message->connection_key(), _, _)) @@ -3681,7 +3701,7 @@ TEST_F(ProtocolHandlerImplTest, times++; // Act - protocol_handler_impl->SendMessageToMobileApp(message, is_final); + protocol_handler_impl->SendMessageToMobileApp(message, false, is_final); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } @@ -3697,8 +3717,12 @@ TEST_F(ProtocolHandlerImplTest, const bool is_final = true; const uint32_t total_data_size = 1; UCharDataVector data(total_data_size); - RawMessagePtr message = std::make_shared<RawMessage>( - connection_key, PROTOCOL_VERSION_3, &data[0], total_data_size, kRpc); + RawMessagePtr message = std::make_shared<RawMessage>(connection_key, + PROTOCOL_VERSION_3, + &data[0], + total_data_size, + false, + kRpc); // Expect getting pair from key from session observer EXPECT_CALL(session_observer_mock, PairFromKey(message->connection_key(), _, _)) @@ -3724,7 +3748,7 @@ TEST_F(ProtocolHandlerImplTest, times++; // Act - protocol_handler_impl->SendMessageToMobileApp(message, is_final); + protocol_handler_impl->SendMessageToMobileApp(message, false, is_final); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } @@ -3740,8 +3764,12 @@ TEST_F(ProtocolHandlerImplTest, SendMessageToMobileApp_SendMultiframeMessage) { const uint32_t total_data_size = MAXIMUM_FRAME_DATA_V2_SIZE * 2; UCharDataVector data(total_data_size); const uint8_t first_consecutive_frame = 0x01; - RawMessagePtr message = std::make_shared<RawMessage>( - connection_key, PROTOCOL_VERSION_3, &data[0], total_data_size, kBulk); + RawMessagePtr message = std::make_shared<RawMessage>(connection_key, + PROTOCOL_VERSION_3, + &data[0], + total_data_size, + false, + kBulk); // Expect getting pair from key from session observer EXPECT_CALL(session_observer_mock, PairFromKey(message->connection_key(), _, _)) @@ -3779,7 +3807,7 @@ TEST_F(ProtocolHandlerImplTest, SendMessageToMobileApp_SendMultiframeMessage) { times++; // Act - protocol_handler_impl->SendMessageToMobileApp(message, is_final); + protocol_handler_impl->SendMessageToMobileApp(message, false, is_final); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } @@ -3828,7 +3856,8 @@ TEST_F(ProtocolHandlerImplTest, SendServiceDataAck_AfterVersion5) { SendMessageToDevice(ExpectedMessage(FRAME_TYPE_CONTROL, FRAME_DATA_SERVICE_DATA_ACK, PROTECTION_OFF, - kMobileNav))).Times(0); + kMobileNav))) + .Times(0); protocol_handler_impl->SendFramesNumber(connection_key, 0); |