1 /* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <gtest/gtest.h> 17 #include "display_log.h" 18 #include "display_power_mgr_client.h" 19 #include "brightness_service.h" 20 21 using namespace testing; 22 using namespace testing::ext; 23 using namespace OHOS; 24 using namespace OHOS::DisplayPowerMgr; 25 using namespace std; 26 27 namespace { 28 const double NO_DISCOUNT = 1.00; 29 } 30 31 class BrightnessServiceTest : public Test { 32 public: SetUp()33 void SetUp() 34 { 35 DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_ON); 36 DisplayPowerMgrClient::GetInstance().DiscountBrightness(NO_DISCOUNT); 37 } 38 TearDown()39 void TearDown() 40 { 41 DisplayPowerMgrClient::GetInstance().RestoreBrightness(); 42 DisplayPowerMgrClient::GetInstance().CancelBoostBrightness(); 43 } 44 }; 45 46 namespace { 47 HWTEST_F(BrightnessServiceTest, BrightnessServiceGet001, TestSize.Level0) 48 { 49 DISPLAY_HILOGI(LABEL_TEST, "BrightnessServiceGet001: fun is start"); 50 auto& brightnessService = BrightnessService::Get(); 51 EXPECT_NE(&brightnessService, nullptr); 52 DISPLAY_HILOGI(LABEL_TEST, "BrightnessServiceGet001: fun is end"); 53 } 54 } // namespace