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