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
16 #include <functional>
17 #include <gtest/gtest.h>
18
19 #include "event_publisher.h"
20
21 using namespace testing::ext;
22
23 namespace OHOS {
24 namespace WorkScheduler {
25
26 class EventPublisherTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
TearDownTestCase()29 static void TearDownTestCase() {}
SetUp()30 void SetUp() {}
TearDown()31 void TearDown() {}
32 static std::shared_ptr<EventPublisher> eventPublisher_;
33 };
34
35 std::shared_ptr<EventPublisher> EventPublisherTest::eventPublisher_ = nullptr;
36
SetUpTestCase()37 void EventPublisherTest::SetUpTestCase()
38 {
39 eventPublisher_ = std::make_shared<EventPublisher>();
40 }
41
42 /**
43 * @tc.name: publishEvent_001
44 * @tc.desc: Test EventPublisher PublishEvent.
45 * @tc.type: FUNC
46 * @tc.require: I8GHCL
47 */
48 HWTEST_F(EventPublisherTest, publishEvent_001, TestSize.Level1)
49 {
50 std::string result;
51 std::string eventType;
52 std::string eventValue;
53 eventPublisher_->PublishEvent(result, eventType, eventValue);
54 EXPECT_EQ(result, std::string("dump -d need right params."));
55 }
56
57 }
58 }