0ac368b2e8d59ead049dee5ef98bca1e30c3207b
[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/test/test_runner.h>
27 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
28 #include <InstallerWrapper.h>
29
30 using namespace InstallerWrapper;
31
32 ////////////////////////////////////////////////////////////////////////////////
33
34 RUNNER_TEST_GROUP_INIT(ParsingTizenAppservice)
35
36 /*
37 Name: correct_csp_policy
38 Description: Tests if widget policy is correctly parsed from config file
39              and stored into database
40 Expected: widget should be installed and policy should mach
41 */
42 RUNNER_TEST(tizen_appservice_disposition)
43 {
44     std::string tizenId;
45     RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/appservice_dispos.wgt",
46             tizenId) == InstallerWrapper::Success);
47
48     WrtDB::WidgetDAOReadOnly dao(DPL::FromASCIIString(tizenId));
49     WidgetApplicationServiceList appsvcList;
50     dao.getAppServiceList(appsvcList);
51     uninstall(tizenId);
52
53     RUNNER_ASSERT_MSG(appsvcList.size() == 4, "Incorrect list size");
54     WidgetApplicationService s;
55     s.src = DPL::FromUTF8String("edit1.html");
56     s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/edit");
57     s.mime = DPL::FromUTF8String("image/jpg");      /* mime type */
58     s.disposition = WidgetApplicationService::Disposition::WINDOW;
59     RUNNER_ASSERT_MSG(
60         std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
61         "Unable to find service #");
62
63     s.src = DPL::FromUTF8String("edit2.html");
64     s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/view");
65     s.mime = DPL::FromUTF8String("audio/ogg");      /* mime type */
66     s.disposition = WidgetApplicationService::Disposition::WINDOW;
67     RUNNER_ASSERT_MSG(
68         std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
69         "Unable to find service ##");
70
71     s.src = DPL::FromUTF8String("edit3.html");
72     s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/call");
73     s.mime = DPL::FromUTF8String("image/png");      /* mime type */
74     s.disposition = WidgetApplicationService::Disposition::INLINE;
75     RUNNER_ASSERT_MSG(
76         std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
77         "Unable to find service ###");
78
79     s.src = DPL::FromUTF8String("edit4.html");
80     s.operation = DPL::FromUTF8String("http://tizen.org/appsvc/operation/send");
81     s.mime = DPL::FromUTF8String("text/css");      /* mime type */
82     s.disposition = WidgetApplicationService::Disposition::WINDOW;
83     RUNNER_ASSERT_MSG(
84         std::find(appsvcList.begin(), appsvcList.end(), s) != appsvcList.end(),
85         "Unable to find service ####");
86 }