Merge branch 'master' of github.sec.samsung.net:appfw/pkgmgr-info into tizen
[platform/core/appfw/pkgmgr-info.git] / test / unit_tests / parcel_utils.cc
index 406212a..fe46667 100644 (file)
@@ -67,7 +67,7 @@ application_x* GetTestApplication(std::string appid) {
   application->guestmode_visibility = strdup("test_guestmode_visibility");
   application->component = strdup("test_component");
   application->permission_type = strdup("test_permission_type");
-  application->component_type = strdup("test_component_type");
+  application->component_type = strdup("test_component");
   application->preload = strdup("test_preload");
   application->submode = strdup("test_submode");
   application->submode_mainid = strdup("test_submode_mainid");
@@ -169,6 +169,16 @@ application_x* GetTestApplication(std::string appid) {
   splashscreen->color_depth = strdup("color_detest_color_depth");
   application->splashscreens =
       g_list_append(application->splashscreens, splashscreen);
+
+  res_control_x* res_control =
+      reinterpret_cast<res_control_x*>(calloc(1, sizeof(res_control_x)));
+  res_control->res_type = strdup("test_res_type");
+  res_control->min_res_version = strdup("1.0.0");
+  res_control->max_res_version = strdup("2.0.0");
+  res_control->auto_close = strdup("true");
+  application->res_control =
+      g_list_append(application->res_control, res_control);
+
   return application;
 }
 
@@ -434,6 +444,8 @@ package_x* GetTestPackage(std::string pkgid) {
   package->backend_installer = strdup("test_backend_installer");
   package->external_path = strdup("test_external_path");
   package->use_system_certs = strdup("test_use_system_certs");
+  package->res_type = strdup("test_res_type");
+  package->res_version = strdup("test_res_version");
 
   icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
   icon->text = strdup("test_text");
@@ -507,6 +519,17 @@ package_x* GetTestPackage(std::string pkgid) {
 
   package->plugin = g_list_append(package->plugin, plugin);
 
+  res_allowed_package_x* allowed_package =
+      reinterpret_cast<res_allowed_package_x*>(calloc(1,
+          sizeof(res_allowed_package_x)));
+  allowed_package->allowed_package = strdup("test_allowed_package");
+  allowed_package->required_privileges = g_list_append(
+      allowed_package->required_privileges,
+          strdup("test_required_privilege1"));
+
+  package->res_allowed_packages =
+      g_list_append(package->res_allowed_packages, allowed_package);
+
   package->application = g_list_append(package->application,
       GetTestApplication("test_app1"));
   package->application = g_list_append(package->application,
@@ -690,6 +713,28 @@ bool IsEqualPackage(package_x* packageA, package_x* packageB) {
     STR_EQ(dependency_a->type, dependency_b->type);
   }
 
+  INT_EQ(g_list_length(packageA->res_allowed_packages),
+      g_list_length(packageB->res_allowed_packages));
+  for (GList* a = packageA->res_allowed_packages,
+      *b = packageB->res_allowed_packages; a && b; a = a->next, b = b->next) {
+    res_allowed_package_x* allowed_package_a =
+        reinterpret_cast<res_allowed_package_x*>(a->data);
+    res_allowed_package_x* allowed_package_b =
+        reinterpret_cast<res_allowed_package_x*>(b->data);
+    STR_EQ(allowed_package_a->allowed_package,
+        allowed_package_b->allowed_package);
+
+    INT_EQ(g_list_length(allowed_package_a->required_privileges),
+        g_list_length(allowed_package_b->required_privileges));
+
+    for (GList* a = allowed_package_a->required_privileges,
+        *b = allowed_package_b->required_privileges; a && b;
+        a = a->next, b = b->next) {
+      STR_EQ(reinterpret_cast<char*>(a->data),
+          reinterpret_cast<char*>(b->data));
+    }
+  }
+
   return true;
 }