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 { SpFpsChart } from '../../../../src/trace/component/chart/SpFpsChart'; 17jest.mock('../../../../src/trace/component/SpSystemTrace', () => { 18 return {}; 19}); 20jest.mock('../../../../src/js-heap/model/DatabaseStruct'); 21const sqlit = require('../../../../src/trace/database/sql/SqlLite.sql'); 22jest.mock('../../../../src/trace/database/sql/SqlLite.sql'); 23jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 24 return {}; 25}); 26jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { 27 return {}; 28}); 29const intersectionObserverMock = () => ({ 30 observe: () => null, 31}); 32window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock); 33window.ResizeObserver = 34 window.ResizeObserver || 35 jest.fn().mockImplementation(() => ({ 36 disconnect: jest.fn(), 37 observe: jest.fn(), 38 unobserve: jest.fn(), 39 })); 40describe('spFpsChart Test', () => { 41 let htmlElement: any = document.createElement('sp-system-trace'); 42 let spFpsChart = new SpFpsChart(htmlElement); 43 let fpsMock = sqlit.getFps; 44 fpsMock.mockResolvedValue([ 45 { startNS: 0, fps: 1 }, 46 { startNS: 2, fps: 3 }, 47 ]); 48 49 it('spFpsChart01', function () { 50 expect(spFpsChart.init()).toBeDefined(); 51 }); 52}); 53