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