• 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_dialog_test.h"
17 #include "battery_service.h"
18 
19 using namespace testing::ext;
20 using namespace OHOS;
21 using namespace OHOS::PowerMgr;
22 using namespace OHOS::HDI::Battery::V1_1;
23 using namespace std;
24 
25 static sptr<BatteryService> g_service;
26 
27 namespace BatteryDialogTest {
SetUpTestCase()28 void BatteryDialogTest::SetUpTestCase()
29 {
30     g_service = DelayedSpSingleton<BatteryService>::GetInstance();
31     g_service->OnStart();
32 }
33 
TearDownTestCase()34 void BatteryDialogTest::TearDownTestCase()
35 {
36     g_service->OnStop();
37     DelayedSpSingleton<BatteryService>::DestroyInstance();
38 }
39 
SetUp()40 void BatteryDialogTest::SetUp()
41 {
42 }
43 
TearDown()44 void BatteryDialogTest::TearDown()
45 {
46 }
47 
48 /**
49  * @tc.name: BatteryDailogST_001
50  * @tc.desc: test pull up BatteryDialog by service
51  * @tc.type: FUNC
52  * @tc.require: issueI5I9BF
53  */
54 HWTEST_F (BatteryDialogTest, BatteryDialogST_001, TestSize.Level1)
55 {
56     EXPECT_TRUE(g_service->ShowBatteryDialog());
57 }
58 
59 /**
60  * @tc.name: BatteryDailogST_002
61  * @tc.desc: test kill BatteryDialog by service
62  * @tc.type: FUNC
63  * @tc.require: issueI5I9BF
64  */
65 HWTEST_F (BatteryDialogTest, BatteryDialogST_002, TestSize.Level1)
66 {
67     EXPECT_TRUE(g_service->DestoryBatteryDialog());
68 }
69 }
70