2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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.
20 #include <gmock/gmock.h>
21 #include <gtest/gtest.h>
23 #include <system_info.h>
27 using ::testing::InitGoogleTest;
28 using ::testing::Test;
29 using ::testing::TestCase;
31 const char *feature_name = (char *)"http://tizen.org/feature/network.zigbee";
33 static bool __check_feature_supported()
35 bool zigbee_supported = FALSE;
36 if (!system_info_get_platform_bool(feature_name, &zigbee_supported)) {
37 if (FALSE == zigbee_supported) {
38 GLOGD("zigbee feature is disabled");
39 return ZIGBEE_ERROR_NOT_SUPPORTED;
41 return ZIGBEE_ERROR_NONE;
43 GLOGD("Error - Feature getting from System Info");
44 return ZIGBEE_ERROR_INVALID_PARAMETER;
52 @author SRID(abhishek.s94)
53 @reviewer HQ(saerome.kim)
55 @description Positive, Enable zigbee manager
56 @apicovered "enable" method on "org.tizen.zigbee.manager" interface
57 @passcase when zbl_enable returns ZIGBEE_ERROR_NONE
58 @failcase when zbl_enable does not return ZIGBEE_ERROR_NONE
59 @precondition __check_feature_supported must return true for zigbee feature
62 TEST(ZigbeeManager, Enable_p)
64 int ret = ZIGBEE_ERROR_NONE;
67 if (ZIGBEE_ERROR_NONE == __check_feature_supported()) {
68 ret = zb_mgr.zbl_enable();
70 EXPECT_EQ(ZIGBEE_ERROR_NONE, ret);
74 @testcase FormNetwork_p
76 @author SRID(abhishek.s94)
77 @reviewer HQ(saerome.kim)
79 @description Positive, Form network using zigbee-manager
80 @apicovered "form_network" method on "org.tizen.zigbee.service" interface
81 @passcase when zbl_form_network returns ZIGBEE_ERROR_NONE
82 @failcase when zbl_form_network does not return ZIGBEE_ERROR_NONE
83 @precondition __check_feature_supported must return true for zigbee feature
86 TEST(ZigbeeManager, FormNetwork_p)
88 int ret = ZIGBEE_ERROR_NONE;
91 if (ZIGBEE_ERROR_NONE == __check_feature_supported()) {
92 ret = zb_mgr.zbl_form_network();
94 EXPECT_EQ(ZIGBEE_ERROR_NONE, ret);
98 @testcase GetNetworkInfo_p
100 @author SRID(abhishek.s94)
101 @reviewer HQ(saerome.kim)
103 @description Positive, get network info using zigbee-manager
104 @apicovered "get_network_info" method on "org.tizen.zigbee.service" interface
105 @passcase when zbl_get_network_info returns ZIGBEE_ERROR_NONE
106 @failcase when zbl_get_network_info does not return ZIGBEE_ERROR_NONE
107 @precondition __check_feature_supported must return true for zigbee feature
110 TEST(ZigbeeManager, GetNetworkInfo_p)
112 int ret = ZIGBEE_ERROR_NONE;
115 if (ZIGBEE_ERROR_NONE == __check_feature_supported()) {
116 ret = zb_mgr.zbl_get_network_info();
118 EXPECT_EQ(ZIGBEE_ERROR_NONE, ret);
124 @author SRID(abhishek.s94)
125 @reviewer HQ(saerome.kim)
127 @description Positive, get mac address using zigbee-manager
128 @apicovered "get_mac" method on "org.tizen.zigbee.service" interface
129 @passcase when zbl_get_mac returns ZIGBEE_ERROR_NONE
130 @failcase when zbl_get_mac does not return ZIGBEE_ERROR_NONE
131 @precondition __check_feature_supported must return true for zigbee feature
134 TEST(ZigbeeManager, GetMac_p)
136 int ret = ZIGBEE_ERROR_NONE;
139 if (ZIGBEE_ERROR_NONE == __check_feature_supported()) {
140 ret = zb_mgr.zbl_get_mac();
142 EXPECT_EQ(ZIGBEE_ERROR_NONE, ret);
146 @testcase PermitJoin_p
148 @author SRID(abhishek.s94)
149 @reviewer HQ(saerome.kim)
151 @description Positive, Allow permit join using zigbee-manager
152 @apicovered "permit_join" method on "org.tizen.zigbee.service" interface
153 @passcase when zbl_permit_join returns ZIGBEE_ERROR_NONE
154 @failcase when zbl_permit_join does not return ZIGBEE_ERROR_NONE
155 @precondition __check_feature_supported must return true for zigbee feature
158 TEST(ZigbeeManager, PermitJoin_p)
160 int ret = ZIGBEE_ERROR_NONE;
163 if (ZIGBEE_ERROR_NONE == __check_feature_supported()) {
164 ret = zb_mgr.zbl_permit_join(1, true);
166 EXPECT_EQ(ZIGBEE_ERROR_NONE, ret);
170 @testcase LeaveNetwork_p
172 @author SRID(abhishek.s94)
173 @reviewer HQ(saerome.kim)
175 @description Positive, Leave network using zigbee-manager
176 @apicovered "leave_network" method on "org.tizen.zigbee.service" interface
177 @passcase when zbl_leave_network returns ZIGBEE_ERROR_NONE
178 @failcase when zbl_leave_network does not return ZIGBEE_ERROR_NONE
179 @precondition __check_feature_supported must return true for zigbee feature
182 TEST(ZigbeeManager, LeaveNetwork_p)
184 int ret = ZIGBEE_ERROR_NONE;
187 if (ZIGBEE_ERROR_NONE == __check_feature_supported()) {
188 ret = zb_mgr.zbl_leave_network();
190 EXPECT_EQ(ZIGBEE_ERROR_NONE, ret);
196 @author SRID(abhishek.s94)
197 @reviewer HQ(saerome.kim)
199 @description Positive, Disable zigbee manager
200 @apicovered "disable" method on "org.tizen.zigbee.manager" interface
201 @passcase when zbl_disable returns ZIGBEE_ERROR_NONE
202 @failcase when zbl_disable does not return ZIGBEE_ERROR_NONE
203 @precondition __check_feature_supported must return true for zigbee feature
206 TEST(ZigbeeManager, Disable_p)
208 int ret = ZIGBEE_ERROR_NONE;
211 if (ZIGBEE_ERROR_NONE == __check_feature_supported()) {
212 ret = zb_mgr.zbl_disable();
214 EXPECT_EQ(ZIGBEE_ERROR_NONE, ret);
217 int main(int argc, char **argv)
221 testing::InitGoogleTest(&argc, argv);
222 } catch (const ::testing::internal::GoogleTestFailureException& ex) {
223 std::cerr << "Caught: GoogleTestFailureException& " << ex.what() << std::endl;
225 std::cerr << "Caught: unknown exception" << std::endl;
229 ret = RUN_ALL_TESTS();
230 } catch (const ::testing::internal::GoogleTestFailureException& ex) {
231 std::cerr << "Caught: GoogleTestFailureException& " << ex.what() << std::endl;
233 std::cerr << "Caught: unknown exception" << std::endl;