Update snapshot(2018-01-04)
[platform/upstream/iotivity.git] / resource / unittests / OCPlatformTest.cpp
index 70b1bc4..bed8cf3 100644 (file)
 
 #include <OCPlatform.h>
 #include <OCApi.h>
+#include <oic_malloc.h>
 #include <gtest/gtest.h>
 
 namespace OCPlatformTest
 {
     using namespace OC;
 
+    static const char* SVR_DB_FILE_NAME = "./oic_svr_db_server.dat";
+    const OCResourceHandle HANDLE_ZERO = 0;
+    const std::string gResourceTypeName = "core.res";
+    const std::string gResourceInterface = DEFAULT_INTERFACE;
+    const uint8_t gResourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
+    OCResourceHandle resourceHandle;
+
+    //OCPersistent Storage Handlers
+    static FILE* client_open(const char * /*path*/, const char *mode)
+    {
+        std::cout << "<===Opening SVR DB file = './oic_svr_db_client.dat' with mode = '" << mode
+                << "' " << std::endl;
+        return fopen(SVR_DB_FILE_NAME, mode);
+    }
+        OCPersistentStorage gps {client_open, fread, fwrite, fclose, unlink, NULL, NULL };
+
     // Callbacks
-    OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> request)
+    OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> /*request*/)
     {
         return OC_EH_OK;
     }
 
-    const OCResourceHandle HANDLE_ZERO = 0;
+    void foundResource(std::shared_ptr<OCResource> /*resource*/)
+    {
+    }
 
-    PlatformConfig cfg;
+    void receivedDeviceInfo(const OCRepresentation& /*rep*/)
+    {
+    }
 
-    void foundResource(std::shared_ptr<OCResource> resource)
+    void presenceHandler(OCStackResult /*result*/,
+            const unsigned int /*nonce*/, const std::string& /*hostAddress*/)
     {
     }
 
-    std::string resourceURI;
-    std::string resourceTypeName = "core.res";
-    std::string resourceInterface = DEFAULT_INTERFACE;
-    uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
-    OCResourceHandle resourceHandle;
+#ifdef WITH_CLOUD
+    void onObserve(const HeaderOptions, const OCRepresentation&, const int&, const int&)
+    {
+    }
+#endif
+
+    void directPairHandler(std::shared_ptr<OCDirectPairing> /*dev*/, OCStackResult /*res*/)
+    {
+    }
+
+    void pairedHandler(const PairedDevices& /*list*/)
+    {
+    }
 
     //Helper methods
+    void DeleteStringLL(OCStringLL* ll)
+    {
+        if (!ll)
+        {
+            return;
+        }
+
+        DeleteStringLL(ll->next);
+        delete[] ll->value;
+        OICFree(ll);
+    }
+
+    void DeleteDeviceInfo(OCDeviceInfo deviceInfo)
+    {
+        delete[] deviceInfo.deviceName;
+        DeleteStringLL(deviceInfo.types);
+        delete[] deviceInfo.specVersion;
+        DeleteStringLL(deviceInfo.dataModelVersions);
+    }
+
+    void DuplicateString(char ** targetString, std::string sourceString)
+    {
+        *targetString = new char[sourceString.length() + 1];
+        strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));
+    }
+
+    bool OCResourcePayloadAddStringLL(OCStringLL **stringLL, std::string value)
+    {
+        char *dup = NULL;
+        DuplicateString(&dup, value);
+        if (!*stringLL)
+        {
+            *stringLL = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
+            (*stringLL)->value = dup;
+            return true;
+        }
+        else
+        {
+            OCStringLL *temp = *stringLL;
+            while(temp->next)
+            {
+                temp = temp->next;
+            }
+            temp->next = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
+            temp->next->value = dup;
+            return true;
+        }
+        return false;
+    }
+
     OCResourceHandle RegisterResource(std::string uri, std::string type, std::string iface)
     {
+        PlatformConfig cfg
+        { OC::ServiceType::OutOfProc, OC::ModeType::Server, "0.0.0.0", 0,
+                OC::QualityOfService::LowQos, &gps };
+        OCPlatform::Configure(cfg);
         EXPECT_EQ(OC_STACK_OK,OCPlatform::registerResource(
                                         resourceHandle, uri, type,
-                                        iface, entityHandler, resourceProperty));
+                                        iface, entityHandler, gResourceProperty));
         return resourceHandle;
     }
 
     OCResourceHandle RegisterResource(std::string uri, std::string type)
     {
+        PlatformConfig cfg
+        { OC::ServiceType::OutOfProc, OC::ModeType::Server, "0.0.0.0", 0,
+                OC::QualityOfService::LowQos, &gps };
+        OCPlatform::Configure(cfg);
         EXPECT_EQ(OC_STACK_OK, OCPlatform::registerResource(
                                         resourceHandle, uri, type,
-                                        resourceInterface, entityHandler, resourceProperty));
+                                        gResourceInterface, entityHandler, gResourceProperty));
         return resourceHandle;
     }
 
     OCResourceHandle RegisterResource(std::string uri)
     {
+        PlatformConfig cfg
+        { OC::ServiceType::OutOfProc, OC::ModeType::Server, "0.0.0.0", 0,
+                OC::QualityOfService::LowQos, &gps };
+        OCPlatform::Configure(cfg);
         EXPECT_EQ(OC_STACK_OK, OCPlatform::registerResource(
-                                        resourceHandle, uri, resourceTypeName,
-                                        resourceInterface, entityHandler, resourceProperty));
+                                        resourceHandle, uri, gResourceTypeName,
+                                        gResourceInterface, entityHandler, gResourceProperty));
         return resourceHandle;
     }
 
