• 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 {mem, ProcessMemStruct,MemRender} from "../../../../dist/trace/database/ui-worker/ProcedureWorkerMem.js";
18// @ts-ignore
19import {Rect} from "../../../../dist/trace/component/trace/timer-shaft/Rect.js";
20
21describe(' Test', () => {
22
23    let frame={
24        x:0,
25        y:9,
26        width:10,
27        height:10
28    }
29    it('MemTest01', () => {
30        let dataList = new Array();
31        dataList.push({startTime: 0, duration: 10, frame: {x:0, y:9, width:10, height:10}})
32        dataList.push({startTime: 1, duration: 111, frame: {x:0, y:9, width:10, height:10}})
33        let rect = new Rect(0, 10, 10, 10);
34        mem(dataList, [{length:0}], 2, 100254, 100254, frame,false)
35    })
36
37    it('MemTest02', () => {
38        let dataList = new Array();
39        dataList.push({startTime: 0, duration: 10, frame: {x:0, y:9, width:10, height:10}})
40        dataList.push({startTime: 1, duration: 111, frame: {x:0, y:9, width:10, height:10}})
41        let rect = new Rect(0, 10, 10, 10);
42        mem(dataList, [{length:0}], 2, 100254, 100254, frame,true)
43    })
44
45    it('MemTest03', () => {
46        const canvas = document.createElement('canvas');
47        canvas.width = 1;
48        canvas.height = 1;
49        const ctx = canvas.getContext('2d');
50
51        const data = {
52            frame: {
53                x: 20,
54                y: 20,
55                width: 100,
56                height: 100
57            },
58            startNS: 200,
59            value: 50
60        }
61        expect(ProcessMemStruct.draw(ctx, data)).toBeUndefined()
62    })
63
64    it('MemTest04', function () {
65        let memRender = new MemRender()
66        let  req = {
67            lazyRefresh:true,
68            type:"",
69            startNS:1,
70            endNS:1,
71            totalNS:1,
72            frame: {
73                x: 20,
74                y: 20,
75                width: 100,
76                height: 100
77            },
78            useCache:false,
79            range:{
80                refresh:"",
81            },
82            canvas:'',
83            context:{
84                font:"11px sans-serif",
85                fillStyle:"#ec407a",
86                globalAlpha:0.6,
87            },
88            lineColor:'',
89            isHover:'',
90            hoverX:1,
91            params:'',
92            wakeupBean:undefined,
93            flagMoveInfo:'',
94            flagSelectedInfo:'',
95            slicesTime:3,
96            id:1,
97            x: 20,
98            y: 20,
99            width: 100,
100            height: 100
101        }
102        window.postMessage = jest.fn(()=>true)
103        expect(memRender.render(req,[],[])).toBeUndefined()
104    });
105});