• 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/component/trace/base/TraceRow.js', () => {
17  return {};
18});
19
20import { Rect } from '../../../../dist/trace/component/trace/timer-shaft/Rect.js';
21// @ts-ignore
22import {
23  HeapTimelineRender,
24  HeapTimelineStruct,
25  HeapTimeline,
26} from '../../../../dist/trace/database/ui-worker/ProcedureWorkerHeapTimeline.js';
27
28describe('ProcedureWorkerHeapTimeline Test', () => {
29  it('HeapTimelineTest', () => {
30    const heapTimelineCanvas = document.createElement('canvas');
31    heapTimelineCanvas.width = 11;
32    heapTimelineCanvas.height = 11;
33    const ctx = heapTimelineCanvas.getContext('2d');
34    let dataList = new Array();
35    dataList.push({
36      startTime: 1,
37      dur: 101,
38      frame: { x: 0, y: 10, width: 10, height: 10 },
39    });
40    dataList.push({ startTime: 1, dur: 111 });
41    let rect = new Rect(0, 10, 10, 10);
42    HeapTimeline(heapTimelineCanvas, ctx, 1, 100254, 100254, rect, (e: any) => {});
43  });
44  it('HeapTimelineStructTest01', () => {
45    const data = {
46      cpu: 3,
47      startNs: 3,
48      value: 111,
49      frame: {
50        x: 40,
51        y: 40,
52        width: 230,
53        height: 132,
54      },
55      maxValue: undefined,
56      startTime: 1,
57      filterID: 3,
58    };
59    const canvas = document.createElement('canvas');
60    canvas.width = 1;
61    canvas.height = 1;
62    const ctx = canvas.getContext('2d');
63    expect(HeapTimelineStruct.draw(ctx, data)).toBeUndefined();
64  });
65  it('HeapTimelineStructTest02', () => {
66    const data = {
67      cpu: 1,
68      startNs: 1,
69      value: 1,
70      frame: {
71        x: 20,
72        y: 20,
73        width: 100,
74        height: 100,
75      },
76      maxValue: undefined,
77      startTime: 1,
78      filterID: 2,
79    };
80    let frame = {
81      x: 20,
82      y: 20,
83      width: 100,
84      height: 100,
85    };
86    expect(HeapTimelineStruct.setFrame(1, 2, 1, data, 0, 2, 2, frame)).toBeUndefined();
87  });
88});
89