• 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('../../../../dist/trace/database/ui-worker/ProcedureWorker.js', () => {
17  return {};
18});
19
20// @ts-ignore
21import { FrameAnimationRender } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerFrameAnimation.js';
22// @ts-ignore
23import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js';
24// @ts-ignore
25import { TraceRow } from '../../../../dist/trace/component/trace/base/TraceRow.js';
26// @ts-ignore
27import { FrameAnimationStruct } from '../../../../dist/trace/database/ui-worker/ProcedureWorkerFrameAnimation.js';
28
29describe('FrameAnimation Test', () => {
30  let frameAnimationRender = new FrameAnimationRender();
31  let rect = new Rect(341, 2, 10, 10);
32  let canvas = document.createElement('canvas');
33  canvas.width = 1;
34  canvas.height = 1;
35  let ctx = canvas.getContext('2d');
36  let dataList = [
37    {
38      animationId: 1,
39      dur: 0,
40      dynamicEndTs: 4774481414,
41      dynamicStartTs: 4091445476,
42      frame: rect,
43      status: 'Response delay',
44      textMetricsWidth: 115.44140625,
45      ts: 4091445476,
46    },
47    {
48      animationId: 1,
49      dur: 683035938,
50      dynamicEndTs: 4774481414,
51      dynamicStartTs: 4091445476,
52      frame: rect,
53      status: 'Completion delay',
54      textMetricsWidth: 133.0703125,
55      ts: 4091445476,
56    },
57  ];
58  TraceRow.range = {
59    startNS: 0,
60    endNS: 16868000000,
61    totalNS: 16868000000,
62  };
63
64  it('FrameAnimationTest01', function () {
65    frameAnimationRender.frameAnimation(
66      dataList,
67      [],
68      TraceRow.range.startNS,
69      TraceRow.range.endNS,
70      TraceRow.range.totalNS,
71      TraceRow.skeleton(),
72      false
73    );
74    let node = {
75      animationId: 1,
76      dur: 0,
77      dynamicEndTs: 4774481414,
78      dynamicStartTs: 4091445476,
79      frame: rect,
80      status: 'Response delay',
81      textMetricsWidth: 115.44140625,
82      ts: 4091445476,
83    };
84    expect(FrameAnimationStruct.draw(ctx!, 1, node, TraceRow.skeleton())).toBeUndefined();
85  });
86});
87