+    //Configure
+    // Enable it when the stack throw an exception
+    // https://jira.iotivity.org/browse/IOT-428
+    TEST(ConfigureTest, DISABLED_ConfigureInvalidModeType)
+    {
+        PlatformConfig cfg {
+             OC::ServiceType::InProc,
+            (OC::ModeType)99,
+             "0.0.0.0",
+             0,
+             OC::QualityOfService::LowQos
+         };
+         OCPlatform::Configure(cfg);
+         EXPECT_ANY_THROW(OCPlatform::setDefaultDeviceEntityHandler(NULL));
+     }
+
+    // Enable it when the stack throw an exception
+    // https://jira.iotivity.org/browse/IOT-428
+    TEST(ConfigureTest, DISABLED_ConfigureInvalidServiceType)
+    {
+        PlatformConfig cfg {
+             (OC::ServiceType)99,
+            OC::ModeType::Client,
+             "0.0.0.0",
+             0,
+             OC::QualityOfService::LowQos
+         };
+         OCPlatform::Configure(cfg);
+         EXPECT_ANY_THROW(OCPlatform::setDefaultDeviceEntityHandler(NULL));
+     }
+
+    // Enable it when the stack throw an exception
+    // https://jira.iotivity.org/browse/IOT-428
+    TEST(ConfigureTest, DISABLED_ConfigureClientOutProc)
+    {
+        PlatformConfig cfg {
+            OC::ServiceType::OutOfProc,
+            OC::ModeType::Client,
+            "0.0.0.0",
+            0,
+            OC::QualityOfService::LowQos
+        };
+        std::string uri = "/a/light66";
+        std::string type = "core.light";
+        uint8_t gResourceProperty = 0;
+        OCPlatform::Configure(cfg);
+        EXPECT_ANY_THROW(OCPlatform::registerResource(
+             resourceHandle, uri, type,
+             gResourceInterface, entityHandler, gResourceProperty));
+    }
+
+    TEST(ConfigureTest, ConfigureServerOutProc)
+    {
+        PlatformConfig cfg
+        {
+            OC::ServiceType::OutOfProc,
+            OC::ModeType::Server,
+            "0.0.0.0",
+            0,
+            OC::QualityOfService::LowQos, &gps
+        };
+        std::string uri = "/a/light67";
+        std::string type = "core.light";
+        uint8_t gResourceProperty = 0;
+        OCPlatform::Configure(cfg);
+
+        EXPECT_ANY_THROW(OCPlatform::registerResource(
+             resourceHandle, uri, type,
+             gResourceInterface, entityHandler, gResourceProperty));
+    }
+
+    TEST(ConfigureTest, ConfigureDefault)
+    {
+        std::string uri = "/a/light68";
+        std::string type = "core.light";
+        uint8_t gResourceProperty = 0;
+        PlatformConfig cfg = {};
+        OCPlatform::Configure(cfg);
+
+        EXPECT_NO_THROW(OCPlatform::registerResource(
+                 resourceHandle, uri, type,
+                 gResourceInterface, entityHandler, gResourceProperty));
+    }
+
+    TEST(ConfigureTest, ConfigureServer)
+    {
+        std::string uri = "/a/light69";
+        std::string type = "core.light";
+        uint8_t gResourceProperty = 0;
+        PlatformConfig cfg {
+            OC::ServiceType::InProc,
+            OC::ModeType::Server,
+            "0.0.0.0",
+            0,
+            OC::QualityOfService::LowQos, &gps
+        };
+        OCPlatform::Configure(cfg);
+
+        EXPECT_NO_THROW(OCPlatform::registerResource(
+                 resourceHandle, uri, type,
+                 gResourceInterface, entityHandler, gResourceProperty));
+    }
+
+    TEST(ConfigureTest, ConfigureClient)
+    {
+        std::string uri = "/a/light70";
+        std::string type = "core.light";
+        uint8_t gResourceProperty = 0;
+        PlatformConfig cfg
+        {
+            OC::ServiceType::InProc,
+            OC::ModeType::Client,
+            "0.0.0.0",
+            0,
+            OC::QualityOfService::LowQos,
+            &gps
+        };
+
+        EXPECT_NO_THROW(OCPlatform::registerResource(
+                 resourceHandle, uri, type,
+                 gResourceInterface, entityHandler, gResourceProperty));
+    }
+    //PersistentStorageTest
+    TEST(ConfigureTest, ConfigureDefaultNULLPersistentStorage)
+    {
+        PlatformConfig cfg {
+             OC::ServiceType::InProc,
+             OC::ModeType::Both,
+             "0.0.0.0",
+             0,
+             OC::QualityOfService::LowQos
+         };
+         OCPlatform::Configure(cfg);
+         EXPECT_NO_THROW(OCPlatform::setDefaultDeviceEntityHandler(nullptr));
+     }
+
+    //PersistentStorageTest
+    TEST(ConfigureTest, ConfigureNULLPersistentStorage)
+    {
+        PlatformConfig cfg {
+             OC::ServiceType::InProc,
+             OC::ModeType::Both,
+             "0.0.0.0",
+             0,
+             OC::QualityOfService::LowQos,
+             nullptr
+         };
+         OCPlatform::Configure(cfg);
+         EXPECT_NO_THROW(OCPlatform::setDefaultDeviceEntityHandler(nullptr));
+     }
+
+    //PersistentStorageTest
+    TEST(ConfigureTest, ConfigurePersistentStorage)
+    {
+         PlatformConfig cfg {
+             OC::ServiceType::InProc,
+             OC::ModeType::Both,
+             "0.0.0.0",
+             0,
+             OC::QualityOfService::LowQos,
+             &gps
+         };
+         OCPlatform::Configure(cfg);
+         EXPECT_NO_THROW(OCPlatform::setDefaultDeviceEntityHandler(nullptr));
+     }
+
+    //PersistentStorageTest
+    TEST(ConfigureTest, ConfigureNULLHandlersPersistentStorage)
+    {
+        PlatformConfig cfg {
+             OC::ServiceType::InProc,
+             OC::ModeType::Both,
+             "0.0.0.0",
+             0,
+             OC::QualityOfService::LowQos,
+             &gps
+         };
+         OCPlatform::Configure(cfg);
+         EXPECT_NO_THROW(OCPlatform::setDefaultDeviceEntityHandler(nullptr));
+     }
+
+
     //RegisterResourceTest
     TEST(RegisterResourceTest, RegisterSingleResource)
     {
@@ -105,17 +379,17 @@ namespace OCPlatformTest
         // We should not allow empty URI.
         std::string emptyStr = "";
         EXPECT_ANY_THROW(OCPlatform::registerResource(resourceHandle, emptyStr, emptyStr,
-                                        emptyStr, entityHandler, resourceProperty));
+                                        emptyStr, entityHandler, gResourceProperty));
     }
 
     TEST(RegisterResourceTest, RegisterZeroResourceProperty)
     {
         std::string uri = "/a/light6";
         std::string type = "core.light";
-        uint8_t resourceProperty = 0;
+        uint8_t gResourceProperty = 0;
         EXPECT_EQ(OC_STACK_OK, OCPlatform::registerResource(
                 resourceHandle, uri, type,
-                resourceInterface, entityHandler, resourceProperty));
+                gResourceInterface, entityHandler, gResourceProperty));
     }
 
     //UnregisterTest
