• 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 {CpuStateRender,CpuStateStruct,cpuState} from "../../../../dist/trace/database/ui-worker/ProcedureWorkerCpuState.js"
18
19describe('ProcedureWorkerCpuState Test', () => {
20
21    it('ProcedureWorkerCpuStateTest01', function () {
22        let node = {
23            frame: {
24                x: 20,
25                y: 20,
26                width: 100,
27                height: 100
28            },
29            startNS: 200,
30            value: 50,
31            startTs:1,
32            dur:10,
33            height:2
34        }
35        let  frame = {
36            x: 20,
37            y: 20,
38            width: 100,
39            height: 100
40        }
41        expect(CpuStateStruct.setFrame(node ,2,2,6,4,frame)).toBeUndefined()
42    });
43
44    it('ProcedureWorkerCpuStateTest01', function () {
45        let node = {
46            frame: {
47                x: 20,
48                y: 20,
49                width: 100,
50                height: 100
51            },
52            startNS: 200,
53            value: 50,
54            startTs:3,
55            dur:1,
56            height:2
57        }
58        let  frame = {
59            x: 20,
60            y: 20,
61            width: 100,
62            height: 100
63        }
64        expect(CpuStateStruct.setFrame(node ,2,2,6,4,frame)).toBeUndefined()
65    });
66
67    it('ProcedureWorkerCpuStateTest02', function () {
68        let cpuStateRender = new CpuStateRender()
69        let node = [{
70            frame: {
71                x: 20,
72                y: 20,
73                width: 100,
74                height: 100
75            },
76            startNS: 200,
77           length:0,
78            height:2
79        }]
80        let  frame = {
81            x: 20,
82            y: 20,
83            width: 100,
84            height: 100
85        }
86        expect(cpuStateRender.cpuState(node ,[{length:1}],"",[],4,1,1,frame,true)).toBeUndefined()
87    });
88
89    it('ProcedureWorkerCpuStateTest03', function () {
90        let cpuStateRender = new CpuStateRender()
91        let dataList = new Array();
92        dataList.push({startNS: 0, dur: 10,length:1, frame: {x:0, y:9, width:10, height:10}})
93        dataList.push({startNS: 1, dur: 2,length:1})
94        let res = [{
95            frame: {
96                x: 20,
97                y: 20,
98                width: 100,
99                height: 100
100            },
101            startNS: 1,
102            length:1,
103            height:2,
104            dur:1
105        }]
106        let  frame = {
107            x: 20,
108            y: 20,
109            width: 100,
110            height: 100
111        }
112        expect(cpuStateRender.cpuState([],dataList,"",res,1,6,5,frame,true)).toBeUndefined()
113    });
114
115    it('ProcedureWorkerCpuStateTest04', function () {
116        let cpuStateRender = new CpuStateRender()
117        let dataList = new Array();
118        dataList.push({startNS: 0, dur: 10,length:1, frame: {x:0, y:9, width:10, height:10}})
119        dataList.push({startNS: 1, dur: 2,length:1})
120        let res = [{
121            frame: {
122                x: 20,
123                y: 20,
124                width: 100,
125                height: 100
126            },
127            startNS: 10,
128            length:1,
129            height:2,
130            dur:1
131        }]
132        let  frame = {
133            x: 20,
134            y: 20,
135            width: 100,
136            height: 100
137        }
138        expect(cpuStateRender.cpuState([],dataList,"",res,1,6,5,frame,true)).toBeUndefined()
139    });
140
141
142})