• 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 { ChartStruct,
18    Msg,
19    MerageBean,
20    merageBeanDataSplit,
21    getByteWithUnit,
22    getTimeString,
23    timeMsFormat2p,
24    getProbablyTime,
25    convertJSON}
26    //@ts-ignore
27     from "../../../../dist/trace/database/logic-worker/ProcedureLogicWorkerCommon.js"
28describe('ProcedureLogicWorkerCommon Test', ()=> {
29
30    it('ChartStructTest', function () {
31        let chartStruct = new ChartStruct();
32        expect(chartStruct).not.toBeUndefined();
33    });
34
35    it('MsgTest', function () {
36        let msg = new Msg();
37        expect(msg).not.toBeUndefined();
38    });
39
40    it('MerageBeanTest01', function () {
41        let merageBean = new MerageBean();
42        expect(merageBean).not.toBeUndefined();
43    });
44
45    it('MerageBeanTest02', function () {
46        let merageBean = new MerageBean();
47        merageBean.parentNode = true;
48        expect(merageBean.parentNode).toBeTruthy();
49    });
50
51    it('MerageBeanTest03', function () {
52        let merageBean = new MerageBean();
53        merageBean.parentNode = false;
54        expect(merageBean.parentNode).toBeFalsy();
55    });
56
57    it('MerageBeanTest04', function () {
58        let merageBean = new MerageBean();
59        merageBean.total = true;
60        expect(merageBean.total).toBeTruthy();
61    });
62
63    it('MerageBeanTest05', function () {
64        let merageBean = new MerageBean();
65        merageBean.total = false;
66        expect(merageBean.total).toBeFalsy();
67    });
68
69    it('MerageBeanTest06', function () {
70        merageBeanDataSplit.recursionChargeInitTree = jest.fn(()=>true)
71        merageBeanDataSplit.resetAllNode = jest.fn(()=>true)
72        expect(merageBeanDataSplit.splitTree('',[{children:[]}],"",true,[''],"")).toBeUndefined();
73    });
74    it('MerageBeanTest30', function () {
75        merageBeanDataSplit.recursionPruneInitTree = jest.fn(()=>true)
76        merageBeanDataSplit.resetAllNode = jest.fn(()=>true)
77        expect(merageBeanDataSplit.splitTree('',[{children:[]}],"",false,[''],"")).toBeUndefined();
78    });
79
80    it('MerageBeanTest07', function () {
81        merageBeanDataSplit.recursionChargeInitTree = jest.fn(()=>true)
82        let node ={
83            symbolName: '',
84            libName: '',
85        }
86        expect(merageBeanDataSplit.recursionChargeInitTree('',node,"",true)).toBeTruthy();
87    });
88
89    it('MerageBeanTest47', function () {
90        merageBeanDataSplit.recursionChargeInitTree = jest.fn(()=>undefined);
91        merageBeanDataSplit.resetAllNode = jest.fn(()=>true)
92        let node = {
93            symbolName: '',
94            libName: '',
95            initChildren: {
96                length: 1,
97            }
98        }
99        expect(merageBeanDataSplit.recursionChargeInitTree('',node,[],true)).toBeUndefined();
100    });
101
102    it('MerageBeanTest30', function () {
103        expect(getByteWithUnit(-1_000_000_001)).toBe("-953.67 Mb");
104    });
105
106    it('MerageBeanTest08', function () {
107        expect(getByteWithUnit(1_000_000_001)).toBe("953.67 Mb");
108    });
109
110    it('MerageBeanTest09', function () {
111        expect(getByteWithUnit(1_000_001)).toBe("976.56 Kb");
112    });
113
114    it('MerageBeanTest10', function () {
115        expect(getByteWithUnit(1_001)).toBe("1001 byte");
116    });
117
118    it('MerageBeanTest11', function () {
119        expect(getByteWithUnit(1_000_000_000_1)).toBe("9.31 Gb");
120    });
121
122    it('MerageBeanTest12', function () {
123        expect(getTimeString(3600_000_000_002)).toBe("1h 2ns ");
124    });
125
126    it('MerageBeanTest13', function () {
127        expect(getTimeString(60_000_000_002)).toBe("1m 2ns ");
128    });
129
130    it('MerageBeanTest14', function () {
131        expect(getTimeString(1_000_000_003)).toBe("1s 3ns ");
132    });
133
134    it('MerageBeanTest15', function () {
135        expect(getTimeString(1_000_004)).toBe("1ms 4ns ");
136    });
137
138    it('MerageBeanTest16', function () {
139        expect(getTimeString(1_003)).toBe("1μs 3ns ");
140    });
141
142    it('MerageBeanTest31', function () {
143        expect(convertJSON('')).toBe("");
144    });
145
146    it('MerageBeanTest33', function () {
147        expect(getProbablyTime('')).toBe("");
148    });
149
150    it('MerageBeanTest34', function () {
151        expect(getProbablyTime(3600_000_000_000)).toBe("1.00h ");
152    });
153
154    it('MerageBeanTest35', function () {
155        expect(getProbablyTime(60_000_000_002)).toBe("1.00m ");
156    });
157
158    it('MerageBeanTest36', function () {
159        expect(getProbablyTime(1_000_000_000)).toBe("1.00s ");
160    });
161
162    it('MerageBeanTest37', function () {
163        expect(getProbablyTime(1_000_000)).toBe("1.00ms ");
164    });
165
166    it('MerageBeanTest38', function () {
167        expect(getProbablyTime(1_000)).toBe("1.00μs ");
168    });
169
170    it('MerageBeanTest44', function () {
171        expect(getProbablyTime(100)).toBe("100ns ");
172    });
173
174    it('MerageBeanTest39', function () {
175        expect(timeMsFormat2p('')).toBe("0s");
176    });
177
178    it('MerageBeanTest40', function () {
179        expect(timeMsFormat2p(3600_000)).toBe("1.00h");
180    });
181
182    it('MerageBeanTest41', function () {
183        expect(timeMsFormat2p(60_000)).toBe("1.00min");
184    });
185
186    it('MerageBeanTest42', function () {
187        expect(timeMsFormat2p(1_000)).toBe("1.00s");
188    });
189
190    it('MerageBeanTest43', function () {
191        expect(timeMsFormat2p(100)).toBe("100.00ms");
192    });
193
194    it('MerageBeanTest17', function () {
195        merageBeanDataSplit.recursionChargeTree = jest.fn(()=>true);
196        let node = [{
197            initChildren:{
198                length:1
199            }
200        }]
201        expect(merageBeanDataSplit.recursionChargeTree(node,"",true)).toBeTruthy();
202    });
203
204    it('MerageBeanTest18', function () {
205        merageBeanDataSplit.recursionPruneInitTree = jest.fn(()=>true);
206        let node = [{
207            initChildren:{
208                length:1
209            }
210        }]
211        expect(merageBeanDataSplit.recursionPruneInitTree('',node,"",true)).toBeTruthy();
212    });
213
214    it('MerageBeanTest19', function () {
215        merageBeanDataSplit.recursionPruneTree = jest.fn(()=>true);
216        let node = [{
217            initChildren:{
218                length:1
219            }
220        }]
221        expect(merageBeanDataSplit.recursionPruneTree(node,"",true)).toBeTruthy();
222    });
223
224    it('MerageBeanTest20', function () {
225        merageBeanDataSplit.recursionChargeByRule = jest.fn(()=>true);
226        let node = [{
227            initChildren:{
228                length:1
229            }
230        }]
231        expect(merageBeanDataSplit.recursionChargeByRule('',node,"",true)).toBeTruthy();
232    });
233
234    it('MerageBeanTest21', function () {
235        merageBeanDataSplit.pruneChildren = jest.fn(()=>true);
236        let node = [{
237            initChildren:{
238                length:1
239            }
240        }]
241        expect(merageBeanDataSplit.pruneChildren('',node,"")).toBeTruthy();
242    });
243
244    it('MerageBeanTest22', function () {
245        merageBeanDataSplit.hideSystemLibrary = jest.fn(()=>true);
246        expect(merageBeanDataSplit.hideSystemLibrary('','')).toBeTruthy();
247    });
248
249    it('MerageBeanTest23', function () {
250        merageBeanDataSplit.hideNumMaxAndMin = jest.fn(()=>true);
251        expect(merageBeanDataSplit.hideNumMaxAndMin('','',1,1)).toBeTruthy();
252    });
253
254    it('MerageBeanTest24', function () {
255        merageBeanDataSplit.resotreAllNode = jest.fn(()=>true);
256        expect(merageBeanDataSplit.resotreAllNode('',true)).toBeTruthy();
257    });
258
259    it('MerageBeanTest25', function () {
260        merageBeanDataSplit.resetAllNode = jest.fn(()=>true);
261        expect(merageBeanDataSplit.resetAllNode('',[],'')).toBeTruthy();
262    });
263
264    it('MerageBeanTest26', function () {
265        merageBeanDataSplit.resetNewAllNode = jest.fn(()=>true);
266        expect(merageBeanDataSplit.resetNewAllNode('',[])).toBeTruthy();
267    });
268
269    it('MerageBeanTest27', function () {
270        merageBeanDataSplit.clearSearchNode = jest.fn(()=>true);
271        expect(merageBeanDataSplit.clearSearchNode('')).toBeTruthy();
272    });
273
274    it('MerageBeanTest28', function () {
275        merageBeanDataSplit.splitAllProcess = jest.fn(()=>true);
276        expect(merageBeanDataSplit.splitAllProcess('','',[])).toBeTruthy();
277    });
278
279    it('MerageBeanTest29', function () {
280        merageBeanDataSplit.splitAllProcess = jest.fn(()=>true);
281        expect(merageBeanDataSplit.splitAllProcess('','',[])).toBeTruthy();
282    });
283})