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