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