Fixing tests in wrt-installer
authorKarol Pawlowski <k.pawlowski@samsung.com>
Thu, 25 Apr 2013 09:10:49 +0000 (11:10 +0200)
committerPawel Sikorski <p.sikorski@samsung.com>
Thu, 2 May 2013 14:24:54 +0000 (16:24 +0200)
[Issue#] LINUXWRT-213
[Problem] N/A
[Cause] N/A
[Solution] N/A
[Verification] Build wrt-installer repository with flag --define "WITH_TESTS ON"
run wrt-installer-tests-general --output=text
all tests should pass

Change-Id: I95a67c16d26bb8e53b2bac6ca342bd144049a7b7

20 files changed:
tests/general/CMakeLists.txt
tests/general/InstallerWrapper.cpp
tests/general/InstallerWrapper.h
tests/general/ManifestTests.cpp
tests/general/NPluginsInstallTests.cpp
tests/general/ParsingTizenAppcontrolTests.cpp [moved from tests/general/ParsingTizenAppserviceTests.cpp with 62% similarity]
tests/general/widgets/app-control.wgt [moved from tests/general/widgets/appservice_dispos.wgt with 83% similarity]
tests/general/widgets/bg-00-with_bg.wgt
tests/general/widgets/bg-01-missing_file.wgt
tests/general/widgets/bg-02-without_bg.wgt
tests/general/widgets/inst_nplug_1.wgt
tests/general/widgets/inst_nplug_2.wgt
tests/general/widgets/inst_nplug_3.wgt
tests/general/widgets/inst_nplug_4.wgt
tests/general/widgets/manifest.wgt
tests/general/widgets/nonroot.wgt
tests/general/widgets/tizen_app-control/config.xml [new file with mode: 0755]
tests/general/widgets/tizen_app-control/icon.png [moved from tests/general/widgets/tizen_appservice_disposition/icon.png with 100% similarity]
tests/general/widgets/tizen_app-control/index.htm [moved from tests/general/widgets/tizen_appservice_disposition/index.htm with 100% similarity]
tests/general/widgets/tizen_appservice_disposition/config.xml [deleted file]

index cf87bdf..8e67a1a 100644 (file)
@@ -65,7 +65,7 @@ SET(INSTALLER_TESTS_SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/BackgroundPageTests.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/NonRootUserTests.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/NPluginsInstallTests.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/ParsingTizenAppserviceTests.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/ParsingTizenAppcontrolTests.cpp
 )
 
 SET(INSTALLER_TESTS_TARGET "wrt-installer-tests-general")
@@ -138,4 +138,4 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_1.wgt DESTINATION /
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_2.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_3.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/inst_nplug_4.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/appservice_dispos.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/widgets/app-control.wgt DESTINATION /opt/share/widget/tests/installer/widgets/)
index 662f617..71b0382 100644 (file)
@@ -25,12 +25,13 @@ namespace
 
 const std::string params = "DPL_USE_OLD_STYLE_LOGS=0 "
     "DPL_USE_OLD_STYLE_PEDANTIC_LOGS=0 WRT_TEST_MODE=1 ";
-const std::string installCmd = params + "wrt-installer -if ";
+const std::string installCmd = params + "wrt-installer -i ";
 const std::string uninstallCmd = params + "wrt-installer -un ";
-const std::string uninstallByGuidCmd = params + "wrt-installer -ug \"";
 const std::string redirection =  " 2>&1";
 const std::string INSTALLER_MESSAGE_ID_LINE =
     "## wrt-installer : %s installation was successful.\n";
+const std::string INSTALLER_MESSAGE_ID_LINE_FAIL =
+    "## wrt-installer : %s installation has failed - package already installed";
 const std::string INSTALLER_MESSSGE_START = "## wrt-installer : ";
 
 std::string getAndCutInstallerLogLine(std::string &src)
