1 /*
2 * Copyright (c) 2022 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 "battery_info_test.h"
17
18 #include <string>
19
20 #include "battery_info.h"
21 #include "battery_log.h"
22
23 using namespace testing::ext;
24
25 namespace OHOS {
26 namespace PowerMgr {
27 namespace {
28 std::shared_ptr<BatteryInfo> g_infoTest = nullptr;
29 } // namespace
30
SetUpTestCase()31 void BatteryInfoTest::SetUpTestCase()
32 {
33 g_infoTest = std::make_shared<BatteryInfo>();
34 }
35
TearDownTestCase()36 void BatteryInfoTest::TearDownTestCase()
37 {
38 g_infoTest = nullptr;
39 }
40
41 /**
42 * @tc.name: BatteryInfo001
43 * @tc.desc: BatteryInfo GetRemainEnergy function test
44 * @tc.type: FUNC
45 */
46 HWTEST_F(BatteryInfoTest, BatteryInfo001, TestSize.Level1)
47 {
48 BATTERY_HILOGD(LABEL_TEST, "BatteryInfo001 begin");
49 g_infoTest->SetRemainEnergy(100);
50 EXPECT_EQ(g_infoTest->GetRemainEnergy(), 100);
51 BATTERY_HILOGD(LABEL_TEST, "BatteryInfo001 end");
52 }
53 } // namespace PowerMgr
54 } // namespace OHOS