• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 { SelectionParam, BoxJumpParam, SelectionData, Counter, Fps } from '../../../dist/trace/bean/BoxSelection.js';
18
19describe('BoxSelection Test', () => {
20  let selectionParam = new SelectionParam();
21  let boxJumpParam = new BoxJumpParam();
22  let selectionData = new SelectionData();
23  let counter = new Counter();
24  let fps = new Fps();
25  it('BoxSelectionTest01', function () {
26    selectionParam = {
27      cpus: 1,
28      threadIds: 2,
29      trackIds: 1,
30      funTids: 2,
31      heapIds: 1,
32      nativeMemory: 3,
33      leftNs: 1,
34      rightNs: 1,
35      hasFps: true,
36      statisticsSelectData: 1,
37    };
38
39    expect(selectionParam).not.toBeUndefined();
40    expect(selectionParam).toMatchInlineSnapshot(
41{
42  cpus: expect.any(Number),
43  threadIds: expect.any(Number),
44  trackIds: expect.any(Number),
45  funTids: expect.any(Number),
46  heapIds: expect.any(Number),
47  nativeMemory: expect.any(Number),
48  leftNs: expect.any(Number),
49  rightNs: expect.any(Number),
50  hasFps: expect.any(Boolean) }, `
51{
52  "cpus": Any<Number>,
53  "funTids": Any<Number>,
54  "hasFps": Any<Boolean>,
55  "heapIds": Any<Number>,
56  "leftNs": Any<Number>,
57  "nativeMemory": Any<Number>,
58  "rightNs": Any<Number>,
59  "statisticsSelectData": 1,
60  "threadIds": Any<Number>,
61  "trackIds": Any<Number>,
62}
63`);
64  });
65
66  it('BoxSelectionTest02', function () {
67    boxJumpParam = {
68      leftNs: 0,
69      rightNs: 0,
70      state: '',
71      processId: 0,
72      threadId: 0,
73    };
74    expect(boxJumpParam).not.toBeUndefined();
75    expect(boxJumpParam).toMatchInlineSnapshot(
76{
77  leftNs: expect.any(Number),
78  rightNs: expect.any(Number),
79  state: expect.any(String),
80  processId: expect.any(Number),
81  threadId: expect.any(Number) }, `
82{
83  "leftNs": Any<Number>,
84  "processId": Any<Number>,
85  "rightNs": Any<Number>,
86  "state": Any<String>,
87  "threadId": Any<Number>,
88}
89`);
90  });
91
92  it('BoxSelectionTest03', function () {
93    selectionData = {
94      name: 'name',
95      process: 'process',
96      pid: 'pid',
97      thread: 'thread',
98      tid: 'tid',
99      wallDuration: 0,
100      avgDuration: 'avgDuration',
101      occurrences: 0,
102      state: 'state',
103      trackId: 0,
104      delta: 'delta',
105      rate: 'rate',
106      avgWeight: 'avgWeight',
107      count: 'count',
108      first: 'first',
109      last: 'last',
110      min: 'min',
111      max: 'max',
112      stateJX: 'stateJX',
113    };
114    expect(selectionData).not.toBeUndefined();
115    expect(selectionData).toMatchInlineSnapshot(
116{
117  process: expect.any(String),
118  pid: expect.any(String),
119  thread: expect.any(String),
120  tid: expect.any(String),
121  wallDuration: expect.any(Number),
122  avgDuration: expect.any(String),
123  occurrences: expect.any(Number),
124  state: expect.any(String),
125  trackId: expect.any(Number),
126  delta: expect.any(String),
127  rate: expect.any(String),
128  avgWeight: expect.any(String),
129  count: expect.any(String),
130  first: expect.any(String),
131  last: expect.any(String),
132  min: expect.any(String),
133  max: expect.any(String),
134  stateJX: expect.any(String) }, `
135{
136  "avgDuration": Any<String>,
137  "avgWeight": Any<String>,
138  "count": Any<String>,
139  "delta": Any<String>,
140  "first": Any<String>,
141  "last": Any<String>,
142  "max": Any<String>,
143  "min": Any<String>,
144  "name": "name",
145  "occurrences": Any<Number>,
146  "pid": Any<String>,
147  "process": Any<String>,
148  "rate": Any<String>,
149  "state": Any<String>,
150  "stateJX": Any<String>,
151  "thread": Any<String>,
152  "tid": Any<String>,
153  "trackId": Any<Number>,
154  "wallDuration": Any<Number>,
155}
156`);
157  });
158
159  it('BoxSelectionTest04', function () {
160    counter = {
161      id: 0,
162      trackId: 0,
163      name: '',
164      value: 0,
165      startTime: 0,
166    };
167    expect(counter).not.toBeUndefined();
168    expect(counter).toMatchInlineSnapshot(
169{
170  id: expect.any(Number),
171  trackId: expect.any(Number),
172  name: expect.any(String),
173  value: expect.any(Number),
174  startTime: expect.any(Number) }, `
175{
176  "id": Any<Number>,
177  "name": Any<String>,
178  "startTime": Any<Number>,
179  "trackId": Any<Number>,
180  "value": Any<Number>,
181}
182`);
183  });
184
185  it('BoxSelectionTest05', function () {
186    fps = {
187      startNS: 0,
188      timeStr: '',
189      fps: 0,
190    };
191    expect(fps).not.toBeUndefined();
192    expect(fps).toMatchInlineSnapshot(
193{
194  startNS: expect.any(Number),
195  timeStr: expect.any(String),
196  fps: expect.any(Number) }, `
197{
198  "fps": Any<Number>,
199  "startNS": Any<Number>,
200  "timeStr": Any<String>,
201}
202`);
203  });
204});
205