• 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 
16 #include "battery_undertemperature_shutdown_test.h"
17 
18 #include <csignal>
19 #include <iostream>
20 #include "utils/hdf_log.h"
21 
22 #include "battery_service.h"
23 #include "power_supply_provider.h"
24 #include "battery_thread_test.h"
25 
26 using namespace testing::ext;
27 using namespace OHOS;
28 using namespace OHOS::PowerMgr;
29 using namespace OHOS::HDI::Battery::V1_1;
30 using namespace std;
31 
32 static sptr<BatteryService> g_service;
33 
34 namespace BatteryUndertemperatureShutdownTest {
SetUpTestCase(void)35 void BatteryUndertemperatureShutdownTest::SetUpTestCase(void)
36 {
37     g_service = DelayedSpSingleton<BatteryService>::GetInstance();
38     g_service->OnStart();
39 }
40 
TearDownTestCase(void)41 void BatteryUndertemperatureShutdownTest::TearDownTestCase(void)
42 {
43     g_service->OnStop();
44     DelayedSpSingleton<BatteryService>::DestroyInstance();
45 }
46 
SetUp(void)47 void BatteryUndertemperatureShutdownTest::SetUp(void)
48 {
49 }
50 
TearDown(void)51 void BatteryUndertemperatureShutdownTest::TearDown(void)
52 {
53 }
54 
55 /**
56  * @tc.name: BatteryST_005
57  * @tc.desc: Test functions temperature in normal range in BatteryHostServiceStub
58  * @tc.type: FUNC
59  */
60 HWTEST_F (BatteryUndertemperatureShutdownTest, BatteryST_005, TestSize.Level1)
61 {
62     HDF_LOGD("%{public}s: enter. BatteryST_005 start.", __func__);
63     g_service->InitConfig();
64 
65     g_service->HandleTemperature(-99);
66     HDF_LOGD("%{public}s: enter. BatteryST_005 end.", __func__);
67 }
68 
69 /**
70  * @tc.name: BatteryST_006
71  * @tc.desc: Test functions lower temperature shutdown in BatteryHostServiceStub
72  * @tc.type: FUNC
73  */
74 HWTEST_F (BatteryUndertemperatureShutdownTest, BatteryST_006, TestSize.Level1)
75 {
76     HDF_LOGD("%{public}s: enter. BatteryST_006 start.", __func__);
77     g_service->InitConfig();
78     if (false) {
79         g_service->HandleTemperature(-100);
80     }
81     HDF_LOGD("%{public}s: enter. BatteryST_006 end.", __func__);
82 }
83 }
84