• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
SetUpTestCase()34 void HgmXmlParserTest::SetUpTestCase() {}
TearDownTestCase()35 void HgmXmlParserTest::TearDownTestCase() {}
SetUp()36 void HgmXmlParserTest::SetUp() {}
TearDown()37 void HgmXmlParserTest::TearDown() {}
38 
39 /**
40  * @tc.name: LoadConfiguration
41  * @tc.desc: Verify the result of LoadConfiguration function
42  * @tc.type: FUNC
43  * @tc.require: I7DMS1
44  */
45 HWTEST_F(HgmXmlParserTest, LoadConfiguration, Function | SmallTest | Level1)
46 {
47     std::unique_ptr<XMLParser> parser = std::make_unique<XMLParser>();
48 
49     PART("CaseDescription") {
50         STEP("1. get an xml parser") {
51             STEP_ASSERT_NE(parser, nullptr);
52         }
53         STEP("2. check the result of configuration") {
54             int32_t load = parser->LoadConfiguration();
55             STEP_ASSERT_EQ(load, 0);
56         }
57     }
58 }
59 
60 /**
61  * @tc.name: Parse
62  * @tc.desc: Verify the result of parsing functions
63  * @tc.type: FUNC
64  * @tc.require: I7DMS1
65  */
66 HWTEST_F(HgmXmlParserTest, Parse, Function | SmallTest | Level1)
67 {
68     std::unique_ptr<XMLParser> parser = std::make_unique<XMLParser>();
69     int32_t load = parser->LoadConfiguration();
70     int32_t parse = parser->Parse();
71     auto parsedData = parser->GetParsedData();
72     auto translateDynamicSetting = parsedData->dynamicSetting_.find("translate")->second;
73     auto scaleDynamicSetting = parsedData->dynamicSetting_.find("scale")->second;
74     auto rotationDynamicSetting = parsedData->dynamicSetting_.find("rotation")->second;
75 
76     PART("CaseDescription") {
77         STEP("1. get an xml parser") {
78             STEP_ASSERT_EQ(load, 0);
79             STEP_ASSERT_EQ(parse, 0);
80         }
81         STEP("2. check the parsing result ") {
82             STEP_ASSERT_EQ(parsedData->isDynamicFrameRateEnable_, "1");
83             STEP_ASSERT_NE(parsedData->customerSettingConfig_.size(), 0);
84             STEP_ASSERT_NE(parsedData->detailedStrategies_.size(), 0);
85             STEP_ASSERT_NE(parsedData->animationDynamicStrats_.size(), 0);
86             STEP_ASSERT_NE(translateDynamicSetting.size(), 0);
87             STEP_ASSERT_NE(scaleDynamicSetting.size(), 0);
88             STEP_ASSERT_NE(rotationDynamicSetting.size(), 0);
89         }
90     }
91 }
92 } // namespace Rosen
93 } // namespace OHOS