From c789a5e07767455c8919d61770004744d7a9c2b6 Mon Sep 17 00:00:00 2001 From: Jay Sharma Date: Fri, 18 Mar 2016 20:29:58 +0530 Subject: [PATCH] [Easy-setup] Unit test case fixes for Mediator Change-Id: Ibcdfe23ee7887d72ac86acdad9b32c8674de8702 Signed-off-by: Jay Sharma Reviewed-on: https://gerrit.iotivity.org/gerrit/6083 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- .../richsdk/unittests/MediatorRichTest.cpp | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/service/easy-setup/mediator/richsdk/unittests/MediatorRichTest.cpp b/service/easy-setup/mediator/richsdk/unittests/MediatorRichTest.cpp index d6e24c7..9992059 100644 --- a/service/easy-setup/mediator/richsdk/unittests/MediatorRichTest.cpp +++ b/service/easy-setup/mediator/richsdk/unittests/MediatorRichTest.cpp @@ -225,11 +225,15 @@ TEST_F(MediatorRichTest, testStartProvisioning) remoteEnrollee = EasySetup::getInstance()->createEnrolleeDevice(netInfo, onboardingConn); remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback); - /*It will throw an exception, - * as it will not be able to discover the provisioning resource - * in the network - */ +#ifdef REMOTE_ARDUINO_ENROLEE + EXPECT_NO_THROW(remoteEnrollee->startProvisioning()); + +#else + /* It will throw the exception + * as it will not able to discover the provisioning resource in the network + */ EXPECT_ANY_THROW(remoteEnrollee->startProvisioning()); +#endif } //startProvisioning [Negative] @@ -250,9 +254,9 @@ TEST_F(MediatorRichTest, testStartProvisioningNegative) remoteEnrollee = EasySetup::getInstance()->createEnrolleeDevice(netInfo, onboardingConn); - /*We are not registering the EasySetupStatusHandler that is why startProvisioning - will throw the Exception & we are checking the same - */ + /* We are not registering the EasySetupStatusHandler, so startProvisioning + * will throw the Exception & we are checking the same + */ EXPECT_ANY_THROW(remoteEnrollee->startProvisioning()); } @@ -275,10 +279,21 @@ TEST_F(MediatorRichTest, testStopProvisioning) remoteEnrollee = EasySetup::getInstance()->createEnrolleeDevice(netInfo, onboardingConn); remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback); - /* It will throw an exception, - * as we are calling stop provisioning api before start provisioning. +#ifdef REMOTE_ARDUINO_ENROLEE + EXPECT_NO_THROW(remoteEnrollee->startProvisioning()); + EXPECT_NO_THROW(remoteEnrollee->stopProvisioning()); + +#else + /* It will throw the exception as + * it will not able to discover the provisioning resource in the network + */ + EXPECT_ANY_THROW(remoteEnrollee->startProvisioning()); + + /* It will throw an exception + * as internally resource will be empty [startProvisioning is not succeed] */ EXPECT_ANY_THROW(remoteEnrollee->stopProvisioning()); +#endif } //stopProvisioning [Negative] @@ -301,8 +316,8 @@ TEST_F(MediatorRichTest, testStopProvisioningNegative) remoteEnrollee->registerEasySetupStatusHandler(&easySetupStatusCallback); /* we didn't call the start provisioning API and directly calling stopProvisioning API. - In this case API will throw the exception & we are checking the same. - */ + * In this case API will throw the exception & we are checking the same. + */ EXPECT_ANY_THROW(remoteEnrollee->stopProvisioning()); } -- 2.7.4