1 /*
2  * Copyright (c) 2022-2023 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 #include "event_server_test.h"
16 
17 #include "event_server.h"
18 #include "file_util.h"
19 
20 using namespace testing::ext;
21 using namespace OHOS::HiviewDFX;
22 
23 namespace {
24 const std::string BBOX_PATH = "/dev/bbox";
25 }
26 
SetUp()27 void EventServerTest::SetUp()
28 {
29     printf("EventServerTest SetUp\n");
30     platform.GetPluginMap();
31 }
32 
TearDown()33 void EventServerTest::TearDown()
34 {
35     printf("EventServerTest TearDown\n");
36 }
37 
38 /**
39  * @tc.name: EventServerTest001
40  * @tc.desc: BBoxDevice test.
41  * @tc.type: FUNC
42  * @tc.require: issueI5NULM
43  */
44 HWTEST_F(EventServerTest, EventServerTest001, TestSize.Level3)
45 {
46     /**
47      * @tc.steps: step1. check whether the node file exists.
48      * @tc.steps: step2. check whether the node file is valid.
49      */
50     if (!FileUtil::FileExists("/dev/bbox")) {
51         printf("The device does not support bbox node\n");
52         return;
53     }
54     BBoxDevice bbox;
55     ASSERT_TRUE(bbox.GetEvents() > 0);
56     ASSERT_NE(bbox.GetName(), "");
57     int res = bbox.Open();
58     ASSERT_TRUE(res >= 0);
59     res = bbox.Close();
60     ASSERT_TRUE(res >= 0);
61 }
62