summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandr Galiuzov (GutHub) <AGaliuzov@luxoft.com>2016-07-11 13:36:10 +0300
committerGitHub <noreply@github.com>2016-07-11 13:36:10 +0300
commit53d298c2ee8777658fd293c53db9d6c4e379bb7d (patch)
tree6968ddf40e84bb510180d86bd043ea199259fe05
parenteb9091afef3b9bce637248ecc35ffabd0a846567 (diff)
parent53931d168b27906b32fe68536d9915840018cbe4 (diff)
downloadsdl_core-53d298c2ee8777658fd293c53db9d6c4e379bb7d.tar.gz
Merge pull request #681 from dev-gh/fix/Fixes_app_default_policies_setting
Fixes saving of default assigned policy
-rw-r--r--src/components/policy/src/sql_pt_representation.cc18
-rw-r--r--src/components/policy/test/sql_pt_representation_test.cc59
2 files changed, 60 insertions, 17 deletions
diff --git a/src/components/policy/src/sql_pt_representation.cc b/src/components/policy/src/sql_pt_representation.cc
index b94e9306d3..20bc2ade4d 100644
--- a/src/components/policy/src/sql_pt_representation.cc
+++ b/src/components/policy/src/sql_pt_representation.cc
@@ -1594,11 +1594,21 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
SetPreloaded(false);
policy_table::Strings default_groups;
- if (GatherAppGroup(kDefaultId, &default_groups) &&
- SaveAppGroup(app_id, default_groups)) {
- return SetIsDefault(app_id, true);
+ if (!GatherAppGroup(kDefaultId, &default_groups) ||
+ !SaveAppGroup(app_id, default_groups)) {
+ return false;
}
- return false;
+ policy_table::RequestTypes request_types;
+ if (!GatherRequestType(kDefaultId, &request_types) ||
+ !SaveRequestType(app_id, request_types)) {
+ return false;
+ }
+ policy_table::AppHMITypes app_types;
+ if (!GatherAppType(kDefaultId, &app_types) ||
+ !SaveAppType(app_id, app_types)) {
+ return false;
+ }
+ return SetIsDefault(app_id, true);
}
bool SQLPTRepresentation::SetIsDefault(const std::string& app_id,
diff --git a/src/components/policy/test/sql_pt_representation_test.cc b/src/components/policy/test/sql_pt_representation_test.cc
index 9a69556d58..1f4df5d15d 100644
--- a/src/components/policy/test/sql_pt_representation_test.cc
+++ b/src/components/policy/test/sql_pt_representation_test.cc
@@ -1381,27 +1381,60 @@ TEST_F(SQLPTRepresentationTest, Drop_DropExistedPT_ExpectZeroTables) {
TEST_F(SQLPTRepresentationTest,
SetDefaultPolicy_SetDefaultPolicyThenCheck_ExpectDefaultPolicySet) {
// Arrange
- const char* query_insert_app =
- "INSERT OR IGNORE INTO `application`(`id`, `keep_context`, "
+ const std::string kDefaultId = "default";
+ const std::string kAppId = "app_1234567";
+ const std::string kRequestType = "HTTP";
+ const std::string kHmiType = "MEDIA";
+
+ const std::string query_insert_default_app =
+ "INSERT INTO `application`(`id`, `keep_context`, "
"`steal_focus`, "
" `default_hmi`, `priority_value`, `is_revoked`, `is_default`, "
"`is_predata`, `memory_kb`, "
- " `heart_beat_timeout_ms`) VALUES( 'default', 0, 0, 'NONE', 'NONE', 0, "
- "0, "
- "0, 64, 10) ";
- ASSERT_TRUE(dbms->Exec(query_insert_app));
+ " `heart_beat_timeout_ms`) "
+ "VALUES( '" +
+ kDefaultId + "', 0, 0, 'NONE', 'NONE', 0, 0, 0, 64, 10) ";
- query_insert_app =
- "INSERT OR IGNORE INTO `application`(`id`, `keep_context`, "
+ ASSERT_TRUE(dbms->Exec(query_insert_default_app.c_str()));
+
+ const std::string query_insert_default_app_request_types =
+ "INSERT INTO `request_type` (`application_id`, `request_type`) "
+ "VALUES ('" +
+ kDefaultId + "', '" + kRequestType + "')";
+
+ ASSERT_TRUE(dbms->Exec(query_insert_default_app_request_types.c_str()));
+
+ const std::string query_insert_default_app_hmi_types =
+ "INSERT INTO `app_type` (`application_id`, `name`) "
+ "VALUES ('" +
+ kDefaultId + "', '" + kHmiType + "')";
+
+ ASSERT_TRUE(dbms->Exec(query_insert_default_app_hmi_types.c_str()));
+
+ const std::string query_insert_new_app =
+ "INSERT INTO `application`(`id`, `keep_context`, "
"`steal_focus`, `default_hmi`, `priority_value`, `is_revoked`, "
"`is_default`, `is_predata`, `memory_kb`, `heart_beat_timeout_ms`) "
- "VALUES( '1234567', 0, 0, 'NONE', 'NONE', 0, 0, 1, 64, 10) ";
- ASSERT_TRUE(dbms->Exec(query_insert_app));
- EXPECT_FALSE(reps->IsDefaultPolicy("1234567"));
+ "VALUES('" +
+ kAppId + "', 0, 0, 'NONE', 'NONE', 0, 0, 1, 64, 10)";
+
+ ASSERT_TRUE(dbms->Exec(query_insert_new_app.c_str()));
+
+ EXPECT_FALSE(reps->IsDefaultPolicy(kAppId));
// Act
- ASSERT_TRUE(reps->SetDefaultPolicy("1234567"));
+ ASSERT_TRUE(reps->SetDefaultPolicy(kAppId));
// Check
- EXPECT_TRUE(reps->IsDefaultPolicy("1234567"));
+ EXPECT_TRUE(reps->IsDefaultPolicy(kAppId));
+
+ policy_table::RequestTypes request_types;
+ GatherRequestType(kAppId, &request_types);
+ ASSERT_TRUE(1 == request_types.size());
+ EXPECT_EQ(policy_table::RT_HTTP, *request_types.begin());
+
+ policy_table::AppHMITypes hmi_types;
+ GatherAppType(kAppId, &hmi_types);
+ ASSERT_TRUE(1 == hmi_types.size());
+ EXPECT_EQ(policy_table::AHT_MEDIA, *hmi_types.begin());
}
TEST_F(SQLPTRepresentationTest,