Add tests for Category element in config.xml 13/61413/4
authorArkadiusz Szulakiewicz <a.szulakiewi@partner.samsung.com>
Mon, 7 Mar 2016 15:07:55 +0000 (16:07 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Wed, 16 Mar 2016 13:23:05 +0000 (06:23 -0700)
Change-Id: Icafa7a6120978d2368966438d1b70ed77e937738

src/unit_tests/manifest_test.cc
src/unit_tests/test_samples/manifest/ManifestTest.CategoryElement_MissingName/config.xml [new file with mode: 0644]
src/unit_tests/test_samples/manifest/ManifestTest.CategoryElement_MultipleElements/config.xml [new file with mode: 0644]
src/unit_tests/test_samples/manifest/ManifestTest.CategoryElement_Valid/config.xml [new file with mode: 0644]

index 183e0b4..da14f60 100644 (file)
@@ -539,3 +539,57 @@ TEST_F(ManifestTest, MetadataElement_MissingKey) {
   }
   ASSERT_EQ(meta_data_map.size(), 0);
 }
+
+TEST_F(ManifestTest, CategoryElement_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();
+
+  std::vector<std::string> categories;
+  for (const char* category : GListRange<char*>(app->category)) {
+    categories.push_back(category);
+  }
+  ASSERT_EQ(categories.size(), 1);
+  ASSERT_CSTR_EQ(categories[0].c_str(),
+                 "http://tizen.org/category/wearable_clock");
+}
+
+TEST_F(ManifestTest, CategoryElement_MissingName) {
+  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> categories;
+  for (const char* category : GListRange<char*>(app->category)) {
+    categories.push_back(category);
+  }
+  ASSERT_TRUE(categories.empty());
+}
+
+TEST_F(ManifestTest, CategoryElement_MultipleElements) {
+  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> categories;
+  for (const char* category : GListRange<char*>(app->category)) {
+    categories.push_back(category);
+  }
+  ASSERT_EQ(categories.size(), 3);
+  ASSERT_CSTR_EQ(categories[0].c_str(),
+                 "http://tizen.org/category/category_0");
+  ASSERT_CSTR_EQ(categories[1].c_str(),
+                 "http://tizen.org/category/category_1");
+  ASSERT_CSTR_EQ(categories[2].c_str(),
+                 "http://tizen.org/category/category_2");
+
+}
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.CategoryElement_MissingName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.CategoryElement_MissingName/config.xml
new file mode 100644 (file)
index 0000000..698d3fd
--- /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:category />
+</widget>
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.CategoryElement_MultipleElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.CategoryElement_MultipleElements/config.xml
new file mode 100644 (file)
index 0000000..5e2a900
--- /dev/null
@@ -0,0 +1,7 @@
+<?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:category name="http://tizen.org/category/category_0" />
+  <tizen:category name="http://tizen.org/category/category_1" />
+  <tizen:category name="http://tizen.org/category/category_2" />
+</widget>
diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.CategoryElement_Valid/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.CategoryElement_Valid/config.xml
new file mode 100644 (file)
index 0000000..55de5ee
--- /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:category name="http://tizen.org/category/wearable_clock" />
+</widget>