• 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 "reboot_test.h"
17 
18 #include <csignal>
19 #include <iostream>
20 #include "utils/hdf_log.h"
21 
22 using namespace testing::ext;
23 using namespace OHOS::HDI::Battery::V1_1;
24 using namespace std;
25 
26 namespace RebootTest {
SetUpTestCase(void)27 void RebootTest::SetUpTestCase(void)
28 {
29 }
30 
TearDownTestCase(void)31 void RebootTest::TearDownTestCase(void)
32 {
33 }
34 
SetUp(void)35 void RebootTest::SetUp(void)
36 {
37 }
38 
TearDown(void)39 void RebootTest::TearDown(void)
40 {
41 }
42 
43 /**
44  * @tc.name: BatteryST_001
45  * @tc.desc: Test functions reboot in ChargerThread, unplugged not until reboot
46  * @tc.type: FUNC
47  */
48 HWTEST_F (RebootTest, BatteryST_001, TestSize.Level1)
49 {
50     HDF_LOGD("%{public}s: BatteryST_001 start.", __func__);
51     std::string reason = "rebootTest";
52     BatteryThreadTest btTest;
53     ChargerThread ct;
54 
55     ChargerThreadInitTest(ct);
56     btTest.SetKeyState(116, 2, 0, ct);
57     btTest.HandlePowerKey(116, 1999, ct); // do not reboot
58     bool screenOn = GetBacklightTest(ct)->GetScreenState();
59     HDF_LOGD("%{public}s: screenOn=%{public}d", __func__, screenOn);
60 
61     ASSERT_TRUE(screenOn);
62     HDF_LOGD("%{public}s: BatteryST_001 end.", __func__);
63 }
64 
65 /**
66  * @tc.name: BatteryST_002
67  * @tc.desc: Test functions reboot in ChargerThread, unplugged until reboot
68  * @tc.type: FUNC
69  */
70 HWTEST_F (RebootTest, BatteryST_002, TestSize.Level1)
71 {
72     HDF_LOGD("%{public}s: BatteryST_002 start.", __func__);
73     std::string reason = "rebootTest";
74     BatteryThreadTest btTest;
75     ChargerThread ct;
76 
77     ChargerThreadInitTest(ct);
78     btTest.SetKeyState(116, 2, 0, ct);
79     if (false) {
80         btTest.HandlePowerKey(116, 2000, ct); // reboot
81     }
82     HDF_LOGD("%{public}s: BatteryST_0022 end.", __func__);
83 }
84 }
85