• 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
16jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
17  return {};
18});
19jest.mock('../../../../src/trace/component/SpSystemTrace', () => {
20  return {};
21});
22import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow';
23import {
24  FrameSpacingRender,
25  FrameSpacingStruct,
26} from '../../../../src/trace/database/ui-worker/ProcedureWorkerFrameSpacing';
27import { Rect } from '../../../../src/trace/component/trace/timer-shaft/Rect';
28
29describe('FrameSpacing Test', () => {
30  let frameSpacingRender = new FrameSpacingRender();
31  let canvas = document.createElement('canvas');
32  canvas.width = 1;
33  canvas.height = 1;
34  let ctx = canvas.getContext('2d');
35  let req = {
36    animationRanges: [{ start: 4091445476, end: 4774481414 }],
37    context: ctx,
38    frameRate: 90,
39    type: 'frame_spacing_slice',
40    useCache: false,
41  };
42  TraceRow.range = {
43    startNS: 0,
44    endNS: 16868000000,
45    totalNS: 16868000000,
46  };
47  let dataList = [
48    {
49      currentFrameHeight: 2753,
50      currentFrameWidth: 1339,
51      currentTs: 11618846517,
52      frame: new Rect(),
53      frameSpacingResult: 0.2,
54      groupId: 0,
55      id: 709,
56      nameId: 'test',
57      preFrameHeight: 2750,
58      preFrameWidth: 1338,
59      preTs: 11629160500,
60      x: 0,
61      y: 4,
62    },
63    {
64      currentFrameHeight: 2753,
65      currentFrameWidth: 1339,
66      currentTs: 11629160579,
67      frame: new Rect(),
68      frameSpacingResult: 0.1,
69      groupId: 11095334538,
70      id: 709,
71      nameId: 'test',
72      preFrameHeight: 2750,
73      preFrameWidth: 1338,
74      preTs: 11618846517,
75      x: 0,
76      y: 4,
77    },
78    {
79      frameSpacingResult: 0.1,
80      groupId: 11095334538,
81      currentFrameHeight: 2755,
82      currentFrameWidth: 1340,
83      currentTs: 11640114746,
84      frame: new Rect(),
85      x: 0,
86      y: 4,
87      id: 710,
88      nameId: 'test',
89      preFrameHeight: 2753,
90      preFrameWidth: 1339,
91      preTs: 11629160579,
92    },
93  ];
94  it('FrameSpacingTest01', function () {
95    expect(frameSpacingRender.render(req, dataList, TraceRow.skeleton())).toBeUndefined();
96  });
97
98  it('FrameSpacingTest02', function () {
99    frameSpacingRender.frameSpacing(
100      dataList,
101      [],
102      TraceRow.range.startNS,
103      TraceRow.range.endNS,
104      TraceRow.range.totalNS,
105      TraceRow.skeleton(),
106      req.animationRanges,
107      false
108    );
109    expect(frameSpacingRender).not.toBeUndefined();
110  });
111
112  it('FrameSpacingTest03', function () {
113    let currentStruct = {
114      currentFrameHeight: 2755,
115      currentFrameWidth: 1340,
116      currentTs: 11640114746,
117      frame: new Rect(),
118      frameSpacingResult: 0.1,
119      groupId: 11095334538,
120      id: 710,
121      nameId: 'test',
122      preFrameHeight: 2753,
123      preFrameWidth: 1339,
124      preTs: 11629160579,
125      x: 0,
126      y: 4,
127    };
128    expect(frameSpacingRender.drawPoint(ctx, currentStruct, TraceRow.skeleton(), 0, 20)).toBeUndefined();
129  });
130  it('FrameSpacingTest04 ', function () {
131    expect(frameSpacingRender.renderMainThread(req,new TraceRow<FrameSpacingStruct>())).toBeUndefined()
132  });
133});
134