Add tests for AppControl element in config.xml 97/60697/8
authorArkadiusz Szulakiewicz <a.szulakiewi@partner.samsung.com>
Tue, 1 Mar 2016 14:05:08 +0000 (15:05 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Mon, 7 Mar 2016 15:56:32 +0000 (07:56 -0800)
Change-Id: I87f8c009e0ba9074e2e7bfd0947393856fdc8bd8

src/unit_tests/manifest_test.cc
src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingMIME/config.xml [new file with mode: 0644]
src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingOperation/config.xml [new file with mode: 0644]
src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingSrc/config.xml [new file with mode: 0644]
src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingURI/config.xml [new file with mode: 0644]
src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_Valid/config.xml [new file with mode: 0644]

index e705cac..9e827f5 100644 (file)
@@ -213,4 +213,64 @@ TEST_F(ManifestTest, PrivilegeElement_MissingName) {
   ASSERT_FALSE(runner.Run());
 }
 
+TEST_F(ManifestTest, AppControlElement_Valid) {
+  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();
+  ASSERT_NE(app, nullptr);
+  std::vector<appcontrol_x*> app_controls;
+  for (appcontrol_x* app_control : GListRange<appcontrol_x*>(app->appcontrol)) {
+    app_controls.push_back(app_control);
+  }
+  ASSERT_EQ(app_controls.size(), 1);
+  ASSERT_CSTR_EQ(app_controls[0]->mime, "image/jpg");
+  ASSERT_CSTR_EQ(app_controls[0]->operation,
+                 "http://tizen.org/appcontrol/operation/edit");
+  ASSERT_CSTR_EQ(app_controls[0]->uri, "myapp");
+}
+
+TEST_F(ManifestTest, AppControlElement_MissingMIME) {
+  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();
+  ASSERT_NE(app, nullptr);
+  std::vector<appcontrol_x*> app_controls;
+  for (appcontrol_x* app_control : GListRange<appcontrol_x*>(app->appcontrol)) {
+    app_controls.push_back(app_control);
+  }
+  ASSERT_CSTR_EQ(app_controls[0]->mime, "");
+}
+
+TEST_F(ManifestTest, AppControlElement_MissingOperation) {
+  StepParseRunner runner(GetMyName());
+  ASSERT_FALSE(runner.Run());
+}
+
+TEST_F(ManifestTest, AppControlElement_MissingSrc) {
+  StepParseRunner runner(GetMyName());
+  ASSERT_FALSE(runner.Run());
+}
+
+TEST_F(ManifestTest, AppControlElement_MissingURI) {
+  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();
+  ASSERT_NE(app, nullptr);
+  std::vector<appcontrol_x*> app_controls;
+  for (appcontrol_x* app_control : GListRange<appcontrol_x*>(app->appcontrol)) {
+    app_controls.push_back(app_control);
+  }
+  ASSERT_CSTR_EQ(app_controls[0]->uri, "");
+}
+
+
 
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingMIME/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingMIME/config.xml
new file mode 100644 (file)
index 0000000..a0f5c94
--- /dev/null
@@ -0,0 +1,9 @@
+<?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:app-control>
+    <tizen:src name="edit.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/edit"/>
+    <tizen:uri name="myapp"/>
+  </tizen:app-control>
+</widget>
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingOperation/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingOperation/config.xml
new file mode 100644 (file)
index 0000000..6e9f364
--- /dev/null
@@ -0,0 +1,9 @@
+<?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:app-control>
+    <tizen:src name="edit.html"/>
+    <tizen:mime name="image/jpg" />
+    <tizen:uri name="myapp"/>
+  </tizen:app-control>
+</widget>
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingSrc/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingSrc/config.xml
new file mode 100644 (file)
index 0000000..4aa7ace
--- /dev/null
@@ -0,0 +1,9 @@
+<?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:app-control>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/edit"/>
+    <tizen:mime name="image/jpg" />
+    <tizen:uri name="myapp"/>
+  </tizen:app-control>
+</widget>
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingURI/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_MissingURI/config.xml
new file mode 100644 (file)
index 0000000..8101514
--- /dev/null
@@ -0,0 +1,9 @@
+<?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:app-control>
+    <tizen:src name="edit.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/edit"/>
+    <tizen:mime name="image/jpg" />
+  </tizen:app-control>
+</widget>
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_Valid/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppControlElement_Valid/config.xml
new file mode 100644 (file)
index 0000000..cdbd2eb
--- /dev/null
@@ -0,0 +1,10 @@
+<?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:app-control>
+    <tizen:src name="edit.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/edit"/>
+    <tizen:mime name="image/jpg" />
+    <tizen:uri name="myapp"/>
+  </tizen:app-control>
+</widget>