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)
61 /* Test cases for prov_adapter*/
64 TEST_F(MediatorCSDKTest, testInitProvProcess)
66 OCStackResult result = InitProvProcess();
67 ASSERT_EQ(OC_STACK_OK, result);
71 TEST_F(MediatorCSDKTest, testResetProvProcess)
73 OCStackResult result = ResetProvProcess();
74 ASSERT_EQ(OC_STACK_OK, result);
77 //RegisterCallback [positive]
78 TEST_F(MediatorCSDKTest, testRegisterCallback)
80 OCStackResult result = RegisterCallback(&OCProvisioningStatusCallback);
81 ASSERT_EQ(OC_STACK_OK, result);
84 //RegisterCallback [Negative]
85 TEST_F(MediatorCSDKTest, testRegisterCallbackNegative)
87 OCStackResult result = RegisterCallback(NULL);
88 ASSERT_EQ(OC_STACK_ERROR, result);
91 //StartProvisioning [positive]
92 TEST_F(MediatorCSDKTest, testStartProvisioning)
94 ProvConfig provConfig;
95 WiFiOnboadingConnection onboardConn;
97 strncpy(onboardConn.ipAddress, "1.1.1.1", IPV4_ADDR_SIZE - 1);
99 strncpy(provConfig.provData.WIFI.ssid, "testAP", NET_WIFI_SSID_SIZE - 1);
100 strncpy(provConfig.provData.WIFI.pwd, "test@123", NET_WIFI_PWD_SIZE - 1);
101 provConfig.connType = CT_ADAPTER_IP;
104 OCStackResult result = StartProvisioning(&provConfig, &onboardConn);
106 ASSERT_EQ(OC_STACK_OK, result);
109 //StartProvisioning [Negative]
110 TEST_F(MediatorCSDKTest, testStartProvisioningNegative)
112 OCStackResult result = StartProvisioning(NULL, NULL);
113 ASSERT_EQ(OC_STACK_ERROR, result);
117 TEST_F(MediatorCSDKTest, testStopProvisioning)
119 // This API always return success
120 OCStackResult result = StopProvisioning(CT_ADAPTER_IP);
121 ASSERT_EQ(OC_STACK_OK, result);