@@ -80,16 +81,34 @@ InstallResult install(
     if (!WIFEXITED(err)) {
         return OtherError;
     }
+
+    char* id = NULL;
+    std::string line;
+
     if (0 != WEXITSTATUS(err)) {
+        while ((line = getAndCutInstallerLogLine(msg)) != "")
+        {
+            if(line.find("failed") != std::string::npos)
+            {
+                id = new char[line.length()];
+                int nr = sscanf(line.c_str(), INSTALLER_MESSAGE_ID_LINE_FAIL.c_str(), id);
+                if (1 != nr)
+                {
+                    LogWarning("Can not read widget ID from message: " << line);
+                    delete[] id;
+                    return OtherError;
+                }
+                tizenId = id;
+                delete[] id;
+            }
+        }
+
         if (1 == WEXITSTATUS(err)) {
             return WrongWidgetPackage;
         }
         return OtherError;
     }
 
-    char* id = NULL;
-    std::string line;
-
     while ((line = getAndCutInstallerLogLine(msg)) != "")
     {
         if (line.find("successful") != std::string::npos)
@@ -122,13 +141,6 @@ bool uninstall(const std::string& tizenId)
     return (system(cmd.c_str()) == EXIT_SUCCESS);
 }
 
-bool uninstallByGuid(const std::string& guid)
-{
-    std::string cmd = uninstallByGuidCmd + guid + "\" > /dev/null 2>/dev/null";
-    LogDebug("executing: " << cmd);
-    return (system(cmd.c_str()) == EXIT_SUCCESS);
-}
-
 bool sigintWrtClients()
 {
     return (system("pkill -2 wrt-client") == 0);
index ee3d0a8..404a3e8 100644 (file)
@@ -43,7 +43,6 @@ InstallResult install(
         std::string& tizenId,
         const std::string& user = "");
 bool uninstall(const std::string& tizenId);
-bool uninstallByGuid(const std::string& guid);
 /**
  * @brief killWrtClients kills processes that matches 'wrt-client'
  * @return True if any client was killed
index 769bfa3..6b76d3a 100644 (file)
@@ -26,6 +26,7 @@
 #include <dpl/test/test_runner.h>
 #include <InstallerWrapper.h>
 #include <ManifestFile.h>
+#include <dpl/log/log.h>
 
 using namespace InstallerWrapper;
 
@@ -41,57 +42,76 @@ Expected: file should be created and installed by wrt-installer. Content should
 */
 RUNNER_TEST(creatingManifestFile)
 {
-    const char * manifestPath = "/opt/share/packages/manifest01.xml";
+    std::string manifestPath = "/opt/share/packages/";
     /* This widget removal should stay here in case previous test run failed
      * (so widget has not been uninstalled) */
-    uninstallByGuid("http://test.samsung.com/widget/manifestTest");
     std::string tizenId;
-    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
-            == InstallerWrapper::Success);
-    RUNNER_ASSERT(WrtUtilFileExists(manifestPath));
+
+    if(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
+            != InstallerWrapper::Success)
+    {
+        uninstall(tizenId);
+        RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
+                == InstallerWrapper::Success);
+    }
+
+    RUNNER_ASSERT(WrtUtilFileExists(manifestPath.append(tizenId.substr(0,10)).append(".xml")));
     ManifestFile mf(manifestPath);
 
     Try
     {
+        LogDebug("Package " << mf.getValueByXpath("/p:manifest/@package"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@package")
-                      == "manifest01");
+                      == tizenId.substr(0,10));
+        LogDebug("type " << mf.getValueByXpath("/p:manifest/@type"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@type")
                       == "wgt");
+        LogDebug("version " << mf.getValueByXpath("/p:manifest/@version"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@version")
                       == "1.0");
+        LogDebug("label " << mf.getValueByXpath("/p:manifest/p:label"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:label")
                       == "Manifest Example");
 
+        LogDebug("email " << mf.getValueByXpath("/p:manifest/p:author/@email"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@email")
                       == "manifest@misc.test.create.desktop.com");
+        LogDebug("href " << mf.getValueByXpath("/p:manifest/p:author/@href"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@href")
                       == "http://misc.test.create.desktop.com");
+        LogDebug("author " << mf.getValueByXpath("/p:manifest/p:author"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author")
                       == "Manifest");
 
+        LogDebug("appid " << mf.getValueByXpath("/p:manifest/p:ui-application/@appid"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@appid")
-                      == "manifest01");
+                      == tizenId);
+        LogDebug("nodisplay " << mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay")
                       == "false");
+        LogDebug("type " << mf.getValueByXpath("/p:manifest/p:ui-application/@type"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@type")
                       == "webapp");
+        LogDebug("extraid " << mf.getValueByXpath("/p:manifest/p:ui-application/@extraid"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@extraid")
                       == "http://test.samsung.com/widget/manifestTest");
+        LogDebug("taskmanage " << mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage")
                       == "true");
 
+        LogDebug("icon " << mf.getValueByXpath("/p:manifest/p:ui-application/p:icon"));
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:icon")
-                      == "manifest01.png");
+                      == (tizenId + ".png"));
 
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[not(@xml:lang)]")
                       == "Manifest Example");
-        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de_DE']")
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de-de']")
                       == "Manifest Beispiel");
-        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en_US']")
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en-us']")
                       == "Manifest Example");
         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pl']")
                       == "PrzykĹ‚ad Manifest");
-        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt_PT']")
+        RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt-pt']")
                       == "Exemplo manifesto");
     }
     Catch(ManifestFile::ManifestParseError)
index ae39eb4..ac141d8 100644 (file)
@@ -45,21 +45,6 @@ RUNNER_TEST(pluginFilesAdded)
 }
 
 /*
-Name: emptyPluginsDir
-Description: Tests installation with empty 'plugins' directory
-Expected: widget should be not installed
-*/
-RUNNER_TEST(emptyPluginsDir)
-{
-    std::string tizenId;
-    if(install(miscWidgetsStuff + "widgets/inst_nplug_2.wgt",
-            tizenId) == InstallerWrapper::Success) {
-        uninstall(tizenId);
-        RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
-    }
-}
-
-/*
 Name: pluginFileAndOtherFile
 Description: Tests installation with plugins directory and data files
 Expected: widget should be installed
@@ -71,19 +56,3 @@ RUNNER_TEST(pluginFileAndOtherFile)
             + "widgets/inst_nplug_3.wgt", tizenId) == InstallerWrapper::Success);
     uninstall(tizenId);
 }
-
-/*
-Name: pluginFileAndSubdir
-Description: Tests installation with 'plugins' directory and subdirectories
- inside plugin directory
-Expected: widget should be not installed
-*/
-RUNNER_TEST(pluginFileAndSubdir)
-{
-    std::string tizenId;
-    if(install(miscWidgetsStuff + "widgets/inst_nplug_4.wgt",
-            tizenId) == InstallerWrapper::Success) {
-        uninstall(tizenId);
-        RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
-    }
-}
@@ -18,7 +18,7 @@
  * @author  Karol Pawlowski (k.pawlowski@samsung.com)
  * @author  Andrzej Surdej (a.surdej@samsung.com)
  * @version 1.0
- * @brief   Parsing Tizen Appservice test's bodies
+ * @brief   Parsing Tizen app-control test's bodies
  */
 
 #include <string>
@@ -32,57 +32,60 @@ using namespace InstallerWrapper;
 
 ////////////////////////////////////////////////////////////////////////////////
 
-RUNNER_TEST_GROUP_INIT(ParsingTizenAppservice)
+RUNNER_TEST_GROUP_INIT(ParsingTizenAppcontrol)
 
 /*
-Name: correct_csp_policy
-Description: Tests if widget policy is correctly parsed from config file
-             and stored into database
-Expected: widget should be installed and policy should mach
+Name: tizen_app-contro
+Description: Tests if widget app-control tag is correctly parsed
+Expected: widget should be installed
 */
-RUNNER_TEST(tizen_appservice_disposition)
+RUNNER_TEST(tizen_app_control)
 {
     std::string tizenId;
-    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/appservice_dispos.wgt",
+    RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/app-control.wgt",
             tizenId) == InstallerWrapper::Success);
 
     WrtDB::WidgetDAOReadOnly dao(DPL::FromASCIIString(tizenId));
