summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAKalinich-Luxoft <AKalinich@luxoft.com>2017-06-09 09:33:10 +0300
committerAKalinich-Luxoft <AKalinich@luxoft.com>2017-12-12 14:09:24 +0200
commit6153f79de2c362dd51c3e945294b74cd9f965ac5 (patch)
treeb3095b8abd593ce7055bfd25ac672e87f993ad9e
parent9e95f67178c575ca5a537f9ef3a69653219b073d (diff)
downloadsdl_core-6153f79de2c362dd51c3e945294b74cd9f965ac5.tar.gz
Renamed OnSuspend->IncrementIgnOffCount and OnAwake->DecrementIgnOffCount
This functions of ResumptionData class was renamed according to their exact logic. Also renamed in mock class and in unit tests.
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data.h13
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data_db.h14
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data_json.h4
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_db.cc4
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_json.cc6
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_resumption_data.h4
-rw-r--r--src/components/application_manager/test/resumption/resume_ctrl_test.cc6
-rw-r--r--src/components/application_manager/test/resumption/resumption_data_db_test.cc26
-rw-r--r--src/components/application_manager/test/resumption/resumption_data_json_test.cc26
9 files changed, 51 insertions, 52 deletions
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h
index aeb65b32b9..f7c12687f4 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h
@@ -91,7 +91,12 @@ class ResumptionData {
* @brief Increments ignition counter for all registered applications
* and remember ign_off time stamp
*/
- virtual void OnSuspend() = 0;
+ virtual void IncrementIgnOffCount() = 0;
+
+ /**
+ * @brief Decrements ignition counter for all registered applications
+ */
+ virtual void DecrementIgnOffCount() = 0;
/**
* @brief Retrieves hash ID for the given mobile app ID
@@ -108,12 +113,6 @@ class ResumptionData {
std::string& hash_id) const = 0;
/**
- * @brief Increments ignition counter for all registered applications
- * and remember ign_off time stamp
- */
- virtual void OnAwake() = 0;
-
- /**
* @brief Retrieves data of saved application for the given mobile app ID
* and device ID
* @param policy_app_id - mobile application id
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h
index 862816bf87..658a9066d2 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h
@@ -113,7 +113,13 @@ class ResumptionDataDB : public ResumptionData {
* @brief Increments ignition counter for all registered applications
* and remember ign_off time stamp
*/
- virtual void OnSuspend();
+ void IncrementIgnOffCount() FINAL;
+
+ /**
+ * @brief Decrements ignition counter for all registered applications
+ * and remember ign_off time stamp
+ */
+ void DecrementIgnOffCount() FINAL;
/**
* @brief Retrieves hash ID for the given mobile app ID
@@ -130,12 +136,6 @@ class ResumptionDataDB : public ResumptionData {
std::string& hash_id) const;
/**
- * @brief Decrements ignition counter for all registered applications
- * and remember ign_off time stamp
- */
- virtual void OnAwake();
-
- /**
* @brief Retrieves data of saved application for the given mobile app ID
* and device ID
* @param policy_app_id - mobile application id
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 0be6d64db2..54c4e8f57a 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
@@ -85,13 +85,13 @@ class ResumptionDataJson : public ResumptionData {
* @brief Increments ignition counter for all registered applications
* and remember ign_off time stamp
*/
- virtual void OnSuspend();
+ void IncrementIgnOffCount() FINAL;
/**
* @brief Increments ignition counter for all registered applications
* and remember ign_off time stamp
*/
- virtual void OnAwake();
+ void DecrementIgnOffCount() FINAL;
/**
* @brief Retrieves hash ID for the given mobile app ID
diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc
index 08de6d8190..59c8220a22 100644
--- a/src/components/application_manager/src/resumption/resumption_data_db.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_db.cc
@@ -212,7 +212,7 @@ uint32_t ResumptionDataDB::GetHMIApplicationID(
return hmi_app_id;
}
-void ResumptionDataDB::OnSuspend() {
+void ResumptionDataDB::IncrementIgnOffCount() {
LOG4CXX_AUTO_TRACE(logger_);
utils::dbms::SQLQuery query_update_suspend_data(db());
@@ -291,7 +291,7 @@ bool ResumptionDataDB::GetHashId(const std::string& policy_app_id,
return SelectHashId(policy_app_id, device_id, hash_id);
}
-void ResumptionDataDB::OnAwake() {
+void ResumptionDataDB::DecrementIgnOffCount() {
LOG4CXX_AUTO_TRACE(logger_);
UpdateDataOnAwake();
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 7866fc4de1..013cd909fc 100644
--- a/src/components/application_manager/src/resumption/resumption_data_json.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_json.cc
@@ -143,11 +143,11 @@ uint32_t ResumptionDataJson::GetHMIApplicationID(
return hmi_app_id;
}
-void ResumptionDataJson::OnSuspend() {
+void ResumptionDataJson::IncrementIgnOffCount() {
using namespace app_mngr;
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock autolock(resumption_lock_);
- Json::Value to_save;
+ Json::Value to_save = Json::arrayValue;
for (Json::Value::iterator it = GetSavedApplications().begin();
it != GetSavedApplications().end();
++it) {
@@ -167,7 +167,7 @@ void ResumptionDataJson::OnSuspend() {
LOG4CXX_DEBUG(logger_, GetResumptionData().toStyledString());
}
-void ResumptionDataJson::OnAwake() {
+void ResumptionDataJson::DecrementIgnOffCount() {
using namespace app_mngr;
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock autolock(resumption_lock_);
diff --git a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h
index 7b16a3bf00..0566c8cda6 100644
--- a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h
+++ b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h
@@ -59,12 +59,12 @@ class MockResumptionData : public ::resumption::ResumptionData {
MOCK_CONST_METHOD2(GetHMIApplicationID,
uint32_t(const std::string& policy_app_id,
const std::string& device_id));
- MOCK_METHOD0(OnSuspend, void());
+ MOCK_METHOD0(IncrementIgnOffCount, void());
MOCK_CONST_METHOD3(GetHashId,
bool(const std::string& policy_app_id,
const std::string& device_id,
std::string& hash_id));
- MOCK_METHOD0(OnAwake, void());
+ MOCK_METHOD0(DecrementIgnOffCount, void());
MOCK_CONST_METHOD3(GetSavedApplication,
bool(const std::string& policy_app_id,
const std::string& device_id,
diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
index f2fc18ca58..bbb814fb5b 100644
--- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc
+++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
@@ -880,7 +880,7 @@ TEST_F(ResumeCtrlTest, CheckPersistenceFilesForResumption_WithChoiceSet) {
// TODO (VVeremjova) APPLINK-16718
TEST_F(ResumeCtrlTest, DISABLED_OnSuspend) {
- EXPECT_CALL(*mock_storage_, OnSuspend());
+ EXPECT_CALL(*mock_storage_, IncrementIgnOffCount());
res_ctrl_->OnSuspend();
}
@@ -896,7 +896,7 @@ TEST_F(ResumeCtrlTest, OnSuspend_EmptyApplicationlist) {
ON_CALL(app_mngr_, applications()).WillByDefault(Return(accessor));
EXPECT_CALL(*mock_storage_, SaveApplication(mock_app)).Times(0);
- EXPECT_CALL(*mock_storage_, OnSuspend());
+ EXPECT_CALL(*mock_storage_, IncrementIgnOffCount()).Times(0);
EXPECT_CALL(*mock_storage_, Persist());
res_ctrl_->OnSuspend();
}
@@ -906,7 +906,7 @@ TEST_F(ResumeCtrlTest, OnAwake) {
EXPECT_CALL(mock_application_manager_settings_,
app_resumption_save_persistent_data_timeout())
.WillOnce(ReturnRef(timeout));
- EXPECT_CALL(*mock_storage_, OnAwake());
+ EXPECT_CALL(*mock_storage_, DecrementIgnOffCount()).Times(0);
res_ctrl_->OnAwake();
}
diff --git a/src/components/application_manager/test/resumption/resumption_data_db_test.cc b/src/components/application_manager/test/resumption/resumption_data_db_test.cc
index aa4db59eac..cf0ebb7fd2 100644
--- a/src/components/application_manager/test/resumption/resumption_data_db_test.cc
+++ b/src/components/application_manager/test/resumption/resumption_data_db_test.cc
@@ -728,7 +728,7 @@ TEST_F(ResumptionDataDBTest, OnSuspend) {
res_db()->SaveApplication(app_mock);
CheckSavedDB();
- res_db()->OnSuspend();
+ res_db()->IncrementIgnOffCount();
ign_off_count_++;
CheckSavedDB();
}
@@ -740,18 +740,18 @@ TEST_F(ResumptionDataDBTest, OnSuspendFourTimes) {
res_db()->SaveApplication(app_mock);
CheckSavedDB();
- res_db()->OnSuspend();
+ res_db()->IncrementIgnOffCount();
ign_off_count_++;
CheckSavedDB();
- res_db()->OnSuspend();
+ res_db()->IncrementIgnOffCount();
ign_off_count_++;
CheckSavedDB();
- res_db()->OnSuspend();
+ res_db()->IncrementIgnOffCount();
ign_off_count_++;
CheckSavedDB();
- res_db()->OnSuspend();
+ res_db()->IncrementIgnOffCount();
ssize_t result = res_db()->IsApplicationSaved(policy_app_id_, kMacAddress_);
EXPECT_EQ(-1, result);
@@ -765,11 +765,11 @@ TEST_F(ResumptionDataDBTest, OnSuspendOnAwake) {
res_db()->SaveApplication(app_mock);
CheckSavedDB();
- res_db()->OnSuspend();
+ res_db()->IncrementIgnOffCount();
ign_off_count_++;
CheckSavedDB();
- res_db()->OnAwake();
+ res_db()->DecrementIgnOffCount();
ign_off_count_ = 0;
CheckSavedDB();
}
@@ -782,7 +782,7 @@ TEST_F(ResumptionDataDBTest, Awake_AppNotSuspended) {
res_db()->SaveApplication(app_mock);
CheckSavedDB();
- res_db()->OnAwake();
+ res_db()->DecrementIgnOffCount();
ign_off_count_ = 0;
CheckSavedDB();
}
@@ -795,12 +795,12 @@ TEST_F(ResumptionDataDBTest, TwiceAwake_AppNotSuspended) {
res_db()->SaveApplication(app_mock);
CheckSavedDB();
- res_db()->OnSuspend();
- res_db()->OnAwake();
+ res_db()->IncrementIgnOffCount();
+ res_db()->DecrementIgnOffCount();
ign_off_count_ = 0;
CheckSavedDB();
- res_db()->OnAwake();
+ res_db()->DecrementIgnOffCount();
CheckSavedDB();
}
@@ -826,14 +826,14 @@ TEST_F(ResumptionDataDBTest, GetIgnOffTime_AfterSuspendAndAwake) {
last_ign_off_time = res_db()->GetIgnOffTime();
EXPECT_EQ(0u, last_ign_off_time);
- res_db()->OnSuspend();
+ res_db()->IncrementIgnOffCount();
uint32_t after_suspend;
after_suspend = res_db()->GetIgnOffTime();
EXPECT_LE(last_ign_off_time, after_suspend);
uint32_t after_awake;
- res_db()->OnAwake();
+ res_db()->DecrementIgnOffCount();
after_awake = res_db()->GetIgnOffTime();
EXPECT_LE(after_suspend, after_awake);
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 834637fa62..e017c39497 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
@@ -257,7 +257,7 @@ TEST_F(ResumptionDataJsonTest, OnSuspend) {
res_json.SaveApplication(app_mock);
CheckSavedJson();
- res_json.OnSuspend();
+ res_json.IncrementIgnOffCount();
ign_off_count_++;
CheckSavedJson();
}
@@ -268,13 +268,13 @@ TEST_F(ResumptionDataJsonTest, OnSuspendFourTimes) {
res_json.SaveApplication(app_mock);
CheckSavedJson();
- res_json.OnSuspend();
+ res_json.IncrementIgnOffCount();
ign_off_count_++;
CheckSavedJson();
- res_json.OnSuspend();
- res_json.OnSuspend();
- res_json.OnSuspend();
+ res_json.IncrementIgnOffCount();
+ res_json.IncrementIgnOffCount();
+ res_json.IncrementIgnOffCount();
EXPECT_TRUE(-1 != res_json.IsApplicationSaved(policy_app_id_, kMacAddress_));
}
@@ -285,11 +285,11 @@ TEST_F(ResumptionDataJsonTest, OnSuspendOnAwake) {
res_json.SaveApplication(app_mock);
CheckSavedJson();
- res_json.OnSuspend();
+ res_json.IncrementIgnOffCount();
ign_off_count_++;
CheckSavedJson();
- res_json.OnAwake();
+ res_json.DecrementIgnOffCount();
ign_off_count_ = 0;
CheckSavedJson();
}
@@ -300,7 +300,7 @@ TEST_F(ResumptionDataJsonTest, Awake_AppNotSuspended) {
res_json.SaveApplication(app_mock);
CheckSavedJson();
- res_json.OnAwake();
+ res_json.DecrementIgnOffCount();
ign_off_count_ = 0;
CheckSavedJson();
}
@@ -311,12 +311,12 @@ TEST_F(ResumptionDataJsonTest, TwiceAwake_AppNotSuspended) {
res_json.SaveApplication(app_mock);
CheckSavedJson();
- res_json.OnSuspend();
- res_json.OnAwake();
+ res_json.IncrementIgnOffCount();
+ res_json.DecrementIgnOffCount();
ign_off_count_ = 0;
CheckSavedJson();
- res_json.OnAwake();
+ res_json.DecrementIgnOffCount();
CheckSavedJson();
}
@@ -339,14 +339,14 @@ TEST_F(ResumptionDataJsonTest, GetIgnOffTime_AfterSuspendAndAwake) {
last_ign_off_time = res_json.GetIgnOffTime();
EXPECT_EQ(0u, last_ign_off_time);
- res_json.OnSuspend();
+ res_json.IncrementIgnOffCount();
uint32_t after_suspend;
after_suspend = res_json.GetIgnOffTime();
EXPECT_LE(last_ign_off_time, after_suspend);
uint32_t after_awake;
- res_json.OnAwake();
+ res_json.DecrementIgnOffCount();
after_awake = res_json.GetIgnOffTime();
EXPECT_LE(after_suspend, after_awake);