• 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 {FrameChart} from "../../../dist/trace/component/FrameChart.js"
18
19describe('FrameChart Test', () => {
20
21    let node= [
22        {children: ''},
23        {children:{length:1}}
24    ]
25    let selectData = [length=1]
26    document.body.innerHTML = '<tab-framechart id="ccc"></tab-framechart>'
27    let frameChart = document.querySelector('#ccc') as FrameChart
28
29    it('FrameChartTest01', function () {
30        frameChart.tabPaneScrollTop = false;
31        expect(frameChart.tabPaneScrollTop).toBeFalsy();
32    });
33
34    it('FrameChartTest02', function () {
35            expect(frameChart.updateFloatHint()).toBeUndefined();
36        });
37
38    it('FrameChartTest03', function () {
39        frameChart.calculateChartData = jest.fn(()=>true)
40        expect(frameChart.redrawChart(selectData)).toBeUndefined();
41    });
42
43    it('FrameChartTest05', function () {
44        let index = frameChart.scale(2)
45        expect(index).toBe(undefined);
46    });
47
48    it('FrameChartTest08', function () {
49        frameChart.translationDraw = jest.fn(()=>true)
50        expect(frameChart.translation()).toBeUndefined();
51    });
52
53    it('FrameChartTest14', function () {
54        let frameChart = new FrameChart();
55        frameChart.translationDraw = jest.fn(()=>true)
56        expect(frameChart.translation(-1)).toBeUndefined();
57    });
58
59    it('FrameChartTest09', function () {
60        frameChart.selectTotalCount = false;
61        expect(frameChart.selectTotalCount).toBeFalsy();
62    });
63
64    it('FrameChartTest11', function () {
65        let frameChart = new FrameChart();
66        frameChart.drawScale = jest.fn(()=>true)
67        expect(frameChart.calculateChartData()).not.toBeUndefined();
68    });
69
70    it('FrameChartTest12', function () {
71        expect(frameChart.updateCanvas()).toBeUndefined();
72    });
73
74    it('FrameChartTest13', function () {
75        let frameChart = new FrameChart();
76        frameChart.translationDraw = jest.fn(()=>true)
77        frameChart.lastCanvasXInScale = 0
78        expect(frameChart.translationByScale()).toBe(undefined);
79    });
80
81    it('FrameChartTest21', function () {
82        let frameChart = new FrameChart();
83        frameChart.translationDraw = jest.fn(()=>true)
84        frameChart.canvasX = 4
85        frameChart.lastCanvasXInScale = 1
86        expect(frameChart.translationByScale()).toBe(undefined);
87    });
88
89    it('FrameChartTest22', function () {
90        let frameChart = new FrameChart();
91        frameChart.translationDraw = jest.fn(()=>true)
92        expect(frameChart.translationByScale(1)).toBe(undefined);
93    });
94    it('FrameChartTest211', function () {
95        expect(frameChart.searchData([],2,2)).toBeNull();
96    });
97
98    it('FrameChartTest15', function () {
99        let frameChart = new FrameChart();
100        frameChart.calculateChartData = jest.fn(()=>true)
101        frameChart.xPoint = 1
102        expect(frameChart.translationDraw()).toBe(undefined);
103    });
104
105    it('FrameChartTest16', function () {
106        expect(frameChart.onMouseClick({button:0})).toBeUndefined();
107    });
108
109    it('FrameChartTest17', function () {
110        let frameChart = new FrameChart();
111        expect(frameChart.initHtml()).toMatchInlineSnapshot(`
112"
113            <style>
114            :host{
115                display: flex;
116                padding: 10px 10px;
117            }
118            .tip{
119                position:absolute;
120                left: 0;
121                background-color: white;
122                border: 1px solid #f9f9f9;
123                width: auto;
124                font-size: 8px;
125                color: #50809e;
126                flex-direction: column;
127                justify-content: center;
128                align-items: flex-start;
129                padding: 2px 10px;
130                display: none;
131                user-select: none;
132            }
133            </style>
134            <canvas id=\\"canvas\\"></canvas>
135            <div id =\\"float_hint\\" class=\\"tip\\"></div>"
136`);
137    });
138
139    it('FrameChartTest18', function () {
140        let frameChart = new FrameChart();
141        expect(frameChart.drawFrameChart(node)).toBeUndefined();
142    });
143
144    it('FrameChartTest19', function () {
145        let frameChart = new FrameChart();
146        frameChart.searchData = jest.fn(()=>true)
147        frameChart.calculateChartData = jest.fn(()=>true)
148        expect(frameChart.onMouseMove()).toBeUndefined();
149    });
150
151    it('FrameChartTest20', function () {
152        expect(frameChart.searchData([],1,1)).toBeNull();
153    });
154
155    it('FrameChartTest23', function () {
156        expect(frameChart.onMouseClick({button:2})).toBeUndefined();
157    });
158
159    it('FrameChartTest24', function () {
160        document.body.innerHTML  = `<sp-application></sp-application>`
161        expect(frameChart.drawScale()).toBeUndefined();
162    });
163
164    it('FrameChartTest25', function () {
165        let frameChart = new FrameChart();
166        frameChart.selectTotalSize = false;
167        expect(frameChart.selectTotalSize).toBeFalsy();
168    });
169
170    it('FrameChartTest26', function () {
171        let frameChart = new FrameChart();
172        frameChart.maxDepth = false;
173        expect(frameChart.maxDepth).toBeFalsy();
174    });
175
176
177    it('FrameChartTest27 ', function () {
178        let frameChart = new FrameChart();
179        expect(frameChart.calMaxDepth(node,1)).toBeUndefined()
180    });
181
182    it('FrameChartTest28 ', function () {
183        let frameChart = new FrameChart();
184        expect(frameChart.mode).toBeUndefined()
185    });
186
187    it('FrameChartTest29', function () {
188        let frameChart = new FrameChart();
189        frameChart.mode  =false
190        expect(frameChart.mode).toBeFalsy()
191    });
192
193    it('FrameChartTest30', function () {
194        frameChart.caldrawArgs  = jest.fn(()=>true)
195        expect(frameChart.caldrawArgs()).toBeTruthy()
196    });
197})
198