summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAKalinich-Luxoft <AKalinich@luxoft.com>2017-10-03 12:18:01 +0300
committerValerii <vmalkov@luxoft.com>2018-01-26 15:17:35 +0200
commit4bd0d237bf5ff7ec53d5e4ee65175ad8cb2c066a (patch)
tree52d0c60db193adf24419cbf9a278d6c47889eb6b
parentb2589108906e79dc82a9a3f21d55a277c4a976a2 (diff)
downloadsdl_core-4bd0d237bf5ff7ec53d5e4ee65175ad8cb2c066a.tar.gz
Fix all affected UTs related to notifications sending
Also fixed some unstable tests
-rw-r--r--src/components/application_manager/test/commands/command_request_impl_test.cc8
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc8
-rw-r--r--src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc20
-rw-r--r--src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc13
-rw-r--r--src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc15
-rw-r--r--src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc5
-rw-r--r--src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc8
-rw-r--r--src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc5
-rw-r--r--src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc9
-rw-r--r--src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc4
10 files changed, 78 insertions, 17 deletions
diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc
index 4493c54d3c..5ebb030e84 100644
--- a/src/components/application_manager/test/commands/command_request_impl_test.cc
+++ b/src/components/application_manager/test/commands/command_request_impl_test.cc
@@ -383,8 +383,14 @@ TEST_F(CommandRequestImplTest,
EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
.WillOnce(Return(mobile_apis::Result::INVALID_ENUM));
+ smart_objects::SmartObjectSPtr response =
+ utils::MakeShared<smart_objects::SmartObject>(
+ smart_objects::SmartType_Map);
+ (*response)[strings::msg_params] =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+
EXPECT_CALL(mock_message_helper_, CreateBlockedByPoliciesResponse(_, _, _, _))
- .WillOnce(Return(smart_objects::SmartObjectSPtr()));
+ .WillOnce(Return(response));
EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _));
EXPECT_FALSE(command->CheckPermissions());
diff --git a/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc
index 6d7ccb1fa0..9e864c7757 100644
--- a/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_hash_change_notification_test.cc
@@ -69,11 +69,15 @@ TEST_F(OnHashChangeNotificationTest, Run_ValidApp_SUCCESS) {
std::string return_string = "1234";
MockAppPtr mock_app = CreateMockApp();
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .Times(2)
+ .WillRepeatedly(Return(mock_app));
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
EXPECT_CALL(*mock_app, curHash()).WillOnce(ReturnRef(return_string));
EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
.WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).WillOnce(SaveArg<0>(&msg));
command->Run();
diff --git a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
index 9cb5610621..678ce52edb 100644
--- a/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_hmi_status_notification_test.cc
@@ -70,7 +70,10 @@ class OnHMIStatusNotificationTest
void SetSendNotificationExpectations(MessageSharedPtr& msg) {
EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
.WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _))
+ .WillOnce(SaveArg<0>(&msg));
}
void VerifySendNotificationData(MessageSharedPtr& msg) {
@@ -110,7 +113,8 @@ TEST_F(OnHMIStatusNotificationTest, Run_InvalidEnum_SUCCESS) {
MockAppPtr mock_app = CreateMockApp();
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .Times(2)
+ .WillRepeatedly(Return(mock_app));
SetSendNotificationExpectations(msg);
@@ -128,7 +132,8 @@ TEST_F(OnHMIStatusNotificationTest, Run_BackgroundAndFalseProperties_SUCCESS) {
MockAppPtr mock_app = CreateMockApp();
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .Times(2)
+ .WillRepeatedly(Return(mock_app));
EXPECT_CALL(*mock_app, tts_properties_in_none()).WillOnce(Return(false));
EXPECT_CALL(*mock_app, set_tts_properties_in_none(true));
@@ -147,7 +152,8 @@ TEST_F(OnHMIStatusNotificationTest, Run_BackgroundAndTrueProperties_SUCCESS) {
MockAppPtr mock_app = CreateMockApp();
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .Times(2)
+ .WillRepeatedly(Return(mock_app));
EXPECT_CALL(*mock_app, tts_properties_in_none()).WillOnce(Return(true));
@@ -166,7 +172,8 @@ TEST_F(OnHMIStatusNotificationTest, Run_FullAndFalseProperties_SUCCESS) {
MockAppPtr mock_app = CreateMockApp();
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .Times(2)
+ .WillRepeatedly(Return(mock_app));
EXPECT_CALL(*mock_app, tts_properties_in_full()).WillOnce(Return(false));
EXPECT_CALL(*mock_app, set_tts_properties_in_full(true));
@@ -188,7 +195,8 @@ TEST_F(OnHMIStatusNotificationTest, Run_FullAndTrueProperties_SUCCESS) {
MockAppPtr mock_app = CreateMockApp();
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .Times(2)
+ .WillRepeatedly(Return(mock_app));
EXPECT_CALL(*mock_app, tts_properties_in_full()).WillOnce(Return(true));
diff --git a/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc
index 7313f32dca..eb62405cd7 100644
--- a/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_keyboard_input_notification_test.cc
@@ -61,10 +61,13 @@ using testing::_;
class OnKeyBoardInputNotificationTest
: public CommandsTest<CommandsTestMocks::kIsNice> {
public:
- void SetSendNotificationExpectations(MessageSharedPtr msg) {
+ void SetSendNotificationExpectations(MessageSharedPtr& msg) {
EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
.WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _))
+ .WillOnce(SaveArg<0>(&msg));
}
void SetSendNotificationVariables(MessageSharedPtr msg) {
@@ -100,8 +103,9 @@ TEST_F(OnKeyBoardInputNotificationTest, Run_ActionActive_SUCCESS) {
EXPECT_CALL(*mock_app, perform_interaction_layout())
.WillOnce(Return(mobile_apis::LayoutMode::KEYBOARD));
EXPECT_CALL(*mock_app, hmi_level()).Times(0);
-
EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
SetSendNotificationExpectations(msg);
@@ -128,6 +132,9 @@ TEST_F(OnKeyBoardInputNotificationTest, Run_ActionNotActive_SUCCESS) {
EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey));
+ EXPECT_CALL(app_mngr_, application(kConnectionKey))
+ .WillOnce(Return(mock_app));
+
SetSendNotificationExpectations(msg);
command->Run();
diff --git a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc
index 7840e35cec..c63da5e552 100644
--- a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc
@@ -78,7 +78,10 @@ TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) {
MockAppPtr mock_app = CreateMockApp();
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .Times(2)
+ .WillRepeatedly(Return(mock_app));
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
MockPolicyHandlerInterface mock_policy_handler;
EXPECT_CALL(app_mngr_, GetPolicyHandler())
.WillRepeatedly(ReturnRef(mock_policy_handler));
@@ -96,7 +99,7 @@ TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) {
EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
.WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).WillOnce(SaveArg<0>(&msg));
command->Run();
@@ -122,7 +125,11 @@ TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) {
MockAppPtr mock_app = CreateMockApp();
EXPECT_CALL(app_mngr_, application(kConnectionKey))
- .WillOnce(Return(mock_app));
+ .Times(2)
+ .WillRepeatedly(Return(mock_app));
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
MockPolicyHandlerInterface mock_policy_handler;
EXPECT_CALL(app_mngr_, GetPolicyHandler())
.WillOnce(ReturnRef(mock_policy_handler));
@@ -133,7 +140,7 @@ TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) {
EXPECT_CALL(mock_message_helper_, PrintSmartObject(_))
.WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, SendMessageToMobile(msg, _));
+ EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).WillOnce(SaveArg<0>(&msg));
command->Run();
diff --git a/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc
index 59cddc325f..8ea52141bd 100644
--- a/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_tbt_client_state_notification_test.cc
@@ -123,6 +123,11 @@ TEST_F(OnTBTClientStateNotificationTest,
EXPECT_CALL(app_mngr_, applications_with_navi())
.WillOnce(Return(applications_with_navi));
+ EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
+
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
EXPECT_CALL(*mock_app, hmi_level())
.WillOnce(Return(mobile_apis::HMILevel::HMI_FULL));
diff --git a/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
index c90991fdf7..698a2246ec 100644
--- a/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_touch_event_notification_test.cc
@@ -133,6 +133,14 @@ TEST_F(OnTouchEventNotificationTest, Run_NotEmptyListOfAppsWithNavi_SUCCESS) {
EXPECT_CALL(app_mngr_, applications_with_mobile_projection())
.WillOnce(Return(applications_with_mobile_projection));
+ EXPECT_CALL(app_mngr_, application(kAppId))
+ .Times(2)
+ .WillRepeatedly(Return(mock_app));
+
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
+ .Times(2)
+ .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
+
EXPECT_CALL(*mock_app, IsFullscreen()).WillRepeatedly(Return(true));
EXPECT_CALL(*mock_app, app_id()).WillRepeatedly(Return(kAppId));
diff --git a/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc
index 05d97856e4..bb506628c5 100644
--- a/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_vehicle_data_notification_test.cc
@@ -130,6 +130,11 @@ TEST_F(OnVehicleDataNotificationTest,
IviInfoUpdated(mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL,
kFuelLevel)).WillOnce(Return(applications));
+ EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
+
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
EXPECT_CALL(*mock_app, app_id()).WillRepeatedly(Return(kAppId));
::utils::custom_string::CustomString dummy_name("test_app");
ON_CALL(*mock_app, name()).WillByDefault(ReturnRef(dummy_name));
diff --git a/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc
index b0dd3c142c..47e629296a 100644
--- a/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc
+++ b/src/components/application_manager/test/commands/mobile/on_way_point_change_notification_test.cc
@@ -101,6 +101,15 @@ TEST_F(OnWayPointChangeNotificationTest,
std::set<int32_t> apps_subscribed_for_way_points;
apps_subscribed_for_way_points.insert(kAppId);
+ MockAppPtr mock_app(CreateMockApp());
+
+ EXPECT_CALL(app_mngr_, application(kAppId)).WillOnce(Return(mock_app));
+
+ EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _))
+ .WillOnce(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(*mock_app, app_id()).WillRepeatedly(Return(kAppId));
+
EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints())
.WillOnce(Return(apps_subscribed_for_way_points));
diff --git a/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc b/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
index cf668c8b36..b174d4f450 100644
--- a/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
+++ b/src/components/application_manager/test/commands/mobile/set_media_clock_timer_test.cc
@@ -319,7 +319,9 @@ TEST_F(SetMediaClockRequestTest, OnEvent_Success) {
hmi_apis::Common_Result::SUCCESS;
(*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Null);
- EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _));
+ EXPECT_CALL(
+ app_mngr_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _));
MockAppPtr app(CreateMockApp());
EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app));