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 #include "platform_config_test.h"
16 #include "plugin_config.h"
17 using namespace testing::ext;
18 using namespace OHOS::HiviewDFX;
19
SetUp()20 void PlatformConfigTest::SetUp()
21 {
22 /**
23 * @tc.setup: create an event loop and multiple event handlers
24 */
25 printf("SetUp.\n");
26 platform.GetPluginMap();
27 }
28
TearDown()29 void PlatformConfigTest::TearDown()
30 {
31 /**
32 * @tc.teardown: destroy the event loop we have created
33 */
34 printf("TearDown.\n");
35 }
36
37 /**
38 * @tc.name: PlatformConfigParse001
39 * @tc.desc: parse a correct config file and check result
40 * @tc.type: FUNC
41 * @tc.require: AR000DPTT5
42 */
43 HWTEST_F(PlatformConfigTest, PlatformConfigParse001, TestSize.Level3)
44 {
45 /**
46 * @tc.steps: step1. create event handler and events
47 */
48 PluginConfig config("/data/test/test_data/plugin_config1");
49 if (!config.StartParse()) {
50 printf("fail to parse plugin config. exit! \n");
51 FAIL();
52 }
53
54 /**
55 * @tc.expected: step1. the event has been processed
56 */
57 auto pluginInfoList = config.GetPluginInfoList();
58 EXPECT_EQ(pluginInfoList.size(), 37ul);
59 for (auto& pluginInfo : pluginInfoList) {
60 printf("read plugin with name:%s \n", pluginInfo.name.c_str());
61 }
62
63 auto pipelineInfoList = config.GetPipelineInfoList();
64 EXPECT_EQ(pipelineInfoList.size(), 10ul);
65 for (auto& pipelineInfo : pipelineInfoList) {
66 printf("read pipeline with name:%s \n", pipelineInfo.name.c_str());
67 }
68 }
69
70 /**
71 * @tc.name: PlatformConfigParse002
72 * @tc.desc: parse a incorrect config file and check result
73 * @tc.type: FUNC
74 * @tc.require: AR000DPTT5
75 */
76 HWTEST_F(PlatformConfigTest, PlatformConfigParse002, TestSize.Level3)
77 {
78 /**
79 * @tc.steps: step1. create event handler and events
80 */
81 PluginConfig config("/data/test/test_data/plugin_config_incomplete");
82 if (!config.StartParse()) {
83 printf("fail to parse plugin config. exit! \n");
84 FAIL();
85 }
86
87 /**
88 * @tc.expected: step1. the event has been processed
89 */
90 auto pluginInfoList = config.GetPluginInfoList();
91 EXPECT_EQ(pluginInfoList.size(), 5ul);
92 for (auto& pluginInfo : pluginInfoList) {
93 printf("read plugin with name:%s \n", pluginInfo.name.c_str());
94 }
95
96 auto pipelineInfoList = config.GetPipelineInfoList();
97 EXPECT_EQ(pipelineInfoList.size(), 0ul);
98 for (auto& pipelineInfo : pipelineInfoList) {
99 printf("read pipeline with name:%s \n", pipelineInfo.name.c_str());
100 }
101 }
102