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 { TabPaneStaticInit } from '../../../../../../src/trace/component/trace/sheet/process/TabPaneStaticInit'; 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/trace/database/ui-worker/ProcedureWorkerAppStartup', () => { 32 return { 33 AppStartupStruct: { 34 getStartupName: jest.fn().mockReturnValue('Unknown Start Step'), 35 }, 36 }; 37}); 38describe('TabPaneStaticInit Test', () => { 39 let tabPaneStaticInit = new TabPaneStaticInit(); 40 let getTabStaticInit = sqlit.getTabStaticInit; 41 42 getTabStaticInit.mockResolvedValue([ 43 { 44 pid: 3913, 45 process: 'com.ohos.smartperf', 46 startTs: 5769042707, 47 dur: 6701042, 48 soName: 'dlopen: /system/lib64/module/net/libsocket.z.so', 49 }, 50 { 51 pid: 3913, 52 process: 'com.ohos.smartperf', 53 startTs: 5696226041, 54 dur: 4319791, 55 soName: 'dlopen: system/lib64/extensionability/libinputmethod_extension_module.z.so', 56 }, 57 ]); 58 it('TabPaneStaticInit01', function () { 59 expect( 60 (tabPaneStaticInit.data = { 61 recordStartNs: 94574874464, 62 leftNs: 5521679251, 63 rightNs: 6407693386, 64 hasFps: false, 65 perfAll: false, 66 fileSysVirtualMemory: false, 67 diskIOLatency: false, 68 fsCount: 0, 69 vmCount: 0, 70 isCurrentPane: false, 71 startup: true, 72 staticInit: true, 73 processIds: [3913], 74 }) 75 ); 76 }); 77 78 it('TabPaneCounterTest02', function () { 79 expect( 80 tabPaneStaticInit.sortByColumn({ 81 key: 'name', 82 sort: () => {}, 83 }) 84 ).toBeUndefined(); 85 }); 86}); 87