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/chart/FrameChart.js" 18 19window.ResizeObserver = window.ResizeObserver || 20 jest.fn().mockImplementation(() => ({ 21 disconnect: jest.fn(), 22 observe: jest.fn(), 23 unobserve: jest.fn(), 24 })); 25 26describe('FrameChart Test', () => { 27 let node= [ 28 {children: ''}, 29 {children:{length:0}} 30 ] 31 let node1= [ 32 {children: ''}, 33 {children:{length:10}} 34 ] 35 let selectData = [length=1] 36 document.body.innerHTML = '<tab-framechart id="ccc"></tab-framechart>' 37 let frameChart = document.querySelector('#ccc') as FrameChart 38 39 it('FrameChartTest01', function () { 40 frameChart.tabPaneScrollTop = false; 41 expect(frameChart.tabPaneScrollTop).toBeFalsy(); 42 }); 43 44 it('FrameChartTest02', function () { 45 expect(frameChart.updateFloatHint()).toBeUndefined(); 46 }); 47 48 it('FrameChartTest03', function () { 49 frameChart.calculateChartData = jest.fn(()=>true) 50 frameChart.calMaxDepth = jest.fn(()=>true) 51 expect(frameChart.redrawChart(selectData)).toBeUndefined(); 52 }); 53 54 it('FrameChartTest05', function () { 55 let index = frameChart.scale(2) 56 expect(index).toBe(undefined); 57 }); 58 59 it('FrameChartTest08', function () { 60 frameChart.translationDraw = jest.fn(()=>true) 61 expect(frameChart.translation()).toBeUndefined(); 62 }); 63 64 it('FrameChartTest14', function () { 65 let frameChart = new FrameChart(); 66 frameChart.translationDraw = jest.fn(()=>true) 67 expect(frameChart.translation(-1)).toBeUndefined(); 68 }); 69 70 it('FrameChartTest09', function () { 71 frameChart.selectTotalCount = false; 72 expect(frameChart.selectTotalCount).toBeFalsy(); 73 }); 74 75 it('FrameChartTest11', function () { 76 let frameChart = new FrameChart(); 77 frameChart._mode = 1; 78 frameChart.drawScale = jest.fn(()=>true) 79 expect(frameChart.calculateChartData()).not.toBeUndefined(); 80 }); 81 82 it('FrameChartTest12', function () { 83 expect(frameChart.updateCanvas()).toBeUndefined(); 84 }); 85 86 it('FrameChartTest13', function () { 87 let frameChart = new FrameChart(); 88 frameChart.translationDraw = jest.fn(()=>true) 89 frameChart.lastCanvasXInScale = 0 90 expect(frameChart.translationByScale()).toBe(undefined); 91 }); 92 93 it('FrameChartTest21', function () { 94 let frameChart = new FrameChart(); 95 frameChart.translationDraw = jest.fn(()=>true) 96 frameChart.canvasX = 4 97 frameChart.lastCanvasXInScale = 1 98 expect(frameChart.translationByScale()).toBe(undefined); 99 }); 100 101 it('FrameChartTest22', function () { 102 let frameChart = new FrameChart(); 103 frameChart.translationDraw = jest.fn(()=>true) 104 expect(frameChart.translationByScale(1)).toBe(undefined); 105 }); 106 it('FrameChartTest211', function () { 107 expect(frameChart.searchData([],2,2)).toBeNull(); 108 }); 109 110 it('FrameChartTest15', function () { 111 let frameChart = new FrameChart(); 112 frameChart.calculateChartData = jest.fn(()=>true) 113 frameChart.xPoint = 1 114 expect(frameChart.translationDraw()).toBe(undefined); 115 }); 116 117 it('FrameChartTest16', function () { 118 expect(frameChart.onMouseClick({button:0})).toBeUndefined(); 119 }); 120 121 it('FrameChartTest17', function () { 122 let frameChart = new FrameChart(); 123 expect(frameChart.initHtml()).toMatchInlineSnapshot(` 124" 125 <style> 126 :host{ 127 display: flex; 128 padding: 10px 10px; 129 } 130 .tip{ 131 position:absolute; 132 left: 0; 133 background-color: white; 134 border: 1px solid #f9f9f9; 135 width: auto; 136 font-size: 8px; 137 color: #50809e; 138 flex-direction: column; 139 justify-content: center; 140 align-items: flex-start; 141 padding: 2px 10px; 142 display: none; 143 user-select: none; 144 } 145 </style> 146 <canvas id=\\"canvas\\"></canvas> 147 <div id =\\"float_hint\\" class=\\"tip\\"></div>" 148`); 149 }); 150 151 it('FrameChartTest18', function () { 152 let frameChart = new FrameChart(); 153 expect(frameChart.drawFrameChart(node)).toBeUndefined(); 154 }); 155 156 it('FrameChartTest20', function () { 157 expect(frameChart.searchData([],1,1)).toBeNull(); 158 }); 159 160 it('FrameChartTest23', function () { 161 expect(frameChart.onMouseClick({button:2})).toBeUndefined(); 162 }); 163 164 it('FrameChartTest24', function () { 165 document.body.innerHTML = `<sp-application></sp-application>` 166 expect(frameChart.drawScale()).toBeUndefined(); 167 }); 168 169 it('FrameChartTest25', function () { 170 let frameChart = new FrameChart(); 171 frameChart.selectTotalSize = false; 172 expect(frameChart.selectTotalSize).toBeFalsy(); 173 }); 174 175 it('FrameChartTest26', function () { 176 let frameChart = new FrameChart(); 177 frameChart.maxDepth = false; 178 expect(frameChart.maxDepth).toBeFalsy(); 179 }); 180 181 182 it('FrameChartTest27 ', function () { 183 let frameChart = new FrameChart(); 184 expect(frameChart.calMaxDepth(node,1)).toBeUndefined() 185 }); 186 187 it('FrameChartTest28 ', function () { 188 let frameChart = new FrameChart(); 189 expect(frameChart.mode).toBeUndefined() 190 }); 191 192 it('FrameChartTest29', function () { 193 let frameChart = new FrameChart(); 194 frameChart.mode =false 195 expect(frameChart.mode).toBeFalsy() 196 }); 197 198 it('FrameChartTest30', function () { 199 frameChart.caldrawArgs = jest.fn(()=>true) 200 expect(frameChart.caldrawArgs()).toBeTruthy() 201 }); 202 203 it('FrameChartTest31', function () { 204 let frameChart = new FrameChart(); 205 frameChart.data = []; 206 expect(frameChart.data).toBeFalsy(); 207 }); 208 209 it('FrameChartTest32', function () { 210 let frameChart = new FrameChart(); 211 expect(frameChart.addChartClickListener(()=>{})).toBeUndefined(); 212 }); 213 214 it('FrameChartTest33', function () { 215 let frameChart = new FrameChart(); 216 expect(frameChart.removeChartClickListener(()=>{})).toBeUndefined(); 217 }); 218 219 it('FrameChartTest34', function () { 220 let frameChart = new FrameChart(); 221 expect(frameChart.calMaxDepth(node1,10)).toBeUndefined(); 222 }); 223 224 it('FrameChartTest35', function () { 225 let frameChart = new FrameChart(); 226 frameChart.drawTriangleOnScale = jest.fn(()=>true); 227 expect(frameChart.drawTriangleOnScale()).toBeTruthy(); 228 }); 229 230 it('FrameChartTest36', function () { 231 frameChart._mode = 1; 232 frameChart.drawScale = jest.fn(()=>true); 233 expect(frameChart.drawScale()).toBeTruthy(); 234 }); 235 236 it('FrameChartTest37', function () { 237 frameChart._mode = 2; 238 frameChart.drawScale = jest.fn(()=>true); 239 expect(frameChart.drawScale()).toBeTruthy(); 240 }); 241 242 it('FrameChartTest38', function () { 243 frameChart._mode = 3; 244 frameChart.drawScale = jest.fn(()=>true); 245 expect(frameChart.drawScale()).toBeTruthy(); 246 }); 247 248 it('FrameChartTest39', function () { 249 expect(frameChart.resetTrans()).toBeUndefined(); 250 }); 251 252 it('FrameChartTest40', function () { 253 expect(frameChart.onMouseClick({button:2})).toBeUndefined(); 254 }); 255 256 it('FrameChartTest41', function () { 257 expect(frameChart.drawDataSet(node,true)).toBeUndefined(); 258 }); 259 260 261 262 263 264 265 266 267 268}) 269