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 { Top10LongestRunTimeProcess } from '../../../../../src/trace/component/schedulingAnalysis/processAnalysis/Top10LongestRunTimeProcess'; 17import { LitTable } from '../../../../../src/base-ui/table/lit-table'; 18// @ts-ignore 19window.ResizeObserver = 20 window.ResizeObserver || 21 jest.fn().mockImplementation(() => ({ 22 disconnect: jest.fn(), 23 observe: jest.fn(), 24 unobserve: jest.fn(), 25 })); 26jest.spyOn(LitTable.prototype, 'reMeauseHeight').mockReturnValue(undefined); 27describe('Top10LongestRunTimeProcess Test', () => { 28 it('Top10LongestRunTimeProcessTest01', () => { 29 let topProcess = new Top10LongestRunTimeProcess(); 30 topProcess.initHtml(); 31 topProcess.initElements(); 32 topProcess.processRunTimeTbl.recycleDataSource = [1, 5, 7, 8]; 33 expect(topProcess.clearData()).toBeUndefined(); 34 let fu = (res: unknown) => {}; 35 expect(topProcess.queryLogicWorker('1', '1', fu)).toBeUndefined(); 36 expect(topProcess.initElements()).toBeUndefined(); 37 expect(topProcess.sortByColumn({ key: 'pName', sort: 2 }, [])).toBeUndefined(); 38 expect(topProcess.initHtml()).not.toBeUndefined(); 39 expect(topProcess.initStyleHtml()).not.toBeUndefined(); 40 expect(topProcess.initTagHtml()).not.toBeUndefined(); 41 let data = [{ no: 5, pid: 9, tid: 10, pName: 'oo', tName: 'sdf', switchCount: 5, dur: 7 }]; 42 expect(topProcess.sortByColumn({ key: 'pName', sort: 2 }, data)).toBeUndefined(); 43 expect(topProcess.sortByColumn({ key: 'tName', sort: 2 }, data)).toBeUndefined(); 44 expect(topProcess.sortByColumn({ key: 'dur', sort: 2 }, data)).toBeUndefined(); 45 expect(topProcess.organizationData(data)).not.toBeUndefined(); 46 expect(topProcess.clearData()).toBeUndefined(); 47 }); 48}); 49