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