• 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 {smaps, SmapsRender, SmapsStruct} from "../../../../dist/trace/database/ui-worker/ProcedureWorkerSmaps.js"
18
19describe('ProcedureWorkerSmaps Test', () => {
20
21    it('ProcedureWorkerSmapsTest01', function () {
22        let List = [{
23            length: 1,
24            ts: 1,
25            frame: {
26                x: 20,
27                y: 20,
28                width: 100,
29                height: 100
30            },
31        }]
32        let arr = [{
33            frame: null,
34            length: 1,
35        }]
36        let frame = {
37            x: 20,
38            y: 20,
39            width: 100,
40            height: 100
41        }
42        expect(smaps(List, arr, 1, 1, 1, frame, true)).toBeUndefined()
43    });
44
45    it('ProcedureWorkerSmapsTest02', function () {
46        let List = [{
47            length: 1,
48            ts: 1,
49            frame: {
50                x: 20,
51                y: 20,
52                width: 100,
53                height: 100
54            },
55        }]
56        let arr = [{
57            frame: null,
58            length: 0,
59        }]
60        let frame = {
61            x: 20,
62            y: 20,
63            width: 100,
64            height: 100
65        }
66        expect(smaps(List, arr, 1, 1, 1, frame, false)).toBeUndefined()
67    });
68
69    it('ProcedureWorkerSmapsTest03', () => {
70        const data = {
71            startNs: 1,
72            value: 1,
73            frame: {
74                x: 20,
75                y: 20,
76                width: 100,
77                height: 100
78            },
79            startTime: 1,
80            ts: 1
81        }
82        const canvas = document.createElement('canvas');
83        canvas.width = 1;
84        canvas.height = 1;
85        const ctx = canvas.getContext('2d');
86        expect(SmapsStruct.draw(ctx, data, 1)).toBeUndefined();
87    });
88
89    it('ProcedureWorkerSmapsTest04', () => {
90        let node = {
91            startNs: 1,
92            value: 1,
93            frame: {
94                x: 20,
95                y: 20,
96                width: 100,
97                height: 100
98            },
99            ts: 1,
100            dur: 1
101        }
102        let frame = {
103            x: 20,
104            y: 20,
105            width: 100,
106            height: 100
107        }
108        expect(SmapsStruct.setSmapsFrame(node, 2, 1, 2, 2, frame)).toBeUndefined();
109    });
110
111    it('ProcedureWorkerSmapsTest05', () => {
112        let node = {
113            startNs: 1,
114            value: 1,
115            frame: {
116                x: 20,
117                y: 20,
118                width: 100,
119                height: 100
120            },
121            ts: 0,
122            dur: 3
123        }
124        let frame = {
125            x: 20,
126            y: 20,
127            width: 100,
128            height: 100
129        }
130        expect(SmapsStruct.setSmapsFrame(node, 2, 1, 2, 2, frame)).toBeUndefined();
131    });
132
133    it('ProcedureWorkerSmapsTest06', function () {
134        let sMapsRender = new SmapsRender()
135        let req = {
136            lazyRefresh: true,
137            type: "",
138            startNS: 1,
139            endNS: 1,
140            totalNS: 1,
141            frame: {
142                x: 20,
143                y: 20,
144                width: 100,
145                height: 100
146            },
147            useCache: false,
148            range: {
149                refresh: "",
150            },
151            canvas: '',
152            context: {
153                font: "11px sans-serif",
154                fillStyle: "#ffffff",
155                globalAlpha: 0.6
156            },
157            lineColor: '',
158            isHover: true,
159            hoverX: 1,
160            wakeupBean: undefined,
161            flagMoveInfo: '',
162            flagSelectedInfo: '',
163            slicesTime: 3,
164            id: 1,
165            x: 20,
166            y: 20,
167            width: 100,
168            height: 100,
169            params: {
170                maxValue: 10,
171                maxValueName: "maxValueName",
172                rowName: "rowName"
173            }
174        }
175        window.postMessage = jest.fn(() => true)
176        expect(sMapsRender.render(req, [], [])).toBeUndefined()
177    });
178})