thermal_uint.test.js 8.3 KB
Newer Older
Q
q00569459 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
/*
 * Copyright (C) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import app from '@system.app'
import thermal from "@ohos.thermal"
import ThermalLevel from "@ohos.thermal"
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'

describe('appInfoTest', function () {
    console.log("*************Thermal API Test Begin*************");
    const MSEC_1000 = 1000;
    test1();
    test2();
    test3();
    test4();
    test5();
    test6();
    test7();
    test8();
    test9();
    test10();
    test11();
    test12();
    test13();
})

function test1() {

    /* @tc.number thermal_manager_js_001
     * @tc.name Thermal_001
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_001', 0, async function (done) {
        console.info("enter");
        await new Promise((resolve, reject) =>{
            setTimeout(()=>{
                var cold = thermal.getThermalLevel();
                console.info("cold level is: " + cold);
                expect(cold >= 0 && cold <= 6).assertTrue();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test2() {

    /* @tc.number thermal_manager_js_002
     * @tc.name Thermal_002
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_002', 0, async function (done) {
        await new Promise((resolve, reject) => {
            setTimeout(()=>{
                var warm = thermal.getThermalLevel();
                console.info("warm level is: " + warm);
                expect(warm >= 0 && warm <= 6).assertTrue();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test3() {

    /* @tc.number thermal_manager_js_003
     * @tc.name Thermal_003
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_003', 0, async function (done) {
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                var hot = thermal.getThermalLevel();
                console.info("hot level is: " + hot);
                expect(hot >= 0 && hot <= 6).assertTrue();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test4() {

    /* @tc.number thermal_manager_js_004
     * @tc.name Thermal_004
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_004', 0, async function (done) {
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                var overheated = thermal.getThermalLevel();
                console.info("overheated level is: " + overheated);
                expect(overheated >= 0 && overheated <= 6).assertTrue();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test5() {

    /* @tc.number thermal_manager_js_005
     * @tc.name Thermal_005
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_005', 0, async function (done) {
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                var warning = thermal.getThermalLevel();
                console.info("warning level is: " + warning);
                expect(warning >= 0 && warning <= 6).assertTrue();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test6() {

    /* @tc.number thermal_manager_js_006
     * @tc.name Thermal_006
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_006', 0, async function (done) {
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                var emergency = thermal.getThermalLevel();
                console.info("emergency level is: " + emergency);
                expect(emergency >= 0 && emergency <= 6).assertTrue();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test7() {

    /* @tc.number thermal_manager_js_007
     * @tc.name Thermal_007
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_007', 0, async function (done) {
        thermal.subscribeThermalLevel((cool) => {
            console.info("cool level is: " + cool);
            count ++;
            expect(cool >= 0 && cool <= 6).assertTrue();
        })
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                thermal.unsubscribeThermalLevel();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test8() {

    /* @tc.number thermal_manager_js_008
     * @tc.name Thermal_008
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_008', 0, async function (done) {
        thermal.subscribeThermalLevel((warm) => {
            console.info("cool level is: " + warm);
            expect(warm >= 0 && warm <= 6).assertTrue();
        })
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                thermal.unsubscribeThermalLevel();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test9() {

    /* @tc.number thermal_manager_js_009
     * @tc.name Thermal_009
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_009', 0, async function (done) {
        thermal.subscribeThermalLevel((hot) => {
            console.info("hot level is: " + hot);
            expect(hot >= 0 && hot <= 6).assertTrue();
        })
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                thermal.unsubscribeThermalLevel();
                resolve();
            }, MSEC_1000 * 2);
        })
        done();
    })

}

function test10() {

    /* @tc.number thermal_manager_js_010
     * @tc.name Thermal_010
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_010', 0, async function (done) {
        thermal.subscribeThermalLevel((overheated) => {
            console.info("overheated level is: " + overheated);
            expect(overheated >= 0 && overheated <= 6).assertTrue();
        })
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                thermal.unsubscribeThermalLevel();
                resolve();
            }, MSEC_1000 * 2);
        })
        done();
    })
}

function test11() {

    /* @tc.number thermal_manager_js_011
     * @tc.name Thermal_011
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_011', 0, async function (done) {
        thermal.subscribeThermalLevel((warning) => {
            console.info("warning level is: " + warning);
            expect(warning >= 0 && warning <= 6).assertTrue();
        })
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                thermal.unsubscribeThermalLevel();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test12() {

    /* @tc.number thermal_manager_js_012
     * @tc.name Thermal_012
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_012', 0, async function (done) {
        thermal.subscribeThermalLevel((emergency) => {
            console.info("emergency level is: " + emergency);
            expect(emergency >= 0 && emergency <= 6).assertTrue();
        })
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                thermal.unsubscribeThermalLevel();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}

function test13() {

    /* @tc.number thermal_manager_js_013
     * @tc.name Thermal_013
     * @tc.desc Thermal acquisition kit
     */
    it('Thermal_013', 0, async function (done) {
        thermal.subscribeThermalLevel((cool) => {
            console.info("cool level is: " + cool);
            expect(cool >= 0 && cool <= 6).assertTrue();
        })
        await new Promise((resolve, reject)=>{
            setTimeout(()=>{
                thermal.unsubscribeThermalLevel();
                resolve();
            }, MSEC_1000 * 4);
        })
        done();
    })
}