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