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 { TabPaneThreadStates } from '../../../../../../src/trace/component/trace/sheet/process/TabPaneThreadStates'; 17 18window.ResizeObserver = 19 window.ResizeObserver || 20 jest.fn().mockImplementation(() => ({ 21 disconnect: jest.fn(), 22 observe: jest.fn(), 23 unobserve: jest.fn(), 24 })); 25 26const sqlit = require('../../../../../../src/trace/database/sql/ProcessThread.sql'); 27jest.mock('../../../../../../src/trace/database/sql/ProcessThread.sql'); 28jest.mock('../../../../../../src/trace/bean/NativeHook', () => { 29 return {}; 30}); 31jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => { 32 return {}; 33}); 34jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { 35 return {}; 36}); 37jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 38 return {}; 39}); 40jest.mock('../../../../../../src/trace/component/SpSystemTrace', () => { 41 return {}; 42}); 43describe('TabPaneThreadStates Test', () => { 44 let tabPaneThreadStates = null; 45 beforeEach(() => { 46 document.body.innerHTML = `<lit-table id="tb-thread-states"></lit-table>`; 47 tabPaneThreadStates = document.querySelector('#tb-thread-states') as TabPaneThreadStates; 48 }); 49 it('TabPaneThreadStatesTest01', function () { 50 let tabPaneThreadStates = new TabPaneThreadStates(); 51 expect( 52 tabPaneThreadStates.sortByColumn({ 53 key: 'name' || 'thread' || 'state', 54 sort: () => {}, 55 }) 56 ).toBeUndefined(); 57 }); 58 59 it('TabPaneThreadStatesTest02', function () { 60 let tabPaneThreadStates = new TabPaneThreadStates(); 61 expect( 62 tabPaneThreadStates.sortByColumn({ 63 key: !'name' || !'thread' || !'state', 64 sort: () => {}, 65 }) 66 ).toBeUndefined(); 67 }); 68 69 it('TabPaneThreadStatesTest03', function () { 70 // @ts-ignore 71 let mockgetTabThreadStates = sqlit.getTabThreadStates; 72 mockgetTabThreadStates.mockResolvedValue([ 73 { 74 process: '11', 75 thread: '222', 76 wallDuration: 10, 77 occurrences: 10, 78 state: 'sss', 79 stateJX: 'mm', 80 }, 81 { 82 process: '11', 83 thread: '222', 84 wallDuration: 10, 85 occurrences: 10, 86 state: 'sss', 87 stateJX: 'mm', 88 }, 89 ]); 90 let a = { rightNs: 1, leftNs: 0, threadIds: [11, 12, 13], processIds: [11, 12, 13] }; 91 expect((tabPaneThreadStates.data = a)).toBeTruthy(); 92 }); 93 94 it('TabPaneThreadStatesTest04', function () { 95 // @ts-ignore 96 let mockgetTabThreadStates = sqlit.getTabThreadStates; 97 mockgetTabThreadStates.mockResolvedValue([]); 98 let a = { rightNs: 1, leftNs: 0, threadIds: [11, 12, 13], processIds: [11, 12, 13] }; 99 expect((tabPaneThreadStates.data = a)).toBeTruthy(); 100 }); 101}); 102