tizen 2.4 release
[framework/web/wrt-installer.git] / tests / general / ParsingTizenAppcontrolTests.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 app-control 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 #include <dpl/log/secure_log.h>
30
31 using namespace InstallerWrapper;
32
33 ////////////////////////////////////////////////////////////////////////////////
34
35 RUNNER_TEST_GROUP_INIT(ParsingTizenAppcontrol)
36
37 /*
38 Name: tizen_app-contro
39 Description: Tests if widget app-control tag is correctly parsed
40 Expected: widget should be installed
41 */
42 RUNNER_TEST(tizen_app_control)
43 {
44     std::string tizenId;
45     RUNNER_ASSERT(install(miscWidgetsStuff + "widgets/app-control.wgt",
46             tizenId) == InstallerWrapper::Success);
47
48     WrtDB::WidgetDAOReadOnly dao(DPL::FromASCIIString(tizenId));
49     WrtDB::WidgetAppControlList appcontrolList;
50     dao.getAppControlList(appcontrolList);
51     uninstall(tizenId);
52
53     _D("Actual size %d", appcontrolList.size());
54     RUNNER_ASSERT_MSG(appcontrolList.size() == 4, "Incorrect list size");
55     WrtDB::WidgetAppControl s;
56     s.src = DPL::FromUTF8String("edit1.html");
57     s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/edit");
58     s.mime = DPL::FromUTF8String("image/jpg");      /* mime type */
59
60     RUNNER_ASSERT_MSG(
61         std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
62         "Unable to find service #");
63
64     s.src = DPL::FromUTF8String("edit2.html");
65     s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/view");
66     s.mime = DPL::FromUTF8String("audio/ogg");      /* mime type */
67
68     RUNNER_ASSERT_MSG(
69         std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
70         "Unable to find service ##");
71
72     s.src = DPL::FromUTF8String("edit3.html");
73     s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/call");
74     s.mime = DPL::FromUTF8String("image/png");      /* mime type */
75
76     RUNNER_ASSERT_MSG(
77         std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
78         "Unable to find service ###");
79
80     s.src = DPL::FromUTF8String("edit4.html");
81     s.operation = DPL::FromUTF8String("http://tizen.org/appcontrol/operation/send");
82     s.mime = DPL::FromUTF8String("text/css");      /* mime type */
83
84     RUNNER_ASSERT_MSG(
85         std::find(appcontrolList.begin(), appcontrolList.end(), s) != appcontrolList.end(),
86         "Unable to find service ####");
87 }