From: hyunuk.tak Date: Fri, 25 Mar 2022 05:30:22 +0000 (+0900) Subject: Add joiner test case for joiner start X-Git-Tag: accepted/tizen/unified/20220914.164046~77 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F05%2F272905%2F1;p=platform%2Fcore%2Fapi%2Fthread.git Add joiner test case for joiner start Change-Id: If16289acf415effc8fc6932d1857436e8e84ab33 Signed-off-by: hyunuk.tak --- diff --git a/tests/unittest/thread-unittest-joiner.cpp b/tests/unittest/thread-unittest-joiner.cpp new file mode 100644 index 0000000..6c12fd4 --- /dev/null +++ b/tests/unittest/thread-unittest-joiner.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "thread.h" + +class ThreadJoinerTest : public ::testing::Test +{ +public: + const char *pskd = "Passkey"; + const char *provUrl = "ProvUrl"; + const char *vendorName = "VendorName"; + const char *vendorModel = "VendorModel"; + const char *vendorSwVersion = "VendorSwVersion"; + const char *vendorData = "VendorData"; + + thread_instance_h instance; + +public: + static void joinerStartCallback(int result, void* user_data) {}; + +protected: + void SetUp() override + { + thread_initialize(); + instance = nullptr; + } + + void TearDown() override + { + thread_deinitialize(); + } +}; + +TEST_F(ThreadJoinerTest, JoinerStartNotInitialized) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize()); + EXPECT_EQ(THREAD_ERROR_NOT_INITIALIZED, + thread_joiner_start(instance, pskd, provUrl, + vendorName, vendorModel, vendorSwVersion, + vendorData, joinerStartCallback, nullptr)); +} + +TEST_F(ThreadJoinerTest, JoinerStartInvalidParameter) +{ + EXPECT_EQ(THREAD_ERROR_INVALID_PARAMETER, + thread_joiner_start(instance, pskd, provUrl, + vendorName, vendorModel, vendorSwVersion, + vendorData, joinerStartCallback, nullptr)); +} + +TEST_F(ThreadJoinerTest, JoinerStartAttachErrorNone) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance)); + EXPECT_EQ(THREAD_ERROR_NONE, + thread_joiner_start(instance, pskd, provUrl, + vendorName, vendorModel, vendorSwVersion, + vendorData, joinerStartCallback, nullptr)); +} \ No newline at end of file