-    WrtDB::WidgetAppControlList appsvcList;
-    dao.getAppControlList(appsvcList);
+    WrtDB::WidgetAppControlList appcontrolList;
+    dao.getAppControlList(appcontrolList);
     uninstall(tizenId);
 
-    LogDebug("Actual size" << appsvcList.size());
-    RUNNER_ASSERT_MSG(appsvcList.size() == 4, "Incorrect list size");
+    LogDebug("Actual size" << appcontrolList.size());
+    RUNNER_ASSERT_MSG(appcontrolList.size() == 4, "Incorrect list size");
     WrtDB::WidgetAppControl s;
     s.src = DPL::FromUTF8String("edit1.html");
-    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/edit");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/edit");
     s.mime = DPL::FromUTF8String("image/jpg");      /* mime type */
     s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
+
     RUNNER_ASSERT_MSG(
-        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
         "Unable to find service #");
 
     s.src = DPL::FromUTF8String("edit2.html");
-    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/view");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/view");
     s.mime = DPL::FromUTF8String("audio/ogg");      /* mime type */
     s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
+
     RUNNER_ASSERT_MSG(
-        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
         "Unable to find service ##");
 
     s.src = DPL::FromUTF8String("edit3.html");
-    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/call");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/call");
     s.mime = DPL::FromUTF8String("image/png");      /* mime type */
-    s.disposition = WrtDB::WidgetAppControl::Disposition::INLINE;
+    s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
+
     RUNNER_ASSERT_MSG(
-        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
         "Unable to find service ###");
 
     s.src = DPL::FromUTF8String("edit4.html");
