1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH 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 <OCPlatform.h>
23 #include <gtest/gtest.h>
25 namespace OCPlatformTest
29 const OCResourceHandle HANDLE_ZERO = 0;
30 const std::string gResourceTypeName = "core.res";
31 const std::string gResourceInterface = DEFAULT_INTERFACE;
32 const uint8_t gResourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
33 OCResourceHandle resourceHandle;
36 OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> request)
41 void foundResource(std::shared_ptr<OCResource> resource)
45 void receivedDeviceInfo(const OCRepresentation& rep)
49 void presenceHandler(OCStackResult result,
50 const unsigned int nonce, const std::string& hostAddress)
55 void DeleteDeviceInfo(OCDeviceInfo deviceInfo)
57 delete[] deviceInfo.deviceName;
61 void DuplicateString(char ** targetString, std::string sourceString)
63 *targetString = new char[sourceString.length() + 1];
64 strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));
67 OCResourceHandle RegisterResource(std::string uri, std::string type, std::string iface)
69 PlatformConfig cfg = {};
70 OCPlatform::Configure(cfg);
71 EXPECT_EQ(OC_STACK_OK,OCPlatform::registerResource(
72 resourceHandle, uri, type,
73 iface, entityHandler, gResourceProperty));
74 return resourceHandle;
77 OCResourceHandle RegisterResource(std::string uri, std::string type)
79 PlatformConfig cfg = {};
80 OCPlatform::Configure(cfg);
81 EXPECT_EQ(OC_STACK_OK, OCPlatform::registerResource(
82 resourceHandle, uri, type,
83 gResourceInterface, entityHandler, gResourceProperty));
84 return resourceHandle;
87 OCResourceHandle RegisterResource(std::string uri)
89 PlatformConfig cfg = {};
90 OCPlatform::Configure(cfg);
91 EXPECT_EQ(OC_STACK_OK, OCPlatform::registerResource(
92 resourceHandle, uri, gResourceTypeName,
93 gResourceInterface, entityHandler, gResourceProperty));
94 return resourceHandle;
98 // Enable it when the stack throw an exception
99 // https://jira.iotivity.org/browse/IOT-428
100 TEST(ConfigureTest, DISABLED_ConfigureInvalidModeType)
103 OC::ServiceType::InProc,
107 OC::QualityOfService::LowQos
109 OCPlatform::Configure(cfg);
110 EXPECT_ANY_THROW(OCPlatform::setDefaultDeviceEntityHandler(NULL));
113 // Enable it when the stack throw an exception
114 // https://jira.iotivity.org/browse/IOT-428
115 TEST(ConfigureTest, DISABLED_ConfigureInvalidServiceType)
119 OC::ModeType::Client,
122 OC::QualityOfService::LowQos
124 OCPlatform::Configure(cfg);
125 EXPECT_ANY_THROW(OCPlatform::setDefaultDeviceEntityHandler(NULL));
128 // Enable it when the stack throw an exception
129 // https://jira.iotivity.org/browse/IOT-428
130 TEST(ConfigureTest, DISABLED_ConfigureClientOutProc)
133 OC::ServiceType::OutOfProc,
134 OC::ModeType::Client,
137 OC::QualityOfService::LowQos
139 std::string uri = "/a/light66";
140 std::string type = "core.light";
141 uint8_t gResourceProperty = 0;
142 OCPlatform::Configure(cfg);
143 EXPECT_ANY_THROW(OCPlatform::registerResource(
144 resourceHandle, uri, type,
145 gResourceInterface, entityHandler, gResourceProperty));
148 TEST(ConfigureTest, ConfigureServerOutProc)
151 OC::ServiceType::OutOfProc,
152 OC::ModeType::Server,
155 OC::QualityOfService::LowQos
157 std::string uri = "/a/light67";
158 std::string type = "core.light";
159 uint8_t gResourceProperty = 0;
160 OCPlatform::Configure(cfg);
162 EXPECT_ANY_THROW(OCPlatform::registerResource(
163 resourceHandle, uri, type,
164 gResourceInterface, entityHandler, gResourceProperty));
167 TEST(ConfigureTest, ConfigureDefault)
169 std::string uri = "/a/light68";
170 std::string type = "core.light";
171 uint8_t gResourceProperty = 0;
172 PlatformConfig cfg = {};
173 OCPlatform::Configure(cfg);
175 EXPECT_NO_THROW(OCPlatform::registerResource(
176 resourceHandle, uri, type,
177 gResourceInterface, entityHandler, gResourceProperty));
180 TEST(ConfigureTest, ConfigureServer)
182 std::string uri = "/a/light69";
183 std::string type = "core.light";
184 uint8_t gResourceProperty = 0;
186 OC::ServiceType::InProc,
187 OC::ModeType::Server,
190 OC::QualityOfService::LowQos
192 OCPlatform::Configure(cfg);
194 EXPECT_NO_THROW(OCPlatform::registerResource(
195 resourceHandle, uri, type,
196 gResourceInterface, entityHandler, gResourceProperty));
199 TEST(ConfigureTest, ConfigureClient)
201 std::string uri = "/a/light70";
202 std::string type = "core.light";
203 uint8_t gResourceProperty = 0;
205 OC::ServiceType::InProc,
206 OC::ModeType::Client,
209 OC::QualityOfService::LowQos
211 OCPlatform::Configure(cfg);
213 EXPECT_NO_THROW(OCPlatform::registerResource(
214 resourceHandle, uri, type,
215 gResourceInterface, entityHandler, gResourceProperty));
218 //RegisterResourceTest
219 TEST(RegisterResourceTest, RegisterSingleResource)
221 std::string uri = "/a/res2";
222 EXPECT_NE(HANDLE_ZERO, RegisterResource(uri));
225 TEST(RegisterResourceTest, RegisterMultipleResources)
227 std::string uri = "/a/multi";
228 //Good enough for 5 resources.
229 for(int i=0; i< 5; i++)
231 uri +=std::to_string(i);
232 EXPECT_NE(HANDLE_ZERO, RegisterResource(uri));
236 TEST(RegisterResourceTest, ReregisterResource)
238 OCResourceHandle resourceHandle = RegisterResource(std::string("/a/light5"),
239 std::string("core.light"));
240 EXPECT_EQ(OC_STACK_OK, OC::OCPlatform::unregisterResource(resourceHandle));
242 EXPECT_NE(HANDLE_ZERO, RegisterResource(std::string("/a/light5"),
243 std::string("core.light")));
247 TEST(RegisterResourceTest, RegisterEmptyResource)
249 // We should not allow empty URI.
250 std::string emptyStr = "";
251 EXPECT_ANY_THROW(OCPlatform::registerResource(resourceHandle, emptyStr, emptyStr,
252 emptyStr, entityHandler, gResourceProperty));
255 TEST(RegisterResourceTest, RegisterZeroResourceProperty)
257 std::string uri = "/a/light6";
258 std::string type = "core.light";
259 uint8_t gResourceProperty = 0;
260 EXPECT_EQ(OC_STACK_OK, OCPlatform::registerResource(
261 resourceHandle, uri, type,
262 gResourceInterface, entityHandler, gResourceProperty));
266 TEST(UnregisterTest, UnregisterZeroHandleValue)
268 EXPECT_ANY_THROW(OC::OCPlatform::unregisterResource(HANDLE_ZERO));
271 //UnbindResourcesTest
272 TEST(UnbindResourcesTest, UnbindResources)
274 OCResourceHandle resourceHome = RegisterResource(std::string("a/home"),
275 std::string("core.home"));
276 OCResourceHandle resourceKitchen = RegisterResource(std::string("a/kitchen"),
277 std::string("core.kitchen"), LINK_INTERFACE);
278 OCResourceHandle resourceRoom = RegisterResource(std::string("a/office"),
279 std::string("core.office"), LINK_INTERFACE);
281 std::vector<OCResourceHandle> rList;
282 rList.push_back(resourceKitchen);
283 rList.push_back(resourceRoom);
284 EXPECT_EQ(OC_STACK_OK, OCPlatform::bindResources(resourceHome, rList));
285 EXPECT_EQ(OC_STACK_OK, OCPlatform::unbindResources(resourceHome, rList));
288 TEST(UnbindResourcesTest, UnbindResourcesWithZero)
290 OCResourceHandle resourceHandle1 = 0;
291 OCResourceHandle resourceHandle2 = 0;
292 OCResourceHandle resourceHandle3 = 0;
294 std::vector<OCResourceHandle> rList;
296 rList.push_back(resourceHandle2);
297 rList.push_back(resourceHandle3);
299 EXPECT_ANY_THROW(OCPlatform::unbindResources(resourceHandle1, rList));
302 //BindInterfaceToResourceTest
303 TEST(BindInterfaceToResourceTest, BindResourceInterface)
305 OCResourceHandle resourceHandle = RegisterResource(std::string("/a/light"),
306 std::string("core.light"));
307 OCStackResult result = OC::OCPlatform::bindInterfaceToResource(resourceHandle,
309 EXPECT_EQ(OC_STACK_OK, result);
312 TEST(BindInterfaceToResourceTest, BindZeroResourceInterface)
314 OCResourceHandle resourceHandle = RegisterResource(std::string("/a/light1"),
315 std::string("core.light"));
316 EXPECT_ANY_THROW(OC::OCPlatform::bindInterfaceToResource(resourceHandle, 0));
319 //BindTypeToResourceTest
320 TEST(BindTypeToResourceTest, BindResourceType)
322 OCResourceHandle resourceHandle = RegisterResource(std::string("/a/light3"),
323 std::string("core.light"));
324 OCStackResult result = OC::OCPlatform::bindTypeToResource(resourceHandle,
326 EXPECT_EQ(OC_STACK_OK, result);
329 TEST(BindTypeToResourceTest, BindZeroResourceType)
331 OCResourceHandle resourceHandle = RegisterResource(std::string("/a/light4"),
332 std::string("core.light"));
333 EXPECT_ANY_THROW(OC::OCPlatform::bindTypeToResource(resourceHandle, 0));
337 TEST(UnbindResourceTest, BindAndUnbindResource)
339 OCResourceHandle resourceHandle1 = RegisterResource(std::string("a/unres"),
340 std::string("core.unres"));
341 OCResourceHandle resourceHandle2 = RegisterResource(std::string("a/unres2"),
342 std::string("core.unres"), LINK_INTERFACE);
344 EXPECT_EQ(OC_STACK_OK, OCPlatform::bindResource(resourceHandle1, resourceHandle2));
345 EXPECT_EQ(OC_STACK_OK, OCPlatform::unbindResource(resourceHandle1, resourceHandle2));
349 TEST(PresenceTest, DISABLED_StartAndStopPresence)
351 EXPECT_EQ(OC_STACK_OK, OCPlatform::startPresence(30));
352 EXPECT_NE(HANDLE_ZERO, RegisterResource( std::string("/a/Presence"),
353 std::string("core.Presence")));
354 EXPECT_EQ(OC_STACK_OK, OCPlatform::stopPresence());
357 TEST(OCPlatformTest, UnbindZeroRsourceHandleValue)
359 EXPECT_ANY_THROW(OCPlatform::unbindResource(HANDLE_ZERO, HANDLE_ZERO));
362 //NotifyAllObserverTest
363 TEST(NotifyAllObserverTest, NotifyAllObservers)
365 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs1"),
366 std::string("core.obs"));
367 EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome));
370 TEST(NotifyAllObserverTest, NotifyAllObserversWithLowQos)
372 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs2"),
373 std::string("core.obs"));
374 EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome,
375 OC::QualityOfService::LowQos));
378 TEST(NotifyAllObserverTest, NotifyAllObserversWithMidQos)
380 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs3"),
381 std::string("core.obs"));
382 EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome,
383 OC::QualityOfService::MidQos));
386 TEST(NotifyAllObserverTest, NotifyAllObserversWithNaQos)
388 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs4"),
389 std::string("core.obs"));
390 EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome,
391 OC::QualityOfService::NaQos));
394 TEST(NotifyAllObserverTest, NotifyAllObserversWithHighQos)
396 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs5"),
397 std::string("core.obs"));
398 EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome,
399 OC::QualityOfService::HighQos));
402 TEST(NotifyAllObserverTest, NotifyListOfObservers)
404 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs6"),
405 std::string("core.obs"));
407 std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
408 ObservationIds interestedObservers;
409 EXPECT_ANY_THROW(OCPlatform::notifyListOfObservers(resourceHome,
410 interestedObservers, resourceResponse));
413 TEST(NotifyAllObserverTest, NotifyListOfObserversWithLowQos)
415 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs7"),
416 std::string("core.obs"));
418 std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
419 ObservationIds interestedObservers;
420 EXPECT_ANY_THROW(OCPlatform::notifyListOfObservers(resourceHome,
421 interestedObservers, resourceResponse,OC::QualityOfService::LowQos));
424 TEST(NotifyAllObserverTest, NotifyListOfObserversWithMidQos)
426 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs8"),
427 std::string("core.obs"));
429 std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
430 ObservationIds interestedObservers;
431 EXPECT_ANY_THROW(OCPlatform::notifyListOfObservers(resourceHome,
432 interestedObservers, resourceResponse,OC::QualityOfService::MidQos));
435 TEST(NotifyAllObserverTest, NotifyListOfObserversWithNaQos)
437 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs9"),
438 std::string("core.obs"));
440 std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
441 ObservationIds interestedObservers;
442 EXPECT_ANY_THROW(OCPlatform::notifyListOfObservers(resourceHome,
443 interestedObservers, resourceResponse,OC::QualityOfService::NaQos));
446 TEST(NotifyAllObserverTest, NotifyListOfObserversWithHighQos)
448 OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs10"),
449 std::string("core.obs"));
451 std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
452 ObservationIds interestedObservers;
453 EXPECT_ANY_THROW(OCPlatform::notifyListOfObservers(resourceHome,
454 interestedObservers, resourceResponse,OC::QualityOfService::HighQos));
457 //DeviceEntityHandlerTest
458 TEST(DeviceEntityHandlerTest, SetDefaultDeviceEntityHandler)
460 EXPECT_EQ(OC_STACK_OK, OCPlatform::setDefaultDeviceEntityHandler(entityHandler));
461 EXPECT_EQ(OC_STACK_OK, OCPlatform::setDefaultDeviceEntityHandler(NULL));
466 TEST(FindResourceTest, DISABLED_FindResourceValid)
468 std::ostringstream requestURI;
469 requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light";
470 EXPECT_EQ(OC_STACK_OK, OCPlatform::findResource("", requestURI.str(),
471 OC_IPV4, &foundResource));
474 TEST(FindResourceTest, FindResourceNullResourceURI)
476 EXPECT_ANY_THROW(OCPlatform::findResource("", nullptr,
477 OC_IPV4, &foundResource));
480 TEST(FindResourceTest, FindResourceNullResourceURI1)
482 std::ostringstream requestURI;
483 requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light";
484 EXPECT_ANY_THROW(OCPlatform::findResource(nullptr, requestURI.str(),
485 OC_IPV4, &foundResource));
488 TEST(FindResourceTest, FindResourceNullHost)
490 std::ostringstream requestURI;
491 requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light";
492 EXPECT_ANY_THROW(OCPlatform::findResource(nullptr, requestURI.str(),
493 OC_IPV4, &foundResource));
496 TEST(FindResourceTest, FindResourceNullresourceHandler)
498 std::ostringstream requestURI;
499 requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light";
500 EXPECT_THROW(OCPlatform::findResource("", requestURI.str(),
501 OC_IPV4, NULL), OC::OCException);
504 TEST(FindResourceTest, DISABLED_FindResourceWithLowQoS)
506 std::ostringstream requestURI;
507 requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light";
508 EXPECT_EQ(OC_STACK_OK,
509 OCPlatform::findResource("", requestURI.str(), OC_IPV4, &foundResource,
510 OC::QualityOfService::LowQos));
513 TEST(FindResourceTest, DISABLED_FindResourceWithMidQos)
515 std::ostringstream requestURI;
516 requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light";
517 EXPECT_EQ(OC_STACK_OK,
518 OCPlatform::findResource("", requestURI.str(), OC_IPV4, &foundResource,
519 OC::QualityOfService::MidQos));
522 TEST(FindResourceTest, DISABLED_FindResourceWithHighQos)
524 std::ostringstream requestURI;
525 requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light";
526 EXPECT_EQ(OC_STACK_OK,
527 OCPlatform::findResource("", requestURI.str(), OC_IPV4, &foundResource,
528 OC::QualityOfService::HighQos));
531 TEST(FindResourceTest, DISABLED_FindResourceWithNaQos)
533 std::ostringstream requestURI;
534 requestURI << OC_WELL_KNOWN_QUERY << "?rt=core.light";
535 EXPECT_EQ(OC_STACK_OK,
536 OCPlatform::findResource("", requestURI.str(), OC_IPV4, &foundResource,
537 OC::QualityOfService::NaQos));
541 TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithValidParameters)
543 std::string deviceDiscoveryURI = "/oic/d";
545 OCPlatform::Configure(cfg);
546 std::ostringstream requestURI;
547 requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
548 EXPECT_EQ(OC_STACK_OK,
549 OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo));
552 TEST(GetDeviceInfoTest, GetDeviceInfoNullDeviceURI)
555 OCPlatform::Configure(cfg);
557 OCPlatform::getDeviceInfo("", nullptr, OC_IPV4, &receivedDeviceInfo));
560 TEST(GetDeviceInfoTest, GetDeviceInfoWithNullDeviceInfoHandler)
562 std::string deviceDiscoveryURI = "/oic/d";
564 OCPlatform::Configure(cfg);
565 std::ostringstream requestURI;
566 requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
568 OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, NULL),
572 TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithLowQos)
574 std::string deviceDiscoveryURI = "/oic/d";
576 OCPlatform::Configure(cfg);
577 std::ostringstream requestURI;
578 requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
579 EXPECT_EQ(OC_STACK_OK,
580 OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo,
581 OC::QualityOfService::LowQos));
584 TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithMidQos)
586 std::string deviceDiscoveryURI = "/oic/d";
588 OCPlatform::Configure(cfg);
589 std::ostringstream requestURI;
590 requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
591 EXPECT_EQ(OC_STACK_OK,
592 OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo,
593 OC::QualityOfService::MidQos));
596 TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithHighQos)
598 std::string deviceDiscoveryURI = "/oic/d";
600 OCPlatform::Configure(cfg);
601 std::ostringstream requestURI;
602 requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
603 EXPECT_EQ(OC_STACK_OK,
604 OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo,
605 OC::QualityOfService::HighQos));
608 TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithNaQos)
610 std::string deviceDiscoveryURI = "/oic/d";
612 OCPlatform::Configure(cfg);
613 std::ostringstream requestURI;
614 requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
615 EXPECT_EQ(OC_STACK_OK,
616 OCPlatform::getDeviceInfo("", requestURI.str(), OC_IPV4, &receivedDeviceInfo,
617 OC::QualityOfService::NaQos));
620 //RegisterDeviceInfo test
621 TEST(RegisterDeviceInfoTest, RegisterDeviceInfoWithValidParameters)
623 OCDeviceInfo deviceInfo;
625 DuplicateString(&deviceInfo.deviceName, "myDeviceName");
627 EXPECT_EQ(OC_STACK_OK, OCPlatform::registerDeviceInfo(deviceInfo));
628 EXPECT_NO_THROW(DeleteDeviceInfo(deviceInfo));
631 TEST(RegisterDeviceInfoTest, RegisterDeviceInfoWithEmptyObject)
633 OCDeviceInfo di = {};
634 EXPECT_ANY_THROW(OCPlatform::registerDeviceInfo(di));
637 //SubscribePresence Test
638 TEST(SubscribePresenceTest, DISABLED_SubscribePresenceWithValidParameters)
640 std::string hostAddress = "192.168.1.2:5000";
641 OCPlatform::OCPresenceHandle presenceHandle = nullptr;
643 EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle, hostAddress,
644 OC_IPV4, &presenceHandler));
647 TEST(SubscribePresenceTest, SubscribePresenceWithNullHost)
649 OCPlatform::OCPresenceHandle presenceHandle = nullptr;
651 EXPECT_ANY_THROW(OCPlatform::subscribePresence(presenceHandle, nullptr,
652 OC_IPV4, &presenceHandler));
655 TEST(SubscribePresenceTest, SubscribePresenceWithNullPresenceHandler)
657 OCPlatform::OCPresenceHandle presenceHandle = nullptr;
659 EXPECT_ANY_THROW(OCPlatform::subscribePresence(presenceHandle, nullptr,
663 TEST(SubscribePresenceTest, DISABLED_SubscribePresenceWithResourceType)
665 OCPlatform::OCPresenceHandle presenceHandle = nullptr;
667 EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle,
668 OC_MULTICAST_IP, "core.light", OC_IPV4, &presenceHandler));
671 TEST(SubscribePresenceTest, SubscribePresenceWithNullResourceType)
673 OCPlatform::OCPresenceHandle presenceHandle = nullptr;
675 EXPECT_ANY_THROW(OCPlatform::subscribePresence(presenceHandle,
676 OC_MULTICAST_IP, nullptr, OC_IPV4, &presenceHandler));
679 TEST(SubscribePresenceTest, DISABLED_UnsubscribePresenceWithValidHandleAndRT)
681 OCPlatform::OCPresenceHandle presenceHandle = nullptr;
683 EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle,
684 OC_MULTICAST_IP, "core.light", OC_IPV4, &presenceHandler));
685 EXPECT_EQ(OC_STACK_OK, OCPlatform::unsubscribePresence(presenceHandle));
688 TEST(SubscribePresenceTest, UnsubscribePresenceWithNullHandle)
690 OCPlatform::OCPresenceHandle presenceHandle = nullptr;
691 EXPECT_ANY_THROW(OCPlatform::unsubscribePresence(presenceHandle));
694 TEST(SubscribePresenceTest, DISABLED_UnsubscribePresenceWithValidHandle)
696 OCPlatform::OCPresenceHandle presenceHandle = nullptr;
698 EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle,
699 OC_MULTICAST_IP, OC_IPV4, &presenceHandler));
700 EXPECT_EQ(OC_STACK_OK, OCPlatform::unsubscribePresence(presenceHandle));