Add unitest and change invalid function name.
authorjaesick.shin <jaesick.shin@samsung.com>
Wed, 31 Aug 2016 06:57:04 +0000 (15:57 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 2 Sep 2016 02:13:02 +0000 (02:13 +0000)
1. Add unittest for NSProviderRegisterTopic case.
2. change invalid function name in NSProviderInterface.h

second patch is comment changed only.

third patch included,
change invalid testcase name.

Change-Id: Iacbc8466c1f2f204b81ff5db28015ef9f5762858
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11195
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/notification/include/NSProviderInterface.h
service/notification/unittest/NSProviderTest.cpp

index af9c19f..38af5a6 100644 (file)
@@ -137,7 +137,7 @@ NSMessage * NSCreateMessage();
  * @param[in]  topicName Topic name to add\r
  * @return ::NS_OK or result code of NSResult\r
  */\r
-NSResult NSProivderRegisterTopic(const char * topicName);\r
+NSResult NSProviderRegisterTopic(const char * topicName);\r
 \r
 /**\r
  * Delete topic from topic list\r
index 1ae689f..399c200 100755 (executable)
@@ -327,6 +327,42 @@ TEST_F(NotificationProviderTest, ExpectCallbackSyncOnReadFromConsumer)
     responseCon.wait_for(lock, std::chrono::milliseconds(5000));
 }
 
+TEST_F(NotificationProviderTest, ExpectEqualAddedTopicsAndRegisteredTopics)
+{
+    std::string str("TEST1");
+    std::string str2("TEST2");
+    NSProviderRegisterTopic(str.c_str());
+    NSProviderRegisterTopic(str2.c_str());
+
+    std::unique_lock< std::mutex > lock{ mutexForCondition };
+    responseCon.wait_for(lock, std::chrono::milliseconds(1000));
+
+    bool isSame = true;
+    NSTopicLL * topics = NSProviderGetTopics();
+
+    if(!topics)
+    {
+        printf("topic is NULL\n");
+        isSame = false;
+    }
+    else
+    {
+        NSTopicLL * iter = topics;
+        std::string compStr(iter->topicName);
+        std::string compStr2(iter->next->topicName);
+
+        printf("str = %s, compStr = %s\n", str.c_str(), iter->topicName);
+        printf("str2 = %s, compStr2 = %s\n", str2.c_str(), iter->next->topicName);
+
+        if(str.compare(compStr) == 0 && str2.compare(compStr2) == 0)
+        {
+            isSame = true;
+        }
+    }
+
+    EXPECT_EQ(isSame, true);
+}
+
 TEST_F(NotificationProviderTest, CancelObserves)
 {
     bool ret = g_consumerSimul.cancelObserves();