diff options
author | Senthil Kumar G S <senthil.gs@samsung.com> | 2019-12-04 16:30:21 +0530 |
---|---|---|
committer | Sudipto <sudipto.bal@samsung.com> | 2020-06-11 23:57:16 +0530 |
commit | 1897553fd6563f30e4841d2da608deaf569f4a91 (patch) | |
tree | ee8cda91c0ce023486f7a319370e2c8a9f771431 /service | |
parent | c0899018a662c0092a45b68da8dd6e3b8f6d65f3 (diff) | |
download | iotivity-1897553fd6563f30e4841d2da608deaf569f4a91.tar.gz iotivity-1897553fd6563f30e4841d2da608deaf569f4a91.tar.bz2 iotivity-1897553fd6563f30e4841d2da608deaf569f4a91.zip |
Add Unit Tests for EasySetup APIs.submit/tizen/20200611.232159accepted/tizen/unified/20200612.144948
UT for some of the samsung specific APIs are added.
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/633
(cherry-picked from 1798784a33171c8902d64fd5cbb083c370a04e13)
Change-Id: Ib37c3d3ce83a2272f82a43a6567dc996b0647199
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
Signed-off-by: Sudipto <sudipto.bal@samsung.com>
Diffstat (limited to 'service')
-rw-r--r-- | service/easy-setup/enrollee/SConscript | 6 | ||||
-rwxr-xr-x | service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp | 215 | ||||
-rwxr-xr-x | service/easy-setup/mediator/richsdk/SConscript | 6 |
3 files changed, 221 insertions, 6 deletions
diff --git a/service/easy-setup/enrollee/SConscript b/service/easy-setup/enrollee/SConscript index b2401f2c9..8ace91e79 100644 --- a/service/easy-setup/enrollee/SConscript +++ b/service/easy-setup/enrollee/SConscript @@ -124,10 +124,10 @@ if target_os == 'arduino': #if target_os == 'arduino': # SConscript('../sampleapp/enrollee/arduino/SConscript') -#if target_os in ['linux']: +if target_os in ['linux']: # SConscript('../sampleapp/enrollee/linux/SConscript') # SConscript('../sampleapp/enrollee/linux-samsung/SConscript') # #Build UnitTestcases for Enrollee -# if enrollee_env.get('SECURED') == '0': -# SConscript('../enrollee/unittests/SConscript') + if enrollee_env.get('SECURED') == '0': + SConscript('../enrollee/unittests/SConscript') diff --git a/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp b/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp index b041d1fe7..0a172bbfb 100755 --- a/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp +++ b/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp @@ -29,6 +29,9 @@ #include "ESMediatorSimulator.h" #include "easysetup.h" +extern "C" { +#include "samsung/sc_easysetup.h" +} using namespace OC; namespace @@ -532,3 +535,215 @@ TEST_F(EasysetupEnrolleeTest, ESSetCallabckForUserDataFailed) EXPECT_EQ(ret, ES_ERROR); ESTerminateEnrollee(); } + +TEST_F(EasysetupEnrolleeTest, ESSC_SetSCProperties) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + SCProperties properties; + strncpy(properties.candidateAPInfo[0].ssid, "x_5GHz", MAXLEN_STRING); + strncpy(properties.candidateAPInfo[0].passphrase, "12345678",MAXLEN_STRING); + properties.candidateAPInfo[0].channel = 149; + strncpy(properties.candidateAPInfo[0].bssid, "aa:bb:cc:dd:ee:01", MAXLEN_STRING); + strncpy(properties.candidateAPInfo[1].ssid, "5GHz", MAXLEN_STRING); + strncpy(properties.candidateAPInfo[1].passphrase, "12345678",MAXLEN_STRING); + properties.candidateAPInfo[1].channel = 161; + strncpy(properties.candidateAPInfo[1].bssid, "aa:bb:cc:dd:ee:02", MAXLEN_STRING); + properties.numCandidateAP=2; + + ret = SetSCProperties(&properties); + EXPECT_EQ(ret, ES_OK); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetNULLSCProperties) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetSCProperties(NULL); + EXPECT_EQ(ret, ES_ERROR); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetTncInfo) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + SCTncInfo info; + strncpy(info.header, "h1", MAXLEN_STRING); + strncpy(info.version, "v1",MAXLEN_STRING); + + ret = SetSCTncInfo(&info); + EXPECT_EQ(ret, ES_OK); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetNULLTncInfo) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetSCTncInfo(NULL); + EXPECT_EQ(ret, ES_ERROR); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetTncStatus) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetSCTncStatus(1); + EXPECT_EQ(ret, ES_OK); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetSCNetConnectionState) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetSCNetConnectionState(NET_STATE_INIT); + EXPECT_EQ(ret, ES_OK); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetRegisterSetDevice) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetRegisterSetDevice("fridge"); + EXPECT_EQ(ret, ES_OK); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetNULLRegisterSetDevice) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetRegisterSetDevice(NULL); + EXPECT_EQ(ret, ES_ERROR); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetNetworkProvInfo) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetNetworkProvInfo("netInfo"); + EXPECT_EQ(ret, ES_OK); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetNULLSetNetworkProvInfo) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetNetworkProvInfo(NULL); + EXPECT_EQ(ret, ES_ERROR); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetSCPnPPin) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetSCPnPPin("123456"); + EXPECT_EQ(ret, ES_OK); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetNULLSCPnPPin) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetSCPnPPin(NULL); + EXPECT_EQ(ret, ES_ERROR); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetESVersionInfo) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetESVersionInfo("1.0"); + EXPECT_EQ(ret, ES_OK); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetNULLESVersionInfo) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetESVersionInfo(NULL); + EXPECT_EQ(ret, ES_ERROR); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetSSOList) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetSSOList("xyz"); + EXPECT_EQ(ret, ES_OK); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ESSC_SetNULLSSOList) +{ + ESResult ret = startEnrollee(); + EXPECT_EQ(ret, ES_OK); + + ret = SetSSOList(NULL); + EXPECT_EQ(ret, ES_ERROR); + ESTerminateEnrollee(); +} + +TEST_F(EasysetupEnrolleeTest, ReadWriteUserCallback) +{ + int cntForReceivedCallbackWithSuccess = 0; + + mocks.OnCallFunc(deviceProvisioningStatusCallback).Do( + [& cntForReceivedCallbackWithSuccess](std::shared_ptr< DevicePropProvisioningStatus > status) + { + if(status->getESResult() == ES_OK) + cntForReceivedCallbackWithSuccess++; + }); + + mocks.OnCallFunc(WiFiConfProvCbInApp).Do( + [& cntForReceivedCallbackWithSuccess](ESWiFiConfData *data) + { + if(!strcmp(data->ssid, "Iotivity_SSID") && + !strcmp(data->pwd, "Iotivity_PWD") && + data->authtype == WPA2_PSK && + data->enctype == TKIP_AES) + { + cntForReceivedCallbackWithSuccess++; + } + }); + + startEnrollee(); + + EXPECT_EQ(ESSetCallbackForUserdata(&ReadUserdataCb, &WriteUserdataCb), ES_OK); + + g_mediatorSimul.provisionDeviceProperties(deviceProvisioningStatusCallback); + + std::unique_lock< std::mutex > lock{ mutexForCondition }; + responseCon.wait_for(lock, g_waitForResponse); + + EXPECT_EQ(cntForReceivedCallbackWithSuccess, 2); + + ESTerminateEnrollee(); +} + diff --git a/service/easy-setup/mediator/richsdk/SConscript b/service/easy-setup/mediator/richsdk/SConscript index eaf542234..585b1ff49 100755 --- a/service/easy-setup/mediator/richsdk/SConscript +++ b/service/easy-setup/mediator/richsdk/SConscript @@ -173,7 +173,7 @@ if target_os in ['android']: ###################################################################### #Build UnitTestcases for Mediator[RichSDK] ################################################ ###################### -#if env.get('SECURED') == '0': -# if target_os == 'linux': -# SConscript('unittests/SConscript') +if env.get('SECURED') == '0': + if target_os == 'linux': + SConscript('unittests/SConscript') |