//-----------------------------------------------------------------------------
static const char TAG[] = "TestHarness";
+char gDeviceUUID[] = "myDeviceUUID";
+char gManufacturerName[] = "myName";
+char gTooLongManufacturerName[] = "extremelylongmanufacturername";
+char gManufacturerUrl[] = "www.foooooooooooooooo.baaaaaaaaaaaaar";
+static OCPrm_t pmSel;
+static char pinNumber;
+static OCDPDev_t peer;
+
std::chrono::seconds const SHORT_TEST_TIMEOUT = std::chrono::seconds(5);
//-----------------------------------------------------------------------------
// Callback functions
//-----------------------------------------------------------------------------
-extern "C" OCStackApplicationResult asyncDoResourcesCallback(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse)
+extern "C" OCStackApplicationResult asyncDoResourcesCallback(void* ctx,
+ OCDoHandle /*handle*/, OCClientResponse * clientResponse)
{
- OC_LOG(INFO, TAG, "Entering asyncDoResourcesCallback");
+ OIC_LOG(INFO, TAG, "Entering asyncDoResourcesCallback");
EXPECT_EQ(OC_STACK_OK, clientResponse->result);
if(ctx == (void*)DEFAULT_CONTEXT_VALUE) {
- OC_LOG_V(INFO, TAG, "Callback Context recvd successfully");
+ OIC_LOG_V(INFO, TAG, "Callback Context recvd successfully");
+ }
+ OIC_LOG_V(INFO, TAG, "result = %d", clientResponse->result);
+
+ return OC_STACK_KEEP_TRANSACTION;
+}
+
+static void resultCallback(OCDPDev_t *UNUSED1, OCStackResult UNUSED2)
+{
+ (void) (UNUSED1);
+ (void) (UNUSED2);
+}
+
+extern "C" OCStackApplicationResult discoveryCallback(void* ctx,
+ OCDoHandle /*handle*/, OCClientResponse * clientResponse)
+{
+ OIC_LOG(INFO, TAG, "Entering asyncDoResourcesCallback");
+
+ EXPECT_EQ(OC_STACK_OK, clientResponse->result);
+
+ if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
+ {
+ OIC_LOG_V(INFO, TAG, "Callback Context recvd successfully");
+ }
+
+ OIC_LOG_V(INFO, TAG, "result = %d", clientResponse->result);
+
+ OCDiscoveryPayload *discoveryPayload = ((OCDiscoveryPayload *) clientResponse->payload);
+ EXPECT_TRUE(discoveryPayload != NULL);
+ OCResourcePayload *res = discoveryPayload->resources;
+ size_t count = 0;
+ for (OCResourcePayload *res1 = discoveryPayload->resources; res1; res1 = res1->next)
+ {
+ count++;
}
- OC_LOG_V(INFO, TAG, "result = %d", clientResponse->result);
+ EXPECT_EQ(3, count);
+ EXPECT_EQ("/a/led1", res->uri);
+ res = res->next;
+ EXPECT_EQ("/a/led2", res->uri);
+ res = res->next;
+ EXPECT_EQ("/a/led3", res->uri);
+ res = res->next;
+ EXPECT_TRUE(res == NULL);
return OC_STACK_KEEP_TRANSACTION;
}
//-----------------------------------------------------------------------------
// Entity handler
//-----------------------------------------------------------------------------
-OCEntityHandlerResult entityHandler(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest,
- void* callbackParam)
+OCEntityHandlerResult entityHandler(OCEntityHandlerFlag /*flag*/,
+ OCEntityHandlerRequest * /*entityHandlerRequest*/,
+ void* /*callbackParam*/)
{
- OC_LOG(INFO, TAG, "Entering entityHandler");
+ OIC_LOG(INFO, TAG, "Entering entityHandler");
return OC_EH_OK;
}
//-----------------------------------------------------------------------------
void InitStack(OCMode mode)
{
- OC_LOG(INFO, TAG, "Entering InitStack");
+ OIC_LOG(INFO, TAG, "Entering InitStack");
EXPECT_EQ(OC_STACK_OK, OCInit(NULL, 0, mode));
- OC_LOG(INFO, TAG, "Leaving InitStack");
+ OIC_LOG(INFO, TAG, "Leaving InitStack");
}
uint8_t InitNumExpectedResources()
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
- OCPlatformInfo info = {};
- info.platformID = (char *) "platform_id";
- info.manufacturerName = (char *) "manufac_name";
-
+ OCPlatformInfo info =
+ {
+ gDeviceUUID,
+ gManufacturerName,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
EXPECT_EQ(OC_STACK_OK, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
}
+TEST(StackStart, SetPlatformInfoWithClientMode)
+{
+ itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
+ EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_CLIENT));
+
+ OCPlatformInfo info =
+ {
+ gDeviceUUID,
+ gManufacturerName,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ EXPECT_EQ(OC_STACK_ERROR, OCSetPlatformInfo(info));
+ EXPECT_EQ(OC_STACK_OK, OCStop());
+}
+
TEST(StackStart, SetPlatformInfoWithNoPlatformID)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
- OCPlatformInfo info = {};
- info.manufacturerName = (char *) "manufac_name";
+ OCPlatformInfo info =
+ {
+ 0,
+ gDeviceUUID,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
- OCPlatformInfo info = {};
- info.platformID = (char *) "platform_id";
+ OCPlatformInfo info =
+ {
+ gDeviceUUID,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
- OCPlatformInfo info = {};
- info.platformID = (char *) "platform_id";
+ OCPlatformInfo info =
+ {
+ gDeviceUUID,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
info.manufacturerName = (char *) "";
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetPlatformInfo(info));
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
- OCPlatformInfo info = {};
- info.platformID = (char *) "platform_id";
- info.manufacturerName = (char *) "extremelylongmanufacturername";
+ OCPlatformInfo info =
+ {
+ gDeviceUUID,
+ gTooLongManufacturerName,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
-
- OCPlatformInfo info = {};
- info.platformID = (char *) "platform_id";
- info.manufacturerName = (char *) "extremelylongmanufacturername";
- info.manufacturerUrl = (char *)"www.foooooooooooooooo.baaaaaaaaaaaaar";
+ OCPlatformInfo info =
+ {
+ gDeviceUUID,
+ gManufacturerName,
+ gManufacturerUrl,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ };
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
}
-
TEST(StackDiscovery, DISABLED_DoResourceDeviceDiscovery)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
OCCallbackData cbData;
OCDoHandle handle;
- OC_LOG(INFO, TAG, "Starting DoResourceDeviceDiscovery test ");
+ OIC_LOG(INFO, TAG, "Starting DoResourceDeviceDiscovery test ");
InitStack(OC_CLIENT);
/* Start a discovery query*/
char szQueryUri[64] = { 0 };
- strcpy(szQueryUri, OC_WELL_KNOWN_QUERY);
+ strcpy(szQueryUri, OC_RSRVD_WELL_KNOWN_URI);
cbData.cb = asyncDoResourcesCallback;
cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
cbData.cd = NULL;
OCCallbackData cbData;
OCDoHandle handle;
- OC_LOG(INFO, TAG, "Starting UpdateResourceNullURI test");
+ OIC_LOG(INFO, TAG, "Starting UpdateResourceNullURI test");
InitStack(OC_CLIENT);
/* Start a discovery query*/
char szQueryUri[64] = { 0 };
- strcpy(szQueryUri, OC_WELL_KNOWN_QUERY);
+ strcpy(szQueryUri, OC_RSRVD_WELL_KNOWN_URI);
cbData.cb = asyncDoResourcesCallback;
cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
cbData.cd = NULL;
TEST(StackResource, CreateResourceBadParams)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceBadParams test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceBadParams test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, CreateResourceBadUri)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceBadUri test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceBadUri test");
InitStack(OC_SERVER);
const char *uri65 = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL";
TEST(StackResource, CreateResourceSuccess)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceSuccess test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceSuccess test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, CreateResourceSuccessWithResourcePolicyPropNone)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceSuccessWithResourcePolicyPropNone test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceSuccessWithResourcePolicyPropNone test");
InitStack(OC_SERVER);
OCResourceHandle handle;
"core.led",
"core.rw",
"/a/led",
- 0,
- NULL,
+ 0,
+ NULL,
OC_RES_PROP_NONE));// the resource is non-discoverable &
// non-observable by the client.
const char* url = OCGetResourceUri(handle);
TEST(StackResource, CreateResourceWithClientStackMode)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceSuccess test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceSuccess test");
InitStack(OC_CLIENT);
OCResourceHandle handle;
TEST(StackResource, CreateResourceFailDuplicateUri)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceFailDuplicateUri test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceFailDuplicateUri test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, CreateResourceMultipleResources)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceMultipleResources test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceMultipleResources test");
InitStack(OC_SERVER);
OCResourceHandle handle1;
TEST(StackResource, CreateResourceBadResoureType)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceBadResoureType test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceBadResoureType test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, CreateResourceGoodResourceType)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceGoodResourceType test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceGoodResourceType test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, ResourceTypeName)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceTypeName test");
+ OIC_LOG(INFO, TAG, "Starting ResourceTypeName test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, ResourceTypeAttrRepresentation)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceTypeAttrRepresentation test");
+ OIC_LOG(INFO, TAG, "Starting ResourceTypeAttrRepresentation test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, ResourceTypeInterface)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceTypeInterface test");
+ OIC_LOG(INFO, TAG, "Starting ResourceTypeInterface test");
InitStack(OC_SERVER);
OCResourceHandle handle;
uint8_t numResourceInterfaces;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle, &numResourceInterfaces));
- EXPECT_EQ(1, numResourceInterfaces);
- const char *resourceInterfaceName = OCGetResourceInterfaceName(handle, 0);
+ EXPECT_EQ(2, numResourceInterfaces);
+ const char *resourceInterfaceName1 = OCGetResourceInterfaceName(handle, 0);
+ EXPECT_STREQ(OC_RSRVD_INTERFACE_DEFAULT, resourceInterfaceName1);
+ const char *resourceInterfaceName = OCGetResourceInterfaceName(handle, 1);
EXPECT_STREQ("core.rw", resourceInterfaceName);
// try getting resource interface names with an invalid index
- resourceInterfaceName = OCGetResourceInterfaceName(handle, 1);
+ resourceInterfaceName = OCGetResourceInterfaceName(handle, 2);
EXPECT_STREQ(NULL, resourceInterfaceName);
// try getting resource interface names with an invalid index
resourceInterfaceName = OCGetResourceInterfaceName(handle, 10);
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceDefaultInterfaceAlwaysFirst test");
+ OIC_LOG(INFO, TAG, "Starting ResourceDefaultInterfaceAlwaysFirst test");
InitStack(OC_SERVER);
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceDuplicateDefaultInterfaces test");
+ OIC_LOG(INFO, TAG, "Starting ResourceDuplicateDefaultInterfaces test");
InitStack(OC_SERVER);
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceDuplicateInterfaces test");
+ OIC_LOG(INFO, TAG, "Starting ResourceDuplicateInterfaces test");
InitStack(OC_SERVER);
uint8_t numResourceInterfaces;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle, &numResourceInterfaces));
- EXPECT_EQ(1, numResourceInterfaces);
+ EXPECT_EQ(2, numResourceInterfaces);
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackResource, ResourceTypeInterfaceMethods)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceTypeInterfaceMethods test");
+ OIC_LOG(INFO, TAG, "Starting ResourceTypeInterfaceMethods test");
InitStack(OC_SERVER);
OCResourceHandle handle;
uint8_t numResourceInterfaces;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle, &numResourceInterfaces));
- EXPECT_EQ(1, numResourceInterfaces);
+ EXPECT_EQ(2, numResourceInterfaces);
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackResource, GetResourceProperties)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting GetResourceProperties test");
+ OIC_LOG(INFO, TAG, "Starting GetResourceProperties test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, StackTestResourceDiscoverOneResourceBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverOneResourceBad test");
+ OIC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverOneResourceBad test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResources(&numResources));
TEST(StackResource, StackTestResourceDiscoverOneResource)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverOneResource test");
+ OIC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverOneResource test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, StackTestResourceDiscoverManyResources)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverManyResources test");
+ OIC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverManyResources test");
InitStack(OC_SERVER);
OCResourceHandle handle1;
TEST(StackBind, BindResourceTypeNameBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceTypeNameBad test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceTypeNameBad test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindResourceTypeNameGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceTypeNameGood test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceTypeNameGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindResourceTypeAttribRepGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceTypeAttribRepGood test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceTypeAttribRepGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindResourceInterfaceNameBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceInterfaceNameBad test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceInterfaceNameBad test");
InitStack(OC_SERVER);
OCResourceHandle handle;
uint8_t numResourceInterfaces;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle, &numResourceInterfaces));
- EXPECT_EQ(1, numResourceInterfaces);
- const char *resourceInterfaceName = OCGetResourceInterfaceName(handle, 0);
+ EXPECT_EQ(2, numResourceInterfaces);
+ const char *resourceInterfaceName = OCGetResourceInterfaceName(handle, 1);
EXPECT_STREQ("core.rw", resourceInterfaceName);
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCBindResourceInterfaceToResource(handle, NULL));
TEST(StackBind, BindResourceInterfaceNameGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceInterfaceNameGood test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceInterfaceNameGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
uint8_t numResourceInterfaces;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle, &numResourceInterfaces));
- EXPECT_EQ(1, numResourceInterfaces);
- const char *resourceInterfaceName = OCGetResourceInterfaceName(handle, 0);
+ EXPECT_EQ(2, numResourceInterfaces);
+ const char *resourceInterfaceName = OCGetResourceInterfaceName(handle, 1);
EXPECT_STREQ("core.rw", resourceInterfaceName);
EXPECT_EQ(OC_STACK_OK, OCBindResourceInterfaceToResource(handle, "core.r"));
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle, &numResourceInterfaces));
- EXPECT_EQ(2, numResourceInterfaces);
- resourceInterfaceName = OCGetResourceInterfaceName(handle, 1);
+ EXPECT_EQ(3, numResourceInterfaces);
+ resourceInterfaceName = OCGetResourceInterfaceName(handle, 2);
EXPECT_STREQ("core.r", resourceInterfaceName);
EXPECT_EQ(OC_STACK_OK, OCStop());
TEST(StackBind, BindResourceInterfaceMethodsBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceInterfaceMethodsBad test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceInterfaceMethodsBad test");
InitStack(OC_SERVER);
OCResourceHandle handle;
uint8_t numResourceInterfaces;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle, &numResourceInterfaces));
- EXPECT_EQ(1, numResourceInterfaces);
+ EXPECT_EQ(2, numResourceInterfaces);
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCBindResourceInterfaceToResource(handle, 0));
TEST(StackBind, BindResourceInterfaceMethodsGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceInterfaceMethodsGood test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceInterfaceMethodsGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
uint8_t numResourceInterfaces;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle, &numResourceInterfaces));
- EXPECT_EQ(1, numResourceInterfaces);
+ EXPECT_EQ(2, numResourceInterfaces);
EXPECT_EQ(OC_STACK_OK, OCBindResourceInterfaceToResource(handle, "core.r"));
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle, &numResourceInterfaces));
- EXPECT_EQ(2, numResourceInterfaces);
+ EXPECT_EQ(3, numResourceInterfaces);
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackBind, BindContainedResourceBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindContainedResourceBad test");
+ OIC_LOG(INFO, TAG, "Starting BindContainedResourceBad test");
InitStack(OC_SERVER);
OCResourceHandle containerHandle;
TEST(StackBind, BindContainedResourceGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindContainedResourceGood test");
+ OIC_LOG(INFO, TAG, "Starting BindContainedResourceGood test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
EXPECT_EQ(OC_STACK_OK, OCBindResource(containerHandle, handle2));
EXPECT_EQ(OC_STACK_OK, OCBindResource(containerHandle, handle3));
EXPECT_EQ(OC_STACK_OK, OCBindResource(containerHandle, handle4));
- EXPECT_EQ(OC_STACK_ERROR, OCBindResource(containerHandle, handle5));
+ EXPECT_EQ(OC_STACK_OK, OCBindResource(containerHandle, handle5));
EXPECT_EQ(handle0, OCGetResourceHandleFromCollection(containerHandle, 0));
EXPECT_EQ(handle1, OCGetResourceHandleFromCollection(containerHandle, 1));
EXPECT_EQ(handle2, OCGetResourceHandleFromCollection(containerHandle, 2));
EXPECT_EQ(handle3, OCGetResourceHandleFromCollection(containerHandle, 3));
EXPECT_EQ(handle4, OCGetResourceHandleFromCollection(containerHandle, 4));
-
- EXPECT_EQ(NULL, OCGetResourceHandleFromCollection(containerHandle, 5));
+ EXPECT_EQ(handle5, OCGetResourceHandleFromCollection(containerHandle, 5));
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackBind, BindEntityHandlerBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindEntityHandlerBad test");
+ OIC_LOG(INFO, TAG, "Starting BindEntityHandlerBad test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindEntityHandlerGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindEntityHandlerGood test");
+ OIC_LOG(INFO, TAG, "Starting BindEntityHandlerGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResourceAccess, GetResourceByIndex)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting GetResourceByIndex test");
+ OIC_LOG(INFO, TAG, "Starting GetResourceByIndex test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
TEST(StackResourceAccess, DeleteHeadResource)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting DeleteHeadResource test");
+ OIC_LOG(INFO, TAG, "Starting DeleteHeadResource test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
TEST(StackResourceAccess, DeleteHeadResource2)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting DeleteHeadResource2 test");
+ OIC_LOG(INFO, TAG, "Starting DeleteHeadResource2 test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
TEST(StackResourceAccess, DeleteLastResource)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting DeleteLastResource test");
+ OIC_LOG(INFO, TAG, "Starting DeleteLastResource test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
TEST(StackResourceAccess, DeleteMiddleResource)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting DeleteMiddleResource test");
+ OIC_LOG(INFO, TAG, "Starting DeleteMiddleResource test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
// Make sure the resource elements are still correct
uint8_t numResourceInterfaces;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResourceInterfaces(handle2, &numResourceInterfaces));
- EXPECT_EQ(1, numResourceInterfaces);
- const char *resourceInterfaceName = OCGetResourceInterfaceName(handle2, 0);
+ EXPECT_EQ(2, numResourceInterfaces);
+ const char *resourceInterfaceName = OCGetResourceInterfaceName(handle2, 1);
EXPECT_STREQ("core.rw", resourceInterfaceName);
EXPECT_EQ(OC_STACK_OK, OCStop());
{
EXPECT_TRUE(std::is_pod<OCHeaderOption>::value);
}
+
+TEST(OCDoDirectPairingTests, Nullpeer)
+{
+ EXPECT_EQ(OC_STACK_INVALID_PARAM,OCDoDirectPairing(NULL, pmSel, &pinNumber, &resultCallback));
+}
+
+TEST(OCDoDirectPairingTests, NullCallback)
+{
+ EXPECT_EQ(OC_STACK_INVALID_CALLBACK,OCDoDirectPairing(&peer, pmSel, &pinNumber, NULL));
+}
+
+TEST(OCDoDirectPairingTests, NullpinNumber)
+{
+ EXPECT_EQ(OC_STACK_INVALID_PARAM,OCDoDirectPairing(&peer, pmSel, NULL, &resultCallback));
+}
+
+TEST(StackResource, MultipleResourcesDiscovery)
+{
+ itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
+ OIC_LOG(INFO, TAG, "Starting MultipleResourcesDiscovery test");
+ InitStack(OC_SERVER);
+
+ OCResourceHandle handle1;
+ EXPECT_EQ(OC_STACK_OK, OCCreateResource(&handle1,
+ "core.led",
+ "core.rw",
+ "/a/led1",
+ 0,
+ NULL,
+ OC_DISCOVERABLE|OC_OBSERVABLE));
+
+ OCResourceHandle handle2;
+ EXPECT_EQ(OC_STACK_OK, OCCreateResource(&handle2,
+ "core.led",
+ "core.rw",
+ "/a/led2",
+ 0,
+ NULL,
+ OC_DISCOVERABLE|OC_OBSERVABLE));
+ OCResourceHandle handle3;
+ EXPECT_EQ(OC_STACK_OK, OCCreateResource(&handle3,
+ "core.led",
+ "core.rw",
+ "/a/led3",
+ 0,
+ NULL,
+ OC_DISCOVERABLE|OC_OBSERVABLE));
+ /* Start a discovery query*/
+ char szQueryUri[256] = "/oic/res?if=oic.if.ll";
+ OCCallbackData cbData;
+ cbData.cb = discoveryCallback;
+ cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
+ cbData.cd = NULL;
+
+ OCDoHandle handle;
+ EXPECT_EQ(OC_STACK_OK, OCDoResource(&handle,
+ OC_REST_DISCOVER,
+ szQueryUri,
+ 0,
+ 0,
+ CT_ADAPTER_IP,
+ OC_LOW_QOS,
+ &cbData,
+ NULL,
+ 0));
+
+ EXPECT_EQ(OC_STACK_OK, OCStop());
+}