[Release] wrt-installer_0.1.49
[framework/web/wrt-installer.git] / tests / general / ParsingTizenAppserviceTests.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  Andrzej Surdej (a.surdej@samsung.com)
20  * @version 1.0
21  * @brief   Parsing Tizen Appservice test's bodies
22  */
23
24 #include <string>
25 #include <algorithm>
26 #include <dpl/log/log.h>
27 #include <dpl/test/test_runner.h>
28 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
29 #include <InstallerWrapper.h>
30
31 using namespace InstallerWrapper;
32
33 ////////////////////////////////////////////////////////////////////////////////
34
35 RUNNER_TEST_GROUP_INIT(ParsingTizenAppservice)
36
37 /*
38 Name: correct_csp_policy
39 Description: Tests if widget policy is correctly parsed from config file
40              and stored into database
41 Expected: widget should be installed and policy should mach
42 */
43 RUNNER_TEST(tizen_appservice_disposition)
44 {
45     std::string tizenId;
46     RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/appservice_dispos.wgt",
47             tizenId) == InstallerWrapper::Success);
48
49     WrtDB::WidgetDAOReadOnly dao(DPL::FromASCIIString(tizenId));
50     WrtDB::WidgetAppControlList appsvcList;
51     dao.getAppControlList(appsvcList);
52     uninstall(tizenId);
53
54     LogDebug("Actual size" << appsvcList.size());
55     RUNNER_ASSERT_MSG(appsvcList.size() == 4, "Incorrect list size");
56     WrtDB::WidgetAppControl s;
57     s.src = DPL::FromUTF8String("edit1.html");
58     s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/edit");
59     s.mime = DPL::FromUTF8String("image/jpg");      /* mime type */
60     s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
61     RUNNER_ASSERT_MSG(
62         std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
63         "Unable to find service #");
64
65     s.src = DPL::FromUTF8String("edit2.html");
66     s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/view");
67     s.mime = DPL::FromUTF8String("audio/ogg");      /* mime type */
68     s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
69     RUNNER_ASSERT_MSG(
70         std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
71         "Unable to find service ##");
72
73     s.src = DPL::FromUTF8String("edit3.html");
74     s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/call");
75     s.mime = DPL::FromUTF8String("image/png");      /* mime type */
76     s.disposition = WrtDB::WidgetAppControl::Disposition::INLINE;
77     RUNNER_ASSERT_MSG(
78         std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
79         "Unable to find service ###");
80
81     s.src = DPL::FromUTF8String("edit4.html");
82     s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/send");
83     s.mime = DPL::FromUTF8String("text/css");      /* mime type */
84     s.disposition = WrtDB::WidgetAppControl::Disposition::WINDOW;
85     RUNNER_ASSERT_MSG(
86         std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
87         "Unable to find service ####");
88 }