1 /*
2  * Copyright (c) 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 <iostream>
16 #include <string>
17 
18 #include "event_publish.h"
19 
20 #include <gtest/gtest.h>
21 
22 using namespace testing::ext;
23 using namespace OHOS::HiviewDFX;
24 
25 class EventPublishTest : public testing::Test {
26 public:
SetUp()27     void SetUp() {};
TearDown()28     void TearDown() {};
SetUpTestCase()29     static void SetUpTestCase() {};
TearDownTestCase()30     static void TearDownTestCase() {};
31 };
32 
33 /**
34  * @tc.name: EventPublishTest001
35  * @tc.desc: used to test PushEvent
36  * @tc.type: FUNC
37 */
38 HWTEST_F(EventPublishTest, EventPublishTest001, TestSize.Level1)
39 {
40     EventPublish::GetInstance().PushEvent(100, "APP_CRASH", HiSysEvent::EventType::BEHAVIOR, "{\"time\":123}");
41     ASSERT_TRUE(true);
42 }
43 
44 /**
45  * @tc.name: EventPublishTest002
46  * @tc.desc: used to test PushEvent
47  * @tc.type: FUNC
48 */
49 HWTEST_F(EventPublishTest, EventPublishTest002, TestSize.Level1)
50 {
51     EventPublish::GetInstance().PushEvent(100, "APP_FREEZE", HiSysEvent::EventType::FAULT, "{\"time\":123}");
52     ASSERT_TRUE(true);
53 }
54 
55 /**
56  * @tc.name: EventPublishTest003
57  * @tc.desc: used to test PushEvent
58  * @tc.type: FUNC
59 */
60 HWTEST_F(EventPublishTest, EventPublishTest003, TestSize.Level1)
61 {
62     EventPublish::GetInstance().PushEvent(100, "ADDRESS_SANITIZER", HiSysEvent::EventType::FAULT, "{\"time\":123}");
63     ASSERT_TRUE(true);
64 }
65 
66 /**
67  * @tc.name: EventPublishTest004
68  * @tc.desc: used to test PushEvent
69  * @tc.type: FUNC
70 */
71 HWTEST_F(EventPublishTest, EventPublishTest004, TestSize.Level1)
72 {
73     EventPublish::GetInstance().PushEvent(100, "APP_START", HiSysEvent::EventType::BEHAVIOR, "{\"time\":123}");
74     ASSERT_TRUE(true);
75 }
76