summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Oleynik <aoleynik@luxoft.com>2016-07-08 16:33:08 +0300
committerAndrey Oleynik <aoleynik@luxoft.com>2016-07-08 16:38:55 +0300
commit53931d168b27906b32fe68536d9915840018cbe4 (patch)
tree0bbfd161e361a3aba743ac030612033983076491
parent383cbfdfdc8f42051f05575cdc93654548b97297 (diff)
downloadsdl_core-53931d168b27906b32fe68536d9915840018cbe4.tar.gz
Updates unit tests to check default policy setting
Relates-to: APPLINK-25284
-rw-r--r--src/components/policy/test/sql_pt_representation_test.cc59
1 files changed, 46 insertions, 13 deletions
diff --git a/src/components/policy/test/sql_pt_representation_test.cc b/src/components/policy/test/sql_pt_representation_test.cc
index c2874122b0..c9b9bd37b0 100644
--- a/src/components/policy/test/sql_pt_representation_test.cc
+++ b/src/components/policy/test/sql_pt_representation_test.cc
@@ -1371,27 +1371,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,