• 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
16// @ts-ignore
17import {CpuStruct} from "../../../dist/trace/bean/CpuStruct.js"
18
19describe('CpuStruct Test', ()=>{
20    const canvas = document.createElement('canvas');
21    canvas.width = 1;
22    canvas.height = 1;
23    const ctx = canvas.getContext('2d');
24    CpuStruct.selectCpuStruct = {};
25
26
27    const data = {
28        frame: {
29            x: 20,
30            y: 20,
31            width: 100,
32            height: 100
33        },
34        startNS: 200,
35        value: 50
36    }
37    const data1 = {
38        frame: {
39            x: 100,
40            y: 100,
41            width: 10,
42            height: 10
43        },
44        startNS: 1000,
45        value: 500
46    }
47
48
49
50    it('CpuStructTest01', function () {
51        expect(CpuStruct.draw(ctx, data)).toBeUndefined()
52        expect(data).toMatchInlineSnapshot({
53  startNS: expect.any(Number),
54  value: expect.any(Number) }, `
55Object {
56  "frame": Object {
57    "height": 100,
58    "width": 100,
59    "x": 20,
60    "y": 20,
61  },
62  "startNS": Any<Number>,
63  "value": Any<Number>,
64}
65`);
66    });
67
68    it('CpuStructTest02', function () {
69        expect(CpuStruct.equals({}, data)).toBeTruthy();
70    });
71
72    it('CpuStructTest03', function () {
73        expect(CpuStruct.equals(data, data)).toBeTruthy();
74    });
75
76    it('CpuStructTest04', function () {
77        expect(CpuStruct.equals(data, data1)).toBeTruthy();
78    });
79
80    it('CpuStructTest05', function () {
81        expect(CpuStruct.draw(ctx, data1)).toBeUndefined()
82        expect(data1).toMatchInlineSnapshot({
83  startNS: expect.any(Number),
84  value: expect.any(Number) }, `
85Object {
86  "frame": Object {
87    "height": 10,
88    "width": 10,
89    "x": 100,
90    "y": 100,
91  },
92  "startNS": Any<Number>,
93  "value": Any<Number>,
94}
95`);
96    });
97
98    it('CpuStructTest06', function () {
99        expect(CpuStruct.equals({}, data)).toBeTruthy();
100        expect(CpuStruct.draw(ctx, data1)).toBeUndefined()
101        expect(data1).toMatchInlineSnapshot({
102  startNS: expect.any(Number),
103  value: expect.any(Number) }, `
104Object {
105  "frame": Object {
106    "height": 10,
107    "width": 10,
108    "x": 100,
109    "y": 100,
110  },
111  "startNS": Any<Number>,
112  "value": Any<Number>,
113}
114`);
115    });
116})
117