Add new smoke tests
[platform/core/appfw/wgt-backend.git] / src / unit_tests / smoke_utils.cc
index 34d6d12..2a8fb85 100644 (file)
@@ -17,6 +17,8 @@
 #include <gtest/gtest.h>
 #include <gtest/gtest-death-test.h>
 
+#include <manifest_parser/utils/version_number.h>
+
 #include <pkgmgr-info.h>
 #include <signal.h>
 #include <unistd.h>
@@ -729,6 +731,13 @@ ci::AppInstaller::Result Recover(const bf::path& recovery_file,
   return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
 }
 
+ci::AppInstaller::Result ManifestDirectInstall(const std::string& pkgid,
+                                               PackageType type,
+                                               RequestResult mode) {
+  const char* argv[] = {"", "-y", pkgid.c_str(), "-u", kTestUserIdStr.c_str()};
+  return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
+}
+
 namespace {
 
 boost::filesystem::path GetTrashPath(const boost::filesystem::path& path) {
@@ -851,10 +860,27 @@ void UninstallAllAppsInDirectory(bf::path dir, bool is_preload) {
 
 void UninstallAllSmokeApps(ci::RequestMode request_mode) {
   std::cout << "Uninstalling all smoke apps" << std::endl;
+  bf::path apps_rw = ci::GetRootAppPath(false, kTestUserId);
+  UninstallAllAppsInDirectory(apps_rw, false);
   if (getuid() == 0 && request_mode == ci::RequestMode::GLOBAL) {
     bf::path root_path = kPreloadApps;
     UninstallAllAppsInDirectory(root_path, true);
   }
-  bf::path apps_rw = ci::GetRootAppPath(false, kTestUserId);
-  UninstallAllAppsInDirectory(apps_rw, false);
+}
+
+int GetAppInstalledTime(const char *appid, uid_t uid)
+{
+       int ret = 0;
+       int installed_time = 0;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_appinfo_get_installed_time(handle, &installed_time);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return installed_time;
 }