From 08acb77b6b5a43116a0008905aeaf960fd2e09f5 Mon Sep 17 00:00:00 2001 From: Frank Ronneburg Date: Thu, 5 Jul 2018 05:33:49 +0900 Subject: Merge pull request #295 in NAR/sdl-core from bugfix/remove_non_const_data_accessor to feature/Ford-WiFi * commit '5aee98d0ad298440aca8fd7da5a9725b595aa775': Update unit tests to align with new Connection Handler methods updated some comments Remove usage of NonConstDataAccessor in ConnectionHandler Conflicts: src/components/connection_handler/src/connection_handler_impl.cc src/components/connection_handler/test/connection_test.cc src/components/connection_handler/test/heart_beat_monitor_test.cc src/components/protocol_handler/test/protocol_handler_tm_test.cc --- .../connection_handler/test/connection_test.cc | 51 +++++++--------------- 1 file changed, 16 insertions(+), 35 deletions(-) (limited to 'src/components/connection_handler/test/connection_test.cc') diff --git a/src/components/connection_handler/test/connection_test.cc b/src/components/connection_handler/test/connection_test.cc index e3c513f5ac..98b83f5fc4 100644 --- a/src/components/connection_handler/test/connection_test.cc +++ b/src/components/connection_handler/test/connection_test.cc @@ -442,7 +442,7 @@ TEST_F(ConnectionTest, RemoveSession) { EXPECT_EQ(0u, connection_->RemoveSession(session_id)); } -TEST_F(ConnectionTest, AddNewSession_VerifySessionConnectionMapAdded) { +TEST_F(ConnectionTest, AddNewSession_VerifyAddSessionCalled) { MockConnectionHandler mock_connection_handler; ConnectionHandle connection_handle = 123; @@ -451,29 +451,20 @@ TEST_F(ConnectionTest, AddNewSession_VerifySessionConnectionMapAdded) { Connection* connection = new Connection( connection_handle, device_handle, &mock_connection_handler, heart_beat); - SessionConnectionMap session_connection_map; - std::shared_ptr session_connection_map_lock_ptr = - std::make_shared(); - EXPECT_CALL(mock_connection_handler, session_connection_map()) - .WillRepeatedly(Return(NonConstDataAccessor( - session_connection_map, session_connection_map_lock_ptr))); - transport_manager::ConnectionUID connection_handle_uid = 1; - uint32_t sid = connection->AddNewSession(connection_handle_uid); - EXPECT_NE(0u, sid); + uint32_t mock_session_id = 2; + EXPECT_CALL(mock_connection_handler, AddSession(connection_handle_uid)) + .WillOnce(Return(mock_session_id)); - // verify that SessionConnectionMap is updated - SessionConnectionMap::iterator it = session_connection_map.find(sid); - EXPECT_TRUE(session_connection_map.end() != it); - - SessionTransports st = it->second; - EXPECT_EQ(connection_handle_uid, st.primary_transport); - EXPECT_EQ(0u, st.secondary_transport); + uint32_t sid = connection->AddNewSession(connection_handle_uid); + EXPECT_EQ(mock_session_id, sid); + EXPECT_CALL(mock_connection_handler, RemoveSession(mock_session_id)) + .WillOnce(Return(true)); // invoked by destructor of connection delete connection; } -TEST_F(ConnectionTest, RemoveSession_VerifySessionConnectionMapRemoved) { +TEST_F(ConnectionTest, RemoveSession_VerifyRemoveSessionCalled) { MockConnectionHandler mock_connection_handler; ConnectionHandle connection_handle = 123; @@ -482,29 +473,19 @@ TEST_F(ConnectionTest, RemoveSession_VerifySessionConnectionMapRemoved) { Connection* connection = new Connection( connection_handle, device_handle, &mock_connection_handler, heart_beat); - SessionConnectionMap session_connection_map; - std::shared_ptr session_connection_map_lock_ptr = - std::make_shared(); - // input some dummy data - SessionTransports st1 = {1234, 0}; - SessionTransports st2 = {2345, 0}; - session_connection_map[0x12] = st1; - session_connection_map[0x23] = st2; - - EXPECT_CALL(mock_connection_handler, session_connection_map()) - .WillRepeatedly(Return(NonConstDataAccessor( - session_connection_map, session_connection_map_lock_ptr))); - transport_manager::ConnectionUID connection_handle_uid = 1; + uint32_t mock_session_id = 10; + EXPECT_CALL(mock_connection_handler, AddSession(connection_handle_uid)) + .WillOnce(Return(mock_session_id)); + EXPECT_CALL(mock_connection_handler, + RemoveSession(static_cast(mock_session_id))) + .WillOnce(Return(true)); + uint32_t sid = connection->AddNewSession(connection_handle_uid); uint32_t ret = connection->RemoveSession(sid); EXPECT_EQ(sid, ret); - // verify that SessionConnectionMap is updated - SessionConnectionMap::iterator it = session_connection_map.find(sid); - EXPECT_TRUE(session_connection_map.end() == it); - delete connection; } -- cgit v1.2.1