• 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 */
15import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow';
16import {
17  AppStartupRender,
18  AppStartupStruct,
19} from '../../../../src/trace/database/ui-worker/ProcedureWorkerAppStartup';
20
21jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
22  return {};
23});
24jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {
25  return {};
26});
27jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => {
28  return {};
29});
30describe('ProcedureWorkerAppStartup Test', () => {
31  it('AppStartupStructTest01', () => {
32    const data = {
33      frame: {
34        x: 20,
35        y: 20,
36        width: 9,
37        height: 3,
38      },
39      dur: 1,
40      value: 'aa',
41      startTs: 12,
42      pid: 1,
43      process: 'null',
44      itid: 12,
45      endItid: 13,
46      tid: 1,
47      startName: '23',
48      stepName: 'st',
49    };
50    const canvas = document.createElement('canvas');
51    canvas.width = 1;
52    canvas.height = 1;
53    const ctx = canvas.getContext('2d');
54    expect(AppStartupStruct.draw(ctx, data)).toBeUndefined();
55  });
56
57  it('AppStartupStructTest02', () => {
58    expect(AppStartupStruct.getStartupName(12)).toBe('Unknown Start Step');
59  });
60  it('AppStartupStructTest03', () => {
61    expect(AppStartupStruct).not.toBeUndefined();
62  });
63  it('AppStartupStructTest04 ', function () {
64    let appStartupRender = new AppStartupRender();
65    let appStartReq = {
66      lazyRefresh: true,
67      type: '',
68      startNS: 5,
69      endNS: 9,
70      totalNS: 4,
71      frame: {
72        x: 32,
73        y: 20,
74        width: 180,
75        height: 180,
76      },
77      useCache: true,
78      range: {
79        refresh: '',
80      },
81      canvas: 'a',
82      appStartupContext: {
83        font: '12px sans-serif',
84        fillStyle: '#a1697d',
85        globalAlpha: 0,
86        measureText: jest.fn(() => true),
87        clearRect: jest.fn(() => true),
88        stroke: jest.fn(() => true),
89        closePath: jest.fn(() => false),
90        beginPath: jest.fn(() => true),
91        fillRect: jest.fn(() => false),
92        fillText: jest.fn(() => true),
93      },
94      isHover: 'true',
95      hoverX: 0,
96      params: '',
97      wakeupBean: undefined,
98      flagMoveInfo: '',
99      flagSelectedInfo: '',
100      slicesTime: 4,
101      id: 1,
102      x: 24,
103      y: 24,
104      width: 100,
105      height: 100,
106    };
107    expect(appStartupRender.renderMainThread(appStartReq, new TraceRow<AppStartupStruct>())).toBeUndefined();
108  });
109});
110