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// @ts-ignore 17import {PowerDetailsEnergy, SystemDetailsEnergy,} from '../../../dist/trace/bean/EnergyStruct.js'; 18 19describe('EnergyStruct Test', () => { 20 let powerDetailsEnergy = new PowerDetailsEnergy(); 21 let systemDetailsEnergy = new SystemDetailsEnergy(); 22 23 it('powerDetailsEnergyTest', function () { 24 expect(powerDetailsEnergy).not.toBeUndefined(); 25 expect(powerDetailsEnergy).toMatchInlineSnapshot( 26{ 27 charge: expect.any(Number), 28 background_time: expect.any(Number), 29 screen_on_time: expect.any(Number), 30 screen_off_time: expect.any(Number), 31 load: expect.any(String), 32 usage: expect.any(Number), 33 duration: expect.any(Number), 34 camera_id: expect.any(Number), 35 foreground_count: expect.any(Number), 36 background_count: expect.any(Number), 37 screen_on_count: expect.any(Number), 38 screen_off_count: expect.any(Number), 39 count: expect.any(Number), 40 appName: expect.any(String), 41 uid: expect.any(Number), 42 foreground_duration: expect.any(Number), 43 foreground_energy: expect.any(Number), 44 background_duration: expect.any(Number), 45 background_energy: expect.any(Number), 46 screen_on_duration: expect.any(Number), 47 screen_on_energy: expect.any(Number), 48 screen_off_duration: expect.any(Number), 49 screen_off_energy: expect.any(Number), 50 energy: expect.any(Number), 51 energyConsumptionRatio: expect.any(String) }, ` 52{ 53 "appName": Any<String>, 54 "background_count": Any<Number>, 55 "background_duration": Any<Number>, 56 "background_energy": Any<Number>, 57 "background_time": Any<Number>, 58 "camera_id": Any<Number>, 59 "charge": Any<Number>, 60 "count": Any<Number>, 61 "duration": Any<Number>, 62 "energy": Any<Number>, 63 "energyConsumptionRatio": Any<String>, 64 "event": undefined, 65 "foreground_count": Any<Number>, 66 "foreground_duration": Any<Number>, 67 "foreground_energy": Any<Number>, 68 "load": Any<String>, 69 "screen_off_count": Any<Number>, 70 "screen_off_duration": Any<Number>, 71 "screen_off_energy": Any<Number>, 72 "screen_off_time": Any<Number>, 73 "screen_on_count": Any<Number>, 74 "screen_on_duration": Any<Number>, 75 "screen_on_energy": Any<Number>, 76 "screen_on_time": Any<Number>, 77 "uid": Any<Number>, 78 "usage": Any<Number>, 79} 80`); 81 }); 82 83 it('systemDetailsEnergyTest', function () { 84 expect(systemDetailsEnergy).not.toBeUndefined(); 85 expect(systemDetailsEnergy).toMatchInlineSnapshot( 86{ 87 eventName: expect.any(String), 88 type: expect.any(String), 89 pid: expect.any(Number), 90 uid: expect.any(Number), 91 state: expect.any(Number), 92 workId: expect.any(String), 93 name: expect.any(String), 94 interval: expect.any(Number), 95 level: expect.any(Number), 96 tag: expect.any(String), 97 message: expect.any(String), 98 log_level: expect.any(String) }, ` 99{ 100 "eventName": Any<String>, 101 "interval": Any<Number>, 102 "level": Any<Number>, 103 "log_level": Any<String>, 104 "message": Any<String>, 105 "name": Any<String>, 106 "pid": Any<Number>, 107 "state": Any<Number>, 108 "tag": Any<String>, 109 "ts": 0, 110 "type": Any<String>, 111 "uid": Any<Number>, 112 "workId": Any<String>, 113} 114`); 115 }); 116}); 117