• 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//@ts-ignore
16import {hiPerfCpu,HiPerfCpuStruct} from "../../../../dist/trace/database/ui-worker/ProcedureWorkerHiPerfCPU.js";
17
18describe('ProcedureWorkerHiPerfCPU Test', ()=>{
19
20
21    let frame={
22        x:0,
23        y:9,
24        width:10,
25        height:10
26    }
27    it('ProcedureWorkerHiPerfCPUTest01',()=>{
28        const data = {
29            frame:undefined,
30            cpu:1,
31            startNs:1,
32            value:1,
33        }
34        const canvas = document.createElement('canvas');
35        canvas.width = 1;
36        canvas.height = 1;
37        const ctx = canvas.getContext('2d');
38        expect(HiPerfCpuStruct.draw(ctx,'',data,true)).toBeUndefined();
39    });
40
41    it('ProcedureWorkerHiPerfCPUTest02', function () {
42        let dataList = new Array();
43        dataList.push({startNS: 0, dur: 10,length:1, frame: {x:0, y:9, width:10, height:10}})
44        dataList.push({startNS: 1, dur: 2,length:1})
45        let res = [{
46            length:1,
47        }]
48        hiPerfCpu(dataList, [{length:1}], "1", res, 3, 6,3,frame,true,1,2,true)
49    });
50
51    it('ProcedureWorkerHiPerfCPUTest03', function () {
52        let dataList = new Array();
53        dataList.push({startNS: 0, dur: 10,length:1, frame: {x:0, y:9, width:10, height:10}})
54        dataList.push({startNS: 1, dur: 2,length:1})
55        let res = [{
56            length:0,
57        }]
58        hiPerfCpu(dataList,[{length:1}], "1", res, 3, 6,3,frame,false,1,2,false)
59    });
60
61    it('ProcedureWorkerHiPerfCPUTest04',()=>{
62        const canvas = document.createElement('canvas');
63        canvas.width = 1;
64        canvas.height = 1;
65        const ctx = canvas.getContext('2d');
66        expect(HiPerfCpuStruct.drawRoundRectPath(ctx,1,1,1,1,1)).toBeUndefined();
67    });
68
69    it('ProcedureWorkerHiPerfCPUTest05', function () {
70        expect(HiPerfCpuStruct.groupBy10MS([{id:1,NS:3},{copy:"1"}],10,"")).toEqual([{"dur": 10000000, "height": 0, "startNS": NaN,}])
71    });
72})