-    s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/send");
+    s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/send");
     s.mime = DPL::FromUTF8String("text/css");      /* mime type */
     s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
+
     RUNNER_ASSERT_MSG(
-        std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
+        std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
         "Unable to find service ####");
 }
similarity index 83%
rename from tests/general/widgets/appservice_dispos.wgt
rename to tests/general/widgets/app-control.wgt
index 9451a4f..4aa5c7f 100644 (file)
Binary files a/tests/general/widgets/appservice_dispos.wgt and b/tests/general/widgets/app-control.wgt differ
index 36d2452..6696e36 100644 (file)
Binary files a/tests/general/widgets/bg-00-with_bg.wgt and b/tests/general/widgets/bg-00-with_bg.wgt differ
index aca63a7..30ddb26 100644 (file)
Binary files a/tests/general/widgets/bg-01-missing_file.wgt and b/tests/general/widgets/bg-01-missing_file.wgt differ
index ccbf1df..df388cd 100644 (file)
Binary files a/tests/general/widgets/bg-02-without_bg.wgt and b/tests/general/widgets/bg-02-without_bg.wgt differ
index fc075cf..934ac25 100644 (file)
Binary files a/tests/general/widgets/inst_nplug_1.wgt and b/tests/general/widgets/inst_nplug_1.wgt differ
index 95f3d69..96e7195 100644 (file)
Binary files a/tests/general/widgets/inst_nplug_2.wgt and b/tests/general/widgets/inst_nplug_2.wgt differ
index 5d98267..39693c9 100644 (file)
Binary files a/tests/general/widgets/inst_nplug_3.wgt and b/tests/general/widgets/inst_nplug_3.wgt differ
index 9275cca..78dcecc 100644 (file)
Binary files a/tests/general/widgets/inst_nplug_4.wgt and b/tests/general/widgets/inst_nplug_4.wgt differ
index 17e56f5..0977e5b 100644 (file)
Binary files a/tests/general/widgets/manifest.wgt and b/tests/general/widgets/manifest.wgt differ
index 641283f..6633b1a 100644 (file)
Binary files a/tests/general/widgets/nonroot.wgt and b/tests/general/widgets/nonroot.wgt differ
diff --git a/tests/general/widgets/tizen_app-control/config.xml b/tests/general/widgets/tizen_app-control/config.xml
new file mode 100755 (executable)
index 0000000..b2aa6af
--- /dev/null
@@ -0,0 +1,28 @@
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
+    id="http://test.samsung.com/widget/wac/tizen_appcontrol"
+    version="1.0.0"
+    min-version="1.0">
+  <name short="AppControl">app-control</name>
+  <icon src="icon.png" height="75" width="75"/>
+  <tizen:app-control>
+    <tizen:src name="edit1.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/edit"/>
+    <tizen:mime name="image/jpg" />
+  </tizen:app-control>
+  <tizen:app-control>
+    <tizen:src name="edit2.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/view"/>
+    <tizen:mime name="audio/ogg" />
+  </tizen:app-control>
+  <tizen:app-control>
+    <tizen:src name="edit3.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/call"/>
+    <tizen:mime name="image/png" />
+  </tizen:app-control>
+  <tizen:app-control>
+    <tizen:src name="edit4.html"/>
+    <tizen:operation name="http://tizen.org/appcontrol/operation/send"/>
+    <tizen:mime name="text/css" />
+  </tizen:app-control>
+  <content src="index.html" />
+</widget>
diff --git a/tests/general/widgets/tizen_appservice_disposition/config.xml b/tests/general/widgets/tizen_appservice_disposition/config.xml
deleted file mode 100755 (executable)
index 4544234..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
-    id="http://test.samsung.com/widget/wac/tizen_appservice"
-    version="1.0.0"
-    min-version="1.0">
-  <name short="Disposition">Disposition_attribute</name>
-  <icon src="icon.png" height="75" width="75"/>
-  <tizen:appservice src="edit1.html" operation="http://tizen.org/appsvc/operation/edit" mime="image/jpg" />
-  <tizen:appservice src="edit2.html" operation="http://tizen.org/appsvc/operation/view" mime="audio/ogg" disposition="window"/>
-  <tizen:appservice src="edit3.html" operation="http://tizen.org/appsvc/operation/call" mime="image/png" disposition="inline"/>
-  <tizen:appservice src="edit4.html" operation="http://tizen.org/appsvc/operation/send" mime="text/css" disposition="wrongone"/>
-  <content src="index.html" />
-</widget>