• 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 "battery_client_death_recipient_test.h"
17 
18 #include "battery_log.h"
19 #include "battery_srv_client.h"
20 #include "test_utils.h"
21 #include <gtest/gtest.h>
22 #include <iostream>
23 #include <string>
24 
25 using namespace testing::ext;
26 using namespace OHOS::PowerMgr;
27 using namespace OHOS;
28 using namespace std;
29 
30 namespace {
31 /**
32  * @tc.name: BatteryClientDeathRecipient001
33  * @tc.desc: test OnRemoteDied function
34  * @tc.type: FUNC
35  */
36 HWTEST_F(BatteryClientDeathRecipientTest, BatteryClient001, TestSize.Level1)
37 {
38     BATTERY_HILOGD(LABEL_TEST, "BatteryClientDeathRecipient001 start.");
39     auto& batterySrvClient = BatterySrvClient::GetInstance();
40     EXPECT_EQ(batterySrvClient.Connect(), ERR_OK);
41 
42     wptr<IRemoteObject> remoteObj = nullptr;
43     std::shared_ptr<IRemoteObject::DeathRecipient> deathRecipient =
44         std::make_shared<BatterySrvClient::BatterySrvDeathRecipient>();
45     EXPECT_NE(deathRecipient, nullptr);
46     deathRecipient->OnRemoteDied(remoteObj);
47     EXPECT_NE(batterySrvClient.proxy_, nullptr);
48     BATTERY_HILOGD(LABEL_TEST, "BatteryClientDeathRecipient001 end.");
49 }
50 } // namespace