summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2021-01-26 14:05:48 -0500
committerjacobkeeler <jacob.keeler@livioradio.com>2021-01-26 14:05:48 -0500
commit9e654e179a355ef0bf7eda549f9c2b022d1d8b36 (patch)
tree895c4b75ef07ceeeaa987a2de0786b290e244dd7
parent61ea4ef6d64308e42dfbb93b61386991f193035b (diff)
downloadsdl_core-fix/protocol_handler_unit_test_segfault.tar.gz
Fix protocol handler unit test crashfix/protocol_handler_unit_test_segfault
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc51
1 files changed, 29 insertions, 22 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 7f70b0cd81..995a96372a 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -4488,8 +4488,8 @@ TEST_F(ProtocolHandlerImplTest, SetHashId_CorrectHashId) {
RawMessagePtr raw_message;
EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_))
- .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter),
- SaveArg<0>(&raw_message),
+ .WillOnce(DoAll(SaveArg<0>(&raw_message),
+ NotifyTestAsyncWaiter(waiter),
Return(transport_manager::E_SUCCESS)));
times++;
@@ -4502,6 +4502,7 @@ TEST_F(ProtocolHandlerImplTest, SetHashId_CorrectHashId) {
full_version);
EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
+ ASSERT_NE(0, raw_message.use_count());
ProtocolPacket protocol_packet;
RESULT_CODE res = protocol_packet.deserializePacket(raw_message->data(),
@@ -4525,8 +4526,8 @@ TEST_F(ProtocolHandlerImplTest, SetHashId_HASH_ID_NOT_SUPPORTED) {
RawMessagePtr raw_message;
EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_))
- .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter),
- SaveArg<0>(&raw_message),
+ .WillOnce(DoAll(SaveArg<0>(&raw_message),
+ NotifyTestAsyncWaiter(waiter),
Return(transport_manager::E_SUCCESS)));
times++;
@@ -4539,6 +4540,7 @@ TEST_F(ProtocolHandlerImplTest, SetHashId_HASH_ID_NOT_SUPPORTED) {
full_version);
EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
+ ASSERT_NE(0, raw_message.use_count());
ProtocolPacket protocol_packet;
RESULT_CODE res = protocol_packet.deserializePacket(raw_message->data(),
@@ -4560,8 +4562,8 @@ TEST_F(ProtocolHandlerImplTest, SetHashId_HASH_ID_WRONG) {
RawMessagePtr raw_message;
EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_))
- .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter),
- SaveArg<0>(&raw_message),
+ .WillOnce(DoAll(SaveArg<0>(&raw_message),
+ NotifyTestAsyncWaiter(waiter),
Return(transport_manager::E_SUCCESS)));
times++;
@@ -4574,6 +4576,7 @@ TEST_F(ProtocolHandlerImplTest, SetHashId_HASH_ID_WRONG) {
full_version);
EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
+ ASSERT_NE(0, raw_message.use_count());
ProtocolPacket protocol_packet;
RESULT_CODE res = protocol_packet.deserializePacket(raw_message->data(),
@@ -4700,8 +4703,8 @@ TEST_F(ProtocolHandlerImplTest,
RawMessagePtr raw_message;
EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_))
- .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter),
- SaveArg<0>(&raw_message),
+ .WillOnce(DoAll(SaveArg<0>(&raw_message),
+ NotifyTestAsyncWaiter(waiter),
Return(transport_manager::E_SUCCESS)));
times++;
@@ -4711,10 +4714,11 @@ TEST_F(ProtocolHandlerImplTest,
kFinalMessage);
handler->Handle(message);
+ EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
+ ASSERT_NE(0, raw_message.use_count());
+
EXPECT_EQ(data_value,
raw_message->data()[protocol_handler::PROTOCOL_HEADER_V2_SIZE]);
-
- EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
}
TEST_F(ProtocolHandlerImplTest,
@@ -4739,8 +4743,8 @@ TEST_F(ProtocolHandlerImplTest,
RawMessagePtr raw_message;
EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_))
- .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter),
- SaveArg<0>(&raw_message),
+ .WillOnce(DoAll(SaveArg<0>(&raw_message),
+ NotifyTestAsyncWaiter(waiter),
Return(transport_manager::E_SUCCESS)));
times++;
@@ -4750,10 +4754,11 @@ TEST_F(ProtocolHandlerImplTest,
kFinalMessage);
handler->Handle(message);
+ EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
+ ASSERT_NE(0, raw_message.use_count());
+
EXPECT_EQ(data_value,
raw_message->data()[protocol_handler::PROTOCOL_HEADER_V2_SIZE]);
-
- EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
}
TEST_F(ProtocolHandlerImplTest,
@@ -4791,8 +4796,8 @@ TEST_F(ProtocolHandlerImplTest,
RawMessagePtr raw_message;
EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_))
- .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter),
- SaveArg<0>(&raw_message),
+ .WillOnce(DoAll(SaveArg<0>(&raw_message),
+ NotifyTestAsyncWaiter(waiter),
Return(transport_manager::E_SUCCESS)));
times++;
@@ -4803,10 +4808,11 @@ TEST_F(ProtocolHandlerImplTest,
message->set_protection_flag(PROTECTION_ON);
handler->Handle(message);
+ EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
+ ASSERT_NE(0, raw_message.use_count());
+
EXPECT_EQ(data_value,
raw_message->data()[protocol_handler::PROTOCOL_HEADER_V2_SIZE]);
-
- EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
}
TEST_F(ProtocolHandlerImplTest,
@@ -4841,8 +4847,8 @@ TEST_F(ProtocolHandlerImplTest,
RawMessagePtr raw_message;
EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_))
- .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter),
- SaveArg<0>(&raw_message),
+ .WillOnce(DoAll(SaveArg<0>(&raw_message),
+ NotifyTestAsyncWaiter(waiter),
Return(transport_manager::E_SUCCESS)));
times++;
@@ -4853,10 +4859,11 @@ TEST_F(ProtocolHandlerImplTest,
message->set_protection_flag(PROTECTION_ON);
handler->Handle(message);
+ EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
+ ASSERT_NE(0, raw_message.use_count());
+
EXPECT_EQ(encrypted_data,
raw_message->data()[protocol_handler::PROTOCOL_HEADER_V2_SIZE]);
-
- EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
}
TEST_F(ProtocolHandlerImplTest, DecryptFrame_NoSecurityManager_Cancelled) {