1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include "platform/event/include/i_event.h"
17
18#include <iostream>
19#include <unistd.h>
20
21#include "gtest/gtest.h"
22
23#include "utils/log/aie_log.h"
24
25using namespace OHOS::AI;
26using namespace testing::ext;
27
28namespace OHOS {
29namespace AI {
30const int EVENT_WAIT_TIME_MS = 1000;
31class IEvent;
32std::shared_ptr<IEvent> g_event = IEvent::MakeShared();
33} // namespace AI
34} // namespace OHOS
35
36class EventTest : public testing::Test {
37public:
38    // SetUpTestCase:The preset action of the test suite is executed before the first TestCase
39    static void SetUpTestCase() {};
40
41    // TearDownTestCase:The test suite cleanup action is executed after the last TestCase
42    static void TearDownTestCase() {};
43
44    // SetUp:Execute before each test case
45    void SetUp() {};
46
47    // TearDown:Execute after each test case
48    void TearDown() {};
49};
50
51/**
52 * @tc.name: EventTest001
53 * @tc.desc: Test the basic usage process of event function.
54 * @tc.type: FUNC
55 * @tc.require: AR000F77MR
56 */
57HWTEST_F(EventTest, EventTest001, TestSize.Level1)
58{
59    ASSERT_TRUE(g_event->Signal());
60    ASSERT_TRUE(g_event->Wait(EVENT_WAIT_TIME_MS));
61    ASSERT_TRUE(g_event->Reset());
62    ASSERT_FALSE(g_event->IsSet());
63}
64