--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * 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 <aul.h>
+#include <aul_watch_control.h>
+#include <gtest/gtest.h>
+
+namespace {
+
+void WatchControlCb(bundle* b, void* user_data) {}
+
+} // namespace
+
+class WatchControlTest : public ::testing::Test {
+ public:
+ WatchControlTest() {}
+
+ virtual void SetUp() {
+ int ret = aul_watch_control_add_handler(WatchControlCb, nullptr,
+ &remove_handler_);
+ EXPECT_EQ(ret, AUL_R_OK);
+ EXPECT_NE(remove_handler_, nullptr);
+ }
+
+ virtual void TearDown() {
+ aul_watch_control_remove_handler(add_handler_);
+ add_handler_ = nullptr;
+ aul_watch_control_remove_handler(remove_handler_);
+ remove_handler_ = nullptr;
+ }
+
+ aul_watch_control_h add_handler_ = nullptr;
+ aul_watch_control_h remove_handler_ = nullptr;
+};
+
+TEST_F(WatchControlTest, aul_watch_control_add_handler_P) {
+ int ret = aul_watch_control_add_handler(WatchControlCb, nullptr,
+ &add_handler_);
+ EXPECT_EQ(ret, AUL_R_OK);
+ EXPECT_NE(add_handler_, nullptr);
+}
+
+TEST_F(WatchControlTest, aul_watch_control_add_handler_N) {
+ int ret = aul_watch_control_add_handler(nullptr, nullptr,
+ &add_handler_);
+ EXPECT_EQ(ret, AUL_R_EINVAL);
+
+ ret = aul_watch_control_add_handler(WatchControlCb, nullptr, nullptr);
+ EXPECT_EQ(ret, AUL_R_EINVAL);
+}
+
+TEST_F(WatchControlTest, aul_watch_control_remove_handler_P) {
+ int ret = aul_watch_control_remove_handler(remove_handler_);
+ EXPECT_EQ(ret, AUL_R_OK);
+ remove_handler_ = nullptr;
+}
+
+TEST_F(WatchControlTest, aul_watch_control_remove_handler_N) {
+ int ret = aul_watch_control_remove_handler(nullptr);
+ EXPECT_EQ(ret, AUL_R_EINVAL);
+
+ aul_watch_control_remove_handler(remove_handler_);
+ ret = aul_watch_control_remove_handler(remove_handler_);
+ EXPECT_EQ(ret, AUL_R_EINVAL);
+ remove_handler_ = nullptr;
+}