SM : Enhance ScopedInstaller 76/91676/3
authorZofia Abramowska <z.abramowska@samsung.com>
Mon, 10 Oct 2016 10:58:04 +0000 (12:58 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Wed, 12 Oct 2016 09:41:34 +0000 (11:41 +0200)
 * Add requestUid parameter to test without explicitly
   given uid
 * Add guard for uninstalling

Change-Id: I8b5fee86094cd4ad062643a8441f114809be2584

src/security-manager-tests/common/scoped_installer.h

index 584cffd..26f05d4 100644 (file)
 
 class ScopedInstaller {
 public:
-    ScopedInstaller(const AppInstallHelper &appInstallHelper)
-        : m_appInstallHelper(appInstallHelper)
+    ScopedInstaller(const AppInstallHelper &appInstallHelper, bool requestUid = true)
+        : m_appInstallHelper(appInstallHelper), m_shouldUninstall(true)
     {
         SecurityManagerTest::InstallRequest instReq;
         instReq.setAppId(m_appInstallHelper.getAppId());
         instReq.setPkgId(m_appInstallHelper.getPkgId());
-        instReq.setUid(m_appInstallHelper.getUID());
         if (m_appInstallHelper.getInstallType() != SM_APP_INSTALL_NONE)
             instReq.setInstallType(m_appInstallHelper.getInstallType());
+        if (requestUid)
+            instReq.setUid(m_appInstallHelper.getUID());
         instReq.setAppTizenVersion(m_appInstallHelper.getVersion());
         if (!m_appInstallHelper.getAuthor().empty())
             instReq.setAuthorId(m_appInstallHelper.getAuthor());
@@ -64,11 +65,14 @@ public:
     }
 
     void uninstallApp() {
+        if (!m_shouldUninstall)
+            return;
         SecurityManagerTest::InstallRequest uninstReq;
         uninstReq.setAppId(m_appInstallHelper.getAppId());
         uninstReq.setUid(m_appInstallHelper.getUID());
 
         SecurityManagerTest::Api::uninstall(uninstReq);
+        m_shouldUninstall = false;
     }
 
     AppInstallHelper& getAIH() {
@@ -77,4 +81,5 @@ public:
 
 protected:
     AppInstallHelper m_appInstallHelper;
+    bool m_shouldUninstall;
 };