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 { TabPaneBoxChild } from '../../../../../../src/trace/component/trace/sheet/cpu/TabPaneBoxChild'; 17const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); 18jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); 19jest.mock('../../../../../../src/trace/bean/NativeHook', () => { 20 return {}; 21}); 22 23window.ResizeObserver = 24 window.ResizeObserver || 25 jest.fn().mockImplementation(() => ({ 26 disconnect: jest.fn(), 27 observe: jest.fn(), 28 unobserve: jest.fn(), 29 })); 30 31describe('TabPaneBoxChild Test', () => { 32 document.body.innerHTML = `<div id="div"></div>`; 33 let element = document.querySelector('#div') as HTMLDivElement; 34 let tabPaneBoxChild = new TabPaneBoxChild(); 35 element.appendChild(tabPaneBoxChild); 36 tabPaneBoxChild.loadDataInCache = true; 37 let getTabBox = sqlit.getTabBoxChildData; 38 let data = [ 39 { 40 process: '', 41 processId: 12, 42 thread: '', 43 state: 2, 44 threadId: 3, 45 duration: 1, 46 startNs: 17, 47 cpu: 2, 48 priority: 1, 49 }, 50 ]; 51 getTabBox.mockResolvedValue(data); 52 tabPaneBoxChild.data = { 53 cpus: [], 54 threadIds: [], 55 trackIds: [], 56 funTids: [], 57 heapIds: [], 58 leftNs: 0, 59 rightNs: 233, 60 hasFps: false, 61 state:'', 62 processId:0, 63 threadId: 0 64 }; 65 66 67 it('TabPaneBoxChildTest01', function () { 68 expect( 69 tabPaneBoxChild.sortByColumn({ 70 key: 'number', 71 }) 72 ).toBeUndefined(); 73 }); 74 75 it('TabPaneCounterTest02', function () { 76 expect( 77 tabPaneBoxChild.sortByColumn({ 78 sort: () => {}, 79 }) 80 ).toBeUndefined(); 81 }); 82 it('TabPaneCounterTest03', function () { 83 let val = [ 84 { 85 leftNs: 11, 86 rightNs: 34, 87 state: true, 88 processId: 3, 89 threadId: 1, 90 }, 91 ]; 92 expect(tabPaneBoxChild.getDataByDB(val)).toBeUndefined(); 93 }); 94}); 95