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 { CpuFreqStruct } from '../../../src/trace/bean/CpuFreqStruct';
17
18describe('CpuFreqStruct Test', () => {
19  const canvas = document.createElement('canvas');
20  canvas.width = 1;
21  canvas.height = 1;
22  const ctx = canvas.getContext('2d');
23
24  CpuFreqStruct.hoverCpuFreqStruct = void 0;
25  const data = {
26    frame: {
27      x: 244,
28      y: 466,
29      width: 34,
30      height: 600,
31    },
32    startNS: 400,
33    value: 43,
34  };
35
36  const dataSource = {
37    frame: {
38      x: 35,
39      y: 66,
40      width: 560,
41      height: 600,
42    },
43    value: 60,
44    maxFreq: 88,
45  };
46
47  it('CpuFreqStructTest01', function () {
48    expect(CpuFreqStruct.draw(ctx, data)).toBeUndefined();
49    expect(data).toMatchInlineSnapshot(`
50{
51  "frame": {
52    "height": 600,
53    "width": 34,
54    "x": 244,
55    "y": 466,
56  },
57  "startNS": 400,
58  "value": 43,
59}
60`);
61  });
62
63  it('CpuFreqStructTest02', function () {
64    expect(CpuFreqStruct.draw(ctx, { startNS: 1 })).toBeUndefined();
65  });
66
67  it('CpuFreqStructTest03 ', function () {
68    expect(CpuFreqStruct.draw(ctx, dataSource)).toBeUndefined();
69  });
70});
71