• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include "display_power_mgr_client.h"
18 #include "setting_provider.h"
19 #include "system_ability_definition.h"
20 #include "display_log.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 using namespace OHOS;
25 using namespace OHOS::DisplayPowerMgr;
26 
27 namespace {
28 const std::string SETTING_BRIGHTNESS_KEY {"settings.display.screen_brightness_status"};
29 const double NO_DISCOUNT = 1.00;
30 }
31 
32 class DisplayPowerMgrBrightnessTest : public Test {
33 public:
SetUp()34     void SetUp()
35     {
36         DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_ON);
37         DisplayPowerMgrClient::GetInstance().DiscountBrightness(NO_DISCOUNT);
38     }
39 
TearDown()40     void TearDown()
41     {
42         DisplayPowerMgrClient::GetInstance().RestoreBrightness();
43         DisplayPowerMgrClient::GetInstance().CancelBoostBrightness();
44     }
45 };
46 
47 namespace {
48 /**
49  * @tc.name: DisplayPowerMgrSetBrightness001
50  * @tc.desc: Test SetBrightness
51  * @tc.type: FUNC
52  */
53 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrSetBrightness001, TestSize.Level0)
54 {
55     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrSetBrightness001: fun is start");
56     const uint32_t SET_BRIGHTNESS = 90;
57     bool ret = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
58     EXPECT_TRUE(ret);
59     uint32_t deviceBrightness = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
60     EXPECT_EQ(deviceBrightness, SET_BRIGHTNESS);
61     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrSetBrightness001: fun is end");
62 }
63 
64 /**
65  * @tc.name: DisplayPowerMgrSettingBrightness001
66  * @tc.desc: Test setting brightness value changed when SetBrightness
67  * @tc.type: FUNC
68  */
69 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrSettingBrightness001, TestSize.Level0)
70 {
71     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrSettingBrightness001: fun is start");
72     const uint32_t SET_BRIGHTNESS_VALUE = 223;
73     bool ret = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS_VALUE);
74     EXPECT_TRUE(ret);
75     const int SLEEP_TIME = 100000;
76     usleep(SLEEP_TIME); // sleep 100ms, wait for setting update
77     uint32_t brightness = DisplayPowerMgrClient::GetInstance().GetBrightness();
78     EXPECT_EQ(brightness, SET_BRIGHTNESS_VALUE);
79     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrSettingBrightness001: fun is end");
80 }
81 
82 /**
83  * @tc.name: DisplayPowerMgrDiscountBrightnessNormal
84  * @tc.desc: Test DiscountBrightness the normal test
85  * @tc.type: FUNC
86  * @tc.require: issueI5HWMN
87  */
88 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightnessNormal, TestSize.Level0)
89 {
90     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessNormal: fun is start");
91     const uint32_t SET_BRIGHTNESS = 91;
92     const int32_t SLEEP_TIME = 200000;
93     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
94     usleep(SLEEP_TIME); // sleep 200ms, wait for setBrightness
95     const double DISCOUNT_NORMAL = 0.8;
96     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_NORMAL);
97     EXPECT_TRUE(ret);
98 
99     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
100     EXPECT_EQ(value, static_cast<uint32_t>(SET_BRIGHTNESS * DISCOUNT_NORMAL));
101     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessNormal: fun is end");
102 }
103 
104 /**
105  * @tc.name: DisplayPowerMgrDiscountBrightnessNormal
106  * @tc.desc: Test DiscountBrightness when screen is off
107  * @tc.type: FUNC
108  * @tc.require: issueI5HWMN
109  */
110 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightnessScreenOff, TestSize.Level0)
111 {
112     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessScreenOff: fun is start");
113     DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_OFF);
114     const double DISCOUNT_VALUE = 0.8;
115     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_VALUE);
116     EXPECT_FALSE(ret);
117     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessScreenOff: fun is end");
118 }
119 
120 /**
121  * @tc.name: DisplayPowerMgrDiscountBrightnessBoundary001
122  * @tc.desc: Test DiscountBrightness the boundary test
123  * @tc.type: FUNC
124  * @tc.require: issueI5HWMN
125  */
126 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightnessBoundary001, TestSize.Level0)
127 {
128     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessBoundary001: fun is start");
129     const uint32_t SET_BRIGHTNESS = 92;
130     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
131     const double DISCOUNT_LOWER_BOUNDARY = 0.01;
132     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_LOWER_BOUNDARY);
133     EXPECT_TRUE(ret);
134 
135     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
136     uint32_t minBrightness = DisplayPowerMgrClient::GetInstance().GetMinBrightness();
137     EXPECT_EQ(value, minBrightness);
138     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessBoundary001: fun is end");
139 }
140 
141 /**
142  * @tc.name: DisplayPowerMgrDiscountBrightnessBoundary002
143  * @tc.desc: Test DiscountBrightness the boundary test
144  * @tc.type: FUNC
145  * @tc.require: issueI5HWMN
146  */
147 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightnessBoundary002, TestSize.Level0)
148 {
149     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessBoundary002: fun is start");
150     const uint32_t SET_BRIGHTNESS = 93;
151     const int32_t SLEEP_TIME = 200000;
152     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
153     usleep(SLEEP_TIME); // sleep 200ms, wait for setBrightness
154     const double DISCOUNT_UPPER_BOUNDARY = 1.0;
155     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_UPPER_BOUNDARY);
156     EXPECT_TRUE(ret);
157 
158     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
159     EXPECT_EQ(value, static_cast<uint32_t>(SET_BRIGHTNESS * DISCOUNT_UPPER_BOUNDARY));
160     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessBoundary002: fun is end");
161 }
162 
163 /**
164  * @tc.name: DisplayPowerMgrDiscountBrightnessAbnormal001
165  * @tc.desc: Test DiscountBrightness the abnormal test
166  * @tc.type: FUNC
167  * @tc.require: issueI5HWMN
168  */
169 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightnessAbnormal001, TestSize.Level0)
170 {
171     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessAbnormal001: fun is start");
172     const uint32_t SET_BRIGHTNESS = 94;
173     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
174     const double DISCOUNT_BEYOND_LOWER_BOUNDARY = 0.0;
175     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_BEYOND_LOWER_BOUNDARY);
176     EXPECT_TRUE(ret);
177 
178     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
179     uint32_t minBrightness = DisplayPowerMgrClient::GetInstance().GetMinBrightness();
180     EXPECT_EQ(value, minBrightness);
181     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessAbnormal001: fun is end");
182 }
183 
184 /**
185  * @tc.name: DisplayPowerMgrDiscountBrightnessAbnormal002
186  * @tc.desc: Test DiscountBrightness the abnormal test
187  * @tc.type: FUNC
188  * @tc.require: issueI5HWMN
189  */
190 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightnessAbnormal002, TestSize.Level0)
191 {
192     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessAbnormal002: fun is start");
193     const uint32_t SET_BRIGHTNESS = 95;
194     const int32_t SLEEP_TIME = 200000;
195     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
196     usleep(SLEEP_TIME); // sleep 200ms, wait for setBrightness
197     const double DISCOUNT_BEYOND_UPPER_BOUNDARY = 2.0;
198     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_BEYOND_UPPER_BOUNDARY);
199     EXPECT_TRUE(ret);
200 
201     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
202     const double DISCOUNT_MAX_VALUE = 1.0;
203     EXPECT_EQ(value, static_cast<uint32_t>(SET_BRIGHTNESS * DISCOUNT_MAX_VALUE));
204     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessAbnormal002: fun is end");
205 }
206 
207 /**
208  * @tc.name: DisplayPowerMgrDiscountBrightnessAbnormal003
209  * @tc.desc: Test DiscountBrightness the abnormal test
210  * @tc.type: FUNC
211  * @tc.require: issueI5HWMN
212  */
213 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightnessAbnormal003, TestSize.Level0)
214 {
215     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessAbnormal003: fun is start");
216     const uint32_t SET_BRIGHTNESS = 96;
217     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
218     const double DISCOUNT_NEGATIVE_VALUE = -1.0;
219     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_NEGATIVE_VALUE);
220     EXPECT_TRUE(ret);
221 
222     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
223     uint32_t minBrightness = DisplayPowerMgrClient::GetInstance().GetMinBrightness();
224     EXPECT_EQ(value, minBrightness);
225     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightnessAbnormal003: fun is end");
226 }
227 
228 /**
229  * @tc.name: DisplayPowerMgrDiscountBrightness001
230  * @tc.desc: Test OverrideBrightness after DiscountBrightness, then RestoreBrightness
231  * @tc.type: FUNC
232  * @tc.require: issueI5HWMN
233  */
234 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightness001, TestSize.Level0)
235 {
236     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness001: fun is start");
237     const uint32_t SET_BRIGHTNESS = 97;
238     const int32_t SLEEP_TIME = 200000;
239     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
240     usleep(SLEEP_TIME); // sleep 200ms, wait for setBrightness
241     const double DISCOUNT_VALUE = 0.8;
242     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_VALUE);
243     EXPECT_TRUE(ret);
244 
245     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
246     EXPECT_EQ(value, static_cast<uint32_t>(DISCOUNT_VALUE * SET_BRIGHTNESS));
247 
248     const uint32_t SET_OVERRIDE_BRIGHTNESS = 200;
249     DisplayPowerMgrClient::GetInstance().OverrideBrightness(SET_OVERRIDE_BRIGHTNESS);
250     value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
251     EXPECT_EQ(value, static_cast<uint32_t>(DISCOUNT_VALUE * SET_OVERRIDE_BRIGHTNESS));
252 
253     DisplayPowerMgrClient::GetInstance().RestoreBrightness();
254     value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
255     EXPECT_EQ(value, static_cast<uint32_t>(DISCOUNT_VALUE * SET_BRIGHTNESS));
256     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness001: fun is end");
257 }
258 
259 /**
260  * @tc.name: DisplayPowerMgrDiscountBrightness002
261  * @tc.desc: Test DiscountBrightness after OverrideBrightness, then RestoreBrightness
262  * @tc.type: FUNC
263  * @tc.require: issueI5HWMN
264  */
265 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightness002, TestSize.Level0)
266 {
267     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness002: fun is start");
268     const uint32_t SET_BRIGHTNESS = 98;
269     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
270     const uint32_t SET_OVERRIDE_BRIGHTNESS = 200;
271     DisplayPowerMgrClient::GetInstance().OverrideBrightness(SET_OVERRIDE_BRIGHTNESS);
272 
273     const double DISCOUNT_VALUE = 0.8;
274     double ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_VALUE);
275     EXPECT_TRUE(ret);
276     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
277     EXPECT_EQ(value, static_cast<uint32_t>(DISCOUNT_VALUE * SET_OVERRIDE_BRIGHTNESS));
278 
279     ret = DisplayPowerMgrClient::GetInstance().RestoreBrightness();
280     EXPECT_TRUE(ret);
281 
282     value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
283     EXPECT_EQ(value, static_cast<uint32_t>(DISCOUNT_VALUE * SET_BRIGHTNESS));
284     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness002: fun is end");
285 }
286 
287 /**
288  * @tc.name: DisplayPowerMgrDiscountBrightness003
289  * @tc.desc: Test DisconutBrightness after BoostBrightness and CancelBoostBrightness
290  * @tc.type: FUNC
291  * @tc.require: issueI5HWMN
292  */
293 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightness003, TestSize.Level0)
294 {
295     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness003: fun is start");
296     const uint32_t SET_BRIGHTNESS = 99;
297     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
298     const uint32_t SET_BOOST_BRIGHTNESS_TIME = 10000;
299     DisplayPowerMgrClient::GetInstance().BoostBrightness(SET_BOOST_BRIGHTNESS_TIME);
300 
301     const double DISCOUNT_VALUE = 0.8;
302     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_VALUE);
303     EXPECT_TRUE(ret);
304 
305     uint32_t maxBrightness = DisplayPowerMgrClient::GetInstance().GetMaxBrightness();
306     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
307     EXPECT_EQ(value, static_cast<uint32_t>(DISCOUNT_VALUE * maxBrightness));
308 
309     DisplayPowerMgrClient::GetInstance().CancelBoostBrightness();
310 
311     value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
312     EXPECT_EQ(value, static_cast<uint32_t>(DISCOUNT_VALUE * SET_BRIGHTNESS));
313     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness003: fun is end");
314 }
315 
316 /**
317  * @tc.name: DisplayPowerMgrDiscountBrightness004
318  * @tc.desc: Test BoostBrightness after DiscountBrightness, then CancelBoostBrightness
319  * @tc.type: FUNC
320  * @tc.require: issueI5HWMN
321  */
322 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightness004, TestSize.Level0)
323 {
324     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness004: fun is start");
325     const uint32_t SET_BRIGHTNESS = 100;
326     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
327     const double DISCOUNT_VALUE = 0.8;
328     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_VALUE);
329     EXPECT_TRUE(ret);
330 
331     const uint32_t SET_BOOST_BRIGHTNESS_TIME = 10000;
332     DisplayPowerMgrClient::GetInstance().BoostBrightness(SET_BOOST_BRIGHTNESS_TIME);
333     uint32_t maxBrightness = DisplayPowerMgrClient::GetInstance().GetMaxBrightness();
334     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
335     EXPECT_EQ(value, static_cast<uint32_t>(DISCOUNT_VALUE * maxBrightness));
336 
337     DisplayPowerMgrClient::GetInstance().CancelBoostBrightness();
338 
339     value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
340     EXPECT_EQ(value, static_cast<uint32_t>(DISCOUNT_VALUE * SET_BRIGHTNESS));
341     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness004: fun is end");
342 }
343 
344 /**
345  * @tc.name: DisplayPowerMgrDiscountBrightness005
346  * @tc.desc: Test DisconutBrightness after SetBrightness, then GetBrightness
347  * @tc.type: FUNC
348  * @tc.require: issueI5HWMN
349  */
350 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDiscountBrightness005, TestSize.Level0)
351 {
352     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness005: fun is start");
353     const uint32_t SET_BRIGHTNESS = 103;
354     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
355     const double DISCOUNT_VALUE = 0.8;
356     bool ret = DisplayPowerMgrClient::GetInstance().DiscountBrightness(DISCOUNT_VALUE);
357     EXPECT_TRUE(ret);
358 
359     uint32_t beforeBrightness = DisplayPowerMgrClient::GetInstance().GetBrightness();
360     EXPECT_EQ(SET_BRIGHTNESS, beforeBrightness);
361     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDiscountBrightness005: fun is end");
362 }
363 
364 /**
365  * @tc.name: DisplayPowerMgrOverrideBrightness001
366  * @tc.desc: Test OverrideBrightness
367  * @tc.type: FUNC
368  */
369 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrOverrideBrightness001, TestSize.Level0)
370 {
371     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness001: fun is start");
372     const uint32_t OVERRIDE_BRIGHTNESS = 255;
373     bool ret = DisplayPowerMgrClient::GetInstance().OverrideBrightness(OVERRIDE_BRIGHTNESS);
374     EXPECT_TRUE(ret);
375     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
376     EXPECT_EQ(value, OVERRIDE_BRIGHTNESS);
377     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness001: fun is end");
378 }
379 
380 /**
381  * @tc.name: DisplayPowerMgrOverrideBrightness002
382  * @tc.desc: Test RestoreBrightness after OverrideBrightness
383  * @tc.type: FUNC
384  */
385 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrOverrideBrightness002, TestSize.Level0)
386 {
387     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness002: fun is start");
388     const uint32_t SET_BRIGHTNESS = 104;
389     const uint32_t OVERRIDE_BRIGHTNESS = 255;
390     const int32_t SLEEP_TIME = 200000;
391     bool ret = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
392     usleep(SLEEP_TIME); // sleep 200ms, wait for setBrightness
393     EXPECT_TRUE(ret);
394     ret = DisplayPowerMgrClient::GetInstance().OverrideBrightness(OVERRIDE_BRIGHTNESS);
395     EXPECT_TRUE(ret);
396     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
397     EXPECT_EQ(value, OVERRIDE_BRIGHTNESS);
398     ret = DisplayPowerMgrClient::GetInstance().RestoreBrightness(); // restore
399     EXPECT_TRUE(ret);
400     value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
401     EXPECT_EQ(value, SET_BRIGHTNESS);
402     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness002: fun is end");
403 }
404 
405 /**
406  * @tc.name: DisplayPowerMgrOverrideBrightness003
407  * @tc.desc: Test SetBrightness after OverrideBrightness
408  * @tc.type: FUNC
409  */
410 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrOverrideBrightness003, TestSize.Level0)
411 {
412     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness003: fun is start");
413     const uint32_t SET_BRIGHTNESS = 105;
414     const uint32_t OVERRIDE_BRIGHTNESS = 255;
415     bool ret = DisplayPowerMgrClient::GetInstance().OverrideBrightness(OVERRIDE_BRIGHTNESS);
416     EXPECT_TRUE(ret);
417     ret = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
418     EXPECT_FALSE(ret);
419     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
420     EXPECT_EQ(value, OVERRIDE_BRIGHTNESS);
421     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness003: fun is end");
422 }
423 
424 /**
425  * @tc.name: DisplayPowerMgrOverrideBrightness004
426  * @tc.desc: Test RestoreBrightness after not override
427  * @tc.type: FUNC
428  */
429 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrOverrideBrightness004, TestSize.Level0)
430 {
431     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness004: fun is start");
432     const uint32_t SET_BRIGHTNESS = 106;
433     bool ret = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
434     EXPECT_TRUE(ret);
435     ret = DisplayPowerMgrClient::GetInstance().RestoreBrightness();
436     EXPECT_FALSE(ret);
437     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
438     EXPECT_EQ(value, SET_BRIGHTNESS);
439     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness004: fun is end");
440 }
441 
442 /**
443  * @tc.name: DisplayPowerMgrOverrideBrightness005
444  * @tc.desc: Test OverrideBrightness off Disable the call
445  * @tc.type: FUNC
446  */
447 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrOverrideBrightness005, TestSize.Level0)
448 {
449     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness005: fun is start");
450     DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_OFF);
451     const uint32_t OVERRIDE_BRIGHTNESS = 100;
452     bool isBoost = DisplayPowerMgrClient::GetInstance().OverrideBrightness(OVERRIDE_BRIGHTNESS);
453     EXPECT_FALSE(isBoost);
454     bool isRestore = DisplayPowerMgrClient::GetInstance().RestoreBrightness();
455     EXPECT_FALSE(isRestore);
456     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness005: fun is end");
457 }
458 
459 /**
460  * @tc.name: DisplayPowerMgrOverrideBrightness006
461  * @tc.desc: Test device brightness when override brightness is 256
462  * @tc.type: FUNC
463  * @tc.require: issueI5YZQR
464  */
465 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrOverrideBrightness006, TestSize.Level0)
466 {
467     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness006: fun is start");
468     uint32_t overrideValue = 256;
469     uint32_t brightnessMax = 255;
470     DisplayPowerMgrClient::GetInstance().OverrideBrightness(overrideValue);
471     uint32_t deviceBrightness = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
472     EXPECT_EQ(brightnessMax, deviceBrightness);
473     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness006: fun is end");
474 }
475 
476 /**
477  * @tc.name: DisplayPowerMgrOverrideBrightness007
478  * @tc.desc: Test device brightness when override brightness is 0
479  * @tc.type: FUNC
480  * @tc.require: issueI5YZQR
481  */
482 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrOverrideBrightness007, TestSize.Level0)
483 {
484     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness007: fun is start");
485     uint32_t overrideValue = 0;
486     uint32_t brightnessMin = 5;
487     EXPECT_TRUE(DisplayPowerMgrClient::GetInstance().OverrideBrightness(overrideValue));
488     uint32_t deviceBrightness = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
489     EXPECT_EQ(brightnessMin, deviceBrightness);
490     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness007: fun is end");
491 }
492 
493 /**
494  * @tc.name: DisplayPowerMgrOverrideBrightness008
495  * @tc.desc: Test device brightness when override brightness is -1
496  * @tc.type: FUNC
497  * @tc.require: issueI5YZQR
498  */
499 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrOverrideBrightness008, TestSize.Level0)
500 {
501     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness008: fun is start");
502     uint32_t overrideValue = -1;
503     uint32_t brightnessMax = 255;
504     EXPECT_TRUE(DisplayPowerMgrClient::GetInstance().OverrideBrightness(overrideValue));
505     uint32_t deviceBrightness = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
506     EXPECT_EQ(brightnessMax, deviceBrightness);
507     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrOverrideBrightness008: fun is end");
508 }
509 
510 /**
511  * @tc.name: DisplayPowerMgrMaxBrightness001
512  * @tc.desc: Test GetMaxBrightness less equals 255
513  * @tc.type: FUNC
514  */
515 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrMaxBrightness001, TestSize.Level0)
516 {
517     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrMaxBrightness001: fun is start");
518     uint32_t max = DisplayPowerMgrClient::GetInstance().GetMaxBrightness();
519     EXPECT_LE(max, 255);
520     bool ret = DisplayPowerMgrClient::GetInstance().SetBrightness(max + 100);
521     EXPECT_TRUE(ret);
522     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
523     EXPECT_EQ(value, max);
524     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrMaxBrightness001: fun is end");
525 }
526 
527 /**
528  * @tc.name: DisplayPowerMgrMinBrightness001
529  * @tc.desc: Test GetMinBrightness greater equals 0
530  * @tc.type: FUNC
531  */
532 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrMinBrightness001, TestSize.Level0)
533 {
534     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrMinBrightness001: fun is start");
535     const uint32_t SET_BRIGHTNESS_VALUE = 0;
536     uint32_t min = DisplayPowerMgrClient::GetInstance().GetMinBrightness();
537     EXPECT_GE(min, 0);
538     bool ret = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS_VALUE);
539     EXPECT_TRUE(ret);
540     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
541     EXPECT_EQ(value, min);
542     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrMinBrightness001: fun is end");
543 }
544 
545 /**
546  * @tc.name: DisplayPowerMgrDefaultBrightness001
547  * @tc.desc: Test GetDefaultnBrightness greater equals 0 and less equals 255
548  * @tc.type: FUNC
549  */
550 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrDefaultBrightness001, TestSize.Level0)
551 {
552     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDefaultBrightness001: fun is start");
553     uint32_t value = DisplayPowerMgrClient::GetInstance().GetDefaultBrightness();
554     EXPECT_GE(value, 0);
555     EXPECT_LE(value, 255);
556     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrDefaultBrightness001: fun is end");
557 }
558 
559 /**
560  * @tc.name: DisplayPowerMgrBoostBrightnessNormal
561  * @tc.desc: Test BoostBrightness the normal test
562  * @tc.type: FUNC
563  */
564 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrBoostBrightnessNormal, TestSize.Level0)
565 {
566     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessNormal: fun is start");
567     const uint32_t BOOST_TIME = 100; // keep BoostBrightness 100ms
568     bool isSucc = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_TIME);
569     EXPECT_TRUE(isSucc);
570     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessNormal: fun is end");
571 }
572 
573 /**
574  * @tc.name: DisplayPowerMgrBoostBrightnessAbnormal
575  * @tc.desc: Test BoostBrightness the abnormal value
576  * @tc.type: FUNC
577  */
578 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrBoostBrightnessAbnormal, TestSize.Level0)
579 {
580     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessAbnormal: fun is start");
581     const uint32_t BOOST_TIME = -1;
582     bool isSucc = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_TIME);
583     EXPECT_FALSE(isSucc);
584     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessAbnormal: fun is end");
585 }
586 
587 /**
588  * @tc.name: DisplayPowerMgrCancelBoostBrightnessNormal
589  * @tc.desc: Test CancelBoostBrightness the normal test
590  * @tc.type: FUNC
591  */
592 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrCancelBoostBrightnessNormal, TestSize.Level0)
593 {
594     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrCancelBoostBrightnessNormal: fun is start");
595     const uint32_t BOOST_TIME = 50000;
596     bool isSucc = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_TIME);
597     EXPECT_TRUE(isSucc);
598     bool isCancel = DisplayPowerMgrClient::GetInstance().CancelBoostBrightness();
599     EXPECT_TRUE(isCancel);
600     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrCancelBoostBrightnessNormal: fun is end");
601 }
602 
603 /**
604  * @tc.name: BoostAndOverrideMutuallyExclusive1
605  * @tc.desc: Test BoostBrightness and OverrideBrightness are mutually exclusive
606  * @tc.type: FUNC
607  */
608 HWTEST_F(DisplayPowerMgrBrightnessTest, BoostAndOverrideMutuallyExclusive1, TestSize.Level0)
609 {
610     DISPLAY_HILOGI(LABEL_TEST, "BoostAndOverrideMutuallyExclusive: fun is start");
611     const uint32_t BOOST_TIME = 50000;
612     const uint32_t OVERRIDE_BIRGHTNESS = 100;
613     bool isBoost = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_TIME);
614     EXPECT_TRUE(isBoost);
615     bool isOverride = DisplayPowerMgrClient::GetInstance().OverrideBrightness(OVERRIDE_BIRGHTNESS);
616     EXPECT_FALSE(isOverride);
617     bool isRestore = DisplayPowerMgrClient::GetInstance().RestoreBrightness();
618     EXPECT_FALSE(isRestore);
619     DISPLAY_HILOGI(LABEL_TEST, "BoostAndOverrideMutuallyExclusive: fun is end");
620 }
621 
622 /**
623  * @tc.name: BoostAndOverrideMutuallyExclusive2
624  * @tc.desc: Test BoostBrightness and OverrideBrightness are mutually exclusive
625  * @tc.type: FUNC
626  */
627 HWTEST_F(DisplayPowerMgrBrightnessTest, BoostAndOverrideMutuallyExclusive2, TestSize.Level0)
628 {
629     DISPLAY_HILOGI(LABEL_TEST, "BoostAndOverrideMutuallyExclusive2: fun is start");
630     const uint32_t BOOST_TIME = 50000;
631     const uint32_t OVERRIDE_BIRGHTNESS = 255;
632     bool isOverride = DisplayPowerMgrClient::GetInstance().OverrideBrightness(OVERRIDE_BIRGHTNESS);
633     EXPECT_TRUE(isOverride);
634     bool isBoost = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_TIME);
635     EXPECT_FALSE(isBoost);
636     bool isCancel = DisplayPowerMgrClient::GetInstance().CancelBoostBrightness();
637     EXPECT_FALSE(isCancel);
638     DISPLAY_HILOGI(LABEL_TEST, "BoostAndOverrideMutuallyExclusive2: fun is end");
639 }
640 
641 /**
642  * @tc.name: DisplayPowerMgrBoostBrightnessTimeout1
643  * @tc.desc: Test BoostBrightness timeout restore system brightness
644  * @tc.type: FUNC
645  */
646 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrBoostBrightnessTimeout1, TestSize.Level0)
647 {
648     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessTimeout1: fun is start");
649     uint32_t beforeValue = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
650     const uint32_t BOOST_BRIGHTNESS_TIME = 100;
651     bool isBoost = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_BRIGHTNESS_TIME);
652     EXPECT_TRUE(isBoost);
653     const int SLEEP_TIME = 200000;
654     usleep(SLEEP_TIME); // sleep 200ms, wait for setting update
655     uint32_t currentValue = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
656     EXPECT_EQ(beforeValue, currentValue);
657     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessTimeout1: fun is end");
658 }
659 
660 /**
661  * @tc.name: DisplayPowerMgrBoostBrightnessTimeout2
662  * @tc.desc: Test BoostBrightness timeout brightness adjustment can be called
663  * @tc.type: FUNC
664  */
665 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrBoostBrightnessTimeout2, TestSize.Level0)
666 {
667     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessTimeout2: fun is start");
668     const uint32_t SET_BRIGHTNESS = 106;
669     const uint32_t BOOST_BRIGHTNESS_TIME = 100;
670     const int SLEEP_TIME = 100000;
671     bool isBoost = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_BRIGHTNESS_TIME);
672     EXPECT_TRUE(isBoost);
673     usleep(SLEEP_TIME); // sleep 100ms, wait for cancel BoostBrightness
674     bool isSet = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
675     EXPECT_TRUE(isSet);
676     uint32_t currentValue = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
677     EXPECT_EQ(SET_BRIGHTNESS, currentValue);
678     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessTimeout2: fun is end");
679 }
680 
681 /**
682  * @tc.name: DisplayPowerMgrBoostBrightnessCancel1
683  * @tc.desc: Test BoostBrightness Cancel restore system brightness
684  * @tc.type: FUNC
685  */
686 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrBoostBrightnessCancel1, TestSize.Level0)
687 {
688     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessCancel1: fun is start");
689     const uint32_t SET_BRIGHTNESS = 106;
690     DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
691     const uint32_t BOOST_BRIGHTNESS_TIME = 10000;
692     const int SLEEP_TIME = 100000;
693     bool isBoost = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_BRIGHTNESS_TIME);
694     EXPECT_TRUE(isBoost);
695     bool isCancel = DisplayPowerMgrClient::GetInstance().CancelBoostBrightness();
696     EXPECT_TRUE(isCancel);
697     usleep(SLEEP_TIME); // sleep 100ms, wait for cancel BoostBrightness
698     uint32_t currentValue = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
699     EXPECT_EQ(SET_BRIGHTNESS, currentValue) << "beforeValue: " << SET_BRIGHTNESS << " currentVal: " << currentValue;
700     DISPLAY_HILOGI(LABEL_TEST, "BoostBrightnessCancel1: beforeValue: %{public}d, currentVal: %{public}d",
701         SET_BRIGHTNESS, currentValue);
702     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessCancel1: fun is end");
703 }
704 
705 /**
706  * @tc.name: DisplayPowerMgrBoostBrightnessCancel2
707  * @tc.desc: Test BoostBrightness Cancel brightness adjustment can be called
708  * @tc.type: FUNC
709  */
710 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrBoostBrightnessCancel2, TestSize.Level0)
711 {
712     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessCancel2: fun is start");
713     const uint32_t BOOST_BRIGHTNESS_TIME = 10000;
714     bool isBoost = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_BRIGHTNESS_TIME);
715     EXPECT_TRUE(isBoost);
716     bool isCancel = DisplayPowerMgrClient::GetInstance().CancelBoostBrightness();
717     EXPECT_TRUE(isCancel);
718     const uint32_t SET_BRIGHTNESS_VALUE = 111;
719     bool isSet = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS_VALUE);
720     EXPECT_TRUE(isSet);
721     uint32_t currentValue = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
722     EXPECT_EQ(SET_BRIGHTNESS_VALUE, currentValue);
723     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessCancel2: fun is end");
724 }
725 
726 /**
727  * @tc.name: DisplayPowerMgrBoostBrightnessNotAdjust
728  * @tc.desc: Test BoostBrightness do not adjust brightness
729  * @tc.type: FUNC
730  */
731 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrBoostBrightnessNotAdjust, TestSize.Level0)
732 {
733     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessNotAdjust: fun is start");
734     const uint32_t SET_BRIGHTNESS = 107;
735     const uint32_t BOOST_BRIGHTNESS_TIME = 10000;
736     bool isBoost = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_BRIGHTNESS_TIME);
737     EXPECT_TRUE(isBoost);
738     bool isSet = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
739     EXPECT_FALSE(isSet);
740     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessNotAdjust: fun is end");
741 }
742 
743 /**
744  * @tc.name: DisplayPowerMgrBoostBrightnessScreenOff
745  * @tc.desc: Test BoostBrightness off Disable the call
746  * @tc.type: FUNC
747  */
748 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrBoostBrightnessScreenOff, TestSize.Level0)
749 {
750     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessScreenOff: fun is start");
751     DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_OFF);
752     const uint32_t BOOST_BRIGHTNESS_TIME = 10000;
753     bool isBoost = DisplayPowerMgrClient::GetInstance().BoostBrightness(BOOST_BRIGHTNESS_TIME);
754     EXPECT_FALSE(isBoost);
755     bool isCancel = DisplayPowerMgrClient::GetInstance().CancelBoostBrightness();
756     EXPECT_FALSE(isCancel);
757     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessScreenOff: fun is end");
758 }
759 
760 /**
761  * @tc.name: DisplayPowerMgrBoostBrightnessMultipleCalls
762  * @tc.desc: Test BoostBrightness multiple calls
763  * @tc.type: FUNC
764  */
765 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrBoostBrightnessMultipleCalls, TestSize.Level0)
766 {
767     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessMultipleCalls: fun is start");
768     const uint32_t SET_BRIGHTNESS = 108;
769     const uint32_t COUNT = 3;
770     const uint32_t TIMEOUT = 100;
771     const uint32_t SLEEP_TIME = 200000;
772     const uint32_t UPDATE_TIME = 20000;
773     for (uint32_t i = 0; i < COUNT; ++i) {
774         bool isBoost = DisplayPowerMgrClient::GetInstance().BoostBrightness(TIMEOUT);
775         usleep(UPDATE_TIME); // wait for set newest BoostBrightness time
776         EXPECT_TRUE(isBoost);
777     }
778     // Brightness adjustment is not allowed
779     bool isSet = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS);
780     EXPECT_FALSE(isSet);
781     // Wait for a timeout
782     usleep(SLEEP_TIME);
783     bool isCancel = DisplayPowerMgrClient::GetInstance().CancelBoostBrightness();
784     EXPECT_FALSE(isCancel);
785     const uint32_t SET_BRIGHTNESS_VALUE = 222;
786     isSet = DisplayPowerMgrClient::GetInstance().SetBrightness(SET_BRIGHTNESS_VALUE);
787     EXPECT_TRUE(isSet);
788     uint32_t currentVal = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
789     EXPECT_EQ(SET_BRIGHTNESS_VALUE, currentVal);
790     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrBoostBrightnessMultipleCalls: fun is end");
791 }
792 
793 /**
794  * @tc.name: DisplayPowerMgrAdjustBrightness001
795  * @tc.desc: Test AdjustBrightness
796  * @tc.type: FUNC
797  */
798 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrAdjustBrightness001, TestSize.Level0)
799 {
800     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrAdjustBrightness001: fun is start");
801     bool ret = DisplayPowerMgrClient::GetInstance().AdjustBrightness(0, 3000);
802     EXPECT_TRUE(ret);
803     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrAdjustBrightness001: fun is end");
804 }
805 
806 /**
807  * @tc.name: DisplayPowerMgrAdjustBrightness002
808  * @tc.desc: Test AutoAdjustBrightness
809  * @tc.type: FUNC
810  */
811 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrAdjustBrightness002, TestSize.Level0)
812 {
813     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrAdjustBrightness002: fun is start");
814     bool ret = DisplayPowerMgrClient::GetInstance().AutoAdjustBrightness(true);
815     if (ret) {
816         DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrAdjustBrightness002: is supported");
817         ret = DisplayPowerMgrClient::GetInstance().AutoAdjustBrightness(false);
818         EXPECT_TRUE(ret);
819     } else {
820         DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrAdjustBrightness002: is not supported");
821         EXPECT_FALSE(ret);
822     }
823 }
824 
825 /**
826  * @tc.name: DisplayPowerMgrAdjustBrightness003
827  * @tc.desc: Test IsAutoAdjustBrightness
828  * @tc.type: FUNC
829  * @tc.require: issueI5YZQR
830  */
831 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrAdjustBrightness003, TestSize.Level0)
832 {
833     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrAdjustBrightness003: fun is start");
834     bool ret = DisplayPowerMgrClient::GetInstance().IsAutoAdjustBrightness();
835     DisplayPowerMgrClient::GetInstance().AutoAdjustBrightness(false);
836     EXPECT_EQ(DisplayPowerMgrClient::GetInstance().IsAutoAdjustBrightness(), false);
837     DisplayPowerMgrClient::GetInstance().AutoAdjustBrightness(ret);
838     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrAdjustBrightness003: fun is end");
839 }
840 
841 /**
842  * @tc.name: DisplayPowerMgrScreenBrightnessEquality001
843  * @tc.desc: Test whether the screen brightness is equal after the screen is on and before the screen is off
844  * @tc.type: FUNC
845  * @tc.require: issueI5YZQR
846  */
847 HWTEST_F(DisplayPowerMgrBrightnessTest, DisplayPowerMgrScreenBrightnessEquality001, TestSize.Level0)
848 {
849     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrScreenBrightnessEquality001: fun is start");
850     uint32_t deviceBrightness1 = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
851     DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_OFF);
852     DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_ON);
853     uint32_t deviceBrightness2 = DisplayPowerMgrClient::GetInstance().GetDeviceBrightness();
854     EXPECT_EQ(deviceBrightness1, deviceBrightness2);
855     DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrScreenBrightnessEquality001: fun is end");
856 }
857 } // namespace
858