Added Haltest for wifi-mesh-manager
[platform/core/connectivity/wifi-mesh-manager.git] / haltest / wifi_mesh_manager_hal_tc.cpp
1 /*
2  * Copyright (c) 2018 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 #include <stdio.h>
18 #include <stdlib.h>
19 #include <iostream>
20 #include <gmock/gmock.h>
21 #include <gtest/gtest.h>
22 #include <unistd.h>
23
24 #include "manager.h"
25 #include "wmesh.h"
26
27 using ::testing::InitGoogleTest;
28 using ::testing::Test;
29 using ::testing::TestCase;
30
31 char *mesh_id = (char *)"haltestnetwork";
32
33 /*
34 @testcase       Enable_p
35 @since_tizen    5.0
36 @author         SRID(abhishek.s94)
37 @reviewer       HQ(saerome.kim)
38 @type           auto
39 @description    Positive, Enable wifi-mesh-manager
40 @apicovered     "enable" dbus method on net.wmesh.manager interface
41 @passcase       when EnableManager() returns ERROR_NONE
42 @failcase       when EnableManager() does not return ERROR_NONE
43 @precondition   None
44 @postcondition  None
45 */
46 TEST(WifiMeshManager, Enable_p)
47 {
48         error_e ret = ERROR_NONE;
49         Manager mgr;
50
51         ret = mgr.EnableManager();
52         EXPECT_EQ(ERROR_NONE, ret);
53 }
54
55 /*
56 @testcase       StartMesh_p
57 @since_tizen    5.0
58 @author         SRID(abhishek.s94)
59 @reviewer       HQ(saerome.kim)
60 @type           auto
61 @description    Positive, Start wifi-mesh-manager
62 @apicovered     "enable_mesh" dbus method on net.wmesh.manager interface
63 @passcase       when EnableMesh() returns ERROR_NONE
64 @failcase       when EnableMesh() does not return ERROR_NONE
65 @precondition   None
66 @postcondition  None
67 */
68 TEST(WifiMeshManager, EnableMesh_p)
69 {
70         error_e ret = ERROR_NONE;
71         Wmesh w;
72
73         ret = w.EnableMesh();
74         EXPECT_EQ(ERROR_NONE, ret);
75 }
76
77 /*
78 @testcase       Scan_p
79 @since_tizen    5.0
80 @author         SRID(abhishek.s94)
81 @reviewer       HQ(saerome.kim)
82 @type           auto
83 @description    Positive, Scan using wifi-mesh-manager
84 @apicovered     "scan" dbus method on net.wmesh.manager interface
85 @passcase       when Scan() returns ERROR_NONE
86 @failcase       when Scan() does not return ERROR_NONE
87 @precondition   None
88 @postcondition  None
89 */
90 TEST(WifiMeshManager, Scan_p)
91 {
92         error_e ret = ERROR_NONE;
93         Wmesh w;
94
95         ret = w.Scan();
96         EXPECT_EQ(ERROR_NONE, ret);
97 }
98
99 /*
100 @testcase       EnableSoftap_p
101 @since_tizen    5.0
102 @author         SRID(abhishek.s94)
103 @reviewer       HQ(saerome.kim)
104 @type           auto
105 @description    Positive, Enable softap using wifi-mesh-manager
106 @apicovered     "enable_softap" dbus method on net.wmesh.manager interface
107 @passcase       when EnableSoftap() returns ERROR_NONE
108 @failcase       when EnableSoftap() does not return ERROR_NONE
109 @precondition   None
110 @postcondition  None
111 */
112 TEST(WifiMeshManager, SetSoftap_p)
113 {
114         static char ssid[] = "haltestnetwork";
115         static char passphrase[] = "00000000";
116         static int channel = 1;
117         static int visibility = 1;
118         static int max_stations = 10;
119         static int security = 2;
120
121         error_e ret = ERROR_NONE;
122         Wmesh w;
123
124         ret = w.SetSoftap(ssid, passphrase,
125                         channel, visibility, max_stations, security);
126         EXPECT_EQ(ERROR_NONE, ret);
127
128         ret = w.GetSoftap();
129         EXPECT_EQ(ERROR_NONE, ret);
130
131         ret = w.EnableSoftap();
132         EXPECT_EQ(ERROR_NONE, ret);
133 }
134
135 /*
136 @testcase       DisableSoftap_p
137 @since_tizen    5.0
138 @author         SRID(abhishek.s94)
139 @reviewer       HQ(saerome.kim)
140 @type           auto
141 @description    Positive, Disable softap using wifi-mesh-manager
142 @apicovered     "disable_softap" dbus method on net.wmesh.manager interface
143 @passcase       when DisableSoftap() returns ERROR_NONE
144 @failcase       when DisableSoftap() does not return ERROR_NONE
145 @precondition   None
146 @postcondition  None
147 */
148 TEST(WifiMeshManager, DisableSoftap_p)
149 {
150         error_e ret = ERROR_NONE;
151         Wmesh w;
152
153         ret = w.DisableSoftap();
154         EXPECT_EQ(ERROR_NONE, ret);
155 }
156
157 /*
158 @testcase       CreateMeshNetwork_p
159 @since_tizen    5.0
160 @author         SRID(abhishek.s94)
161 @reviewer       HQ(saerome.kim)
162 @type           auto
163 @description    Positive, Create mesh network using wifi-mesh-manager
164 @apicovered     "create_mesh_network" dbus method on net.wmesh.manager interface
165 @passcase       when CreateMeshNetwork() returns ERROR_NONE
166 @failcase       when CreateMeshNetwork() does not return ERROR_NONE
167 @precondition   None
168 @postcondition  None
169 */
170 TEST(WifiMeshManager, CreateMeshNetwork_p)
171 {
172         error_e ret = ERROR_NONE;
173         Wmesh w;
174
175         ret = w.CreateMeshNetwork(mesh_id, 1, 2, 1);
176         EXPECT_EQ(ERROR_NONE, ret);
177 }
178
179 /*
180 @testcase       ConnectMeshNetwork_p
181 @since_tizen    5.0
182 @author         SRID(abhishek.s94)
183 @reviewer       HQ(saerome.kim)
184 @type           auto
185 @description    Positive, Connect to a mesh network using wifi-mesh-manager
186 @apicovered     "connect_mesh_network" dbus method on net.wmesh.manager interface
187 @passcase       when ConnectMeshNetwork() returns ERROR_NONE
188 @failcase       when ConnectMeshNetwork() does not return ERROR_NONE
189 @precondition   None
190 @postcondition  None
191 */
192 TEST(WifiMeshManager, ConnectMeshNetwork_p)
193 {
194         error_e ret = ERROR_NONE;
195         Wmesh w;
196         char *passphrase = (char *)"00000000";
197
198         ret = w.ConnectMeshNetwork(mesh_id, 1, 2, passphrase);
199         EXPECT_EQ(ERROR_NONE, ret);
200 }
201
202
203 /*
204 @testcase       Stop_p
205 @since_tizen    5.0
206 @author         SRID(abhishek.s94)
207 @reviewer       HQ(saerome.kim)
208 @type           auto
209 @description    Positive, Stop wifi-mesh-manager
210 @apicovered     "disable_mesh" dbus method on net.wmesh.manager interface
211 @passcase       when DisableMesh() returns ERROR_NONE
212 @failcase       when DisableMesh() does not return ERROR_NONE
213 @precondition   None
214 @postcondition  None
215 */
216 TEST(WifiMeshManager, DisableMesh_p)
217 {
218         error_e ret = ERROR_NONE;
219         Wmesh w;
220
221         ret = w.DisableMesh();
222         EXPECT_EQ(ERROR_NONE, ret);
223 }
224
225 /*
226 @testcase       Disable_p
227 @since_tizen    5.0
228 @author         SRID(abhishek.s94)
229 @reviewer       HQ(saerome.kim)
230 @type           auto
231 @description    Positive, Disable wifi-mesh-manager
232 @apicovered     "disable" dbus method on net.wmesh.manager interface
233 @passcase       when DisableManager() returns ERROR_NONE
234 @failcase       when DisableManager() does not return ERROR_NONE
235 @precondition   None
236 @postcondition  None
237 */
238 TEST(WifiMeshManager, Disable_p)
239 {
240         error_e ret = ERROR_NONE;
241         Manager mgr;
242
243         ret = mgr.DisableManager();
244         EXPECT_EQ(ERROR_NONE, ret);
245 }
246
247 int main(int argc, char **argv)
248 {
249         int ret = 0;
250         try {
251                 testing::InitGoogleTest(&argc, argv);
252         } catch (const ::testing::internal::GoogleTestFailureException& ex) {
253                 std::cerr << "Caught: GoogleTestFailureException& " << ex.what() << std::endl;
254         } catch (...) {
255                 std::cerr << "Caught: unknown exception" << std::endl;
256         }
257
258         try {
259                 ret = RUN_ALL_TESTS();
260         } catch (const ::testing::internal::GoogleTestFailureException& ex) {
261                 std::cerr << "Caught: GoogleTestFailureException& " << ex.what() << std::endl;
262         } catch (...) {
263                 std::cerr << "Caught: unknown exception" << std::endl;
264         }
265         return ret;
266 }