@@ -202,7 +476,7 @@ namespace OCPlatformTest
     }
 
     //PresenceTest
-    TEST(PresenceTest, StartAndStopPresence)
+    TEST(PresenceTest, DISABLED_StartAndStopPresence)
     {
         EXPECT_EQ(OC_STACK_OK, OCPlatform::startPresence(30));
         EXPECT_NE(HANDLE_ZERO, RegisterResource( std::string("/a/Presence"),
@@ -218,15 +492,47 @@ namespace OCPlatformTest
     //NotifyAllObserverTest
     TEST(NotifyAllObserverTest, NotifyAllObservers)
     {
-        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs"),
+        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs1"),
             std::string("core.obs"));
         EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome));
     }
 
-    TEST(NotifyAllObserverTest, NotifyListOfObservers)
+    TEST(NotifyAllObserverTest, NotifyAllObserversWithLowQos)
     {
         OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs2"),
             std::string("core.obs"));
+        EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome,
+                OC::QualityOfService::LowQos));
+    }
+
+    TEST(NotifyAllObserverTest, NotifyAllObserversWithMidQos)
+    {
+        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs3"),
+            std::string("core.obs"));
+        EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome,
+                OC::QualityOfService::MidQos));
+    }
+
+    TEST(NotifyAllObserverTest, NotifyAllObserversWithNaQos)
+    {
+        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs4"),
+            std::string("core.obs"));
+        EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome,
+                OC::QualityOfService::NaQos));
+    }
+
+    TEST(NotifyAllObserverTest, NotifyAllObserversWithHighQos)
+    {
+        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs5"),
+            std::string("core.obs"));
+        EXPECT_EQ(OC_STACK_NO_OBSERVERS, OCPlatform::notifyAllObservers(resourceHome,
+                OC::QualityOfService::HighQos));
+    }
+
+    TEST(NotifyAllObserverTest, NotifyListOfObservers)
+    {
+        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs6"),
+            std::string("core.obs"));
 
         std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
         ObservationIds interestedObservers;
