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 <gtest/gtest.h>
17 #include <test_header.h>
18
19 #include "xml_parser.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS {
25 namespace Rosen {
26 class HgmXmlParserTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp();
31 void TearDown();
32
33 static constexpr char CONFIG[] = "/sys_prod/etc/graphic/hgm_policy_config.xml";
34 };
35
SetUpTestCase()36 void HgmXmlParserTest::SetUpTestCase() {}
TearDownTestCase()37 void HgmXmlParserTest::TearDownTestCase() {}
SetUp()38 void HgmXmlParserTest::SetUp() {}
TearDown()39 void HgmXmlParserTest::TearDown() {}
40
41 /**
42 * @tc.name: LoadConfiguration
43 * @tc.desc: Verify the result of LoadConfiguration function
44 * @tc.type: FUNC
45 * @tc.require: I7DMS1
46 */
47 HWTEST_F(HgmXmlParserTest, LoadConfiguration, Function | SmallTest | Level1)
48 {
49 std::unique_ptr<XMLParser> parser = std::make_unique<XMLParser>();
50
51 PART("CaseDescription") {
52 STEP("1. get an xml parser") {
53 STEP_ASSERT_NE(parser, nullptr);
54 }
55 STEP("2. check the result of configuration") {
56 int32_t load = parser->LoadConfiguration(CONFIG);
57 STEP_ASSERT_GE(load, 0);
58 }
59 }
60 }
61
62 /**
63 * @tc.name: Parse
64 * @tc.desc: Verify the result of parsing functions
65 * @tc.type: FUNC
66 * @tc.require: I7DMS1
67 */
68 HWTEST_F(HgmXmlParserTest, Parse, Function | SmallTest | Level1)
69 {
70 std::unique_ptr<XMLParser> parser = std::make_unique<XMLParser>();
71 int32_t load = parser->LoadConfiguration(CONFIG);
72 EXPECT_LE(load, XML_FILE_LOAD_FAIL);
73 parser->Parse();
74 parser->GetParsedData();
75 }
76 } // namespace Rosen
77 } // namespace OHOS