1/* 2 * Copyright (C) 2024 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 16import brightness from '@ohos.brightness'; 17import { describe, it, expect } from '@ohos/hypium' 18 19const ERROR_CODE = 202; 20 21export default function brightnessTest() { 22describe('brightnessTest', function () { 23 /** 24 * @tc.number SUB_PowerSystem_ErrorCodeTest_JSTest_0050 25 * @tc.name testSystem_API_Test_brightness_Manager_0100 26 * @tc.desc Test the third-party application call setValue will be blocked 27 * @tc.level: Level 3 28 * @tc.type: Functiontion 29 * @tc.size: MediumTest 30 */ 31 it('System_API_Test_brightness_Manager_0100', 0, async function (done) { 32 let TAG = 'System_API_Test_brightness_Manager_0100'; 33 try { 34 brightness.setValue(128); 35 } catch (error) { 36 console.info(TAG + ` setValue err: ${error.code} ${error.message}`); 37 expect(error.code).assertEqual(ERROR_CODE); 38 done(); 39 } 40 }) 41 42 /** 43 * @tc.number SUB_PowerSystem_ErrorCodeTest_JSTest_0050 44 * @tc.name testSystem_API_Test_brightness_Manager_0200 45 * @tc.desc Test the third-party application call setValue will be blocked 46 * @tc.level: Level 3 47 * @tc.type: Functiontion 48 * @tc.size: MediumTest 49 */ 50 it('System_API_Test_brightness_Manager_0200', 0, async function (done) { 51 let TAG = 'System_API_Test_brightness_Manager_0200'; 52 try { 53 brightness.setValue(128, true); 54 } catch (error) { 55 console.info(TAG + ` setValue err: ${error.code} ${error.message}`); 56 expect(error.code).assertEqual(ERROR_CODE); 57 done(); 58 } 59 }) 60 61 /** 62 * @tc.number SUB_PowerSystem_ErrorCodeTest_JSTest_0060 63 * @tc.name testSystem_API_Test_brightness_Manager_0300 64 * @tc.desc Test the third-party application call setValue will be blocked 65 * @tc.level: Level 3 66 * @tc.type: Functiontion 67 * @tc.size: MediumTest 68 */ 69 it('System_API_Test_brightness_Manager_0300', 0, async function (done) { 70 let TAG = 'System_API_Test_brightness_Manager_0300'; 71 try { 72 brightness.setValue(255, false); 73 } catch (error) { 74 console.info(TAG + ` setValue err: ${error.code} ${error.message}`); 75 expect(error.code).assertEqual(ERROR_CODE); 76 done(); 77 } 78 }) 79}) 80} 81