/* * 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 {PowerDetailsEnergy, SystemDetailsEnergy,} from '../../../src/trace/bean/EnergyStruct'; describe('EnergyStruct Test', () => { let powerDetailsEnergy = new PowerDetailsEnergy(); let systemDetailsEnergy = new SystemDetailsEnergy(); it('powerDetailsEnergyTest', function () { expect(powerDetailsEnergy).not.toBeUndefined(); expect(powerDetailsEnergy).toMatchInlineSnapshot( { charge: expect.any(Number), background_time: expect.any(Number), screen_on_time: expect.any(Number), screen_off_time: expect.any(Number), load: expect.any(String), usage: expect.any(Number), duration: expect.any(Number), camera_id: expect.any(Number), foreground_count: expect.any(Number), background_count: expect.any(Number), screen_on_count: expect.any(Number), screen_off_count: expect.any(Number), count: expect.any(Number), appName: expect.any(String), uid: expect.any(Number), foreground_duration: expect.any(Number), foreground_energy: expect.any(Number), background_duration: expect.any(Number), background_energy: expect.any(Number), screen_on_duration: expect.any(Number), screen_on_energy: expect.any(Number), screen_off_duration: expect.any(Number), screen_off_energy: expect.any(Number), energy: expect.any(Number), energyConsumptionRatio: expect.any(String) }, ` { "appName": Any, "background_count": Any, "background_duration": Any, "background_energy": Any, "background_time": Any, "camera_id": Any, "charge": Any, "count": Any, "duration": Any, "energy": Any, "energyConsumptionRatio": Any, "event": undefined, "foreground_count": Any, "foreground_duration": Any, "foreground_energy": Any, "load": Any, "screen_off_count": Any, "screen_off_duration": Any, "screen_off_energy": Any, "screen_off_time": Any, "screen_on_count": Any, "screen_on_duration": Any, "screen_on_energy": Any, "screen_on_time": Any, "uid": Any, "usage": Any, } `); }); it('systemDetailsEnergyTest', function () { expect(systemDetailsEnergy).not.toBeUndefined(); expect(systemDetailsEnergy).toMatchInlineSnapshot( { eventName: expect.any(String), type: expect.any(String), pid: expect.any(Number), uid: expect.any(Number), state: expect.any(Number), workId: expect.any(String), name: expect.any(String), interval: expect.any(Number), level: expect.any(Number), tag: expect.any(String), message: expect.any(String), log_level: expect.any(String) }, ` { "eventName": Any, "interval": Any, "level": Any, "log_level": Any, "message": Any, "name": Any, "pid": Any, "state": Any, "tag": Any, "ts": 0, "type": Any, "uid": Any, "workId": Any, } `); }); });