diff options
author | JackLivio <jack@livio.io> | 2019-03-13 13:07:49 -0400 |
---|---|---|
committer | JackLivio <jack@livio.io> | 2019-03-13 13:07:49 -0400 |
commit | 1c32db10769c284450346b5e2de829bb437bff7e (patch) | |
tree | bd5b028edeeeec097fd922fa867f31101f348f87 /src/components/transport_manager/test/transport_manager_impl_test.cc | |
parent | 121f62b0ca53bcf6fdcb6ffb561261524b412ed2 (diff) | |
download | sdl_core-1c32db10769c284450346b5e2de829bb437bff7e.tar.gz |
Cloud app disconnect tests + fix
Diffstat (limited to 'src/components/transport_manager/test/transport_manager_impl_test.cc')
-rw-r--r-- | src/components/transport_manager/test/transport_manager_impl_test.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/components/transport_manager/test/transport_manager_impl_test.cc b/src/components/transport_manager/test/transport_manager_impl_test.cc index 5f13adcd44..dbf0899a1b 100644 --- a/src/components/transport_manager/test/transport_manager_impl_test.cc +++ b/src/components/transport_manager/test/transport_manager_impl_test.cc @@ -190,6 +190,24 @@ class TransportManagerImplTest : public ::testing::Test { tm_.TestHandle(test_event); } + void HandlePending() { + TransportAdapterEvent test_event(EventTypeEnum::ON_CONNECT_PENDING, + mock_adapter_, + dev_info_.mac_address(), + application_id_, + test_message_, + error_); + + EXPECT_CALL(*mock_adapter_, DeviceName(dev_info_.mac_address())) + .WillOnce(Return(dev_info_.name())); + EXPECT_CALL(*mock_adapter_, GetConnectionType()) + .WillRepeatedly(Return(dev_info_.connection_type())); + + EXPECT_CALL(*tm_listener_, OnConnectionPending(dev_info_, connection_key_)); + + tm_.TestHandle(test_event); + } + void HandleConnectionFailed() { TransportAdapterEvent test_event(EventTypeEnum::ON_CONNECT_FAIL, mock_adapter_, @@ -405,6 +423,32 @@ TEST_F(TransportManagerImplTest, DisconnectDevice_DeviceNotConnected) { EXPECT_EQ(E_INVALID_HANDLE, tm_.DisconnectDevice(device_handle_)); } +TEST_F(TransportManagerImplTest, Pending) { + // Calling HandlePending twice verifies the connection_id stays the same if + // the connection exists. + HandlePending(); + HandlePending(); + + // Now create pending event for new app id and verify connection_id is + // incremented + TransportAdapterEvent test_event(EventTypeEnum::ON_CONNECT_PENDING, + mock_adapter_, + dev_info_.mac_address(), + application_id_ + 1, + test_message_, + error_); + + EXPECT_CALL(*mock_adapter_, DeviceName(dev_info_.mac_address())) + .WillOnce(Return(dev_info_.name())); + EXPECT_CALL(*mock_adapter_, GetConnectionType()) + .WillRepeatedly(Return(dev_info_.connection_type())); + + EXPECT_CALL(*tm_listener_, + OnConnectionPending(dev_info_, connection_key_ + 1)); + + tm_.TestHandle(test_event); +} + TEST_F(TransportManagerImplTest, Disconnect) { // Arrange HandleConnection(); |