2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <boost/signals2.hpp>
20 #include <boost/test/unit_test.hpp>
21 #include <boost/concept_check.hpp>
25 BOOST_AUTO_TEST_SUITE(action)
27 BOOST_AUTO_TEST_CASE(action_constructors)
29 tizen_browser::base_ui::Action action_01;
30 BOOST_CHECK_EQUAL(action_01.isEnabled(), true);
31 BOOST_CHECK_EQUAL(action_01.isCheckable(), false);
32 BOOST_CHECK_EQUAL(action_01.isChecked(), false);
33 BOOST_CHECK_EQUAL(action_01.isIconVisibleInMenu(), true);
35 std::string a02_text("test02");
36 tizen_browser::base_ui::Action action_02(a02_text);
37 BOOST_CHECK_EQUAL(action_02.isEnabled(), true);
38 BOOST_CHECK_EQUAL(action_02.isCheckable(), false);
39 BOOST_CHECK_EQUAL(action_02.isChecked(), false);
40 BOOST_CHECK_EQUAL(action_02.isIconVisibleInMenu(), true);
41 BOOST_CHECK_EQUAL(action_02.getText(), a02_text);
43 std::string a03_text("test02");
44 tizen_browser::base_ui::Action action_03(a03_text);
45 BOOST_CHECK_EQUAL(action_03.isEnabled(), true);
46 BOOST_CHECK_EQUAL(action_03.isCheckable(), false);
47 BOOST_CHECK_EQUAL(action_03.isChecked(), false);
48 BOOST_CHECK_EQUAL(action_03.isIconVisibleInMenu(), true);
49 BOOST_CHECK_EQUAL(action_03.getText(), a03_text);
51 std::string a04_text("test04");
52 std::string a04_icon("test04Icon");
53 tizen_browser::base_ui::Action action_04(a04_icon, a04_text);
54 BOOST_CHECK_EQUAL(action_04.isEnabled(), true);
55 BOOST_CHECK_EQUAL(action_04.isCheckable(), false);
56 BOOST_CHECK_EQUAL(action_04.isChecked(), false);
57 BOOST_CHECK_EQUAL(action_04.isIconVisibleInMenu(), true);
58 BOOST_CHECK_EQUAL(action_04.getText(), a04_text);
59 BOOST_CHECK_EQUAL(action_04.getIcon(), a04_icon);
62 BOOST_AUTO_TEST_CASE(action_get_and_set){
65 std::string iconText("iconText");
66 std::string text("text");
67 std::string statusTip("statusTip");
68 std::string toolTip("toolTip");
69 std::string icon("icon");
70 std::string selIcon("selIcon");
71 std::string disIcon("disabledIcon");
73 tizen_browser::base_ui::Action action;
75 action.setIconText(iconText);
77 action.setStatusTip(statusTip);
78 action.setToolTip(toolTip);
80 action.setSelIcon(selIcon);
81 action.setDisIcon(disIcon);
83 BOOST_CHECK_EQUAL(action.getIconText(), iconText);
84 BOOST_CHECK_EQUAL(action.getText(), text);
85 BOOST_CHECK_EQUAL(action.getStatusTip(), statusTip);
86 BOOST_CHECK_EQUAL(action.getToolTip(), toolTip);
87 BOOST_CHECK_EQUAL(action.getIcon(), icon);
88 BOOST_CHECK_EQUAL(action.getSelIcon(), selIcon);
89 BOOST_CHECK_EQUAL(action.getDisIcon(), disIcon);
92 BOOST_AUTO_TEST_CASE(action_bool_behaviour){
94 tizen_browser::base_ui::Action action_01;
95 //action is not checkable by defalut,
96 //this call should be ignored.
97 action_01.setChecked(true);
98 BOOST_CHECK_EQUAL(action_01.isCheckable(), false);
99 BOOST_CHECK_EQUAL(action_01.isChecked(), false);
101 tizen_browser::base_ui::Action action_02;
102 action_02.setCheckable(true);
103 action_02.setChecked(true);
104 BOOST_CHECK_EQUAL(action_02.isCheckable(), true);
105 BOOST_CHECK_EQUAL(action_02.isChecked(), true);
109 BOOST_CHECK_EQUAL(action_02.isChecked(), false);
113 BOOST_AUTO_TEST_CASE(action_trigger_test){
114 struct TriggerHandler{
116 :beenCalled(false){};
118 BOOST_CHECK_EQUAL(beenCalled, true);
128 TriggerHandler triggered;
129 tizen_browser::base_ui::Action action_01;
130 action_01.triggered.connect(boost::ref(triggered));
132 BOOST_CHECK_EQUAL(triggered.beenCalled, true);
135 BOOST_AUTO_TEST_CASE(action_togle_test){
136 struct ToggleHandler{
138 :isChecked(false),beenCalled(false){};
141 void operator()(bool checked){
149 ToggleHandler toggelHandler;
150 tizen_browser::base_ui::Action action;
152 action.setCheckable(true);
153 action.toggled.connect(boost::ref(toggelHandler));
156 BOOST_CHECK_EQUAL(toggelHandler.beenCalled, true);
157 BOOST_CHECK_EQUAL(action.isChecked(), toggelHandler.isChecked);
160 BOOST_AUTO_TEST_SUITE_END()