void NSSetIsStartedConsumer(bool setValue)
{
* NSGetBoneIsStartedConsumer() = setValue;
+
+ if (setValue == false)
+ {
+ pthread_mutex_destroy(*NSGetStackMutex());
+ *NSGetStackMutex() = NULL;
+
+ NSOICFree(*NSGetConsumerId());
+ *NSGetConsumerId() = NULL;
+ }
}
bool NSIsStartedConsumer()
NSConsumerThread * thread = NSThreadInit(NSProviderChangedFunc, (void *) data);
NS_VERIFY_NOT_NULL_V(thread);
+
+ NSDestroyThreadHandle(thread);
}
NSSyncInfoReceivedCallback * NSGetBoneNotificationSyncCb()
NSConsumerThread * thread = NSThreadInit(NSNotificationSyncFunc, (void *) retSync);
NS_VERIFY_NOT_NULL_V(thread);
+
+ NSDestroyThreadHandle(thread);
}
NSMessageReceivedCallback * NSGetBoneMessagePostedCb()
NSConsumerThread * thread = NSThreadInit(NSMessagePostFunc, (void *) retMsg);
NS_VERIFY_NOT_NULL_V(thread);
+
+ NSDestroyThreadHandle(thread);
}
NSTask * NSMakeTask(NSTaskType type, void * data)
} NSMessageStateList;
// Mutex of MessageState storage
-pthread_mutex_t * NSGetMessageListMutex();
+pthread_mutex_t ** NSGetMessageListMutex();
void NSLockMessageListMutex();
void NSUnlockMessageListMutex();
*(NSGetProviderCacheList()) = cache;
}
-void NSDestroyProviderCacheList()
+void NSDestroyInternalCachedList()
{
NSCacheList * cache = *(NSGetProviderCacheList());
if (cache)
}
NSSetProviderCacheList(NULL);
+
+ NSDestroyMessageStateList();
+ pthread_mutex_destroy(*NSGetMessageListMutex());
+ *NSGetMessageListMutex() = NULL;
}
NSProvider_internal * NSProviderCacheFind(const char * providerId)
NSConsumerPushEvent(task);
}
-
- NSDestroyMessageStateList();
}
void NSConsumerHandleProviderDiscovered(NSProvider_internal * provider)
}
// implements of MessageState function
-pthread_mutex_t * NSGetMessageListMutex()
+pthread_mutex_t ** NSGetMessageListMutex()
{
static pthread_mutex_t * g_mutex = NULL;
if (g_mutex == NULL)
pthread_mutex_init(g_mutex, NULL);
}
- return g_mutex;
+ return & g_mutex;
}
void NSLockMessageListMutex()
{
NS_LOG_V(DEBUG, "%s", __func__);
- pthread_mutex_lock(NSGetMessageListMutex());
+ pthread_mutex_lock(*NSGetMessageListMutex());
}
void NSUnlockMessageListMutex()
{
NS_LOG_V(DEBUG, "%s", __func__);
- pthread_mutex_unlock(NSGetMessageListMutex());
+ pthread_mutex_unlock(*NSGetMessageListMutex());
}
NSMessageStateList * NSGetMessageStateList()
void NSDestroyMessageCacheList();
-void NSDestroyProviderCacheList();
+void NSDestroyInternalCachedList();
NSMessage * NSMessageCacheFind(const char *);
NSConsumerListenerTermiate();
NSCancelAllSubscription();
+
NSThreadStop(*(NSGetMsgHandleThreadHandle()));
+ NSSetMsgHandleThreadHandle(NULL);
+
NSDestroyQueue(*(NSGetMsgHandleQueue()));
NSSetMsgHandleQueue(NULL);
- NSDestroyProviderCacheList();
+ NSDestroyInternalCachedList();
}
void * NSConsumerMsgHandleThreadFunc(void * threadHandle)
EXPECT_EQ(NS_SYNC_DELETED, state);
}
+TEST_F(NotificationConsumerTest, ExpectGetProviderSuccessWithValidProviderId)
+{
+ NSProvider * provider = NSConsumerGetProvider(g_provider->providerId);
+ int ret = strcmp(provider->providerId, g_provider->providerId);
+ EXPECT_EQ(0, ret);
+ free(provider);
+}
+
+TEST_F(NotificationConsumerTest, ExpectGetProviderSuccessWithInvalidProviderId)
+{
+ NSProvider * provider = NSConsumerGetProvider("123456789012345678901234567890123457");
+ EXPECT_EQ(provider, (void*)NULL);
+}
+
+TEST_F(NotificationConsumerTest, ExpectGetProviderSuccessWithNULL)
+{
+ NSProvider * provider = NSConsumerGetProvider(NULL);
+ EXPECT_EQ(provider, (void*)NULL);
+}
+
TEST_F(NotificationConsumerTest, ExpectGetTopicListIsNULL)
{
NSTopicLL * currentTopics = NSConsumerGetTopicList(g_provider->providerId);
OC::OCPlatform::unregisterResource(m_messageHandle);
OC::OCPlatform::unregisterResource(m_syncHandle);
OC::OCPlatform::unregisterResource(m_topicHandle);
+ m_allowedTopicList.clear();
+ m_topicList.clear();
}
void createNotificationResource()