• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 "stats_service_test.h"
17 
18 #include <if_system_ability_manager.h>
19 #include <iservice_registry.h>
20 #include <system_ability_definition.h>
21 #include "gtest/gtest-message.h"
22 #include "gtest/gtest-test-part.h"
23 #include "gtest/gtest.h"
24 #include "gtest/hwext/gtest-ext.h"
25 #include "gtest/hwext/gtest-tag.h"
26 #include "iremote_object.h"
27 #include "ostream"
28 #include "refbase.h"
29 
30 using namespace testing::ext;
31 using namespace OHOS::PowerMgr;
32 using namespace OHOS;
33 
SetUpTestCase()34 void StatsServiceTest::SetUpTestCase()
35 {
36     GTEST_LOG_(INFO) << __func__;
37 }
38 
TearDownTestCase()39 void StatsServiceTest::TearDownTestCase()
40 {
41     GTEST_LOG_(INFO) << __func__;
42 }
43 
SetUp()44 void StatsServiceTest::SetUp()
45 {
46     GTEST_LOG_(INFO) << __func__;
47 }
48 
TearDown()49 void StatsServiceTest::TearDown()
50 {
51     GTEST_LOG_(INFO) << __func__;
52 }
53 
54 namespace {
55 /**
56  * @tc.name: StatsServiceTest_001
57  * @tc.desc: test BatteryStatsService service ready.
58  * @tc.type: FUNC
59  */
60 HWTEST_F (StatsServiceTest, StatsServiceTest_001, TestSize.Level0)
61 {
62     sptr<ISystemAbilityManager> sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
63     ASSERT_TRUE(sam != nullptr) << "StatsServiceTest_001 fail to get GetSystemAbilityManager";
64     sptr<IRemoteObject> remoteObject_ = sam->CheckSystemAbility(POWER_MANAGER_BATT_STATS_SERVICE_ID);
65     ASSERT_TRUE(remoteObject_ != nullptr) << "GetSystemAbility failed.";
66 }
67 }