From: Karol Pawlowski Date: Thu, 25 Apr 2013 09:10:49 +0000 (+0200) Subject: Fixing tests in wrt-installer X-Git-Tag: submit/tizen_2.2/20130713.111652^2~167 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33564dea878334fca86408eeea9cd04c87adfd6d;p=platform%2Fframework%2Fweb%2Fwrt-installer.git Fixing tests in wrt-installer [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 --- diff --git a/tests/general/CMakeLists.txt b/tests/general/CMakeLists.txt index cf87bdf..8e67a1a 100644 --- a/tests/general/CMakeLists.txt +++ b/tests/general/CMakeLists.txt @@ -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/) diff --git a/tests/general/InstallerWrapper.cpp b/tests/general/InstallerWrapper.cpp index 662f617..71b0382 100644 --- a/tests/general/InstallerWrapper.cpp +++ b/tests/general/InstallerWrapper.cpp @@ -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); diff --git a/tests/general/InstallerWrapper.h b/tests/general/InstallerWrapper.h index ee3d0a8..404a3e8 100644 --- a/tests/general/InstallerWrapper.h +++ b/tests/general/InstallerWrapper.h @@ -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 diff --git a/tests/general/ManifestTests.cpp b/tests/general/ManifestTests.cpp index 769bfa3..6b76d3a 100644 --- a/tests/general/ManifestTests.cpp +++ b/tests/general/ManifestTests.cpp @@ -26,6 +26,7 @@ #include #include #include +#include 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) diff --git a/tests/general/NPluginsInstallTests.cpp b/tests/general/NPluginsInstallTests.cpp index ae39eb4..ac141d8 100644 --- a/tests/general/NPluginsInstallTests.cpp +++ b/tests/general/NPluginsInstallTests.cpp @@ -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"); - } -} diff --git a/tests/general/ParsingTizenAppserviceTests.cpp b/tests/general/ParsingTizenAppcontrolTests.cpp similarity index 62% rename from tests/general/ParsingTizenAppserviceTests.cpp rename to tests/general/ParsingTizenAppcontrolTests.cpp index 5896f41..67572f1 100644 --- a/tests/general/ParsingTizenAppserviceTests.cpp +++ b/tests/general/ParsingTizenAppcontrolTests.cpp @@ -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 @@ -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 ####"); } diff --git a/tests/general/widgets/appservice_dispos.wgt b/tests/general/widgets/app-control.wgt similarity index 83% rename from tests/general/widgets/appservice_dispos.wgt rename to tests/general/widgets/app-control.wgt index 9451a4f..4aa5c7f 100644 Binary files a/tests/general/widgets/appservice_dispos.wgt and b/tests/general/widgets/app-control.wgt differ diff --git a/tests/general/widgets/bg-00-with_bg.wgt b/tests/general/widgets/bg-00-with_bg.wgt index 36d2452..6696e36 100644 Binary files a/tests/general/widgets/bg-00-with_bg.wgt and b/tests/general/widgets/bg-00-with_bg.wgt differ diff --git a/tests/general/widgets/bg-01-missing_file.wgt b/tests/general/widgets/bg-01-missing_file.wgt index aca63a7..30ddb26 100644 Binary files a/tests/general/widgets/bg-01-missing_file.wgt and b/tests/general/widgets/bg-01-missing_file.wgt differ diff --git a/tests/general/widgets/bg-02-without_bg.wgt b/tests/general/widgets/bg-02-without_bg.wgt index ccbf1df..df388cd 100644 Binary files a/tests/general/widgets/bg-02-without_bg.wgt and b/tests/general/widgets/bg-02-without_bg.wgt differ diff --git a/tests/general/widgets/inst_nplug_1.wgt b/tests/general/widgets/inst_nplug_1.wgt index fc075cf..934ac25 100644 Binary files a/tests/general/widgets/inst_nplug_1.wgt and b/tests/general/widgets/inst_nplug_1.wgt differ diff --git a/tests/general/widgets/inst_nplug_2.wgt b/tests/general/widgets/inst_nplug_2.wgt index 95f3d69..96e7195 100644 Binary files a/tests/general/widgets/inst_nplug_2.wgt and b/tests/general/widgets/inst_nplug_2.wgt differ diff --git a/tests/general/widgets/inst_nplug_3.wgt b/tests/general/widgets/inst_nplug_3.wgt index 5d98267..39693c9 100644 Binary files a/tests/general/widgets/inst_nplug_3.wgt and b/tests/general/widgets/inst_nplug_3.wgt differ diff --git a/tests/general/widgets/inst_nplug_4.wgt b/tests/general/widgets/inst_nplug_4.wgt index 9275cca..78dcecc 100644 Binary files a/tests/general/widgets/inst_nplug_4.wgt and b/tests/general/widgets/inst_nplug_4.wgt differ diff --git a/tests/general/widgets/manifest.wgt b/tests/general/widgets/manifest.wgt index 17e56f5..0977e5b 100644 Binary files a/tests/general/widgets/manifest.wgt and b/tests/general/widgets/manifest.wgt differ diff --git a/tests/general/widgets/nonroot.wgt b/tests/general/widgets/nonroot.wgt index 641283f..6633b1a 100644 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 index 0000000..b2aa6af --- /dev/null +++ b/tests/general/widgets/tizen_app-control/config.xml @@ -0,0 +1,28 @@ + + app-control + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/general/widgets/tizen_appservice_disposition/icon.png b/tests/general/widgets/tizen_app-control/icon.png similarity index 100% rename from tests/general/widgets/tizen_appservice_disposition/icon.png rename to tests/general/widgets/tizen_app-control/icon.png diff --git a/tests/general/widgets/tizen_appservice_disposition/index.htm b/tests/general/widgets/tizen_app-control/index.htm similarity index 100% rename from tests/general/widgets/tizen_appservice_disposition/index.htm rename to tests/general/widgets/tizen_app-control/index.htm diff --git a/tests/general/widgets/tizen_appservice_disposition/config.xml b/tests/general/widgets/tizen_appservice_disposition/config.xml deleted file mode 100755 index 4544234..0000000 --- a/tests/general/widgets/tizen_appservice_disposition/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - Disposition_attribute - - - - - - -