1 /*
2  * Copyright (c) 2024 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 <gtest/gtest.h>
17 
18 #include "battery_log.h"
19 #include "battery_srv_client.h"
20 #include "ohbattery_info.h"
21 
22 namespace OHOS {
23 namespace PowerMgr {
24 using namespace testing::ext;
25 class OhBatteryInfoTest : public testing::Test {
26 public:
SetUp()27     void SetUp() override {};
TearDown()28     void TearDown() override {};
SetUpTestCase()29     static void SetUpTestCase() {};
TearDownTestCase()30     static void TearDownTestCase() {};
31 };
32 
33 HWTEST_F(OhBatteryInfoTest, OH_BatteryInfo_GetCapacity_001, TestSize.Level1)
34 {
35     BATTERY_HILOGI(LABEL_TEST, "OH_BatteryInfo_GetCapacity_001 start");
36     BatterySrvClient& batterySrvClient = BatterySrvClient::GetInstance();
37     int32_t resultFromClient = batterySrvClient.GetCapacity();
38     int32_t resultFromCApi = OH_BatteryInfo_GetCapacity();
39     EXPECT_EQ(resultFromClient, resultFromCApi);
40 }
41 
42 HWTEST_F(OhBatteryInfoTest, OH_BatteryInfo_GetPluggedType_001, TestSize.Level1)
43 {
44     BATTERY_HILOGI(LABEL_TEST, "OH_BatteryInfo_GetPluggedType_001 start");
45     BatterySrvClient& batterySrvClient = BatterySrvClient::GetInstance();
46     BatteryPluggedType resultFromClient = batterySrvClient.GetPluggedType();
47     BatteryInfo_BatteryPluggedType resultFromCApi = OH_BatteryInfo_GetPluggedType();
48     EXPECT_EQ(static_cast<uint32_t>(resultFromClient), static_cast<uint32_t>(resultFromCApi));
49 }
50 }
51 }