• 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 "event_logger_config_test.h"
16 
17 #include <iostream>
18 #include <memory>
19 
20 #include "event_logger_config.h"
21 using namespace testing::ext;
22 using namespace OHOS::HiviewDFX;
23 
SetUp()24 void EventLoggerConfigTest::SetUp()
25 {
26     /**
27      * @tc.setup: create an event loop and multiple event handlers
28      */
29     printf("SetUp.\n");
30 }
31 
TearDown()32 void EventLoggerConfigTest::TearDown()
33 {
34     /**
35      * @tc.teardown: destroy the event loop we have created
36      */
37     printf("TearDown.\n");
38 }
39 
40 /**
41  * @tc.name: EventLoggerConfigTest002
42  * @tc.desc: parse a incorrect config file and check result
43  * @tc.type: FUNC
44  * @tc.require: AR000FT621
45  */
46 HWTEST_F(EventLoggerConfigTest, EventLoggerConfigTest002, TestSize.Level3)
47 {
48     /**
49      * @tc.steps: step1. create event handler and events
50      */
51     auto config = std::make_unique<EventLoggerConfig>("/data/test/test_data/event_logger_config");
52     EventLoggerConfig::EventLoggerConfigData configOut;
53     bool ret = config->FindConfigLine(0, "FWK_BLOCK", configOut);
54     EXPECT_EQ(ret, true);
55     EXPECT_EQ(configOut.action == "b,s=1,n=2,pb:0", true);
56     EXPECT_EQ(configOut.interval, 30);
57 
58     ret = config->FindConfigLine(0, "RESUME03", configOut);
59     EXPECT_EQ(ret, true);
60     EXPECT_EQ(configOut.action == "b,s=332,m=sd:2.2.10;tr56,pb:0", true);
61     EXPECT_EQ(configOut.interval, 87);
62     EXPECT_EQ(config->GetVersion() == "0.1", true);
63 
64     ret = config->FindConfigLine(0, "RESUME04", configOut);
65     EXPECT_EQ(ret, false);
66 
67     ret = config->FindConfigLine(0, "RESUME05", configOut);
68     EXPECT_EQ(ret, true);
69     EXPECT_EQ(configOut.id, 0x123);
70     EXPECT_EQ(configOut.action == "b,s=1456,n=pdc,pb:0", true);
71     EXPECT_EQ(configOut.interval, 31);
72     EXPECT_EQ(config->GetVersion() == "0.1", true);
73 }
74