From c62885a24bc3cfbe143fe2635434dafde35e451e Mon Sep 17 00:00:00 2001 From: zhounanzhao Date: Fri, 24 Nov 2023 20:35:57 +0800 Subject: [PATCH] add ut for watchdog Change-Id: I463a883f8f5d306e75cd0603f51769118a9e7984 Signed-off-by: zhounanzhao --- services/test/BUILD.gn | 1 + services/test/src/watchdog_test.cpp | 57 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 services/test/src/watchdog_test.cpp diff --git a/services/test/BUILD.gn b/services/test/BUILD.gn index 5dbd371..7174678 100644 --- a/services/test/BUILD.gn +++ b/services/test/BUILD.gn @@ -38,6 +38,7 @@ ohos_unittest("WorkScheduleServiceTest") { ] sources = [ "src/event_publisher_test.cpp", + "src/watchdog_test.cpp", "src/workschedulerservice_test.cpp", ] diff --git a/services/test/src/watchdog_test.cpp b/services/test/src/watchdog_test.cpp new file mode 100644 index 0000000..66273fd --- /dev/null +++ b/services/test/src/watchdog_test.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device 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 +#include + +#include "watchdog.h" + +using namespace testing::ext; + +namespace OHOS { +namespace WorkScheduler { + +class WatchdogTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase() {} + void SetUp() {} + void TearDown() {} + static std::shared_ptr watchdog_; +}; + +std::shared_ptr WatchdogTest::watchdog_ = nullptr; + +void WatchdogTest::SetUpTestCase() +{ + std::shared_ptr service; + std::shared_ptr runner; + watchdog_ = std::make_shared(service, runner); +} + +/** + * @tc.name: watchdog_001 + * @tc.desc: Test Watchdog AddWatchdog. + * @tc.type: FUNC + * @tc.require: I8JBRY + */ +HWTEST_F(WatchdogTest, watchdog_001, TestSize.Level1) +{ + bool result = watchdog_->AddWatchdog(1, 1); + EXPECT_EQ(result, false); +} + +} +} \ No newline at end of file -- Gitee