• 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 {proc, ProcessStruct,ProcessRender} from "../../../../dist/trace/database/ui-worker/ProcedureWorkerProcess.js";
18// @ts-ignore
19import {Rect} from "../../../../dist/trace/component/trace/timer-shaft/Rect.js";
20
21describe(' ProcessTest', () => {
22
23    let res = [{
24        startNS: 0,
25        dur: 10,
26        frame: {
27            x:0,
28            y:9,
29            width:10,
30            height:10
31        }
32    }]
33    it('ProcessTest01', () => {
34        let dataList = new Array();
35        dataList.push({startTime: 0, dur: 10, frame: {x:0, y:9, width:10, height:10}})
36        dataList.push({startTime: 1, dur: 111})
37        let rect = new Rect(0, 10, 10, 10);
38        proc(dataList, res, 1, 100254, 100254, rect)
39    })
40
41    it('ProcessTest02', () => {
42        let dataList = new Array();
43        dataList.push({startTime: 0, dur: 10, frame: {x:0, y:9, width:10, height:10}})
44        dataList.push({startTime: 1, dur: 111, frame: {x:0, y:9, width:10, height:10}})
45        let rect = new Rect(0, 10, 10, 10);
46        proc(dataList, res, 1, 100254, 100254, rect)
47    })
48
49    it('ProcessTest04', () => {
50        const node = {
51            frame: {
52                x: 20,
53                y: 20,
54                width: 100,
55                height: 100
56            },
57            startNS: 200,
58            value: 50,
59            startTime:0,
60            dur:0
61        }
62        const frame = {
63            x: 20,
64            y: 20,
65            width: 100,
66            height: 100
67        }
68        expect(ProcessStruct.setFrame(node, 1,1,1,frame)).toBeUndefined()
69    })
70
71    it('ProcessTest05', () => {
72        const node = {
73            frame: {
74                x: 20,
75                y: 20,
76                width: 0,
77                height: 100
78            },
79            startNS: 200,
80            value: 50,
81            startTime:2,
82            dur:2
83        }
84        const frame = {
85            x: 20,
86            y: 20,
87            width: 100,
88            height: 100
89        }
90        expect(ProcessStruct.setFrame(node, 1,1,1,frame)).toBeUndefined()
91    })
92
93    it('ProcessTest06', function () {
94        let processRender = new ProcessRender()
95        let  req = {
96            lazyRefresh:true,
97            type:"",
98            startNS:1,
99            endNS:1,
100            totalNS:1,
101            frame: {
102                x: 20,
103                y: 20,
104                width: 100,
105                height: 100
106            },
107            useCache:false,
108            range:{
109                refresh:"",
110            },
111            canvas:'',
112            context:{
113                font:"11px sans-serif",
114                fillStyle:"#ec407a",
115                globalAlpha:0.6,
116            },
117            lineColor:'',
118            isHover:'',
119            hoverX:1,
120            params:'',
121            wakeupBean:undefined,
122            flagMoveInfo:'',
123            flagSelectedInfo:'',
124            slicesTime:3,
125            id:1,
126            x: 20,
127            y: 20,
128            width: 100,
129            height: 100
130        }
131        window.postMessage = jest.fn(()=>true)
132        expect(processRender.render(req,[],[])).toBeUndefined()
133    });
134});