1 /*
2 * Copyright (c) 2022 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 <gtest/gtest.h>
17 #include <hilog/log.h>
18 #include <memory>
19 #include <unistd.h>
20 #include "platform/common/rs_event_detector.h"
21
22 using namespace testing;
23 using namespace testing::ext;
24
25 namespace OHOS::Rosen {
26 class RSEventTest : public testing::Test {
27 public:
28 static constexpr HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, 0, "RSEventTest" };
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp() override;
32 void TearDown() override;
33
34 static inline std::shared_ptr<RSBaseEventDetector> detector = nullptr;
35 };
36
SetUpTestCase()37 void RSEventTest::SetUpTestCase() {}
TearDownTestCase()38 void RSEventTest::TearDownTestCase() {}
SetUp()39 void RSEventTest::SetUp() {}
TearDown()40 void RSEventTest::TearDown() {}
41
42 /**
43 * @tc.name: CreateAndDestroy001
44 * @tc.desc: Verify the main function of detector
45 * @tc.type: FUNC
46 * @tc.require: issueI5GKGC
47 */
48 HWTEST_F(RSEventTest, CreateAndDestroy001, Function | SmallTest | Level2)
49 {
50 // The best way to create RSDetector.
51 auto d = RSBaseEventDetector::CreateRSTimeOutDetector(2000, "RS_EVENT_TEST");
52 EXPECT_NE(d.get(), nullptr);
53 }
54
55 /**
56 * @tc.name: CreateAndDestroy002
57 * @tc.desc: Verify the main function of detector
58 * @tc.type: FUNC
59 * @tc.require: issueI5GKGC
60 */
61 HWTEST_F(RSEventTest, CreateAndDestroy002, Function | SmallTest | Level2)
62 {
63 // The best way to create RSDetector.
64 auto d = RSBaseEventDetector::CreateRSTimeOutDetector(2000, "RS_EVENT_TEST");
65 // Verify string id
66 EXPECT_EQ(d->GetStringId(), "RS_EVENT_TEST");
67 }
68 } // namespace OHOS::Rosen
69