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 { TabPaneIrqCounter } from '../../../../../../src/trace/component/trace/sheet/irq/TabPaneIrqCounter'; 17import { IrqStruct } from '../../../../../../src/trace/database/ui-worker/ProcedureWorkerIrq'; 18jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { 19 return {}; 20}); 21const sqlite = require('../../../../../../src/trace/database/sql/Irq.sql'); 22jest.mock('../../../../../../src/trace/database/sql/Irq.sql'); 23 24window.ResizeObserver = 25 window.ResizeObserver || 26 jest.fn().mockImplementation(() => ({ 27 disconnect: jest.fn(), 28 observe: jest.fn(), 29 unobserve: jest.fn(), 30 })); 31 32describe('TabPaneIrqCounter Test', () => { 33 document.body.innerHTML = `<div><tabpane-irq-counter id="irq"></tabpane-irq-counter></div>`; 34 let tabPaneIrqCounter = document.querySelector<TabPaneIrqCounter>('#irq'); 35 let map = new Map(); 36 map.set('irq', [new IrqStruct()]); 37 let frameData = { 38 leftNs: 253, 39 rightNs: 1252, 40 argSetId: 5, 41 startNS: 11111, 42 dur: 22222, 43 name: 'irq', 44 irqMapData: map, 45 framesData: [ 46 { 47 id: 25, 48 ts: 254151, 49 dur: 1202, 50 name: '1583', 51 argSetId: 5, 52 type: '0', 53 pid: 20, 54 gpu_dur: 2568, 55 app_dur: 110, 56 }, 57 ], 58 }; 59 60 let irqData = sqlite.queryIrqDataBoxSelect; 61 irqData.mockResolvedValue([ 62 { 63 irqName: "name", 64 wallDuration: 9536, 65 maxDuration: 5239, 66 count: 1, 67 avgDuration: 2563 68 } 69 ]); 70 71 let softIrqData = sqlite.querySoftIrqDataBoxSelect; 72 softIrqData.mockResolvedValue([ 73 { 74 irqName: "name", 75 wallDuration: 6765, 76 maxDuration: 56756, 77 count: 1, 78 avgDuration: 46545 79 } 80 ]); 81 82 it('TabPaneIrqCounterTest01', function () { 83 tabPaneIrqCounter.data = frameData; 84 expect(tabPaneIrqCounter.data).not.toBeUndefined(); 85 }); 86}); 87