@@ -234,10 +540,382 @@ namespace OCPlatformTest
             interestedObservers, resourceResponse));
     }
 
+    TEST(NotifyAllObserverTest, NotifyListOfObserversWithLowQos)
+    {
+        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs7"),
+            std::string("core.obs"));
+
+        std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
+        ObservationIds interestedObservers;
+        EXPECT_ANY_THROW(OCPlatform::notifyListOfObservers(resourceHome,
+            interestedObservers, resourceResponse,OC::QualityOfService::LowQos));
+    }
+
+    TEST(NotifyAllObserverTest, NotifyListOfObserversWithMidQos)
+    {
+        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs8"),
+            std::string("core.obs"));
+
+        std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
+        ObservationIds interestedObservers;
+        EXPECT_ANY_THROW(OCPlatform::notifyListOfObservers(resourceHome,
+            interestedObservers, resourceResponse,OC::QualityOfService::MidQos));
+    }
+
+    TEST(NotifyAllObserverTest, NotifyListOfObserversWithNaQos)
+    {
+        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs9"),
+            std::string("core.obs"));
+
+        std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
+        ObservationIds interestedObservers;
+        EXPECT_ANY_THROW(OCPlatform::notifyListOfObservers(resourceHome,
+            interestedObservers, resourceResponse,OC::QualityOfService::NaQos));
+    }
+
+    TEST(NotifyAllObserverTest, NotifyListOfObserversWithHighQos)
+    {
+        OCResourceHandle resourceHome = RegisterResource(std::string("/a/obs10"),
+            std::string("core.obs"));
+
+        std::shared_ptr<OCResourceResponse> resourceResponse(new OCResourceResponse());
+        ObservationIds interestedObservers;
+        EXPECT_ANY_THROW(OCPlatform::notifyListOfObservers(resourceHome,
+            interestedObservers, resourceResponse,OC::QualityOfService::HighQos));
+    }
+
     //DeviceEntityHandlerTest
     TEST(DeviceEntityHandlerTest, SetDefaultDeviceEntityHandler)
     {
         EXPECT_EQ(OC_STACK_OK, OCPlatform::setDefaultDeviceEntityHandler(entityHandler));
         EXPECT_EQ(OC_STACK_OK, OCPlatform::setDefaultDeviceEntityHandler(NULL));
     }
