diff options
author | Vladislav Antonov <vlantonov@luxoft.com> | 2016-06-14 14:00:40 +0300 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-06-23 12:09:52 +0300 |
commit | 9d23bb8ede22799c03c6af359410f6d5344ff3a1 (patch) | |
tree | 1cb3ff4da13c85e4501ace00bd0bf5d92f9655a7 | |
parent | 11944fd80ff1b6437e8552bb71c62c0c23edc606 (diff) | |
download | sdl_core-9d23bb8ede22799c03c6af359410f6d5344ff3a1.tar.gz |
Add Unit tests for ResumptionDataJson class
Added Unit test for Init method of
ResumptionDataJson class.
Covered lines of Suspend method in Unit test.
Removed IsResumptionDataValid method of ResumptionDataJson class
4 files changed, 9 insertions, 33 deletions
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h index b521fe4fc8..d872e5a614 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h @@ -219,13 +219,6 @@ class ResumptionDataJson : public ResumptionData { */ void SetLastIgnOffTime(time_t ign_off_time); - /* - * @brief Return true if application resumption data is valid, - * otherwise false - * @param index application index in the resumption list - */ - bool IsResumptionDataValid(uint32_t index) const; - LastState& last_state_; DISALLOW_COPY_AND_ASSIGN(ResumptionDataJson); }; diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index 8e6282fc50..d148f856a6 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -191,7 +191,7 @@ smart_objects::SmartObject ResumptionData::GetApplicationFiles( int i = 0; for (AppFilesMap::const_iterator file_it = app_files.begin(); file_it != app_files.end(); - file_it++) { + ++file_it) { const AppFile& file = file_it->second; if (file.is_persistent) { smart_objects::SmartObject file_data = diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index bb2faa412c..cd0289486e 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -442,31 +442,6 @@ ssize_t ResumptionDataJson::GetObjectIndex(const std::string& policy_app_id, return -1; } -bool ResumptionDataJson::IsResumptionDataValid(uint32_t index) const { - using namespace app_mngr; - using namespace utils::json; - SDL_AUTO_TRACE(); - sync_primitives::AutoLock autolock(resumption_lock_); - const JsonValueRef json_app = GetSavedApplications()[index]; - if (!json_app.HasMember(strings::app_id) || - !json_app.HasMember(strings::ign_off_count) || - !json_app.HasMember(strings::hmi_level) || - !json_app.HasMember(strings::hmi_app_id) || - !json_app.HasMember(strings::time_stamp) || - !json_app.HasMember(strings::device_id)) { - SDL_ERROR("Wrong resumption data"); - return false; - } - - if (json_app.HasMember(strings::hmi_app_id) && - 0 >= json_app[strings::hmi_app_id].AsUInt()) { - SDL_ERROR("Wrong resumption hmi app ID"); - return false; - } - - return true; -} - void ResumptionDataJson::SetSavedApplication( utils::json::JsonValueRef apps_json) { SDL_AUTO_TRACE(); diff --git a/src/components/application_manager/test/resumption/resumption_data_json_test.cc b/src/components/application_manager/test/resumption/resumption_data_json_test.cc index 2bbb146bed..3ff870a904 100644 --- a/src/components/application_manager/test/resumption/resumption_data_json_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_json_test.cc @@ -224,6 +224,10 @@ TEST_F(ResumptionDataJsonTest, UpdateHmiLevel) { CheckSavedJson(); } +TEST_F(ResumptionDataJsonTest, Init) { + EXPECT_TRUE(res_json.Init()); +} + TEST_F(ResumptionDataJsonTest, IsHMIApplicationIdExist_AppIsSaved) { PrepareData(); res_json.SaveApplication(app_mock); @@ -283,6 +287,10 @@ TEST_F(ResumptionDataJsonTest, OnSuspendFourTimes) { EXPECT_TRUE(-1 != res_json.IsApplicationSaved(policy_app_id_, kMacAddress_)); } +TEST_F(ResumptionDataJsonTest, Persist) { + res_json.Persist(); +} + TEST_F(ResumptionDataJsonTest, OnSuspendOnAwake) { PrepareData(); SetZeroIgnOff(); |