[Release] wrt-installer_0.1.53
[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 #include <dpl/log/log.h>
30
31 using namespace InstallerWrapper;
32
33 ////////////////////////////////////////////////////////////////////////////////
34
35 RUNNER_TEST_GROUP_INIT(Manifest)
36
37 /*
38 Name: creatingManifestFile
39 Description: Creation of manifest file by wrt-installer test
40 Expected: file should be created and installed by wrt-installer. Content should
41  match expected values
42 */
43 RUNNER_TEST(creatingManifestFile)
44 {
45     std::string manifestPath = "/opt/share/packages/";
46     /* This widget removal should stay here in case previous test run failed
47      * (so widget has not been uninstalled) */
48     std::string tizenId;
49
50     if(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
51             != InstallerWrapper::Success)
52     {
53         uninstall(tizenId);
54         RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/manifest.wgt", tizenId)
55                 == InstallerWrapper::Success);
56     }
57
58     RUNNER_ASSERT(WrtUtilFileExists(manifestPath.append(tizenId.substr(0,10)).append(".xml")));
59     ManifestFile mf(manifestPath);
60
61     Try
62     {
63         LogDebug("Package " << mf.getValueByXpath("/p:manifest/@package"));
64         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@package")
65                       == tizenId.substr(0,10));
66         LogDebug("type " << mf.getValueByXpath("/p:manifest/@type"));
67         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@type")
68                       == "wgt");
69         LogDebug("version " << mf.getValueByXpath("/p:manifest/@version"));
70         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/@version")
71                       == "1.0");
72         LogDebug("label " << mf.getValueByXpath("/p:manifest/p:label"));
73         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:label")
74                       == "Manifest Example");
75
76         LogDebug("email " << mf.getValueByXpath("/p:manifest/p:author/@email"));
77         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@email")
78                       == "manifest@misc.test.create.desktop.com");
79         LogDebug("href " << mf.getValueByXpath("/p:manifest/p:author/@href"));
80         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author/@href")
81                       == "http://misc.test.create.desktop.com");
82         LogDebug("author " << mf.getValueByXpath("/p:manifest/p:author"));
83         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:author")
84                       == "Manifest");
85
86         LogDebug("appid " << mf.getValueByXpath("/p:manifest/p:ui-application/@appid"));
87         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@appid")
88                       == tizenId);
89         LogDebug("nodisplay " << mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay"));
90         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@nodisplay")
91                       == "false");
92         LogDebug("type " << mf.getValueByXpath("/p:manifest/p:ui-application/@type"));
93         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@type")
94                       == "webapp");
95         LogDebug("extraid " << mf.getValueByXpath("/p:manifest/p:ui-application/@extraid"));
96         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@extraid")
97                       == "http://test.samsung.com/widget/manifestTest");
98         LogDebug("taskmanage " << mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage"));
99         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/@taskmanage")
100                       == "true");
101
102         LogDebug("icon " << mf.getValueByXpath("/p:manifest/p:ui-application/p:icon"));
103         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:icon")
104                       == (tizenId + ".png"));
105
106         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[not(@xml:lang)]")
107                       == "Manifest Example");
108         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='de-de']")
109                       == "Manifest Beispiel");
110         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='en-us']")
111                       == "Manifest Example");
112         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pl']")
113                       == "PrzykĹ‚ad Manifest");
114         RUNNER_ASSERT(mf.getValueByXpath("/p:manifest/p:ui-application/p:label[@xml:lang='pt-pt']")
115                       == "Exemplo manifesto");
116     }
117     Catch(ManifestFile::ManifestParseError)
118     {
119         RUNNER_ASSERT_MSG(false,DPL::Exception::KnownExceptionToString(_rethrown_exception));
120     }
121     /* If test finished sucessfully than uninstall test widget */
122     uninstall(tizenId);
123 }