1 /*
2 * Copyright (c) 2021-2023 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_mgr_policy_test.h"
17
18 #include "power_mgr_client.h"
19 #include "thermal_mgr_client.h"
20 #include "mock_thermal_mgr_client.h"
21 #include "modulemgr.h"
22
23 #define private public
24 #define protected public
25 #include "thermal_service.h"
26 #include "thermal_srv_config_parser.h"
27 #include "thermal_srv_sensor_info.h"
28 #include "v1_1/ithermal_interface.h"
29 #include "v1_1/thermal_types.h"
30 #undef private
31 #undef protected
32
33 using namespace testing::ext;
34 using namespace OHOS::PowerMgr;
35 using namespace OHOS;
36 using namespace std;
37
38 namespace {
39 const std::string SYSTEM_THERMAL_SERVICE_CONFIG_PATH = "/system/etc/thermal_config/thermal_service_config.xml";
40 sptr<ThermalService> g_service = nullptr;
41 const int32_t LEVEL_0 = 0;
42 const int32_t LEVEL_1 = 1;
43 const int32_t LEVEL_2 = 2;
44 const int32_t LEVEL_3 = 3;
45 const int32_t LEVEL_4 = 4;
46 }
47
TearDown()48 void ThermalMgrPolicyTest::TearDown()
49 {
50 g_service->SetScene("");
51 HdfThermalCallbackInfo event;
52 ThermalZoneInfo info1;
53 info1.type = "battery";
54 info1.temp = 0;
55 event.info.push_back(info1);
56 info1.type = "ap";
57 event.info.push_back(info1);
58 info1.type = "ambient";
59 event.info.push_back(info1);
60 info1.type = "shell";
61 event.info.push_back(info1);
62 info1.type = "pa";
63 event.info.push_back(info1);
64 g_service->HandleThermalCallbackEvent(event);
65 }
66
SetUpTestCase()67 void ThermalMgrPolicyTest::SetUpTestCase()
68 {
69 g_service = ThermalService::GetInstance();
70 g_service->InitSystemTestModules();
71 g_service->OnStart();
72 g_service->InitStateMachine();
73 g_service->InitActionManager();
74 g_service->GetBaseinfoObj()->Init();
75 g_service->GetObserver()->InitSensorTypeMap();
76 }
77
TearDownTestCase()78 void ThermalMgrPolicyTest::TearDownTestCase()
79 {
80 g_service->OnStop();
81 }
82
83 namespace {
84 /**
85 * @tc.name: ThermalMgrPolicyTest001
86 * @tc.desc: test get current configured level by setting temp
87 * @tc.type: FEATURE
88 * @tc.cond: Set Battery temp, High Temp
89 * @tc.result level 1
90 */
91 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest001, Function|MediumTest|Level2)
92 {
93 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest001 function start!");
94 HdfThermalCallbackInfo event;
95 ThermalZoneInfo info1;
96 info1.type = "battery";
97 info1.temp = 40100;
98 event.info.push_back(info1);
99 g_service->HandleThermalCallbackEvent(event);
100 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
101 EXPECT_TRUE(value == LEVEL_1) << "ThermalMgrPolicyTest001 failed";
102 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest001 function end!");
103 }
104
105 /**
106 * @tc.name: ThermalMgrPolicyTest002
107 * @tc.desc: test get current configured level by setting temp
108 * @tc.type: FEATURE
109 * @tc.cond: Set Battery temp, High Temp
110 * @tc.result level 2
111 */
112 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest002, Function|MediumTest|Level2)
113 {
114 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest002 function start!");
115 HdfThermalCallbackInfo event;
116 ThermalZoneInfo info1;
117 info1.type = "battery";
118 info1.temp = 43100;
119 event.info.push_back(info1);
120 g_service->HandleThermalCallbackEvent(event);
121 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
122 EXPECT_TRUE(value == LEVEL_2) << "ThermalMgrPolicyTest002 failed";
123 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest002 function end!");
124 }
125
126 /**
127 * @tc.name: ThermalMgrPolicyTest003
128 * @tc.desc: test get current configured level by setting temp
129 * @tc.type: FEATURE
130 * @tc.cond: Set Battery temp, High Temp
131 * @tc.result level 3
132 */
133 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest003, Function|MediumTest|Level2)
134 {
135 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest003 function start!");
136 HdfThermalCallbackInfo event;
137 ThermalZoneInfo info1;
138 info1.type = "battery";
139 info1.temp = 46100;
140 event.info.push_back(info1);
141 g_service->HandleThermalCallbackEvent(event);
142 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
143 EXPECT_TRUE(value == LEVEL_3) << "ThermalMgrPolicyTest003 failed";
144 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest003 function end!");
145 }
146
147 /**
148 * @tc.name: ThermalMgrPolicyTest004
149 * @tc.desc: test get current configured level by setting temp
150 * @tc.type: FEATURE
151 * @tc.cond: Set Battery temp, High Temp
152 * @tc.result level 4
153 */
154 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest004, Function|MediumTest|Level2)
155 {
156 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest004 function start!");
157 HdfThermalCallbackInfo event;
158 ThermalZoneInfo info1;
159 info1.type = "battery";
160 info1.temp = 48100;
161 event.info.push_back(info1);
162 g_service->HandleThermalCallbackEvent(event);
163 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
164 EXPECT_TRUE(value == LEVEL_4) << "ThermalMgrPolicyTest004 failed";
165 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest004 function end!");
166 }
167
168 /**
169 * @tc.name: ThermalMgrPolicyTest005
170 * @tc.desc: test level asc logic by setting temp
171 * @tc.type: FEATURE
172 * @tc.cond: Set Battery temp, High Temp
173 * @tc.result level 1 ==> level 4
174 */
175 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest005, Function|MediumTest|Level2)
176 {
177 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest005 function start!");
178 HdfThermalCallbackInfo event;
179 ThermalZoneInfo info1;
180 info1.type = "battery";
181 info1.temp = 40100;
182 event.info.push_back(info1);
183 g_service->HandleThermalCallbackEvent(event);
184 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
185 EXPECT_TRUE(value == LEVEL_1) << "ThermalMgrPolicyTest005 failed";
186 event.info.clear();
187
188 info1.temp = 48100;
189 event.info.push_back(info1);
190 g_service->HandleThermalCallbackEvent(event);
191 value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
192 EXPECT_TRUE(value == LEVEL_4) << "ThermalMgrPolicyTest005 failed";
193 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest005 function end!");
194 }
195
196 /**
197 * @tc.name: ThermalMgrPolicyTest006
198 * @tc.desc: test level asc logic by setting temp
199 * @tc.type: FEATURE
200 * @tc.cond: Set Battery temp, High Temp
201 * @tc.result level 2 ==> level 4
202 */
203 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest006, Function|MediumTest|Level2)
204 {
205 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest006 function start!");
206 HdfThermalCallbackInfo event;
207 ThermalZoneInfo info1;
208 info1.type = "battery";
209 info1.temp = 43100;
210 event.info.push_back(info1);
211 g_service->HandleThermalCallbackEvent(event);
212 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
213 EXPECT_TRUE(value == LEVEL_2) << "ThermalMgrPolicyTest006 failed";
214 event.info.clear();
215
216 info1.temp = 48100;
217 event.info.push_back(info1);
218 g_service->HandleThermalCallbackEvent(event);
219 value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
220 EXPECT_TRUE(value == LEVEL_4) << "ThermalMgrPolicyTest006 failed";
221 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest006 function end!");
222 }
223
224 /**
225 * @tc.name: ThermalMgrPolicyTest007
226 * @tc.desc: test level desc logic by setting temp
227 * @tc.type: FEATURE
228 * @tc.cond: Set Battery temp, High Temp
229 * @tc.result level 4 ===> level 1
230 */
231 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest007, Function|MediumTest|Level2)
232 {
233 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest007 function start!");
234 HdfThermalCallbackInfo event;
235 ThermalZoneInfo info1;
236 info1.type = "battery";
237 info1.temp = 48200;
238 event.info.push_back(info1);
239 g_service->HandleThermalCallbackEvent(event);
240 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
241 EXPECT_TRUE(value == LEVEL_4) << "ThermalMgrPolicyTest007 failed";
242 event.info.clear();
243
244 info1.temp = 40900;
245 event.info.push_back(info1);
246 g_service->HandleThermalCallbackEvent(event);
247 value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
248 EXPECT_TRUE(value == LEVEL_1) << "ThermalMgrPolicyTest007 failed";
249 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest007 function end!");
250 }
251
252 /**
253 * @tc.name: ThermalMgrPolicyTest008
254 * @tc.desc: test level desc logic by setting temp
255 * @tc.type: FEATURE
256 * @tc.cond: Set Battery temp, High Temp
257 * @tc.result level 3 ===> level 0
258 */
259 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest008, Function|MediumTest|Level2)
260 {
261 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest008 function start!");
262 HdfThermalCallbackInfo event;
263 ThermalZoneInfo info1;
264 info1.type = "battery";
265 info1.temp = 46100;
266 event.info.push_back(info1);
267 g_service->HandleThermalCallbackEvent(event);
268 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
269 EXPECT_TRUE(value == LEVEL_3) << "ThermalMgrPolicyTest008 failed";
270 event.info.clear();
271
272 info1.temp = 37000;
273 event.info.push_back(info1);
274 g_service->HandleThermalCallbackEvent(event);
275 value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
276 EXPECT_TRUE(value == LEVEL_0) << "ThermalMgrPolicyTest008 failed";
277 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest008 function end!");
278 }
279
280 /**
281 * @tc.name: ThermalMgrPolicyTest009
282 * @tc.desc: test get current configured level by setting temp
283 * @tc.type: FEATURE
284 * @tc.cond: Set Battery temp, Lower Temp
285 * @tc.result level 1
286 */
287 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest009, Function|MediumTest|Level2)
288 {
289 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest009 function start!");
290 HdfThermalCallbackInfo event;
291 ThermalZoneInfo info1;
292 info1.type = "battery";
293 info1.temp = -10000;
294 event.info.push_back(info1);
295 g_service->HandleThermalCallbackEvent(event);
296 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
297 EXPECT_TRUE(value == LEVEL_1) << "ThermalMgrPolicyTest009 failed";
298 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest009 function end!");
299 }
300
301 /**
302 * @tc.name: ThermalMgrPolicyTest010
303 * @tc.desc: test get current configured level by setting temp
304 * @tc.type: FEATURE
305 * @tc.cond: Set Battery temp, Lower Temp
306 * @tc.result level 2
307 */
308 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest010, Function|MediumTest|Level2)
309 {
310 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest010 function start!");
311 HdfThermalCallbackInfo event;
312 ThermalZoneInfo info1;
313 info1.type = "battery";
314 info1.temp = -15000;
315 event.info.push_back(info1);
316 g_service->HandleThermalCallbackEvent(event);
317 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
318 EXPECT_TRUE(value == LEVEL_2) << "ThermalMgrPolicyTest010 failed";
319 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest010 function end!");
320 }
321
322 /**
323 * @tc.name: ThermalMgrPolicyTest011
324 * @tc.desc: test get current configured level by setting temp
325 * @tc.type: FEATURE
326 * @tc.cond: Set Battery temp, Lower Temp
327 * @tc.result level 3
328 */
329 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest011, Function|MediumTest|Level2)
330 {
331 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest011 function start!");
332 HdfThermalCallbackInfo event;
333 ThermalZoneInfo info1;
334 info1.type = "battery";
335 info1.temp = -20100;
336 event.info.push_back(info1);
337 g_service->HandleThermalCallbackEvent(event);
338 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
339 EXPECT_TRUE(value == LEVEL_3) << "ThermalMgrPolicyTest011 failed";
340 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest011 function end!");
341 }
342
343 /**
344 * @tc.name: ThermalMgrPolicyTest012
345 * @tc.desc: test get current configured level by setting temp
346 * @tc.type: FEATURE
347 * @tc.cond: Set Battery temp, Lower Temp
348 * @tc.result level 4
349 */
350 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest012, Function|MediumTest|Level2)
351 {
352 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest012 function start!");
353 HdfThermalCallbackInfo event;
354 ThermalZoneInfo info1;
355 info1.type = "battery";
356 info1.temp = -22000;
357 event.info.push_back(info1);
358 g_service->HandleThermalCallbackEvent(event);
359 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
360 EXPECT_TRUE(value == LEVEL_4) << "ThermalMgrPolicyTest012 failed";
361 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest012 function end!");
362 }
363
364 /**
365 * @tc.name: ThermalMgrPolicyTest013
366 * @tc.desc: test level asc logic by setting temp
367 * @tc.type: FEATURE
368 * @tc.cond: Set Battery temp, Lower Temp
369 * @tc.result level 1 ==> level 4
370 */
371 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest013, Function|MediumTest|Level2)
372 {
373 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest013 function start!");
374 HdfThermalCallbackInfo event;
375 ThermalZoneInfo info1;
376 info1.type = "battery";
377 info1.temp = -10000;
378 event.info.push_back(info1);
379 g_service->HandleThermalCallbackEvent(event);
380 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
381 EXPECT_TRUE(value == LEVEL_1) << "ThermalMgrPolicyTest013 failed";
382 event.info.clear();
383
384 info1.temp = -22000;
385 event.info.push_back(info1);
386 g_service->HandleThermalCallbackEvent(event);
387 value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
388 EXPECT_TRUE(value == LEVEL_4) << "ThermalMgrPolicyTest013 failed";
389 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest013 function end!");
390 }
391
392 /**
393 * @tc.name: ThermalMgrPolicyTest014
394 * @tc.desc: test level asc logic by setting temp
395 * @tc.type: FEATURE
396 * @tc.cond: Set Battery temp, High Temp
397 * @tc.result level 2 ==> level 4
398 */
399 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest014, Function|MediumTest|Level2)
400 {
401 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest014 function start!");
402 HdfThermalCallbackInfo event;
403 ThermalZoneInfo info1;
404 info1.type = "battery";
405 info1.temp = -15000;
406 event.info.push_back(info1);
407 g_service->HandleThermalCallbackEvent(event);
408 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
409 EXPECT_TRUE(value == LEVEL_2) << "ThermalMgrPolicyTest014 failed";
410 event.info.clear();
411
412 info1.temp = -22000;
413 event.info.push_back(info1);
414 g_service->HandleThermalCallbackEvent(event);
415 value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
416 EXPECT_TRUE(value == LEVEL_4) << "ThermalMgrPolicyTest014 failed";
417 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest014 function end!");
418 }
419
420 /**
421 * @tc.name: ThermalMgrPolicyTest015
422 * @tc.desc: test level desc logic by setting temp
423 * @tc.type: FEATURE
424 * @tc.cond: Set Battery temp, High Temp
425 * @tc.result level 4 ===> level 1
426 */
427 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest015, Function|MediumTest|Level2)
428 {
429 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest015 function start!");
430 HdfThermalCallbackInfo event;
431 ThermalZoneInfo info1;
432 info1.type = "battery";
433 info1.temp = -22000;
434 event.info.push_back(info1);
435 g_service->HandleThermalCallbackEvent(event);
436 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
437 EXPECT_TRUE(value == LEVEL_4) << "ThermalMgrPolicyTest015 failed";
438 event.info.clear();
439
440 info1.temp = -10000;
441 event.info.push_back(info1);
442 g_service->HandleThermalCallbackEvent(event);
443 value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
444 EXPECT_TRUE(value == LEVEL_1) << "ThermalMgrPolicyTest015 failed";
445 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest015 function end!");
446 }
447
448 /**
449 * @tc.name: ThermalMgrPolicyTest016
450 * @tc.desc: test level desc logic by setting temp
451 * @tc.type: FEATURE
452 * @tc.cond: Set Battery temp, High Temp
453 * @tc.result level 3 ===> level 0
454 */
455 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest016, Function|MediumTest|Level2)
456 {
457 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest016 function start!");
458 HdfThermalCallbackInfo event;
459 ThermalZoneInfo info1;
460 info1.type = "battery";
461 info1.temp = -19100;
462 event.info.push_back(info1);
463 g_service->HandleThermalCallbackEvent(event);
464 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
465 EXPECT_TRUE(value == LEVEL_3) << "ThermalMgrPolicyTest016 failed";
466 event.info.clear();
467
468 info1.temp = -1000;
469 event.info.push_back(info1);
470 g_service->HandleThermalCallbackEvent(event);
471 value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
472 EXPECT_TRUE(value == LEVEL_0) << "ThermalMgrPolicyTest016 failed";
473 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest016 function end!");
474 }
475
476 /**
477 * @tc.name: ThermalMgrPolicyTest017
478 * @tc.desc: test level asc logic by setting temp
479 * @tc.type: FEATURE
480 * @tc.cond: Set PA temp, High Temp With Aux sensor
481 * @tc.result level 1
482 */
483 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest017, Function|MediumTest|Level2)
484 {
485 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest017 function start!");
486 HdfThermalCallbackInfo event;
487 ThermalZoneInfo info1;
488 info1.type = "pa";
489 info1.temp = 41000;
490 event.info.push_back(info1);
491 info1.type = "ambient";
492 info1.temp = 10000;
493 event.info.push_back(info1);
494 g_service->HandleThermalCallbackEvent(event);
495 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
496 EXPECT_TRUE(value == LEVEL_1) << "ThermalMgrPolicyTest017 failed";
497 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest017 function end!");
498 }
499
500 /**
501 * @tc.name: ThermalMgrPolicyTest018
502 * @tc.desc: test level asc logic by setting temp
503 * @tc.type: FEATURE
504 * @tc.cond: Set PA temp, High Temp With Aux sensor
505 * @tc.result level 1
506 */
507 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest018, Function|MediumTest|Level2)
508 {
509 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest018 function start!");
510 HdfThermalCallbackInfo event;
511 ThermalZoneInfo info1;
512 info1.type = "pa";
513 info1.temp = 44000;
514 event.info.push_back(info1);
515 info1.type = "ambient";
516 info1.temp = 10000;
517 event.info.push_back(info1);
518 g_service->HandleThermalCallbackEvent(event);
519 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
520 EXPECT_TRUE(value == LEVEL_2) << "ThermalMgrPolicyTest018 failed";
521 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest018 function end!");
522 }
523
524 /**
525 * @tc.name: ThermalMgrPolicyTest019
526 * @tc.desc: test level asc logic by setting temp
527 * @tc.type: FEATURE
528 * @tc.cond: Set PA temp, High Temp With Aux sensor
529 * @tc.result level 0
530 */
531 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest019, Function|MediumTest|Level2)
532 {
533 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest019 function start!");
534 HdfThermalCallbackInfo event;
535 ThermalZoneInfo info1;
536 info1.type = "pa";
537 info1.temp = 44000;
538 event.info.push_back(info1);
539 info1.type = "ambient";
540 info1.temp = 1000;
541 event.info.push_back(info1);
542 g_service->HandleThermalCallbackEvent(event);
543 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
544 EXPECT_TRUE(value == LEVEL_0) << "ThermalMgrPolicyTest019 failed";
545 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest019 function end!");
546 }
547
548 /**
549 * @tc.name: ThermalMgrPolicyTest020
550 * @tc.desc: test level asc logic by setting temp
551 * @tc.type: FEATURE
552 * @tc.cond: Set PA temp, High Temp With Aux sensor
553 * @tc.result level 1
554 */
555 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest020, Function|MediumTest|Level2)
556 {
557 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest020 function start!");
558 HdfThermalCallbackInfo event;
559 ThermalZoneInfo info1;
560 info1.type = "ap";
561 info1.temp = 78000;
562 event.info.push_back(info1);
563 info1.type = "ambient";
564 info1.temp = 1000;
565 event.info.push_back(info1);
566 info1.type = "shell";
567 info1.temp = 2000;
568 event.info.push_back(info1);
569 g_service->HandleThermalCallbackEvent(event);
570 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
571 EXPECT_TRUE(value == LEVEL_1) << "ThermalMgrPolicyTest020 failed";
572 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest020 function end!");
573 }
574
575 /**
576 * @tc.name: ThermalMgrPolicyTest021
577 * @tc.desc: test level asc logic by setting temp
578 * @tc.type: FEATURE
579 * @tc.cond: Set PA temp, High Temp With Aux sensor
580 * @tc.result level 0
581 */
582 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest021, Function|MediumTest|Level2)
583 {
584 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest021 function start!");
585 HdfThermalCallbackInfo event;
586 ThermalZoneInfo info1;
587 info1.type = "ap";
588 info1.temp = 78000;
589 event.info.push_back(info1);
590 info1.type = "ambient";
591 info1.temp = 1000;
592 event.info.push_back(info1);
593 info1.type = "shell";
594 info1.temp = -100;
595 event.info.push_back(info1);
596 g_service->HandleThermalCallbackEvent(event);
597 int32_t value = ConvertInt(GetNodeValue(CONFIG_LEVEL_PATH));
598 EXPECT_TRUE(value == LEVEL_0) << "ThermalMgrPolicyTest021 failed";
599 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest021 function end!");
600 }
601
602 /**
603 * @tc.name: ThermalMgrPolicyTest022
604 * @tc.desc: test get charge currentby setting temp
605 * @tc.type: FEATURE
606 * @tc.cond: Set BATTERY temp, state not satisfied
607 * @tc.result level 1, current 1800
608 */
609 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest022, Function|MediumTest|Level2)
610 {
611 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest022 function start!");
612 HdfThermalCallbackInfo event;
613 ThermalZoneInfo info1;
614 info1.type = "battery";
615 info1.temp = 40100;
616 event.info.push_back(info1);
617 g_service->HandleThermalCallbackEvent(event);
618 int32_t value = ConvertInt(GetNodeValue(BATTERY_CHARGER_CURRENT_PATH));
619 int32_t currentNow = 1800;
620 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest022 failed";
621 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest022 function end!");
622 }
623
624 /**
625 * @tc.name: ThermalMgrPolicyTest023
626 * @tc.desc: test get charge currentby setting temp
627 * @tc.type: FEATURE
628 * @tc.cond: Set BATTERY temp, state: scene = "cam"
629 * @tc.result level 1, current 1200
630 * @tc.require: issueI5HWGZ
631 */
632 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest023, Function|MediumTest|Level2)
633 {
634 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest023 function start!");
635 HdfThermalCallbackInfo event;
636 ThermalZoneInfo info1;
637 info1.type = "battery";
638 info1.temp = 40100;
639 event.info.push_back(info1);
640 g_service->SetScene("cam");
641 g_service->HandleThermalCallbackEvent(event);
642 int32_t value = ConvertInt(GetNodeValue(BATTERY_CHARGER_CURRENT_PATH));
643 int32_t currentNow = 1200;
644 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest023 failed";
645 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest023 function end!");
646 }
647
648 /**
649 * @tc.name: ThermalMgrPolicyTest024
650 * @tc.desc: test get charge currentby setting temp
651 * @tc.type: FEATURE
652 * @tc.cond: Set BATTERY temp, state not satisfied
653 * @tc.result level 2, current 1500
654 */
655 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest024, Function|MediumTest|Level2)
656 {
657 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest024 function start!");
658 HdfThermalCallbackInfo event;
659 ThermalZoneInfo info1;
660 info1.type = "battery";
661 info1.temp = 43100;
662 event.info.push_back(info1);
663 g_service->HandleThermalCallbackEvent(event);
664 int32_t value = ConvertInt(GetNodeValue(BATTERY_CHARGER_CURRENT_PATH));
665 int32_t currentNow = 1500;
666 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest024 failed";
667 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest024 function end!");
668 }
669
670 /**
671 * @tc.name: ThermalMgrPolicyTest025
672 * @tc.desc: test get charge currentby setting temp
673 * @tc.type: FEATURE
674 * @tc.cond: Set BATTERY temp, state: scene = "cam"
675 * @tc.result level 2, current 1000
676 * @tc.require: issueI5HWGZ
677 */
678 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest025, Function|MediumTest|Level2)
679 {
680 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest025 function start!");
681 HdfThermalCallbackInfo event;
682 ThermalZoneInfo info1;
683 info1.type = "battery";
684 info1.temp = 43100;
685 event.info.push_back(info1);
686 g_service->SetScene("cam");
687 g_service->HandleThermalCallbackEvent(event);
688 int32_t value = ConvertInt(GetNodeValue(BATTERY_CHARGER_CURRENT_PATH));
689 int32_t currentNow = 1000;
690 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest025 failed";
691 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest025 function end!");
692 }
693
694 /**
695 * @tc.name: ThermalMgrPolicyTest026
696 * @tc.desc: test get charge currentby setting temp
697 * @tc.type: FEATURE
698 * @tc.cond: Set BATTERY temp, state not satisfied
699 * @tc.result level 3, current 1300
700 */
701 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest026, Function|MediumTest|Level2)
702 {
703 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest026 function start!");
704 HdfThermalCallbackInfo event;
705 ThermalZoneInfo info1;
706 info1.type = "battery";
707 info1.temp = 46100;
708 event.info.push_back(info1);
709 g_service->HandleThermalCallbackEvent(event);
710 int32_t value = ConvertInt(GetNodeValue(BATTERY_CHARGER_CURRENT_PATH));
711 int32_t currentNow = 1300;
712 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest026 failed";
713 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest026 function end!");
714 }
715
716 /**
717 * @tc.name: ThermalMgrPolicyTest027
718 * @tc.desc: test get charge currentby setting temp
719 * @tc.type: FEATURE
720 * @tc.cond: Set BATTERY temp, state: scene = "cam"
721 * @tc.result level 3, current 800
722 * @tc.require: issueI5HWGZ
723 */
724 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest027, Function|MediumTest|Level2)
725 {
726 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest027 function start!");
727 HdfThermalCallbackInfo event;
728 ThermalZoneInfo info1;
729 info1.type = "battery";
730 info1.temp = 46100;
731 event.info.push_back(info1);
732 g_service->SetScene("cam");
733 g_service->HandleThermalCallbackEvent(event);
734 int32_t value = ConvertInt(GetNodeValue(BATTERY_CHARGER_CURRENT_PATH));
735 int32_t currentNow = 800;
736 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest027 failed";
737 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest027 function end!");
738 }
739
740 /**
741 * @tc.name: ThermalMgrPolicyTest028
742 * @tc.desc: test get current configured level by setting temp
743 * @tc.type: FEATURE
744 * @tc.cond: Set Battery temp, Lower Temp
745 * @tc.result level 1 current 1850
746 */
747 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest028, Function|MediumTest|Level2)
748 {
749 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest028 function start!");
750 HdfThermalCallbackInfo event;
751 ThermalZoneInfo info1;
752 info1.type = "battery";
753 info1.temp = -10000;
754 event.info.push_back(info1);
755 g_service->HandleThermalCallbackEvent(event);
756 int32_t value = ConvertInt(GetNodeValue(BATTERY_CHARGER_CURRENT_PATH));
757 int32_t currentNow = 1850;
758 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest028 failed";
759 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest028 function end!");
760 }
761
762 /**
763 * @tc.name: ThermalMgrPolicyTest029
764 * @tc.desc: test get current configured level by setting temp
765 * @tc.type: FEATURE
766 * @tc.cond: Set Battery temp, Lower Temp
767 * @tc.result level 2 current 1550
768 */
769 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest029, Function|MediumTest|Level2)
770 {
771 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest029 function start!");
772 HdfThermalCallbackInfo event;
773 ThermalZoneInfo info1;
774 info1.type = "battery";
775 info1.temp = -14100;
776 event.info.push_back(info1);
777 g_service->HandleThermalCallbackEvent(event);
778 int32_t value = ConvertInt(GetNodeValue(BATTERY_CHARGER_CURRENT_PATH));
779 int32_t currentNow = 1550;
780 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest029 failed";
781 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest029 function end!");
782 }
783
784 /**
785 * @tc.name: ThermalMgrPolicyTest030
786 * @tc.desc: test get current configured level by setting temp
787 * @tc.type: FEATURE
788 * @tc.cond: Set Battery temp, Lower Temp
789 * @tc.result level 3 current 1150
790 */
791 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest030, Function|MediumTest|Level2)
792 {
793 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest030 function start!");
794 HdfThermalCallbackInfo event;
795 ThermalZoneInfo info1;
796 info1.type = "battery";
797 info1.temp = -19100;
798 event.info.push_back(info1);
799 g_service->HandleThermalCallbackEvent(event);
800 int32_t value = ConvertInt(GetNodeValue(BATTERY_CHARGER_CURRENT_PATH));
801 int32_t currentNow = 1150;
802 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest030 failed";
803 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest030 function end!");
804 }
805
806 /**
807 * @tc.name: ThermalMgrPolicyTest031
808 * @tc.desc: test get brightness configured level by setting temp
809 * @tc.type: FEATURE
810 * @tc.cond: Set Battery temp, Lower Temp
811 * @tc.result level 1 brightness factor is 1.0
812 * @tc.require: issueI5HWH6
813 */
814 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest031, Function|MediumTest|Level2)
815 {
816 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest031 function start!");
817 HdfThermalCallbackInfo event;
818 ThermalZoneInfo info1;
819 info1.type = "battery";
820 info1.temp = 40100;
821 event.info.push_back(info1);
822 g_service->HandleThermalCallbackEvent(event);
823 std::string ret = GetNodeValue(LCD_PATH);
824 EXPECT_TRUE(ret.substr(0, 3) == "1.0") << "ThermalMgrPolicyTest031 failed";
825 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest031 function end!");
826 }
827
828 /**
829 * @tc.name: ThermalMgrPolicyTest032
830 * @tc.desc: test get brightness configured level by setting temp
831 * @tc.type: FEATURE
832 * @tc.cond: Set Battery temp, Lower Temp
833 * @tc.result level 2 brightness factor is 0.9
834 * @tc.require: issueI5HWH6
835 */
836 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest032, Function|MediumTest|Level2)
837 {
838 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest032 function start!");
839 HdfThermalCallbackInfo event;
840 ThermalZoneInfo info1;
841 info1.type = "battery";
842 info1.temp = 43100;
843 event.info.push_back(info1);
844 g_service->HandleThermalCallbackEvent(event);
845 std::string ret = GetNodeValue(LCD_PATH);
846 EXPECT_TRUE(ret.substr(0, 3) == "0.9") << "ThermalMgrPolicyTest032 failed";
847 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest032 function end!");
848 }
849
850 /**
851 * @tc.name: ThermalMgrPolicyTest033
852 * @tc.desc: test get brightness configured level by setting temp
853 * @tc.type: FEATURE
854 * @tc.cond: Set Battery temp, Lower Temp
855 * @tc.result level 3 brightness factor is 0.8
856 * @tc.require: issueI5HWH6
857 */
858 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest033, Function|MediumTest|Level2)
859 {
860 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest033 function start!");
861 HdfThermalCallbackInfo event;
862 ThermalZoneInfo info1;
863 info1.type = "battery";
864 info1.temp = 46100;
865 event.info.push_back(info1);
866 g_service->HandleThermalCallbackEvent(event);
867 std::string ret = GetNodeValue(LCD_PATH);
868 EXPECT_TRUE(ret.substr(0, 3) == "0.8") << "ThermalMgrPolicyTest033 failed";
869 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest033 function end!");
870 }
871
872 /**
873 * @tc.name: ThermalMgrPolicyTest034
874 * @tc.desc: test level asc logic by setting temp
875 * @tc.type: FEATURE
876 * @tc.cond: Set PA temp, High Temp With Aux sensor
877 * @tc.result level 1 brightness factor is 0.7
878 * @tc.require: issueI5HWH6
879 */
880 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest034, Function|MediumTest|Level2)
881 {
882 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest034 function start!");
883 HdfThermalCallbackInfo event;
884 ThermalZoneInfo info1;
885 info1.type = "pa";
886 info1.temp = 41000;
887 event.info.push_back(info1);
888 info1.type = "ambient";
889 info1.temp = 10000;
890 event.info.push_back(info1);
891 g_service->HandleThermalCallbackEvent(event);
892 std::string ret = GetNodeValue(LCD_PATH);
893 EXPECT_TRUE(ret.substr(0, 3) == "0.7") << "ThermalMgrPolicyTest034 failed";
894 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest034 function end!");
895 }
896
897 /**
898 * @tc.name: ThermalMgrPolicyTest035
899 * @tc.desc: test level asc logic by setting temp
900 * @tc.type: FEATURE
901 * @tc.cond: Set PA temp, High Temp With Aux sensor
902 * @tc.result level 2 brightness factor is 0.6
903 * @tc.require: issueI5HWH6
904 */
905 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest035, Function|MediumTest|Level2)
906 {
907 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest035 function start!");
908 HdfThermalCallbackInfo event;
909 ThermalZoneInfo info1;
910 info1.type = "pa";
911 info1.temp = 44000;
912 event.info.push_back(info1);
913 info1.type = "ambient";
914 info1.temp = 10000;
915 event.info.push_back(info1);
916 g_service->HandleThermalCallbackEvent(event);
917 std::string ret = GetNodeValue(LCD_PATH);
918 EXPECT_TRUE(ret.substr(0, 3) == "0.6") << "ThermalMgrPolicyTest035 failed";
919 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest035 function end!");
920 }
921
922 /**
923 * @tc.name: ThermalMgrPolicyTest036
924 * @tc.desc: get process and shutdown value
925 * @tc.type: FEATURE
926 * @tc.cond: Set AP temp, High Temp With Aux sensor
927 * @tc.result level 1, process 3, shutdown 1
928 */
929 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest036, Function|MediumTest|Level2)
930 {
931 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest036 function start!");
932 HdfThermalCallbackInfo event;
933 ThermalZoneInfo info1;
934 info1.type = "ap";
935 info1.temp = 78000;
936 event.info.push_back(info1);
937 info1.type = "ambient";
938 info1.temp = 10000;
939 event.info.push_back(info1);
940 info1.type = "shell";
941 info1.temp = 3000;
942 event.info.push_back(info1);
943 g_service->HandleThermalCallbackEvent(event);
944 int32_t value = ConvertInt(GetNodeValue(PROCESS_PATH));
945 if (PowerMgrClient::GetInstance().IsScreenOn()) {
946 EXPECT_TRUE(value == 3) << "ThermalMgrPolicyTest036 failed";
947 } else {
948 EXPECT_TRUE(value == 0) << "ThermalMgrPolicyTest036 failed";
949 }
950
951 value = ConvertInt(GetNodeValue(SHUTDOWN_PATH));
952 if (PowerMgrClient::GetInstance().IsScreenOn()) {
953 EXPECT_EQ(true, value == 1) << "ThermalMgrPolicyTest036 failed";
954 } else {
955 EXPECT_EQ(true, value == 0) << "ThermalMgrPolicyTest036 failed";
956 }
957 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest036 function end!");
958 }
959
960 /**
961 * @tc.name: ThermalMgrPolicyTest037
962 * @tc.desc: test get process value by setting temp
963 * @tc.type: FEATURE
964 * @tc.cond: Set Battery temp, Lower Temp
965 * @tc.result level 1 procss 1
966 */
967 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest037, Function|MediumTest|Level2)
968 {
969 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest037 function start!");
970 HdfThermalCallbackInfo event;
971 ThermalZoneInfo info1;
972 info1.type = "battery";
973 info1.temp = 40100;
974 event.info.push_back(info1);
975 g_service->HandleThermalCallbackEvent(event);
976 int32_t value = ConvertInt(GetNodeValue(PROCESS_PATH));
977 EXPECT_TRUE(value == LEVEL_3) << "ThermalMgrPolicyTest037 failed";
978 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest037 function end!");
979 }
980
981 /**
982 * @tc.name: ThermalMgrPolicyTest038
983 * @tc.desc: test get process value by setting temp
984 * @tc.type: FEATURE
985 * @tc.cond: Set Battery temp, Lower Temp
986 * @tc.result level 2 procss 2
987 */
988 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest038, Function|MediumTest|Level2)
989 {
990 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest038 function start!");
991 HdfThermalCallbackInfo event;
992 ThermalZoneInfo info1;
993 info1.type = "battery";
994 info1.temp = 43100;
995 event.info.push_back(info1);
996 g_service->HandleThermalCallbackEvent(event);
997 int32_t value = ConvertInt(GetNodeValue(PROCESS_PATH));
998 EXPECT_TRUE(value == LEVEL_2) << "ThermalMgrPolicyTest038 failed";
999 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest038 function end!");
1000 }
1001
1002 /**
1003 * @tc.name: ThermalMgrPolicyTest039
1004 * @tc.desc: test get process value by setting temp
1005 * @tc.type: FEATURE
1006 * @tc.cond: Set Battery temp, Lower Temp
1007 * @tc.result level 3 procss 1
1008 */
1009 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest039, Function|MediumTest|Level2)
1010 {
1011 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest039 function start!");
1012 HdfThermalCallbackInfo event;
1013 ThermalZoneInfo info1;
1014 info1.type = "battery";
1015 info1.temp = 46100;
1016 event.info.push_back(info1);
1017 g_service->HandleThermalCallbackEvent(event);
1018 int32_t value = ConvertInt(GetNodeValue(PROCESS_PATH));
1019 EXPECT_TRUE(value == LEVEL_1) << "ThermalMgrPolicyTest039 failed";
1020 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest039 function end!");
1021 }
1022
1023 /**
1024 * @tc.name: ThermalMgrPolicyTest040
1025 * @tc.desc: test get process by setting temp
1026 * @tc.type: FEATURE
1027 * @tc.cond: Set PA temp, High Temp With Aux sensor
1028 * @tc.result level 1 process 2
1029 */
1030 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest040, Function|MediumTest|Level2)
1031 {
1032 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest040 function start!");
1033 HdfThermalCallbackInfo event;
1034 ThermalZoneInfo info1;
1035 info1.type = "pa";
1036 info1.temp = 41000;
1037 event.info.push_back(info1);
1038 info1.type = "ambient";
1039 info1.temp = 10000;
1040 event.info.push_back(info1);
1041 g_service->HandleThermalCallbackEvent(event);
1042 std::string ret = GetNodeValue(PROCESS_PATH);
1043 int32_t value = ConvertInt(ret);
1044 EXPECT_TRUE(value == LEVEL_2) << "ThermalMgrPolicyTest040 failed";
1045 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest040 function end!");
1046 }
1047
1048 /**
1049 * @tc.name: ThermalMgrPolicyTest041
1050 * @tc.desc: test get process by setting temp
1051 * @tc.type: FEATURE
1052 * @tc.cond: Set PA temp, High Temp With Aux sensor
1053 * @tc.result level 2 process 3
1054 */
1055 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest041, Function|MediumTest|Level2)
1056 {
1057 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest041 function start!");
1058 HdfThermalCallbackInfo event;
1059 ThermalZoneInfo info1;
1060 info1.type = "pa";
1061 info1.temp = 44000;
1062 event.info.push_back(info1);
1063 info1.type = "ambient";
1064 info1.temp = 10000;
1065 event.info.push_back(info1);
1066 g_service->HandleThermalCallbackEvent(event);
1067 int32_t value = ConvertInt(GetNodeValue(PROCESS_PATH));
1068 EXPECT_TRUE(value == LEVEL_3) << "ThermalMgrPolicyTest041 failed";
1069 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest041 function end!");
1070 }
1071
1072 /**
1073 * @tc.name: ThermalMgrPolicyTest042
1074 * @tc.desc: get the config current by setting battery temp
1075 * @tc.type: FEATURE
1076 * @tc.cond: Set Battery temp, High Temp, charge_type: buck
1077 * @tc.result level 1, current 1200
1078 */
1079 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest042, Function|MediumTest|Level2)
1080 {
1081 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest042 function start!");
1082 HdfThermalCallbackInfo event;
1083 ThermalZoneInfo info1;
1084 info1.type = "battery";
1085 info1.temp = 40100;
1086 event.info.push_back(info1);
1087 g_service->HandleThermalCallbackEvent(event);
1088 int32_t value = ConvertInt(GetNodeValue(BUCK_CURRENT_PATH));
1089 int32_t currentNow = 1200;
1090 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest042 failed";
1091 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest042 function end!");
1092 }
1093
1094 /**
1095 * @tc.name: ThermalMgrPolicyTest043
1096 * @tc.desc: get the config voltage by setting battery temp
1097 * @tc.type: FEATURE
1098 * @tc.cond: Set Battery temp, High Temp, charge_type: sc
1099 * @tc.result level 1, voltage 4000
1100 */
1101 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest043, Function|MediumTest|Level2)
1102 {
1103 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest043 function start!");
1104 HdfThermalCallbackInfo event;
1105 ThermalZoneInfo info1;
1106 info1.type = "battery";
1107 info1.temp = 40100;
1108 event.info.push_back(info1);
1109 g_service->HandleThermalCallbackEvent(event);
1110 int32_t value = ConvertInt(GetNodeValue(SC_VOLTAGE_PATH));
1111 int32_t voltage = 4000;
1112 EXPECT_TRUE(value == voltage) << "ThermalMgrPolicyTest043 failed";
1113 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest043 function end!");
1114 }
1115
1116 /**
1117 * @tc.name: ThermalMgrPolicyTest044
1118 * @tc.desc: get the config voltage by setting battery temp
1119 * @tc.type: FEATURE
1120 * @tc.cond: Set Battery temp, High Temp, charge_type: buck
1121 * @tc.result level 1, voltage 3000
1122 */
1123 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest044, Function|MediumTest|Level2)
1124 {
1125 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest044 function start!");
1126 HdfThermalCallbackInfo event;
1127 ThermalZoneInfo info1;
1128 info1.type = "battery";
1129 info1.temp = 40100;
1130 event.info.push_back(info1);
1131 g_service->HandleThermalCallbackEvent(event);
1132 int32_t value = ConvertInt(GetNodeValue(BUCK_VOLTAGE_PATH));
1133 int32_t voltage = 3000;
1134 EXPECT_TRUE(value == voltage) << "ThermalMgrPolicyTest044 failed";
1135 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest044 function end!");
1136 }
1137
1138 /**
1139 * @tc.name: ThermalMgrPolicyTest045
1140 * @tc.desc: get the config current by setting battery temp
1141 * @tc.type: FEATURE
1142 * @tc.cond: Set Battery temp, High Temp, charge_type: buck
1143 * @tc.result level 2, current 1000
1144 */
1145 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest045, Function|MediumTest|Level2)
1146 {
1147 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest045 function start!");
1148 HdfThermalCallbackInfo event;
1149 ThermalZoneInfo info1;
1150 info1.type = "battery";
1151 info1.temp = 43100;
1152 event.info.push_back(info1);
1153 g_service->HandleThermalCallbackEvent(event);
1154 int32_t value = ConvertInt(GetNodeValue(BUCK_CURRENT_PATH));
1155 int32_t currentNow = 1000;
1156 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest045 failed";
1157 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest045 function end!");
1158 }
1159
1160 /**
1161 * @tc.name: ThermalMgrPolicyTest046
1162 * @tc.desc: get the config voltage by setting battery temp
1163 * @tc.type: FEATURE
1164 * @tc.cond: Set Battery temp, High Temp, charge_type: sc
1165 * @tc.result level 2, voltage 3000
1166 */
1167 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest046, Function|MediumTest|Level2)
1168 {
1169 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest046 function start!");
1170 HdfThermalCallbackInfo event;
1171 ThermalZoneInfo info1;
1172 info1.type = "battery";
1173 info1.temp = 43100;
1174 event.info.push_back(info1);
1175 g_service->HandleThermalCallbackEvent(event);
1176 int32_t value = ConvertInt(GetNodeValue(SC_VOLTAGE_PATH));
1177 int32_t voltage = 3000;
1178 EXPECT_TRUE(value == voltage) << "ThermalMgrPolicyTest046 failed";
1179 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest046 function end!");
1180 }
1181
1182 /**
1183 * @tc.name: ThermalMgrPolicyTest047
1184 * @tc.desc: get the config voltage by setting battery temp
1185 * @tc.type: FEATURE
1186 * @tc.cond: Set Battery temp, High Temp, charge_type: buck
1187 * @tc.result level 2, voltage 2000
1188 */
1189 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest047, Function|MediumTest|Level2)
1190 {
1191 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest047 function start!");
1192 HdfThermalCallbackInfo event;
1193 ThermalZoneInfo info1;
1194 info1.type = "battery";
1195 info1.temp = 43100;
1196 event.info.push_back(info1);
1197 g_service->HandleThermalCallbackEvent(event);
1198 int32_t value = ConvertInt(GetNodeValue(BUCK_VOLTAGE_PATH));
1199 int32_t voltage = 2000;
1200 EXPECT_TRUE(value == voltage) << "ThermalMgrPolicyTest047 failed";
1201 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest047 function end!");
1202 }
1203
1204 /**
1205 * @tc.name: ThermalMgrPolicyTest048
1206 * @tc.desc: get the config current by setting battery temp
1207 * @tc.type: FEATURE
1208 * @tc.cond: Set Battery temp, High Temp, charge_type: buck
1209 * @tc.result level 3, current 800
1210 */
1211 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest048, Function|MediumTest|Level2)
1212 {
1213 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest048 function start!");
1214 HdfThermalCallbackInfo event;
1215 ThermalZoneInfo info1;
1216 info1.type = "battery";
1217 info1.temp = 46100;
1218 event.info.push_back(info1);
1219 g_service->HandleThermalCallbackEvent(event);
1220 int32_t value = ConvertInt(GetNodeValue(BUCK_CURRENT_PATH));
1221 int32_t currentNow = 800;
1222 EXPECT_TRUE(value == currentNow) << "ThermalMgrPolicyTest048 failed";
1223 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest048 function end!");
1224 }
1225
1226 /**
1227 * @tc.name: ThermalMgrPolicyTest049
1228 * @tc.desc: get the config voltage by setting battery temp
1229 * @tc.type: FEATURE
1230 * @tc.cond: Set Battery temp, High Temp, charge_type: sc
1231 * @tc.result level 3, voltage 2000
1232 */
1233 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest049, Function|MediumTest|Level2)
1234 {
1235 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest049 function start!");
1236 HdfThermalCallbackInfo event;
1237 ThermalZoneInfo info1;
1238 info1.type = "battery";
1239 info1.temp = 46100;
1240 event.info.push_back(info1);
1241 g_service->HandleThermalCallbackEvent(event);
1242 std::string ret = GetNodeValue(SC_VOLTAGE_PATH);
1243 int32_t value = ConvertInt(ret);
1244 EXPECT_TRUE(value == 2000) << "ThermalMgrPolicyTest049 failed";
1245 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest049 function end!");
1246 }
1247
1248 /**
1249 * @tc.name: ThermalMgrPolicyTest050
1250 * @tc.desc: get the config voltage by setting battery temp
1251 * @tc.type: FEATURE
1252 * @tc.cond: Set Battery temp, High Temp, charge_type: buck
1253 * @tc.result level 3, voltage 1000
1254 */
1255 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest050, Function|MediumTest|Level2)
1256 {
1257 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest050 function start!");
1258 HdfThermalCallbackInfo event;
1259 ThermalZoneInfo info1;
1260 info1.type = "battery";
1261 info1.temp = 46100;
1262 event.info.push_back(info1);
1263 g_service->HandleThermalCallbackEvent(event);
1264 std::string ret = GetNodeValue(BUCK_VOLTAGE_PATH);
1265 int32_t value = ConvertInt(ret);
1266 EXPECT_TRUE(value == 1000) << "ThermalMgrPolicyTest050 failed";
1267 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest050 function end!");
1268 }
1269
1270 /**
1271 * @tc.name: ThermalMgrPolicyTest053
1272 * @tc.desc: test set brightness according to the scene
1273 * @tc.type: FEATURE
1274 * @tc.cond: Set Battery temp, Lower Temp
1275 * @tc.result level 1, scene cam, brightness factor is 0.99
1276 * @tc.require: issueI5HWH6
1277 */
1278 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest053, Function|MediumTest|Level2)
1279 {
1280 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest053 function start!");
1281 HdfThermalCallbackInfo event;
1282 ThermalZoneInfo info1;
1283 info1.type = "battery";
1284 info1.temp = 40100;
1285 event.info.push_back(info1);
1286 g_service->SetScene("cam");
1287 g_service->HandleThermalCallbackEvent(event);
1288 std::string ret = GetNodeValue(LCD_PATH);
1289 EXPECT_TRUE(ret.substr(0, 4) == "0.99") << "ThermalMgrPolicyTest053 failed";
1290 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest053 function end!");
1291 }
1292
1293 /**
1294 * @tc.name: ThermalMgrPolicyTest054
1295 * @tc.desc: test set brightness according to the scene
1296 * @tc.type: FEATURE
1297 * @tc.cond: Set Battery temp, Lower Temp
1298 * @tc.result level 2, scene cam, brightness factor is 0.98
1299 * @tc.require: issueI5HWH6
1300 */
1301 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest054, Function|MediumTest|Level2)
1302 {
1303 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest054 function start!");
1304 HdfThermalCallbackInfo event;
1305 ThermalZoneInfo info1;
1306 info1.type = "battery";
1307 info1.temp = 43100;
1308 event.info.push_back(info1);
1309 g_service->SetScene("cam");
1310 g_service->HandleThermalCallbackEvent(event);
1311 std::string ret = GetNodeValue(LCD_PATH);
1312 EXPECT_TRUE(ret.substr(0, 4) == "0.89") << "ThermalMgrPolicyTest054 failed";
1313 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest054 function end!");
1314 }
1315
1316 /**
1317 * @tc.name: ThermalMgrPolicyTest055
1318 * @tc.desc: test set brightness according to the scene
1319 * @tc.type: FEATURE
1320 * @tc.cond: Set Battery temp, Lower Temp
1321 * @tc.result level 3, scene cam, brightness factor is 0.97
1322 * @tc.require: issueI5HWH6
1323 */
1324 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest055, Function|MediumTest|Level2)
1325 {
1326 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest055 function start!");
1327 HdfThermalCallbackInfo event;
1328 ThermalZoneInfo info1;
1329 info1.type = "battery";
1330 info1.temp = 46100;
1331 event.info.push_back(info1);
1332 g_service->SetScene("cam");
1333 g_service->HandleThermalCallbackEvent(event);
1334 std::string ret = GetNodeValue(LCD_PATH);
1335 EXPECT_TRUE(ret.substr(0, 4) == "0.79") << "ThermalMgrPolicyTest055 failed";
1336 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest055 function end!");
1337 }
1338
1339 /**
1340 * @tc.name: ThermalMgrPolicyTest056
1341 * @tc.desc: test set brightness according to the scene
1342 * @tc.type: FEATURE
1343 * @tc.cond: Set Battery temp, Lower Temp
1344 * @tc.result level 1, scene call, brightness factor is 0.98
1345 * @tc.require: issueI5HWH6
1346 */
1347 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest056, Function|MediumTest|Level2)
1348 {
1349 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest056 function start!");
1350 HdfThermalCallbackInfo event;
1351 ThermalZoneInfo info1;
1352 info1.type = "battery";
1353 info1.temp = 40100;
1354 event.info.push_back(info1);
1355 g_service->SetScene("call");
1356 g_service->HandleThermalCallbackEvent(event);
1357 std::string ret = GetNodeValue(LCD_PATH);
1358 EXPECT_TRUE(ret.substr(0, 4) == "0.98") << "ThermalMgrPolicyTest056 failed";
1359 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest056 function end!");
1360 }
1361
1362 /**
1363 * @tc.name: ThermalMgrPolicyTest057
1364 * @tc.desc: test set brightness according to the scene
1365 * @tc.type: FEATURE
1366 * @tc.cond: Set Battery temp, Lower Temp
1367 * @tc.result level 2, scene call, brightness factor is 0.88
1368 * @tc.require: issueI5HWH6
1369 */
1370 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest057, Function|MediumTest|Level2)
1371 {
1372 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest057 function start!");
1373 HdfThermalCallbackInfo event;
1374 ThermalZoneInfo info1;
1375 info1.type = "battery";
1376 info1.temp = 43100;
1377 event.info.push_back(info1);
1378 g_service->SetScene("call");
1379 g_service->HandleThermalCallbackEvent(event);
1380 std::string ret = GetNodeValue(LCD_PATH);
1381 EXPECT_TRUE(ret.substr(0, 4) == "0.88") << "ThermalMgrPolicyTest057 failed";
1382 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest057 function end!");
1383 }
1384
1385 /**
1386 * @tc.name: ThermalMgrPolicyTest058
1387 * @tc.desc: test set brightness according to the scene
1388 * @tc.type: FEATURE
1389 * @tc.cond: Set Battery temp, Lower Temp
1390 * @tc.result level 3, scene call, brightness factor is 0.78
1391 * @tc.require: issueI5HWH6
1392 */
1393 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest058, Function|MediumTest|Level2)
1394 {
1395 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest058 function start!");
1396 HdfThermalCallbackInfo event;
1397 ThermalZoneInfo info1;
1398 info1.type = "battery";
1399 info1.temp = 46100;
1400 event.info.push_back(info1);
1401 g_service->SetScene("call");
1402 g_service->HandleThermalCallbackEvent(event);
1403 std::string ret = GetNodeValue(LCD_PATH);
1404 EXPECT_TRUE(ret.substr(0, 4) == "0.78") << "ThermalMgrPolicyTest058 failed";
1405 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest058 function end!");
1406 }
1407
1408 /**
1409 * @tc.name: ThermalMgrPolicyTest059
1410 * @tc.desc: test set brightness according to the scene
1411 * @tc.type: FEATURE
1412 * @tc.cond: Set Battery temp, Lower Temp
1413 * @tc.result level 1, scene game, brightness factor is 0.97
1414 * @tc.require: issueI5HWH6
1415 */
1416 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest059, Function|MediumTest|Level2)
1417 {
1418 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest059 function start!");
1419 HdfThermalCallbackInfo event;
1420 ThermalZoneInfo info1;
1421 info1.type = "battery";
1422 info1.temp = 40100;
1423 event.info.push_back(info1);
1424 g_service->SetScene("game");
1425 g_service->HandleThermalCallbackEvent(event);
1426 std::string ret = GetNodeValue(LCD_PATH);
1427 EXPECT_TRUE(ret.substr(0, 4) == "0.97") << "ThermalMgrPolicyTest059 failed";
1428 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest059 function end!");
1429 }
1430
1431 /**
1432 * @tc.name: ThermalMgrPolicyTest060
1433 * @tc.desc: test set brightness according to the scene
1434 * @tc.type: FEATURE
1435 * @tc.cond: Set Battery temp, Lower Temp
1436 * @tc.result level 2, scene game, brightness factor is 0.87
1437 * @tc.require: issueI5HWH6
1438 */
1439 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest060, Function|MediumTest|Level2)
1440 {
1441 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest060 function start!");
1442 HdfThermalCallbackInfo event;
1443 ThermalZoneInfo info1;
1444 info1.type = "battery";
1445 info1.temp = 43100;
1446 event.info.push_back(info1);
1447 g_service->SetScene("game");
1448 g_service->HandleThermalCallbackEvent(event);
1449 std::string ret = GetNodeValue(LCD_PATH);
1450 EXPECT_TRUE(ret.substr(0, 4) == "0.87") << "ThermalMgrPolicyTest060 failed";
1451 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest060 function end!");
1452 }
1453
1454 /**
1455 * @tc.name: ThermalMgrPolicyTest061
1456 * @tc.desc: test set brightness according to the scene
1457 * @tc.type: FEATURE
1458 * @tc.cond: Set Battery temp, Lower Temp
1459 * @tc.result level 3, scene game, brightness factor is 0.77
1460 * @tc.require: issueI5HWH6
1461 */
1462 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest061, Function|MediumTest|Level2)
1463 {
1464 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest061 function start!");
1465 HdfThermalCallbackInfo event;
1466 ThermalZoneInfo info1;
1467 info1.type = "battery";
1468 info1.temp = 46100;
1469 event.info.push_back(info1);
1470 g_service->SetScene("game");
1471 g_service->HandleThermalCallbackEvent(event);
1472 std::string ret = GetNodeValue(LCD_PATH);
1473 EXPECT_TRUE(ret.substr(0, 4) == "0.77") << "ThermalMgrPolicyTest061 failed";
1474 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest061 function end!");
1475 }
1476
1477 /**
1478 * @tc.name: ThermalMgrPolicyTest062
1479 * @tc.desc: test set brightness according to the scene
1480 * @tc.type: FEATURE
1481 * @tc.cond: Set Battery temp, Lower Temp
1482 * @tc.result level 1, scene test, brightness factor is 0.91
1483 * @tc.require: issueI5HWH6
1484 */
1485 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest062, Function|MediumTest|Level2)
1486 {
1487 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest062 function start!");
1488 HdfThermalCallbackInfo event;
1489 ThermalZoneInfo info1;
1490 info1.type = "battery";
1491 info1.temp = 40100;
1492 event.info.push_back(info1);
1493 g_service->SetScene("test");
1494 g_service->HandleThermalCallbackEvent(event);
1495 std::string ret = GetNodeValue(LCD_PATH);
1496 EXPECT_TRUE(ret.substr(0, 4) == "0.91") << "ThermalMgrPolicyTest062 failed";
1497 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest062 function end!");
1498 }
1499
1500 /**
1501 * @tc.name: ThermalMgrPolicyTest063
1502 * @tc.desc: test set brightness according to the scene
1503 * @tc.type: FEATURE
1504 * @tc.cond: Set Battery temp, Lower Temp
1505 * @tc.result level 1, brightness factor is 1.0; scene game, brightness factor is 0.97
1506 * @tc.require: issueI5HWH6
1507 */
1508 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest063, Function|MediumTest|Level2)
1509 {
1510 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest063 function start!");
1511 HdfThermalCallbackInfo event;
1512 ThermalZoneInfo info1;
1513 info1.type = "battery";
1514 info1.temp = 40100;
1515 event.info.push_back(info1);
1516 g_service->HandleThermalCallbackEvent(event);
1517 std::string ret = GetNodeValue(LCD_PATH);
1518 EXPECT_TRUE(ret.substr(0, 3) == "1.0") << "ThermalMgrPolicyTest063 failed";
1519 event.info.clear();
1520
1521 g_service->SetScene("game");
1522 info1.temp = 40100;
1523 event.info.push_back(info1);
1524 g_service->HandleThermalCallbackEvent(event);
1525 ret = GetNodeValue(LCD_PATH);
1526 EXPECT_TRUE(ret.substr(0, 4) == "0.97") << "ThermalMgrPolicyTest063 failed";
1527 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest063 function end!");
1528 }
1529
1530 /**
1531 * @tc.name: ThermalMgrPolicyTest064
1532 * @tc.desc: test set brightness according to the scene
1533 * @tc.type: FEATURE
1534 * @tc.cond: Set Battery temp, Lower Temp
1535 * @tc.result level 1, scene call, brightness factor is 0.98; scene empty, brightness factor is 1.0
1536 * @tc.require: issueI5HWH6
1537 */
1538 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest064, Function|MediumTest|Level2)
1539 {
1540 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest064 function start!");
1541 HdfThermalCallbackInfo event;
1542 ThermalZoneInfo info1;
1543 info1.type = "battery";
1544 info1.temp = 40100;
1545 event.info.push_back(info1);
1546 g_service->SetScene("call");
1547 g_service->HandleThermalCallbackEvent(event);
1548 std::string ret = GetNodeValue(LCD_PATH);
1549 EXPECT_TRUE(ret.substr(0, 4) == "0.98") << "ThermalMgrPolicyTest064 failed";
1550 event.info.clear();
1551
1552 g_service->SetScene("");
1553 info1.temp = 40100;
1554 event.info.push_back(info1);
1555 g_service->HandleThermalCallbackEvent(event);
1556 ret = GetNodeValue(LCD_PATH);
1557 EXPECT_TRUE(ret.substr(0, 3) == "1.0") << "ThermalMgrPolicyTest064 failed";
1558 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest064 function end!");
1559 }
1560
1561 /**
1562 * @tc.name: ThermalMgrPolicyTest065
1563 * @tc.desc: test set brightness according to the scene
1564 * @tc.type: FEATURE
1565 * @tc.cond: Set Battery temp, Lower Temp
1566 * @tc.result scene cam, level 1, brightness factor is 0.99
1567 * @tc.require: issueI5HWH6
1568 */
1569 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest065, Function|MediumTest|Level2)
1570 {
1571 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest065 function start!");
1572 HdfThermalCallbackInfo event;
1573 ThermalZoneInfo info1;
1574 info1.type = "battery";
1575 info1.temp = 40100;
1576 event.info.push_back(info1);
1577 g_service->SetScene("cam");
1578 g_service->HandleThermalCallbackEvent(event);
1579 std::string ret = GetNodeValue(LCD_PATH);
1580 EXPECT_TRUE(ret.substr(0, 4) == "0.99") << "ThermalMgrPolicyTest065 failed";
1581 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest065 function end!");
1582 }
1583
1584 /**
1585 * @tc.name: ThermalMgrPolicyTest066
1586 * @tc.desc: test set brightness according to the scene
1587 * @tc.type: FEATURE
1588 * @tc.cond: Set Battery temp, Lower Temp
1589 * @tc.result scene call, level 2, brightness factor is 0.88
1590 * @tc.require: issueI5HWH6
1591 */
1592 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest066, Function|MediumTest|Level2)
1593 {
1594 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest066 function start!");
1595 HdfThermalCallbackInfo event;
1596 ThermalZoneInfo info1;
1597 info1.type = "battery";
1598 info1.temp = 43100;
1599 event.info.push_back(info1);
1600 g_service->SetScene("call");
1601 g_service->HandleThermalCallbackEvent(event);
1602 std::string ret = GetNodeValue(LCD_PATH);
1603 EXPECT_TRUE(ret.substr(0, 4) == "0.88") << "ThermalMgrPolicyTest066 failed";
1604 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest066 function end!");
1605 }
1606
1607 /**
1608 * @tc.name: ThermalMgrPolicyTest067
1609 * @tc.desc: test set brightness according to the scene
1610 * @tc.type: FEATURE
1611 * @tc.cond: Set Battery temp, Lower Temp
1612 * @tc.result scene game, level 3, brightness factor is 0.77
1613 * @tc.require: issueI5HWH6
1614 */
1615 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest067, Function|MediumTest|Level2)
1616 {
1617 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest067 function start!");
1618 HdfThermalCallbackInfo event;
1619 ThermalZoneInfo info1;
1620 info1.type = "battery";
1621 info1.temp = 46100;
1622 event.info.push_back(info1);
1623 g_service->SetScene("game");
1624 g_service->HandleThermalCallbackEvent(event);
1625 std::string ret = GetNodeValue(LCD_PATH);
1626 EXPECT_TRUE(ret.substr(0, 4) == "0.77") << "ThermalMgrPolicyTest066 failed";
1627 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest067 function end!");
1628 }
1629
1630 /**
1631 * @tc.name: ThermalMgrPolicyTest068
1632 * @tc.desc: get the config volume by setting battery temp
1633 * @tc.type: FEATURE
1634 * @tc.cond: Set Battery temp
1635 * @tc.result level 1, volume 1.0
1636 * @tc.require: issueI5HWH6
1637 */
1638 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest068, Function|MediumTest|Level2)
1639 {
1640 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest068 function start!");
1641 HdfThermalCallbackInfo event;
1642 ThermalZoneInfo info1;
1643 info1.type = "battery";
1644 info1.temp = 40100;
1645 event.info.push_back(info1);
1646 g_service->HandleThermalCallbackEvent(event);
1647 std::string ret = GetNodeValue(VOLUME_PATH);
1648 EXPECT_TRUE(ret.substr(0, 3) == "1.0") << "ThermalMgrPolicyTest068 failed";
1649 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest068 function end!");
1650 }
1651
1652 /**
1653 * @tc.name: ThermalMgrPolicyTest069
1654 * @tc.desc: get the config current by setting battery temp
1655 * @tc.type: FEATURE
1656 * @tc.cond: Set Battery temp
1657 * @tc.result level 2, volume 0.8
1658 * @tc.require: issueI5HWH6
1659 */
1660 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest069, Function|MediumTest|Level2)
1661 {
1662 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest069 function start!");
1663 HdfThermalCallbackInfo event;
1664 ThermalZoneInfo info1;
1665 info1.type = "battery";
1666 info1.temp = 43100;
1667 event.info.push_back(info1);
1668 g_service->HandleThermalCallbackEvent(event);
1669 std::string ret = GetNodeValue(VOLUME_PATH);
1670 EXPECT_TRUE(ret.substr(0, 3) == "0.8") << "ThermalMgrPolicyTest069 failed";
1671 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest069 function end!");
1672 }
1673
1674 /**
1675 * @tc.name: ThermalMgrPolicyTest070
1676 * @tc.desc: get the config current by setting battery temp
1677 * @tc.type: FEATURE
1678 * @tc.cond: Set Battery temp
1679 * @tc.result level 3, volume 0.7
1680 * @tc.require: issueI5HWH6
1681 */
1682 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest070, Function|MediumTest|Level2)
1683 {
1684 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest070 function start!");
1685 HdfThermalCallbackInfo event;
1686 ThermalZoneInfo info1;
1687 info1.type = "battery";
1688 info1.temp = 46100;
1689 event.info.push_back(info1);
1690 g_service->HandleThermalCallbackEvent(event);
1691 std::string ret = GetNodeValue(VOLUME_PATH);
1692 EXPECT_TRUE(ret.substr(0, 3) == "0.7") << "ThermalMgrPolicyTest070 failed";
1693 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest070 function end!");
1694 }
1695
1696 /**
1697 * @tc.name: ThermalMgrPolicyTest071
1698 * @tc.desc: test GetThermalSensorTemp function
1699 * @tc.type: FUNC
1700 * @tc.cond: Set Battery temp
1701 * @tc.result: Function return value is equal to the set value
1702 * @tc.require: issueI63SZ4
1703 */
1704 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest071, Function|MediumTest|Level2)
1705 {
1706 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest071 function start!");
1707 HdfThermalCallbackInfo event;
1708 ThermalZoneInfo info1;
1709 info1.type = "battery";
1710 info1.temp = 40100;
1711 event.info.push_back(info1);
1712 g_service->HandleThermalCallbackEvent(event);
1713 ThermalSrvSensorInfo info;
1714 bool thermalInfoRet = false;
1715 g_service->GetThermalSrvSensorInfo(static_cast<int32_t>(SensorType::BATTERY), info, thermalInfoRet);
1716 EXPECT_TRUE(thermalInfoRet);
1717 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest071 function end!");
1718 }
1719
1720 /**
1721 * @tc.name: ThermalMgrPolicyTest072
1722 * @tc.desc: get the config airplane by setting battery temp
1723 * @tc.type: FEATURE
1724 * @tc.cond: Set Battery temp
1725 * @tc.result level 2, airplane 1
1726 * @tc.require: issueIADG4V
1727 */
1728 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest072, Function|MediumTest|Level2)
1729 {
1730 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest072 function start!");
1731 HdfThermalCallbackInfo event;
1732 ThermalZoneInfo info1;
1733 info1.type = "battery";
1734 info1.temp = 43100;
1735 event.info.push_back(info1);
1736 g_service->HandleThermalCallbackEvent(event);
1737 std::string ret = GetNodeValue(AIRPLANE_PATH);
1738 EXPECT_TRUE(ret == "1") << "ThermalMgrPolicyTest072 failed";
1739 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest072 function end!");
1740 }
1741
1742 /**
1743 * @tc.name: ThermalMgrPolicyTest073
1744 * @tc.desc: test DecryptConfig
1745 * @tc.type: FUNC
1746 */
1747 HWTEST_F (ThermalMgrPolicyTest, ThermalMgrPolicyTest073, Function|MediumTest|Level2)
1748 {
1749 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest073 function start!");
1750 string path = "test";
1751 string result = "";
1752 #if (defined(__aarch64__) || defined(__x86_64__))
1753 constexpr const char* THERMAL_PLUGIN_AUTORUN_PATH = "/system/lib64/thermalplugin/autorun";
1754 #else
1755 constexpr const char* THERMAL_PLUGIN_AUTORUN_PATH = "/system/lib/thermalplugin/autorun";
1756 #endif
1757 ModuleMgrScan(THERMAL_PLUGIN_AUTORUN_PATH);
1758 bool ret = g_service->GetConfigParser().DecryptConfig(path, result);
1759 if (result.empty()) {
1760 EXPECT_FALSE(ret);
1761 } else {
1762 EXPECT_TRUE(ret);
1763 }
1764 THERMAL_HILOGI(LABEL_TEST, "ThermalMgrPolicyTest073 function end!");
1765 }
1766 }
1767