Add tests for Privilege element in config.xml 96/60696/5
authorArkadiusz Szulakiewicz <a.szulakiewi@partner.samsung.com>
Tue, 1 Mar 2016 13:39:21 +0000 (14:39 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Thu, 3 Mar 2016 16:21:03 +0000 (08:21 -0800)
Change-Id: Ic0bd88aa5fa8c7024d2756cea9ec84dfd6d0c9fd

src/unit_tests/manifest_test.cc
src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_InvalidName/config.xml [new file with mode: 0644]
src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ManyElements/config.xml [new file with mode: 0644]
src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_MissingName/config.xml [new file with mode: 0644]
src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ValidName/config.xml [new file with mode: 0644]

index ec3e1c2..e705cac 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <memory>
 #include <string>
+#include <vector>
 
 #include "wgt/step/step_parse.h"
 #include "wgt/wgt_backend_data.h"
@@ -168,7 +169,48 @@ TEST_F(ManifestTest, ApplicationElement_MissingVersion) {
   ASSERT_FALSE(runner.Run());
 }
 
+TEST_F(ManifestTest, PrivilegeElement_ValidName) {
+  StepParseRunner runner(GetMyName());
+  ASSERT_TRUE(runner.Run());
+  manifest_x* m = runner.GetManifest();
+  ASSERT_NE(m, nullptr);
+  auto apps = GListRange<application_x*>(m->application);
+  application_x* app = *apps.begin();
+  std::vector<std::string> priv_vec;
+  for (const char* priv : GListRange<char*>(m->privileges)) {
+    priv_vec.push_back(priv);
+  }
+  ASSERT_FALSE(priv_vec.empty());
+  const char* expected_name = "http://tizen.org/privilege/application.launch";
+  ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name);
+}
 
+TEST_F(ManifestTest, PrivilegeElement_ManyElements) {
+  StepParseRunner runner(GetMyName());
+  ASSERT_TRUE(runner.Run());
+  manifest_x* m = runner.GetManifest();
+  ASSERT_NE(m, nullptr);
+  auto apps = GListRange<application_x*>(m->application);
+  application_x* app = *apps.begin();
+  std::vector<std::string> priv_vec;
+  for (const char* priv : GListRange<char*>(m->privileges)) {
+    priv_vec.push_back(priv);
+  }
+  ASSERT_EQ(priv_vec.size(), 2);
+  const char* first_priv = "http://tizen.org/privilege/application.close";
+  ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv);
+  const char* second_priv = "http://tizen.org/privilege/application.launch";
+  ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv);
+}
 
+TEST_F(ManifestTest, PrivilegeElement_InvalidName) {
+  StepParseRunner runner(GetMyName());
+  ASSERT_FALSE(runner.Run());
+}
+
+TEST_F(ManifestTest, PrivilegeElement_MissingName) {
+  StepParseRunner runner(GetMyName());
+  ASSERT_FALSE(runner.Run());
+}
 
 
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_InvalidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_InvalidName/config.xml
new file mode 100644 (file)
index 0000000..6fb0b33
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
+  <tizen:application id="package0id.appid" package="package0id" required_version="3.0"/>
+  <tizen:privilege name=""/>
+</widget>
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ManyElements/config.xml
new file mode 100644 (file)
index 0000000..94fbcc1
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
+  <tizen:application id="package0id.appid" package="package0id" required_version="3.0"/>
+  <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
+  <tizen:privilege name="http://tizen.org/privilege/application.close"/>
+</widget>
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_MissingName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_MissingName/config.xml
new file mode 100644 (file)
index 0000000..a9defae
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
+  <tizen:application id="package0id.appid" package="package0id" required_version="3.0"/>
+  <tizen:privilege/>
+</widget>
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.PrivilegeElement_ValidName/config.xml
new file mode 100644 (file)
index 0000000..f4ff663
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets">
+  <tizen:application id="package0id.appid" package="package0id" required_version="3.0"/>
+  <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
+</widget>