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
16import { SampleRender, SampleStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerBpftrace';
17import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow';
18
19jest.mock('../../../../src/trace/database/ui-worker/cpu/ProcedureWorkerCPU', () => {
20  return {};
21});
22jest.mock('../../../../src/trace/component/SpSystemTrace', () => {
23  return {};
24});
25describe('ProcedureWorkerSample Test', () => {
26  const canvas = document.createElement('canvas');
27  canvas.width = 10;
28  canvas.height = 10;
29  const ctx = canvas.getContext('2d');
30  it('ProcedureWorkerSampleTest01 ', function () {
31    const data = {
32      frame: {
33        x: 210,
34        y: 209,
35        width: 111,
36        height: 100,
37      },
38      name: 'Sample',
39      cycle: -1,
40      value: 0,
41      depth: 0,
42      detail: 1
43    };
44    expect(SampleStruct.draw(ctx, data)).toBeUndefined();
45  });
46  it('ProcedureWorkerSampleTest02 ', function () {
47    const data = {
48      context: ctx!,
49      useCache: true,
50      type: '',
51      traceRange: [],
52    };
53    let sampleRender = new SampleRender();
54    TraceRow.range = jest.fn(() => true);
55    TraceRow.range!.startNS = jest.fn(() => 0);
56    expect(sampleRender.renderMainThread(data, new TraceRow<SampleStruct>())).toBeUndefined();
57  });
58});