summaryrefslogtreecommitdiff
path: root/src/components/connection_handler/test/connection_test.cc
diff options
context:
space:
mode:
authorFrank Ronneburg <fronneburg@xevo.com>2018-07-05 05:33:49 +0900
committerfronneburg <fronneburg@xevo.com>2018-07-04 13:51:58 -0700
commit08acb77b6b5a43116a0008905aeaf960fd2e09f5 (patch)
tree1a71e3384f97eda2e15870722f45e749ffd88a5d /src/components/connection_handler/test/connection_test.cc
parent558bbe28dac48af20aef7ae350d290aaf8dd0d1f (diff)
downloadsdl_core-08acb77b6b5a43116a0008905aeaf960fd2e09f5.tar.gz
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
Diffstat (limited to 'src/components/connection_handler/test/connection_test.cc')
-rw-r--r--src/components/connection_handler/test/connection_test.cc51
1 files changed, 16 insertions, 35 deletions
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<sync_primitives::Lock> session_connection_map_lock_ptr =
- std::make_shared<sync_primitives::Lock>();
- EXPECT_CALL(mock_connection_handler, session_connection_map())
- .WillRepeatedly(Return(NonConstDataAccessor<SessionConnectionMap>(
- 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<sync_primitives::Lock> session_connection_map_lock_ptr =
- std::make_shared<sync_primitives::Lock>();
- // 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<SessionConnectionMap>(
- 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<uint8_t>(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;
}