1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "UnitTestHelper.h"
24 #include "OCPlatform.h"
26 #include "oic_string.h"
29 #include "provisioningapi.h"
30 #include "provisioning.h"
37 #include <condition_variable>
39 class MediatorCSDKTest: public TestWithMock
45 TestWithMock::SetUp();
50 TestWithMock::TearDown();
56 void OCProvisioningStatusCallback(EasySetupInfo *easySetupInfo) {
57 OC_UNUSED(easySetupInfo);
60 /* Test cases for prov_adapter*/
63 TEST_F(MediatorCSDKTest, testInitProvProcess)
65 OCStackResult result = InitProvProcess();
66 ASSERT_EQ(OC_STACK_OK, result);
70 TEST_F(MediatorCSDKTest, testResetProvProcess)
72 OCStackResult result = ResetProvProcess();
73 ASSERT_EQ(OC_STACK_OK, result);
76 //RegisterCallback [positive]
77 TEST_F(MediatorCSDKTest, testRegisterCallback)
79 OCStackResult result = RegisterCallback(&OCProvisioningStatusCallback);
80 ASSERT_EQ(OC_STACK_OK, result);
83 //RegisterCallback [Negative]
84 TEST_F(MediatorCSDKTest, testRegisterCallbackNegative)
86 OCStackResult result = RegisterCallback(NULL);
87 ASSERT_EQ(OC_STACK_ERROR, result);
90 //StartProvisioning [positive]
91 TEST_F(MediatorCSDKTest, testStartProvisioning)
93 ProvConfig provConfig;
94 WiFiOnboadingConnection onboardConn;
96 strncpy(onboardConn.ipAddress, "1.1.1.1", IPV4_ADDR_SIZE - 1);
98 strncpy(provConfig.provData.WIFI.ssid, "testAP", NET_WIFI_SSID_SIZE - 1);
99 strncpy(provConfig.provData.WIFI.pwd, "test@123", NET_WIFI_PWD_SIZE - 1);
100 provConfig.connType = CT_ADAPTER_IP;
103 OCStackResult result = StartProvisioning(&provConfig, &onboardConn);
105 ASSERT_EQ(OC_STACK_OK, result);
108 //StartProvisioning [Negative]
109 TEST_F(MediatorCSDKTest, testStartProvisioningNegative)
111 OCStackResult result = StartProvisioning(NULL, NULL);
112 ASSERT_EQ(OC_STACK_ERROR, result);
116 TEST_F(MediatorCSDKTest, testStopProvisioning)
118 // This API always return success
119 OCStackResult result = StopProvisioning(CT_ADAPTER_IP);
120 ASSERT_EQ(OC_STACK_OK, result);