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 { TabPaneGpuTotalBoxSelect } from '../../../../../../src/trace/component/trace/sheet/gpu/TabPaneGpuTotalBoxSelect'; 16 17jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 18 return {}; 19}); 20jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { 21 return {}; 22}); 23jest.mock('../../../../../../src/trace/bean/NativeHook', () => { 24 return {}; 25}); 26const sqlite = require('../../../../../../src/trace/database/sql/Gpu.sql'); 27jest.mock('../../../../../../src/trace/database/sql/Gpu.sql'); 28 29// @ts-ignore 30window.ResizeObserver = 31 window.ResizeObserver || 32 jest.fn().mockImplementation(() => ({ 33 unobserve: jest.fn(), 34 disconnect: jest.fn(), 35 observe: jest.fn(), 36 })); 37 38describe('TabPaneGpuTotalBoxSelect Test', () => { 39 document.body.innerHTML = `<div><tabpane-gpu-total-box-select id="tree"></tabpane-gpu-total-box-select></div>`; 40 let tabPaneGpuTotalBoxSelect = document.querySelector<TabPaneGpuTotalBoxSelect>('#tree'); 41 let queryGpuDataByRange = sqlite.queryGpuDataByRange; 42 queryGpuDataByRange.mockResolvedValue([ 43 { 44 startTs: 23, 45 windowId: 1, 46 moduleId: 2, 47 categoryId: 0, 48 sumSize: 10, 49 avgSize: 1, 50 maxSize: 1, 51 minSize: 0, 52 }, 53 { 54 startTs: 23, 55 windowId: 1, 56 moduleId: 2, 57 categoryId: 0, 58 sumSize: 10, 59 avgSize: 1, 60 maxSize: 1, 61 minSize: 0, 62 }, 63 ]); 64 it('TabPaneGpuTotalBoxSelectTest01', () => { 65 tabPaneGpuTotalBoxSelect.data = { 66 type: '', 67 startTs: 1, 68 }; 69 expect(tabPaneGpuTotalBoxSelect.data).toBeUndefined(); 70 }); 71 it('TabPaneGpuTotalBoxSelectTest02', () => { 72 let tabPaneGpuTotalBoxSelects = new TabPaneGpuTotalBoxSelect(); 73 tabPaneGpuTotalBoxSelects.gpuBoxTbl = jest.fn(() => true); 74 expect( 75 tabPaneGpuTotalBoxSelects.sortByColumn({ 76 sort: 0, 77 }) 78 ).toBeUndefined(); 79 }); 80}); 81