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
26 #include <dpl/utils/wrt_utility.h>
27 #include <dpl/test/test_runner.h>
28 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
29 #include <dpl/log/log.h>
30 #include <InstallerWrapper.h>
31 #include <ManifestFile.h>
33 using namespace InstallerWrapper;
37 const std::string miscWidgetsStuff = "/opt/share/widget/tests/installer/";
44 Result(bool exc = false, bool exd = false, bool exs = false)
45 : m_exc(exc), m_exd(exd), m_exs(exs) {}
50 ////////////////////////////////////////////////////////////////////////////////
52 RUNNER_TEST_GROUP_INIT(Manifest)
55 Name: creatingManifestFile
56 Description: Creation of manifest file by wrt-installer test
57 Expected: file should be created and installed by wrt-installer. Content should
60 RUNNER_TEST(creatingManifestFile)
62 const char * manifestPath = "/opt/share/packages/manifest01.xml";
63 /* This widget removal should stay here in case previous test run failed
64 * (so widget has not been uninstalled) */
65 uninstallByGuid("http://test.samsung.com/widget/manifestTest");
67 RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
68 == InstallerWrapper::Success);
69 RUNNER_ASSERT(WrtUtilFileExists(manifestPath));
70 ManifestFile mf(manifestPath);
74 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@package")
76 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@type")
78 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@version")
80 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:label")
81 == "Manifest Example");
83 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@email")
84 == "manifest@misc.test.create.desktop.com");
85 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@href")
86 == "http://misc.test.create.desktop.com");
87 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author")
90 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@appid")
92 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay")
94 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@type")
96 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@extraid")
97 == "http://test.samsung.com/widget/manifestTest");
98 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage")
101 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:icon")
102 == "manifest01.png");
104 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[not(@xml:lang)]")
105 == "Manifest Example");
106 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de_DE']")
107 == "Manifest Beispiel");
108 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en_US']")
109 == "Manifest Example");
110 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pl']")
111 == "Przykład Manifest");
112 RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt_PT']")
113 == "Exemplo manifesto");
115 Catch(ManifestFile::ManifestParseError)
117 RUNNER_ASSERT_MSG(false,DPL::Exception::KnownExceptionToString(_rethrown_exception));
119 /* If test finished sucessfully than uninstall test widget */
123 ////////////////////////////////////////////////////////////////////////////////
125 RUNNER_TEST_GROUP_INIT(BackgroundPage)
128 Name: widgetWithBackgroundPage
129 Description: Tests if widget with background page is installed correctly
130 Expected: widget should be installed correctly
132 RUNNER_TEST(widgetWithBackgroundPage)
135 RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/bg-00-with_bg.wgt",
136 tizenId) == InstallerWrapper::Success);
141 Name: missingBackgroundFile
142 Description: Tests if widget with declared in conifg background page
143 but missing background file will be installed correctly.
144 Expected: widget should NOT be installed
146 RUNNER_TEST(missingBackgroundFile)
149 if(install(miscWidgetsStuff + "widgets/bg-01-missing_file.wgt",
150 tizenId) == InstallerWrapper::Success) {
152 RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
157 Name: widgetWithoutBackgroundPage
158 Description: Complementary test to check if normal widget\
159 without background page is successfully installed
160 Expected: widget should be installed
162 RUNNER_TEST(widgetWithoutBackgroundPage)
165 RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/bg-02-without_bg.wgt",
166 tizenId) == InstallerWrapper::Success);
170 ////////////////////////////////////////////////////////////////////////////////
172 RUNNER_TEST_GROUP_INIT(NonRootUser)
175 Name: widgetNonRootInstallation
176 Description: Check installation from other user than root
177 Expected: widget should be installed
179 RUNNER_TEST(widgetNonRootInstallation)
182 RUNNER_ASSERT(install(
183 miscWidgetsStuff + "widgets/nonroot.wgt",
185 "app") == InstallerWrapper::Success);
189 ////////////////////////////////////////////////////////////////////////////////
191 RUNNER_TEST_GROUP_INIT(NPluginsInstall)
194 Name: pluginFilesAdded
195 Description: Tests installation of plugins attached to widget
196 Expected: widget should be succesfully installed
198 RUNNER_TEST(pluginFilesAdded)
201 RUNNER_ASSERT(install(miscWidgetsStuff
202 + "widgets/inst_nplug_1.wgt", tizenId) == InstallerWrapper::Success);
207 Name: emptyPluginsDir
208 Description: Tests installation with empty 'plugins' directory
209 Expected: widget should be not installed
211 RUNNER_TEST(emptyPluginsDir)
214 if(install(miscWidgetsStuff + "widgets/inst_nplug_2.wgt",
215 tizenId) == InstallerWrapper::Success) {
217 RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
222 Name: pluginFileAndOtherFile
223 Description: Tests installation with plugins directory and data files
224 Expected: widget should be installed
226 RUNNER_TEST(pluginFileAndOtherFile)
229 RUNNER_ASSERT(install(miscWidgetsStuff
230 + "widgets/inst_nplug_3.wgt", tizenId) == InstallerWrapper::Success);
235 Name: pluginFileAndSubdir
236 Description: Tests installation with 'plugins' directory and subdirectories
237 inside plugin directory
238 Expected: widget should be not installed
240 RUNNER_TEST(pluginFileAndSubdir)
243 if(install(miscWidgetsStuff + "widgets/inst_nplug_4.wgt",
244 tizenId) == InstallerWrapper::Success) {
246 RUNNER_ASSERT_MSG(false, "Invalid widget package installed");
250 RUNNER_TEST_GROUP_INIT(ParsingTizenAppservice)
256 Name: correct_csp_policy
257 Description: Tests if widget policy is correctly parsed from config file
258 and stored into database
259 Expected: widget should be installed and policy should mach
261 RUNNER_TEST(tizen_appservice_disposition)
264 RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/appservice_dispos.wgt",
265 tizenId) == InstallerWrapper::Success);
267 WrtDB::WidgetDAOReadOnly dao(DPL::FromASCIIString(tizenId));
268 WidgetApplicationServiceList appsvcList;
269 dao.getAppServiceList(appsvcList);
272 RUNNER_ASSERT_MSG(appsvcList.size() == 4, "Incorrect list size");
273 WidgetApplicationService s;
274 s.src = DPL::FromUTF8String("edit1.html");
275 s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/edit");
276 s.mime = DPL::FromUTF8String("image/jpg"); /* mime type */
277 s.disposition = WidgetApplicationService::Disposition::WINDOW;
279 std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
280 "Unable to find service #");
282 s.src = DPL::FromUTF8String("edit2.html");
283 s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/view");
284 s.mime = DPL::FromUTF8String("audio/ogg"); /* mime type */
285 s.disposition = WidgetApplicationService::Disposition::WINDOW;
287 std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
288 "Unable to find service ##");
290 s.src = DPL::FromUTF8String("edit3.html");
291 s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/call");
292 s.mime = DPL::FromUTF8String("image/png"); /* mime type */
293 s.disposition = WidgetApplicationService::Disposition::INLINE;
295 std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
296 "Unable to find service ###");
298 s.src = DPL::FromUTF8String("edit4.html");
299 s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/send");
300 s.mime = DPL::FromUTF8String("text/css"); /* mime type */
301 s.disposition = WidgetApplicationService::Disposition::WINDOW;
303 std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
304 "Unable to find service ####");