10485dae0Sopenharmony_ci/* 20485dae0Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 30485dae0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 40485dae0Sopenharmony_ci * you may not use this file except in compliance with the License. 50485dae0Sopenharmony_ci * You may obtain a copy of the License at 60485dae0Sopenharmony_ci * 70485dae0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 80485dae0Sopenharmony_ci * 90485dae0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 100485dae0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 110485dae0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120485dae0Sopenharmony_ci * See the License for the specific language governing permissions and 130485dae0Sopenharmony_ci * limitations under the License. 140485dae0Sopenharmony_ci */ 150485dae0Sopenharmony_ci 160485dae0Sopenharmony_ci#include "platform/event/include/i_event.h" 170485dae0Sopenharmony_ci 180485dae0Sopenharmony_ci#include <iostream> 190485dae0Sopenharmony_ci#include <unistd.h> 200485dae0Sopenharmony_ci 210485dae0Sopenharmony_ci#include "gtest/gtest.h" 220485dae0Sopenharmony_ci 230485dae0Sopenharmony_ci#include "utils/log/aie_log.h" 240485dae0Sopenharmony_ci 250485dae0Sopenharmony_ciusing namespace OHOS::AI; 260485dae0Sopenharmony_ciusing namespace testing::ext; 270485dae0Sopenharmony_ci 280485dae0Sopenharmony_cinamespace OHOS { 290485dae0Sopenharmony_cinamespace AI { 300485dae0Sopenharmony_ciconst int EVENT_WAIT_TIME_MS = 1000; 310485dae0Sopenharmony_ciclass IEvent; 320485dae0Sopenharmony_cistd::shared_ptr<IEvent> g_event = IEvent::MakeShared(); 330485dae0Sopenharmony_ci} // namespace AI 340485dae0Sopenharmony_ci} // namespace OHOS 350485dae0Sopenharmony_ci 360485dae0Sopenharmony_ciclass EventTest : public testing::Test { 370485dae0Sopenharmony_cipublic: 380485dae0Sopenharmony_ci // SetUpTestCase:The preset action of the test suite is executed before the first TestCase 390485dae0Sopenharmony_ci static void SetUpTestCase() {}; 400485dae0Sopenharmony_ci 410485dae0Sopenharmony_ci // TearDownTestCase:The test suite cleanup action is executed after the last TestCase 420485dae0Sopenharmony_ci static void TearDownTestCase() {}; 430485dae0Sopenharmony_ci 440485dae0Sopenharmony_ci // SetUp:Execute before each test case 450485dae0Sopenharmony_ci void SetUp() {}; 460485dae0Sopenharmony_ci 470485dae0Sopenharmony_ci // TearDown:Execute after each test case 480485dae0Sopenharmony_ci void TearDown() {}; 490485dae0Sopenharmony_ci}; 500485dae0Sopenharmony_ci 510485dae0Sopenharmony_ci/** 520485dae0Sopenharmony_ci * @tc.name: EventTest001 530485dae0Sopenharmony_ci * @tc.desc: Test the basic usage process of event function. 540485dae0Sopenharmony_ci * @tc.type: FUNC 550485dae0Sopenharmony_ci * @tc.require: AR000F77MR 560485dae0Sopenharmony_ci */ 570485dae0Sopenharmony_ciHWTEST_F(EventTest, EventTest001, TestSize.Level1) 580485dae0Sopenharmony_ci{ 590485dae0Sopenharmony_ci ASSERT_TRUE(g_event->Signal()); 600485dae0Sopenharmony_ci ASSERT_TRUE(g_event->Wait(EVENT_WAIT_TIME_MS)); 610485dae0Sopenharmony_ci ASSERT_TRUE(g_event->Reset()); 620485dae0Sopenharmony_ci ASSERT_FALSE(g_event->IsSet()); 630485dae0Sopenharmony_ci} 64