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 */ 15import { TabPaneDmaVmTrackerComparison } from '../../../../../../src/trace/component/trace/sheet/vmtracker/TabPaneDmaVmTrackerComparison'; 16const sqlite = require('../../../../../../src/trace/database/sql/Dma.sql'); 17jest.mock('../../../../../../src/trace/database/sql/Dma.sql'); 18jest.mock('../../../../../../src/base-ui/select/LitSelect', () => { 19 return {}; 20}); 21jest.mock('../../../../../../src/trace/bean/NativeHook', () => { 22 return {}; 23}); 24jest.mock('../../../../../../src/base-ui/table/lit-table', () => { 25 return { 26 snapshotDataSource: () => {}, 27 removeAttribute: () => {}, 28 }; 29}); 30 31// @ts-ignore 32window.ResizeObserver = 33 window.ResizeObserver || 34 jest.fn().mockImplementation(() => ({ 35 disconnect: jest.fn(), 36 observe: jest.fn(), 37 unobserve: jest.fn(), 38 })); 39 40describe('TabPaneDmaVmTrackerComparison Test', () => { 41 let tabPaneDmaVmTrackerComparison = new TabPaneDmaVmTrackerComparison(); 42 let getTabDmaVmTrackerComparisonData = sqlite.getTabDmaVmTrackerComparisonData; 43 let dmaVmTrackerData = [ 44 { 45 startNs: 0, 46 value: 100, 47 }, 48 ]; 49 let datalist = [ 50 { 51 name: 'Snapshot2', 52 startNs: 980052, 53 type: 'VmTracker', 54 value: 0, 55 }, 56 { 57 name: 'Snapshot1', 58 startNs: 478261, 59 type: 'VmTracker', 60 value: 0, 61 }, 62 ]; 63 tabPaneDmaVmTrackerComparison.init = jest.fn(() => true); 64 getTabDmaVmTrackerComparisonData.mockResolvedValue(dmaVmTrackerData); 65 it('TabPaneDmaVmTrackerComparison01', function () { 66 expect(tabPaneDmaVmTrackerComparison.queryDataByDB(10)).toBeTruthy(); 67 }); 68 it('TabPaneDmaVmTrackerComparison03', function () { 69 expect(tabPaneDmaVmTrackerComparison.comparisonDataByDB(10, datalist)).toBeTruthy(); 70 }); 71 it('TabPaneDmaVmTrackerComparison04', function () { 72 expect(tabPaneDmaVmTrackerComparison.selectStamps(datalist)).toBeUndefined(); 73 }); 74}); 75