2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @author Karol Pawlowski (k.pawlowski@samsung.com)
19 * @author Tomasz Iwanek (t.iwanek@samsung.com)
21 * @brief Miscellaneous test's bodies
25 #include <dpl/utils/wrt_utility.h>
26 #include <dpl/test/test_runner.h>
27 #include <dpl/log/log.h>
28 #include <InstallerWrapper.h>
29 #include <ManifestFile.h>
31 using namespace InstallerWrapper;
35 const std::string miscWidgetsStuff = "/opt/share/widget/tests/misc/";
42 Result(bool exc = false, bool exd = false, bool exs = false)
43 : m_exc(exc), m_exd(exd), m_exs(exs) {}
48 ////////////////////////////////////////////////////////////////////////////////
50 RUNNER_TEST_GROUP_INIT(Manifest)
53 Name: creatingManifestFile
54 Description: Creation of manifest file by wrt-installer test
55 Expected: file should be created and installed by wrt-installer. Content should
58 RUNNER_TEST(creatingManifestFile)
60 const char * manifestPath = "/opt/share/packages/manifest01.xml";
61 /* This widget removal should stay here in case previous test run failed
62 * (so widget has not been uninstalled) */
63 uninstallByGuid("http://test.samsung.com/widget/manifestTest");
65 RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
66 == InstallerWrapper::Success);
67 RUNNER_ASSERT(WrtUtilFileExists(manifestPath));
68 ManifestFile mf(manifestPath);
72 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@package")
74 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@type")
76 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@version")
78 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:label")
79 == "Manifest Example");
81 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@email")
82 == "manifest@misc.test.create.desktop.com");
83 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@href")
84 == "http://misc.test.create.desktop.com");
85 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author")
88 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@appid")
90 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay")
92 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@type")
94 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@extraid")
95 == "http://test.samsung.com/widget/manifestTest");
96 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage")
99 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:icon")
100 == "manifest01.png");
102 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[not(@xml:lang)]")
103 == "Manifest Example");
104 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de_DE']")
105 == "Manifest Beispiel");
106 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en_US']")
107 == "Manifest Example");
108 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pl']")
109 == "Przykład Manifest");
110 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt_PT']")
111 == "Exemplo manifesto");
113 Catch(ManifestFile::ManifestParseError)
115 RUNNER_ASSERT_MSG(false,DPL::Exception::KnownExceptionToString(_rethrown_exception));
117 /* If test finished sucessfully than uninstall test widget */
121 ////////////////////////////////////////////////////////////////////////////////
123 RUNNER_TEST_GROUP_INIT(BackgroundPage)
126 Name: widgetWithBackgroundPage
127 Description: Tests if widget with background page is installed correctly
128 Expected: widget should be installed correctly
130 RUNNER_TEST(widgetWithBackgroundPage)
133 RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/bg-00-with_bg.wgt",
134 tizenId) == InstallerWrapper::Success);
139 Name: missingBackgroundFile
140 Description: Tests if widget with declared in conifg background page
141 but missing background file will be installed correctly.
142 Expected: widget should NOT be installed
144 RUNNER_TEST(missingBackgroundFile)
147 if(install(miscWidgetsStuff + "widgets/bg-01-missing_file.wgt",
148 tizenId) == InstallerWrapper::Success) {
150 RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
155 Name: widgetWithoutBackgroundPage
156 Description: Complementary test to check if normal widget\
157 without background page is successfully installed
158 Expected: widget should be installed
160 RUNNER_TEST(widgetWithoutBackgroundPage)
163 RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/bg-02-without_bg.wgt",
164 tizenId) == InstallerWrapper::Success);
168 ////////////////////////////////////////////////////////////////////////////////
170 RUNNER_TEST_GROUP_INIT(NonRootUser)
173 Name: widgetNonRootInstallation
174 Description: Check installation from other user than root
175 Expected: widget should be installed
177 RUNNER_TEST(widgetNonRootInstallation)
180 RUNNER_ASSERT(install(
181 miscWidgetsStuff + "widgets/nonroot.wgt",
183 "app") == InstallerWrapper::Success);
187 ////////////////////////////////////////////////////////////////////////////////
189 RUNNER_TEST_GROUP_INIT(NPluginsInstall)
192 Name: pluginFilesAdded
193 Description: Tests installation of plugins attached to widget
194 Expected: widget should be succesfully installed
196 RUNNER_TEST(pluginFilesAdded)
199 RUNNER_ASSERT(install(miscWidgetsStuff
200 + "widgets/inst_nplug_1.wgt", tizenId) == InstallerWrapper::Success);
205 Name: emptyPluginsDir
206 Description: Tests installation with empty 'plugins' directory
207 Expected: widget should be not installed
209 RUNNER_TEST(emptyPluginsDir)
212 if(install(miscWidgetsStuff + "widgets/inst_nplug_2.wgt",
213 tizenId) == InstallerWrapper::Success) {
215 RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
220 Name: pluginFileAndOtherFile
221 Description: Tests installation with plugins directory and data files
222 Expected: widget should be installed
224 RUNNER_TEST(pluginFileAndOtherFile)
227 RUNNER_ASSERT(install(miscWidgetsStuff
228 + "widgets/inst_nplug_3.wgt", tizenId) == InstallerWrapper::Success);
233 Name: pluginFileAndSubdir
234 Description: Tests installation with 'plugins' directory and subdirectories
235 inside plugin directory
236 Expected: widget should be not installed
238 RUNNER_TEST(pluginFileAndSubdir)
241 if(install(miscWidgetsStuff + "widgets/inst_nplug_4.wgt",
242 tizenId) == InstallerWrapper::Success) {
244 RUNNER_ASSERT_MSG(false, "Invalid widget package installed");