17c804472Sopenharmony_ci/*
27c804472Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
37c804472Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
47c804472Sopenharmony_ci * you may not use this file except in compliance with the License.
57c804472Sopenharmony_ci * You may obtain a copy of the License at
67c804472Sopenharmony_ci *
77c804472Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
87c804472Sopenharmony_ci *
97c804472Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
107c804472Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
117c804472Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127c804472Sopenharmony_ci * See the License for the specific language governing permissions and
137c804472Sopenharmony_ci * limitations under the License.
147c804472Sopenharmony_ci */
157c804472Sopenharmony_ci
167c804472Sopenharmony_ci#include "gtest/gtest.h"
177c804472Sopenharmony_ci#define private public
187c804472Sopenharmony_ci#include "brightness_impl.h"
197c804472Sopenharmony_ci#include "SharedData.h"
207c804472Sopenharmony_ci
217c804472Sopenharmony_cinamespace {
227c804472Sopenharmony_ci    TEST(BrightnessImplTest, SetAndGetValueImplTest)
237c804472Sopenharmony_ci    {
247c804472Sopenharmony_ci        uint8_t minVal = 0;
257c804472Sopenharmony_ci        uint8_t curVal = 100;
267c804472Sopenharmony_ci        uint8_t maxVal = 100;
277c804472Sopenharmony_ci        SharedData<uint8_t>(SharedDataType::BRIGHTNESS_VALUE, curVal, minVal, maxVal);
287c804472Sopenharmony_ci        // set value failed
297c804472Sopenharmony_ci        uint8_t setVal = 200;
307c804472Sopenharmony_ci        int32_t ret = OHOS::ACELite::BrightnessImpl::SetValueImpl(setVal);
317c804472Sopenharmony_ci        EXPECT_EQ(ret, OHOS::ACELite::EC_API_INVALID_PARAM);
327c804472Sopenharmony_ci        // set value successed
337c804472Sopenharmony_ci        setVal = 80;
347c804472Sopenharmony_ci        ret = OHOS::ACELite::BrightnessImpl::SetValueImpl(setVal);
357c804472Sopenharmony_ci        EXPECT_EQ(ret, 0);
367c804472Sopenharmony_ci        uint8_t val;
377c804472Sopenharmony_ci        OHOS::ACELite::BrightnessImpl::GetValueImpl(val);
387c804472Sopenharmony_ci        EXPECT_EQ(val, setVal);
397c804472Sopenharmony_ci    }
407c804472Sopenharmony_ci
417c804472Sopenharmony_ci    TEST(BrightnessImplTest, SetAndGetModeImplTest)
427c804472Sopenharmony_ci    {
437c804472Sopenharmony_ci        SharedData<uint8_t>(SharedDataType::BRIGHTNESS_MODE, (uint8_t)BrightnessMode::MANUAL,
447c804472Sopenharmony_ci            (uint8_t)BrightnessMode::MANUAL, (uint8_t)BrightnessMode::AUTO);
457c804472Sopenharmony_ci        // set value failed
467c804472Sopenharmony_ci        uint8_t setVal = 200;
477c804472Sopenharmony_ci        int32_t ret = OHOS::ACELite::BrightnessImpl::SetModeImpl(setVal);
487c804472Sopenharmony_ci        EXPECT_EQ(ret, OHOS::ACELite::EC_API_INVALID_PARAM);
497c804472Sopenharmony_ci        // set value successed
507c804472Sopenharmony_ci        setVal = 1;
517c804472Sopenharmony_ci        ret = OHOS::ACELite::BrightnessImpl::SetModeImpl(setVal);
527c804472Sopenharmony_ci        EXPECT_EQ(ret, 0);
537c804472Sopenharmony_ci        uint8_t val;
547c804472Sopenharmony_ci        OHOS::ACELite::BrightnessImpl::GetModeImpl(val);
557c804472Sopenharmony_ci        EXPECT_EQ(val, setVal);
567c804472Sopenharmony_ci    }
577c804472Sopenharmony_ci
587c804472Sopenharmony_ci    TEST(BrightnessImplTest, SetKeepScreenOnImplTest)
597c804472Sopenharmony_ci    {
607c804472Sopenharmony_ci        SharedData<bool>(SharedDataType::KEEP_SCREEN_ON, true);
617c804472Sopenharmony_ci        OHOS::ACELite::BrightnessImpl brightness;
627c804472Sopenharmony_ci        brightness.SetKeepScreenOnImpl(false);
637c804472Sopenharmony_ci        EXPECT_FALSE(SharedData<bool>::GetData(SharedDataType::KEEP_SCREEN_ON));
647c804472Sopenharmony_ci    }
657c804472Sopenharmony_ci
667c804472Sopenharmony_ci    TEST(BrightnessImplTest, SetAlwaysOnModeTest)
677c804472Sopenharmony_ci    {
687c804472Sopenharmony_ci        bool mode = 0;
697c804472Sopenharmony_ci        OHOS::ACELite::BrightnessImpl::SetAlwaysOnMode(mode);
707c804472Sopenharmony_ci        EXPECT_EQ(mode, 0);
717c804472Sopenharmony_ci    }
727c804472Sopenharmony_ci
737c804472Sopenharmony_ci    TEST(BrightnessImplTest, GetAndSetSysModeTest)
747c804472Sopenharmony_ci    {
757c804472Sopenharmony_ci        uint8_t mode = 0;
767c804472Sopenharmony_ci        OHOS::ACELite::BrightnessImpl::SetSysMode(0);
777c804472Sopenharmony_ci        int32_t ret = OHOS::ACELite::BrightnessImpl::GetSysMode(mode);
787c804472Sopenharmony_ci        EXPECT_EQ(ret, 0);
797c804472Sopenharmony_ci        EXPECT_EQ(mode, 0);
807c804472Sopenharmony_ci    }
817c804472Sopenharmony_ci
827c804472Sopenharmony_ci    TEST(BrightnessImplTest, SetAndGetSysAlwaysOnStateImplTest)
837c804472Sopenharmony_ci    {
847c804472Sopenharmony_ci        OHOS::ACELite::BrightnessImpl brightness;
857c804472Sopenharmony_ci        uint8_t alwaysOnState = 1;
867c804472Sopenharmony_ci        brightness.SetSysAlwaysOnState(alwaysOnState);
877c804472Sopenharmony_ci        uint8_t ret = brightness.GetSysAlwaysOnState();
887c804472Sopenharmony_ci        EXPECT_EQ(ret, 0);
897c804472Sopenharmony_ci    }
907c804472Sopenharmony_ci
917c804472Sopenharmony_ci    TEST(BrightnessImplTest, GetCurBrightLevelTest)
927c804472Sopenharmony_ci    {
937c804472Sopenharmony_ci        uint8_t ret = OHOS::ACELite::BrightnessImpl::GetCurBrightLevel();
947c804472Sopenharmony_ci        EXPECT_EQ(ret, 0);
957c804472Sopenharmony_ci    }
967c804472Sopenharmony_ci}