[Release]wrt-installer_0.1.6
[framework/web/wrt-installer.git] / tests / general / ManifestTests.cpp
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  * @file    TestCases.cpp
18  * @author  Karol Pawlowski (k.pawlowski@samsung.com)
19  * @author  Tomasz Iwanek (t.iwanek@samsung.com)
20  * @version 1.0
21  * @brief   Manifest installation test's bodies
22  */
23
24 #include <string>
25 #include <dpl/utils/wrt_utility.h>
26 #include <dpl/test/test_runner.h>
27 #include <InstallerWrapper.h>
28 #include <ManifestFile.h>
29
30 using namespace InstallerWrapper;
31
32 ////////////////////////////////////////////////////////////////////////////////
33
34 RUNNER_TEST_GROUP_INIT(Manifest)
35
36 /*
37 Name: creatingManifestFile
38 Description: Creation of manifest file by wrt-installer test
39 Expected: file should be created and installed by wrt-installer. Content should
40  match expected values
41 */
42 RUNNER_TEST(creatingManifestFile)
43 {
44     const char * manifestPath = "/opt/share/packages/manifest01.xml";
45     /* This widget removal should stay here in case previous test run failed
46      * (so widget has not been uninstalled) */
47     uninstallByGuid("http://test.samsung.com/widget/manifestTest");
48     std::string tizenId;
49     RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
50             == InstallerWrapper::Success);
51     RUNNER_ASSERT(WrtUtilFileExists(manifestPath));
52     ManifestFile mf(manifestPath);
53
54     Try
55     {
56         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@package")
57                       == "manifest01");
58         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@type")
59                       == "wgt");
60         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@version")
61                       == "1.0");
62         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:label")
63                       == "Manifest Example");
64
65         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@email")
66                       == "manifest@misc.test.create.desktop.com");
67         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@href")
68                       == "http://misc.test.create.desktop.com");
69         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author")
70                       == "Manifest");
71
72         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@appid")
73                       == "manifest01");
74         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay")
75                       == "false");
76         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@type")
77                       == "webapp");
78         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@extraid")
79                       == "http://test.samsung.com/widget/manifestTest");
80         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage")
81                       == "true");
82
83         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:icon")
84                       == "manifest01.png");
85
86         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[not(@xml:lang)]")
87                       == "Manifest Example");
88         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de_DE']")
89                       == "Manifest Beispiel");
90         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en_US']")
91                       == "Manifest Example");
92         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pl']")
93                       == "PrzykĹ‚ad Manifest");
94         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt_PT']")
95                       == "Exemplo manifesto");
96     }
97     Catch(ManifestFile::ManifestParseError)
98     {
99         RUNNER_ASSERT_MSG(false,DPL::Exception::KnownExceptionToString(_rethrown_exception));
100     }
101     /* If test finished sucessfully than uninstall test widget */
102     uninstall(tizenId);
103 }