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