• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "thermal_mock_proxy_writeinterfacetoken_test.h"
17 
18 #include "mock_thermal_remote_object.h"
19 #include "thermal_action_callback_proxy.h"
20 #include "thermal_level_callback_proxy.h"
21 #include "thermal_log.h"
22 #include "thermal_srv_proxy.h"
23 #include "thermal_srv_sensor_info.h"
24 #include "thermal_temp_callback_proxy.h"
25 
26 using namespace testing::ext;
27 using namespace OHOS::PowerMgr;
28 using namespace OHOS;
29 using namespace std;
30 
31 namespace {
32 /**
33  * @tc.name: ThermalMockProxyWriteinterfacetokenTest001
34  * @tc.desc: proxy test
35  * @tc.type: FUNC
36  * @tc.require: issueI5YZQ2
37  */
38 HWTEST_F(ThermalMockProxyWriteinterfacetokenTest, ThermalMockProxyWriteinterfacetokenTest001, TestSize.Level0)
39 {
40     THERMAL_HILOGD(LABEL_TEST, "ThermalMockProxyWriteinterfacetokenTest001 start.");
41     sptr<MockThermalRemoteObject> sptrRemoteObj = new MockThermalRemoteObject();
42     EXPECT_FALSE(sptrRemoteObj == nullptr);
43     std::shared_ptr<ThermalSrvProxy> srvProxy = std::make_shared<ThermalSrvProxy>(sptrRemoteObj);
44     EXPECT_FALSE(srvProxy == nullptr);
45     std::vector<std::string> typeList;
46     std::string desc;
47     sptr<IThermalTempCallback> tempCallback = new ThermalTempCallbackProxy(sptrRemoteObj);
48     EXPECT_FALSE(tempCallback == nullptr);
49     EXPECT_FALSE(srvProxy->SubscribeThermalTempCallback(typeList, tempCallback));
50     EXPECT_FALSE(srvProxy->UnSubscribeThermalTempCallback(tempCallback));
51     sptr<IThermalLevelCallback> levelCallback = new ThermalLevelCallbackProxy(sptrRemoteObj);
52     EXPECT_FALSE(levelCallback == nullptr);
53     EXPECT_FALSE(srvProxy->SubscribeThermalLevelCallback(levelCallback));
54     EXPECT_FALSE(srvProxy->UnSubscribeThermalLevelCallback(levelCallback));
55     sptr<IThermalActionCallback> actionCallback = new ThermalActionCallbackProxy(sptrRemoteObj);
56     EXPECT_FALSE(actionCallback == nullptr);
57     EXPECT_FALSE(srvProxy->SubscribeThermalActionCallback(typeList, desc, actionCallback));
58     EXPECT_FALSE(srvProxy->UnSubscribeThermalActionCallback(actionCallback));
59 
60     SensorType type = SensorType::SOC;
61     sptr<ThermalSrvSensorInfo> sensorInfo = new ThermalSrvSensorInfo();
62     EXPECT_FALSE(sensorInfo == nullptr);
63     EXPECT_FALSE(srvProxy->GetThermalSrvSensorInfo(type, *sensorInfo));
64     ThermalLevel level = ThermalLevel::COOL;
65     EXPECT_FALSE(srvProxy->GetThermalLevel(level));
66     std::string sence;
67     EXPECT_FALSE(srvProxy->SetScene(sence));
68     THERMAL_HILOGD(LABEL_TEST, "ThermalMockProxyWriteinterfacetokenTest001 end.");
69 }
70 
71 /**
72  * @tc.name: ThermalMockProxyWriteinterfacetokenTest002
73  * @tc.desc: proxy test
74  * @tc.type: FUNC
75  * @tc.require: issueI5YZQ2
76  */
77 HWTEST_F(ThermalMockProxyWriteinterfacetokenTest, ThermalMockProxyWriteinterfacetokenTest002, TestSize.Level0)
78 {
79     THERMAL_HILOGD(LABEL_TEST, "ThermalMockProxyWriteinterfacetokenTest002 start.");
80     sptr<MockThermalRemoteObject> sptrRemoteObj = new MockThermalRemoteObject();
81     EXPECT_FALSE(sptrRemoteObj == nullptr);
82     std::shared_ptr<ThermalTempCallbackProxy> tempProxy = std::make_shared<ThermalTempCallbackProxy>(sptrRemoteObj);
83     EXPECT_FALSE(tempProxy == nullptr);
84     using TempCallbackMap = std::map<std::string, int32_t>;
85     TempCallbackMap tempCbMap;
86     EXPECT_FALSE(tempProxy->OnThermalTempChanged(tempCbMap));
87     std::shared_ptr<ThermalActionCallbackProxy> actionProxy =
88         std::make_shared<ThermalActionCallbackProxy>(sptrRemoteObj);
89     EXPECT_FALSE(actionProxy == nullptr);
90     using ActionCallbackMap = std::map<std::string, std::string>;
91     ActionCallbackMap map;
92     EXPECT_FALSE(actionProxy->OnThermalActionChanged(map));
93     std::shared_ptr<ThermalLevelCallbackProxy> levalProxy = std::make_shared<ThermalLevelCallbackProxy>(sptrRemoteObj);
94     EXPECT_FALSE(levalProxy == nullptr);
95     ThermalLevel level = ThermalLevel::COOL;
96     EXPECT_FALSE(levalProxy->OnThermalLevelChanged(level));
97     THERMAL_HILOGD(LABEL_TEST, "ThermalMockProxyWriteinterfacetokenTest002 end.");
98 }
99 } // namespace
100