+
+
+    //FindResource test
+    TEST(FindResourceTest, DISABLED_FindResourceValid)
+    {
+      std::ostringstream requestURI;
+      requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.light";
+      EXPECT_EQ(OC_STACK_OK, OCPlatform::findResource("", requestURI.str(),
+              CT_DEFAULT, &foundResource));
+    }
+
+    TEST(FindResourceTest, FindResourceNullResourceURI)
+    {
+      EXPECT_ANY_THROW(OCPlatform::findResource("", nullptr,
+              CT_DEFAULT, &foundResource));
+    }
+
+    TEST(FindResourceTest, FindResourceNullResourceURI1)
+    {
+      std::ostringstream requestURI;
+      requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.light";
+      EXPECT_ANY_THROW(OCPlatform::findResource(nullptr, requestURI.str(),
+              CT_DEFAULT, &foundResource));
+    }
+
+    TEST(FindResourceTest, FindResourceNullHost)
+    {
+      std::ostringstream requestURI;
+      requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.light";
+      EXPECT_ANY_THROW(OCPlatform::findResource(nullptr, requestURI.str(),
+              CT_DEFAULT, &foundResource));
+    }
+
+    TEST(FindResourceTest, FindResourceNullresourceHandler)
+    {
+      std::ostringstream requestURI;
+      requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.light";
+      EXPECT_THROW(OCPlatform::findResource("", requestURI.str(),
+              CT_DEFAULT, NULL), OC::OCException);
+    }
+
+    TEST(FindResourceTest, DISABLED_FindResourceWithLowQoS)
+    {
+        std::ostringstream requestURI;
+        requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.light";
+        EXPECT_EQ(OC_STACK_OK,
+                OCPlatform::findResource("", requestURI.str(), CT_DEFAULT, &foundResource,
+                        OC::QualityOfService::LowQos));
+    }
+
+    TEST(FindResourceTest, DISABLED_FindResourceWithMidQos)
+    {
+        std::ostringstream requestURI;
+        requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.light";
+        EXPECT_EQ(OC_STACK_OK,
+                OCPlatform::findResource("", requestURI.str(), CT_DEFAULT, &foundResource,
+                        OC::QualityOfService::MidQos));
+    }
+
+    TEST(FindResourceTest, DISABLED_FindResourceWithHighQos)
+    {
+        std::ostringstream requestURI;
+        requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.light";
+        EXPECT_EQ(OC_STACK_OK,
+                OCPlatform::findResource("", requestURI.str(), CT_DEFAULT, &foundResource,
+                        OC::QualityOfService::HighQos));
+    }
+
+    TEST(FindResourceTest, DISABLED_FindResourceWithNaQos)
+    {
+        std::ostringstream requestURI;
+        requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.light";
+        EXPECT_EQ(OC_STACK_OK,
+                OCPlatform::findResource("", requestURI.str(), CT_DEFAULT, &foundResource,
+                        OC::QualityOfService::NaQos));
+    }
+
+    //GetDeviceInfo Test
+    TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithValidParameters)
+    {
+        std::string deviceDiscoveryURI = "/oic/d";
+        PlatformConfig cfg;
+        OCPlatform::Configure(cfg);
+        std::ostringstream requestURI;
+        requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
+        EXPECT_EQ(OC_STACK_OK,
+                OCPlatform::getDeviceInfo("", requestURI.str(), CT_DEFAULT, &receivedDeviceInfo));
+    }
+
+    TEST(GetDeviceInfoTest, GetDeviceInfoNullDeviceURI)
+    {
+        PlatformConfig cfg;
+        OCPlatform::Configure(cfg);
+        EXPECT_ANY_THROW(
+                OCPlatform::getDeviceInfo("", nullptr, CT_DEFAULT, &receivedDeviceInfo));
+    }
+
+    TEST(GetDeviceInfoTest, GetDeviceInfoWithNullDeviceInfoHandler)
+    {
+        std::string deviceDiscoveryURI = "/oic/d";
+        PlatformConfig cfg;
+        OCPlatform::Configure(cfg);
+        std::ostringstream requestURI;
+        requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
+        EXPECT_THROW(
+                OCPlatform::getDeviceInfo("", requestURI.str(), CT_DEFAULT, NULL),
+                OC::OCException);
+    }
+
+    TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithLowQos)
+    {
+        std::string deviceDiscoveryURI = "/oic/d";
+        PlatformConfig cfg;
+        OCPlatform::Configure(cfg);
+        std::ostringstream requestURI;
+        requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
+        EXPECT_EQ(OC_STACK_OK,
+                OCPlatform::getDeviceInfo("", requestURI.str(), CT_DEFAULT, &receivedDeviceInfo,
+                        OC::QualityOfService::LowQos));
+    }
+
+    TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithMidQos)
+    {
+        std::string deviceDiscoveryURI = "/oic/d";
+        PlatformConfig cfg;
+        OCPlatform::Configure(cfg);
+        std::ostringstream requestURI;
+        requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
+        EXPECT_EQ(OC_STACK_OK,
+                OCPlatform::getDeviceInfo("", requestURI.str(), CT_DEFAULT, &receivedDeviceInfo,
+                        OC::QualityOfService::MidQos));
+    }
+
+    TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithHighQos)
+    {
+        std::string deviceDiscoveryURI = "/oic/d";
+        PlatformConfig cfg;
+        OCPlatform::Configure(cfg);
+        std::ostringstream requestURI;
+        requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
+        EXPECT_EQ(OC_STACK_OK,
+                OCPlatform::getDeviceInfo("", requestURI.str(), CT_DEFAULT, &receivedDeviceInfo,
+                        OC::QualityOfService::HighQos));
+    }
+
+    TEST(GetDeviceInfoTest, DISABLED_GetDeviceInfoWithNaQos)
+    {
+        std::string deviceDiscoveryURI = "/oic/d";
+        PlatformConfig cfg;
+        OCPlatform::Configure(cfg);
+        std::ostringstream requestURI;
+        requestURI << OC_MULTICAST_PREFIX << deviceDiscoveryURI;
+        EXPECT_EQ(OC_STACK_OK,
+                OCPlatform::getDeviceInfo("", requestURI.str(), CT_DEFAULT, &receivedDeviceInfo,
+                        OC::QualityOfService::NaQos));
+    }
+
+    //RegisterDeviceInfo test
+    TEST(RegisterDeviceInfoTest, RegisterDeviceInfoWithValidParameters)
+    {
+        OCDeviceInfo deviceInfo;
+        DuplicateString(&deviceInfo.deviceName, "myDeviceName");
+        deviceInfo.types = NULL;
+        OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.wk.d");
+        OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.d.tv");
+        DuplicateString(&deviceInfo.specVersion, "mySpecVersion");
+        deviceInfo.dataModelVersions = nullptr;
+        OCResourcePayloadAddStringLL(&deviceInfo.dataModelVersions, "myDataModelVersions");
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::registerDeviceInfo(deviceInfo));
+        EXPECT_NO_THROW(DeleteDeviceInfo(deviceInfo));
+    }
+
+    TEST(RegisterDeviceInfoTest, RegisterDeviceInfoWithEmptyObject)
+    {
+        OCDeviceInfo di = {0, 0, 0, 0};
+        EXPECT_ANY_THROW(OCPlatform::registerDeviceInfo(di));
+    }
+
+    //SubscribePresence Test
+    TEST(SubscribePresenceTest, DISABLED_SubscribePresenceWithValidParameters)
+    {
+        std::string hostAddress = "192.168.1.2:5000";
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle, hostAddress,
+                 CT_DEFAULT, &presenceHandler));
+    }
+
+    TEST(SubscribePresenceTest, SubscribePresenceWithNullHost)
+    {
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+
+        EXPECT_ANY_THROW(OCPlatform::subscribePresence(presenceHandle, nullptr,
+                 CT_DEFAULT, &presenceHandler));
+    }
+
+    TEST(SubscribePresenceTest, SubscribePresenceWithNullPresenceHandler)
+    {
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+
+        EXPECT_ANY_THROW(OCPlatform::subscribePresence(presenceHandle, nullptr,
+                 CT_DEFAULT, NULL));
+    }
+
+    TEST(SubscribePresenceTest, DISABLED_SubscribePresenceWithResourceType)
+    {
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle,
+                OC_MULTICAST_IP, "core.light", CT_DEFAULT, &presenceHandler));
+    }
+
+    TEST(SubscribePresenceTest, SubscribePresenceWithNullResourceType)
+    {
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+
+        EXPECT_ANY_THROW(OCPlatform::subscribePresence(presenceHandle,
+                OC_MULTICAST_IP, nullptr, CT_DEFAULT, &presenceHandler));
+    }
+
+    TEST(SubscribePresenceTest, DISABLED_UnsubscribePresenceWithValidHandleAndRT)
+    {
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle,
+                OC_MULTICAST_IP, "core.light", CT_DEFAULT, &presenceHandler));
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::unsubscribePresence(presenceHandle));
+    }
+
+    TEST(SubscribePresenceTest, UnsubscribePresenceWithNullHandle)
+    {
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+        EXPECT_ANY_THROW(OCPlatform::unsubscribePresence(presenceHandle));
+    }
+
+    TEST(SubscribePresenceTest, DISABLED_UnsubscribePresenceWithValidHandle)
+    {
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribePresence(presenceHandle,
+                OC_MULTICAST_IP, CT_DEFAULT, &presenceHandler));
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::unsubscribePresence(presenceHandle));
+    }
+
+#ifdef WITH_CLOUD
+    // SubscribeDevicePresence Test
+    TEST(SubscribeDevicePresenceTest, DISABLED_SubscribeDevicePresenceWithValidParameters)
+    {
+        std::string hostAddress = "192.168.1.2:5000";
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+        std::vector<std::string> di;
+
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribeDevicePresence(presenceHandle,
+                hostAddress, di, CT_DEFAULT, &onObserve));
+    }
+
+    TEST(SubscribeDevicePresenceTest, SubscribeDevicePresenceWithNullHost)
+    {
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+        std::vector<std::string> di;
+
+        EXPECT_ANY_THROW(OCPlatform::subscribeDevicePresence(presenceHandle,
+                        nullptr, di, CT_DEFAULT, &onObserve));
+    }
+
+    TEST(SubscribeDevicePresenceTest, SubscribeDevicePresenceWithNullOnObserve)
+    {
+        std::string hostAddress = "192.168.1.2:5000";
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+        std::vector<std::string> di;
+
+        EXPECT_ANY_THROW(OCPlatform::subscribeDevicePresence(presenceHandle,
+                        hostAddress, di, CT_DEFAULT, NULL));
+    }
+
+    TEST(SubscribeDevicePresenceTest, DISABLED_UnsubscribePresenceWithValidHandle)
+    {
+        std::string hostAddress = "192.168.1.2:5000";
+        OCPlatform::OCPresenceHandle presenceHandle = nullptr;
+        std::vector<std::string> di;
+
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::subscribeDevicePresence(presenceHandle,
+                hostAddress, di, CT_DEFAULT, &onObserve));
+        EXPECT_EQ(OC_STACK_OK, OCPlatform::unsubscribePresence(presenceHandle));
+    }
+#endif
+
+    TEST(FindDirectPairingTest, FindDirectPairingNullCallback)
+    {
+        EXPECT_ANY_THROW(OCPlatform::findDirectPairingDevices(1, nullptr));
+    }
+
+    TEST(FindDirectPairingTest, FindDirectPairingZeroTimeout)
+    {
+        EXPECT_ANY_THROW(OCPlatform::findDirectPairingDevices(0, &pairedHandler));
+    }
+
+    TEST(GetDirectPairedTest, GetDirectPairedNullCallback)
+    {
+        EXPECT_ANY_THROW(OCPlatform::getDirectPairedDevices(nullptr));
+    }
+
+    TEST(DoDirectPairingTest, DoDirectPairingNullCallback)
+    {
+        OCDPDev_t peer;
+        OCPrm_t pmSel = DP_PRE_CONFIGURED;
+        std::string pin("");
+        std::shared_ptr<OCDirectPairing> s_dp(new OCDirectPairing(&peer));
+        EXPECT_ANY_THROW(OCPlatform::doDirectPairing(s_dp, pmSel, pin, nullptr));
+    }
+
+    TEST(DoDirectPairingTest, DoDirectPairingNullPeer)
+    {
+        OCDPDev_t peer;
+        OCPrm_t pmSel = DP_PRE_CONFIGURED;
+        std::string pin("");
+        std::shared_ptr<OCDirectPairing> s_dp(new OCDirectPairing(&peer));
+        EXPECT_ANY_THROW(OCPlatform::doDirectPairing(nullptr, pmSel, pin, &directPairHandler));
+    }
+
+    TEST(DoDirectPairingTest, DoDirectPairingNullPeerNullCallback)
+    {
+        OCDPDev_t peer;
+        OCPrm_t pmSel = DP_PRE_CONFIGURED;
+        std::string pin("");
+        std::shared_ptr<OCDirectPairing> s_dp(new OCDirectPairing(&peer));
+        EXPECT_ANY_THROW(OCPlatform::doDirectPairing(nullptr, pmSel, pin, nullptr));
+    }
 }