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 16import { TraceRowRecyclerView } from '../../../../../src/trace/component/trace/base/TraceRowRecyclerView'; 17import { TraceRowObject } from "../../../../../src/trace/component/trace/base/TraceRowObject"; 18 19jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 20 return {}; 21}); 22jest.mock('../../../../../src/js-heap/model/DatabaseStruct', () => { 23 return {}; 24}); 25jest.mock('../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { 26 return {}; 27}); 28describe('TraceRow Test', () => { 29 beforeAll(() => {}); 30 31 it('Utils Test01', () => { 32 let traceRow = new TraceRowRecyclerView(); 33 expect(traceRow); 34 }); 35 36 it('Test02', function () { 37 let traceRow = new TraceRowRecyclerView(); 38 expect(traceRow.dataSource).toBeTruthy(); 39 }); 40 41 it('Test03', function () { 42 let traceRow = new TraceRowRecyclerView(); 43 traceRow.measureHeight = jest.fn(() => true); 44 let obj = new TraceRowObject(); 45 traceRow.dataSource = [obj]; 46 expect(traceRow.dataSource).toBeTruthy(); 47 }); 48 49 it('Test04', function () { 50 let traceRow = new TraceRowRecyclerView(); 51 expect(traceRow.renderType).toBeTruthy(); 52 }); 53 54 it('Test05', function () { 55 let traceRow = new TraceRowRecyclerView(); 56 traceRow.renderType = 'type' 57 expect(traceRow.renderType).toEqual('type'); 58 }); 59 60 it('Test06', function () { 61 let traceRow = new TraceRowRecyclerView(); 62 const obj = { 63 folder: false, 64 top: 0, 65 name: '', 66 children: false, 67 rowId: '', 68 rowType: '', 69 rowParentId: '1', 70 expansion: false, 71 rowHidden: false, 72 rowHeight: 40, 73 }; 74 const el = { 75 obj: undefined, 76 style: { top: 1, visibility: 'visible' }, 77 name: '', 78 rowId: '', 79 rowType: '', 80 rowParentId: '1', 81 expansion: false, 82 rowHidden: false, 83 setAttribute: '', 84 removeAttribute: '', 85 }; 86 expect(traceRow.refreshRow(el, !obj)).toBeUndefined(); 87 }); 88 89 it('Test08', function () { 90 let traceRow = new TraceRowRecyclerView(); 91 expect(traceRow.initUI()).toBeUndefined(); 92 }); 93 94 it('Test09', function () { 95 let traceRow = new TraceRowRecyclerView(); 96 expect(traceRow.initUI()).toBeUndefined(); 97 }); 98 it('Test10', function () { 99 let traceRow = new TraceRowRecyclerView(); 100 let mouseScrollEvent: MouseEvent = new MouseEvent('scroll', <MouseEventInit>{ clientX: 1, clientY: 2 }); 101 traceRow.vessel.dispatchEvent(mouseScrollEvent); 102 }); 103 104}); 105