• 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 {fileSysChart,FileSysChartStruct} from "../../../../dist/trace/database/ui-worker/ProcedureWorkerFileSystem.js"
18
19describe('ProcedureWorkerFileSystem Test', () => {
20
21    it('ProcedureWorkerFileSystemTest01', function () {
22        let frame = {
23            x: 20,
24            y: 20,
25            width: 100,
26            height: 100
27        }
28        expect(fileSysChart([], [{length: 1}], "", [{length: 1}], 1, 2, 1, frame, true, true,true)).toBeUndefined()
29    });
30
31    it('ProcedureWorkerFileSystemTest02', function () {
32        let frame = {
33            x: 20,
34            y: 20,
35            width: 100,
36            height: 100
37        }
38        expect(fileSysChart([], [{length: 1}], "", [{length: 0}], 1, 2, 1, frame, false, false,false)).toBeUndefined()
39    });
40
41    it('ProcedureWorkerFileSystemTest03', function () {
42        let frame = {
43            x: 20,
44            y: 20,
45            width: 100,
46            height: 100
47        }
48        let dataList = new Array();
49        dataList.push({startTime: 0, dur: 10, frame: {x:0, y:9, width:10, height:1}})
50        dataList.push({startTime: 1, dur: 111})
51        fileSysChart(dataList, dataList, "", [{length: 0}], 1, 2, 1, frame, true, false,false)
52    });
53
54    it('ProcedureWorkerFileSystemTest03', function () {
55        let frame = {
56            x: 20,
57            y: 20,
58            width: 100,
59            height: 100
60        }
61        let dataList = new Array();
62        dataList.push({startTime: 0, dur: 10, frame: {x:0, y:9, width:10, height:0}})
63        dataList.push({startTime: 1, dur: 111})
64        fileSysChart(dataList, dataList, "", [{length: 0}], 1, 2, 1, frame, true, false,false)
65    });
66
67    it('ProcedureWorkerFileSystemTest04', function () {
68        let node = {
69            frame: {
70                x: 20,
71                y: 20,
72                width: 100,
73                height: 100
74            },
75            startNS: 0,
76            value: 50,
77            startTs:3,
78            dur:1,
79            height:2
80        }
81        let  frame = {
82            x: 20,
83            y: 20,
84            width: 100,
85            height: 100
86        }
87        expect(FileSysChartStruct.setFrame(node,2, 1,2,frame)).toBeUndefined()
88    });
89
90    it('ProcedureWorkerFileSystemTest05', function () {
91        let node = {
92            frame: {
93                x: 20,
94                y: 20,
95                width: 100,
96                height: 100
97            },
98            startNS: 2,
99            value: 50,
100            startTs:3,
101            dur:3,
102            height:2
103        }
104        let  frame = {
105            x: 20,
106            y: 20,
107            width: 100,
108            height: 100
109        }
110        expect(FileSysChartStruct.setFrame(node,2, 1,2,frame)).toBeUndefined()
111    });
112
113    it('ProcedureWorkerFileSystemTest06', function () {
114        expect(FileSysChartStruct.computeHeightNoGroup([{length:1}],10)).toEqual([{
115            "dur": 10, "group10Ms": false, "height": 18, "size": 1, "startNS": 0},
116            {"dur": 0, "group10Ms": false, "height": 0, "size": 0, "startNS": 10}
117        ]);
118    });
119
120    it('ProcedureWorkerFileSystemTest07', function () {
121        expect(FileSysChartStruct.groupBy10MSWithMaxLatency([{id:1,NS:3},{copy:"1"}])).toEqual([{"dur": 10000000, "height": NaN, "startNS": NaN,"group10Ms": true,"size": undefined,}])
122    });
123
124    it('ProcedureWorkerFileSystemTest08', function () {
125        expect(FileSysChartStruct.groupBy10MSWithCount([{id:1,NS:3},{copy:"1"}])).toEqual([{"dur": 10000000, "height": 36, "startNS": NaN,"group10Ms": true,"size": 2,}])
126    });
127
128})