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.
22 #include <gmock/gmock.h>
23 #include <gtest/gtest.h>
26 #include "gtest-vpn-settings.h"
28 #ifdef TIZEN_TEST_GCOV
29 extern "C" void __gcov_flush(void);
32 using ::testing::InitGoogleTest;
33 using ::testing::Test;
34 using ::testing::TestCase;
36 TEST(VpnSetting, vpnInitialize_p)
41 ret = vpn.vpnInitialize_p();
42 EXPECT_EQ(VPN_ERROR_NONE, ret);
45 TEST(VpnSetting, vpnInitialize_n)
50 ret = vpn.vpnInitialize_n();
51 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
54 TEST(VpnSetting, vpnDeinitialize_p)
59 ret = vpn.vpnDeinitialize_p();
60 EXPECT_EQ(VPN_ERROR_NONE, ret);
63 TEST(VpnSetting, vpnDeinitialize_n)
68 ret = vpn.vpnDeinitialize_n();
69 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
72 TEST(VpnSetting, vpnSettingsInit_p)
77 ret = vpn.vpnSettingsInit_p();
78 EXPECT_EQ(VPN_ERROR_NONE, ret);
81 TEST(VpnSetting, vpnSettingsInit_n)
86 ret = vpn.vpnSettingsInit_n();
87 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
90 TEST(VpnSetting, vpnSettingsDeinit_p)
95 ret = vpn.vpnSettingsDeinit_p();
96 EXPECT_EQ(VPN_ERROR_NONE, ret);
99 TEST(VpnSetting, vpnSettingsDeinit_n1)
104 ret = vpn.vpnSettingsDeinit_n1();
105 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
108 TEST(VpnSetting, vpnSettingsDeinit_n2)
113 ret = vpn.vpnSettingsDeinit_n2();
114 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
117 TEST(VpnSetting, vpnSettingsSetSpecific_p1)
122 ret = vpn.vpnSettingsSetSpecific_p1();
123 EXPECT_EQ(VPN_ERROR_NONE, ret);
126 TEST(VpnSetting, vpnSettingsSetSpecific_p2)
131 ret = vpn.vpnSettingsSetSpecific_p2();
132 EXPECT_EQ(VPN_ERROR_NONE, ret);
135 TEST(VpnSetting, vpnSettingsSetSpecific_n1)
140 ret = vpn.vpnSettingsSetSpecific_n1();
141 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
144 TEST(VpnSetting, vpnSettingsSetSpecific_n2)
149 ret = vpn.vpnSettingsSetSpecific_n2();
150 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
153 TEST(VpnSetting, vpnSettingsSetSpecific_n3)
158 ret = vpn.vpnSettingsSetSpecific_n3();
159 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
162 TEST(VpnSetting, vpnSettingsSetType_p)
167 ret = vpn.vpnSettingsSetType_p();
168 EXPECT_EQ(VPN_ERROR_NONE, ret);
171 TEST(VpnSetting, vpnSettingsSetType_n1)
176 ret = vpn.vpnSettingsSetType_n1();
177 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
180 TEST(VpnSetting, vpnSettingsSetType_n2)
185 ret = vpn.vpnSettingsSetType_n2();
186 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
189 TEST(VpnSetting, vpnSettingsSetName_p)
194 ret = vpn.vpnSettingsSetName_p();
195 EXPECT_EQ(VPN_ERROR_NONE, ret);
198 TEST(VpnSetting, vpnSettingsSetName_n1)
203 ret = vpn.vpnSettingsSetName_n1();
204 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
207 TEST(VpnSetting, vpnSettingsSetName_n2)
212 ret = vpn.vpnSettingsSetName_n2();
213 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
216 TEST(VpnSetting, vpnSettingsSetHost_p)
221 ret = vpn.vpnSettingsSetHost_p();
222 EXPECT_EQ(VPN_ERROR_NONE, ret);
225 TEST(VpnSetting, vpnSettingsSetHost_n1)
230 ret = vpn.vpnSettingsSetHost_n1();
231 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
234 TEST(VpnSetting, vpnSettingsSetHost_n2)
239 ret = vpn.vpnSettingsSetHost_n2();
240 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
243 TEST(VpnSetting, vpnSettingsSetDomain_p)
248 ret = vpn.vpnSettingsSetDomain_p();
249 EXPECT_EQ(VPN_ERROR_NONE, ret);
252 TEST(VpnSetting, vpnSettingsSetDomain_n1)
257 ret = vpn.vpnSettingsSetDomain_n1();
258 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
261 TEST(VpnSetting, vpnSettingsSetDomain_n2)
266 ret = vpn.vpnSettingsSetDomain_n2();
267 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
270 TEST(VpnSetting, DISABLED_vpnCreate_p1)
275 ret = vpn.vpnCreate_p1();
276 EXPECT_EQ(VPN_ERROR_NONE, ret);
279 TEST(VpnSetting, DISABLED_vpnCreate_p2)
284 ret = vpn.vpnCreate_p2();
285 EXPECT_EQ(VPN_ERROR_NONE, ret);
288 TEST(VpnSetting, vpnCreate_n1)
293 ret = vpn.vpnCreate_n1();
294 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
297 TEST(VpnSetting, vpnCreate_n2)
302 ret = vpn.vpnCreate_n2();
303 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
306 TEST(VpnSetting, DISABLED_vpnRemove_p1)
311 ret = vpn.vpnRemove_p1();
312 EXPECT_EQ(VPN_ERROR_NONE, ret);
315 TEST(VpnSetting, DISABLED_vpnRemove_p2)
320 ret = vpn.vpnRemove_p2();
321 EXPECT_EQ(VPN_ERROR_NONE, ret);
324 TEST(VpnSetting, vpnRemove_n1)
329 ret = vpn.vpnRemove_n1();
330 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
333 TEST(VpnSetting, vpnRemove_n2)
338 ret = vpn.vpnRemove_n2();
339 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
342 TEST(VpnSetting, vpnRemove_n3)
347 ret = vpn.vpnRemove_n3();
348 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
351 TEST(VpnSetting, DISABLED_vpnConnect_p1)
356 ret = vpn.vpnConnect_p1();
357 EXPECT_EQ(VPN_ERROR_NONE, ret);
360 TEST(VpnSetting, DISABLED_vpnConnect_p2)
365 ret = vpn.vpnConnect_p2();
366 EXPECT_EQ(VPN_ERROR_NONE, ret);
369 TEST(VpnSetting, vpnConnect_n1)
374 ret = vpn.vpnConnect_n1();
375 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
378 TEST(VpnSetting, vpnConnect_n2)
383 ret = vpn.vpnConnect_n2();
384 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
387 TEST(VpnSetting, vpnConnect_n3)
392 ret = vpn.vpnConnect_n3();
393 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
396 TEST(VpnSetting, DISABLED_vpnDisconnect_p1)
401 ret = vpn.vpnDisconnect_p1();
402 EXPECT_EQ(VPN_ERROR_NONE, ret);
405 TEST(VpnSetting, DISABLED_vpnDisconnect_p2)
410 ret = vpn.vpnDisconnect_p2();
411 EXPECT_EQ(VPN_ERROR_NONE, ret);
414 TEST(VpnSetting, vpnDisconnect_n1)
419 ret = vpn.vpnDisconnect_n1();
420 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
423 TEST(VpnSetting, vpnDisconnect_n2)
428 ret = vpn.vpnDisconnect_n2();
429 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
432 TEST(VpnSetting, vpnDisconnect_n3)
437 ret = vpn.vpnDisconnect_n3();
438 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
441 TEST(VpnSetting, DISABLED_vpnGetVpnHandle_p)
446 ret = vpn.vpnGetVpnHandle_p();
447 EXPECT_EQ(VPN_ERROR_NONE, ret);
450 TEST(VpnSetting, vpnGetVpnHandle_n1)
455 ret = vpn.vpnGetVpnHandle_n1();
456 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
459 TEST(VpnSetting, vpnGetVpnHandle_n2)
464 ret = vpn.vpnGetVpnHandle_n2();
465 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
468 TEST(VpnSetting, vpnGetVpnHandle_n3)
473 ret = vpn.vpnGetVpnHandle_n3();
474 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
477 TEST(VpnSetting, vpnGetVpnHandle_n4)
482 ret = vpn.vpnGetVpnHandle_n4();
483 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
486 TEST(VpnSetting, vpnGetVpnHandle_n5)
491 ret = vpn.vpnGetVpnHandle_n5();
492 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
495 TEST(VpnSetting, vpnGetVpnHandle_n6)
500 ret = vpn.vpnGetVpnHandle_n6();
501 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
504 TEST(VpnSetting, DISABLED_vpnGetVpnInfoName_p)
509 ret = vpn.vpnGetVpnInfoName_p();
510 EXPECT_EQ(VPN_ERROR_NONE, ret);
513 TEST(VpnSetting, vpnGetVpnInfoName_n1)
518 ret = vpn.vpnGetVpnInfoName_n1();
519 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
522 TEST(VpnSetting, vpnGetVpnInfoName_n2)
527 ret = vpn.vpnGetVpnInfoName_n2();
528 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
531 TEST(VpnSetting, vpnGetVpnInfoName_n3)
536 ret = vpn.vpnGetVpnInfoName_n3();
537 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
540 TEST(VpnSetting, vpnGetVpnInfoName_n4)
545 ret = vpn.vpnGetVpnInfoName_n4();
546 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
549 TEST(VpnSetting, DISABLED_vpnGetVpnInfoType_p)
554 ret = vpn.vpnGetVpnInfoType_p();
555 EXPECT_EQ(VPN_ERROR_NONE, ret);
558 TEST(VpnSetting, vpnGetVpnInfoType_n1)
563 ret = vpn.vpnGetVpnInfoType_n1();
564 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
567 TEST(VpnSetting, vpnGetVpnInfoType_n2)
572 ret = vpn.vpnGetVpnInfoType_n2();
573 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
576 TEST(VpnSetting, vpnGetVpnInfoType_n3)
581 ret = vpn.vpnGetVpnInfoType_n3();
582 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
585 TEST(VpnSetting, vpnGetVpnInfoType_n4)
590 ret = vpn.vpnGetVpnInfoType_n4();
591 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
594 TEST(VpnSetting, DISABLED_vpnGetVpnInfoHost_p)
599 ret = vpn.vpnGetVpnInfoHost_p();
600 EXPECT_EQ(VPN_ERROR_NONE, ret);
603 TEST(VpnSetting, vpnGetVpnInfoHost_n1)
608 ret = vpn.vpnGetVpnInfoHost_n1();
609 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
612 TEST(VpnSetting, vpnGetVpnInfoHost_n2)
617 ret = vpn.vpnGetVpnInfoHost_n2();
618 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
621 TEST(VpnSetting, vpnGetVpnInfoHost_n3)
626 ret = vpn.vpnGetVpnInfoHost_n3();
627 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
630 TEST(VpnSetting, vpnGetVpnInfoHost_n4)
635 ret = vpn.vpnGetVpnInfoHost_n4();
636 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
639 TEST(VpnSetting, DISABLED_vpnGetVpnInfoDomain_p)
644 ret = vpn.vpnGetVpnInfoDomain_p();
645 EXPECT_EQ(VPN_ERROR_NONE, ret);
648 TEST(VpnSetting, vpnGetVpnInfoDomain_n1)
653 ret = vpn.vpnGetVpnInfoDomain_n1();
654 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
657 TEST(VpnSetting, vpnGetVpnInfoDomain_n2)
662 ret = vpn.vpnGetVpnInfoDomain_n2();
663 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
666 TEST(VpnSetting, vpnGetVpnInfoDomain_n3)
671 ret = vpn.vpnGetVpnInfoDomain_n3();
672 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
675 TEST(VpnSetting, vpnGetVpnInfoDomain_n4)
680 ret = vpn.vpnGetVpnInfoDomain_n4();
681 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
684 TEST(VpnSetting, vpnGetVpnHandleList_p)
689 ret = vpn.vpnGetVpnHandleList_p();
690 EXPECT_EQ(VPN_ERROR_NONE, ret);
693 TEST(VpnSetting, vpnGetVpnHandleList_n)
698 ret = vpn.vpnGetVpnHandleList_n();
699 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
702 TEST(VpnSetting, DISABLED_vpnSetStateCallback_p)
707 ret = vpn.vpnSetStateCallback_p();
708 EXPECT_EQ(VPN_ERROR_NONE, ret);
711 TEST(VpnSetting, vpnSetStateCallback_n1)
716 ret = vpn.vpnSetStateCallback_n1();
717 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
720 TEST(VpnSetting, vpnSetStateCallback_n2)
725 ret = vpn.vpnSetStateCallback_n2();
726 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
729 TEST(VpnSetting, vpnSetStateCallback_n3)
734 ret = vpn.vpnSetStateCallback_n3();
735 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
738 TEST(VpnSetting, vpnSetStateCallback_n4)
743 ret = vpn.vpnSetStateCallback_n4();
744 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
747 TEST(VpnSetting, DISABLED_vpnUnsetStateCallback_p)
752 ret = vpn.vpnUnsetStateCallback_p();
753 EXPECT_EQ(VPN_ERROR_NONE, ret);
756 TEST(VpnSetting, vpnUnsetStateCallback_n1)
761 ret = vpn.vpnUnsetStateCallback_n1();
762 EXPECT_EQ(VPN_ERROR_INVALID_OPERATION, ret);
765 TEST(VpnSetting, vpnUnsetStateCallback_n2)
770 ret = vpn.vpnUnsetStateCallback_n2();
771 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
774 TEST(VpnSetting, vpnUnsetStateCallback_n3)
779 ret = vpn.vpnUnsetStateCallback_n3();
780 EXPECT_EQ(VPN_ERROR_INVALID_PARAMETER, ret);
783 int main(int argc, char **argv)
787 #ifdef TIZEN_TEST_GCOV
788 setenv("GCOV_PREFIX", "/tmp", 1);
791 InitGoogleTest(&argc, argv);
792 ret = RUN_ALL_TESTS();
794 #ifdef TIZEN_TEST_GCOV