diff options
Diffstat (limited to 'src/components/application_manager/test/application_manager_impl_test.cc')
-rw-r--r-- | src/components/application_manager/test/application_manager_impl_test.cc | 82 |
1 files changed, 60 insertions, 22 deletions
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index aa82c6b86b..b5fba2cc54 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -59,6 +59,7 @@ #include "protocol/bson_object_keys.h" #include "protocol_handler/mock_protocol_handler.h" #include "protocol_handler/mock_session_observer.h" +#include "resumption/last_state_wrapper_impl.h" #include "resumption/mock_last_state.h" #include "utils/custom_string.h" #include "utils/file_system.h" @@ -153,9 +154,12 @@ class ApplicationManagerImplTest std::make_shared<NiceMock<resumption_test::MockResumptionData> >( mock_app_mngr_)) , mock_rpc_service_(new MockRPCService) + , mock_last_state_(std::make_shared<resumption_test::MockLastState>()) , mock_policy_handler_(new NiceMock<MockPolicyHandlerInterface>) - , mock_app_service_manager_( - new MockAppServiceManager(mock_app_mngr_, mock_last_state_)) + , mock_app_service_manager_(new MockAppServiceManager( + mock_app_mngr_, + std::make_shared<resumption::LastStateWrapperImpl>( + mock_last_state_))) , mock_message_helper_( application_manager::MockMessageHelper::message_helper_mock()) , mock_statistics_manager_( @@ -207,7 +211,7 @@ class ApplicationManagerImplTest .WillByDefault(Return()); app_manager_impl_->SetAppServiceManager(mock_app_service_manager_); Json::Value empty; - ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty)); + ON_CALL(*mock_last_state_, dictionary()).WillByDefault(Return(empty)); auto request = std::make_shared<smart_objects::SmartObject>( smart_objects::SmartType_Map); @@ -313,7 +317,7 @@ class ApplicationManagerImplTest MockStateController mock_state_ctrl_; MockRPCService* mock_rpc_service_; - resumption_test::MockLastState mock_last_state_; + std::shared_ptr<resumption_test::MockLastState> mock_last_state_; NiceMock<con_test::MockConnectionHandler> mock_connection_handler_; NiceMock<protocol_handler_test::MockSessionObserver> mock_session_observer_; NiceMock<MockApplicationManagerSettings> mock_application_manager_settings_; @@ -531,10 +535,16 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_VideoServiceStart) { const protocol_handler::ServiceType service_type = protocol_handler::ServiceType::kMobileNav; const int32_t session_key = 123; + HmiStatePtr hmi_state(std::make_shared<HmiState>( + mock_app_ptr_, mock_app_mngr_, HmiState::STATE_ID_REGULAR)); + hmi_state->set_video_streaming_state( + mobile_apis::VideoStreamingState::eType::STREAMABLE); + hmi_state->set_hmi_level(mobile_apis::HMILevel::HMI_FULL); + + EXPECT_CALL(*mock_app_ptr_, CurrentHmiState(_)) + .WillRepeatedly(Return(hmi_state)); EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) - .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; std::vector<std::string> rejected_params; @@ -595,8 +605,14 @@ TEST_F(ApplicationManagerImplTest, EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); // HMI level is not FULL nor LIMITED - EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) - .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_BACKGROUND)); + HmiStatePtr hmi_state(std::make_shared<HmiState>( + mock_app_ptr_, mock_app_mngr_, HmiState::STATE_ID_REGULAR)); + hmi_state->set_video_streaming_state( + mobile_apis::VideoStreamingState::eType::STREAMABLE); + hmi_state->set_hmi_level(mobile_apis::HMILevel::HMI_BACKGROUND); + + EXPECT_CALL(*mock_app_ptr_, CurrentHmiState(_)) + .WillRepeatedly(Return(hmi_state)); bool result = false; std::vector<std::string> rejected_params; @@ -625,8 +641,14 @@ TEST_F(ApplicationManagerImplTest, const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) - .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED)); + HmiStatePtr hmi_state(std::make_shared<HmiState>( + mock_app_ptr_, mock_app_mngr_, HmiState::STATE_ID_REGULAR)); + hmi_state->set_video_streaming_state( + mobile_apis::VideoStreamingState::eType::STREAMABLE); + hmi_state->set_hmi_level(mobile_apis::HMILevel::HMI_LIMITED); + + EXPECT_CALL(*mock_app_ptr_, CurrentHmiState(_)) + .WillRepeatedly(Return(hmi_state)); bool result = false; std::vector<std::string> rejected_params; @@ -709,8 +731,13 @@ TEST_F(ApplicationManagerImplTest, const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) - .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); + HmiStatePtr hmi_state(std::make_shared<HmiState>( + mock_app_ptr_, mock_app_mngr_, HmiState::STATE_ID_REGULAR)); + hmi_state->set_video_streaming_state( + mobile_apis::VideoStreamingState::eType::STREAMABLE); + hmi_state->set_hmi_level(mobile_apis::HMILevel::HMI_FULL); + EXPECT_CALL(*mock_app_ptr_, CurrentHmiState(_)) + .WillRepeatedly(Return(hmi_state)); bool result = false; std::vector<std::string> rejected_params; @@ -783,8 +810,13 @@ TEST_F(ApplicationManagerImplTest, const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) - .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); + HmiStatePtr hmi_state(std::make_shared<HmiState>( + mock_app_ptr_, mock_app_mngr_, HmiState::STATE_ID_REGULAR)); + hmi_state->set_video_streaming_state( + mobile_apis::VideoStreamingState::eType::STREAMABLE); + hmi_state->set_hmi_level(mobile_apis::HMILevel::HMI_FULL); + EXPECT_CALL(*mock_app_ptr_, CurrentHmiState(_)) + .WillRepeatedly(Return(hmi_state)); bool result = false; std::vector<std::string> rejected_params; @@ -818,8 +850,13 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_AudioServiceStart) { const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) - .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); + HmiStatePtr hmi_state(std::make_shared<HmiState>( + mock_app_ptr_, mock_app_mngr_, HmiState::STATE_ID_REGULAR)); + hmi_state->set_video_streaming_state( + mobile_apis::VideoStreamingState::eType::STREAMABLE); + hmi_state->set_hmi_level(mobile_apis::HMILevel::HMI_FULL); + EXPECT_CALL(*mock_app_ptr_, CurrentHmiState(_)) + .WillRepeatedly(Return(hmi_state)); bool result = false; std::vector<std::string> rejected_params; @@ -848,8 +885,13 @@ TEST_F(ApplicationManagerImplTest, const int32_t session_key = 123; EXPECT_CALL(*mock_app_ptr_, app_id()).WillRepeatedly(Return(session_key)); EXPECT_CALL(*mock_app_ptr_, is_navi()).WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) - .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); + HmiStatePtr hmi_state(std::make_shared<HmiState>( + mock_app_ptr_, mock_app_mngr_, HmiState::STATE_ID_REGULAR)); + hmi_state->set_video_streaming_state( + mobile_apis::VideoStreamingState::eType::STREAMABLE); + hmi_state->set_hmi_level(mobile_apis::HMILevel::HMI_FULL); + EXPECT_CALL(*mock_app_ptr_, CurrentHmiState(_)) + .WillRepeatedly(Return(hmi_state)); bool result = false; std::vector<std::string> rejected_params; @@ -1016,8 +1058,6 @@ TEST_F(ApplicationManagerImplTest, nonswitching_device_id, "USB"); - EXPECT_CALL(*mock_message_helper_, CreateDeviceListSO(_, _, _)) - .WillOnce(Return(smart_objects::SmartObjectSPtr())); app_manager_impl_->OnDeviceSwitchingStart(switching_device, non_switching_device); EXPECT_TRUE( @@ -1087,8 +1127,6 @@ TEST_F(ApplicationManagerImplTest, nonswitching_device_id, "USB"); - EXPECT_CALL(*mock_message_helper_, CreateDeviceListSO(_, _, _)) - .WillOnce(Return(smart_objects::SmartObjectSPtr())); app_manager_impl_->OnDeviceSwitchingStart(switching_device, non_switching_device); |