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 { TabPanePurgTotal } from '../../../../../../src/trace/component/trace/sheet/ability/TabPanePurgTotal'; 16 17const sqlit = require('../../../../../../src/trace/database/sql/Ability.sql'); 18jest.mock('../../../../../../src/trace/database/sql/Ability.sql'); 19jest.mock('../../../../../../src/trace/bean/NativeHook', () => { 20 return {}; 21}); 22// @ts-ignore 23window.ResizeObserver = 24 window.ResizeObserver || 25 jest.fn().mockImplementation(() => ({ 26 disconnect: jest.fn(), 27 observe: jest.fn(), 28 unobserve: jest.fn(), 29 })); 30 31describe('TabPanePurgTotal Test', () => { 32 let tabPanePurgTotal = new TabPanePurgTotal(); 33 let querySysPurgeableTab = sqlit.querySysPurgeableTab; 34 querySysPurgeableTab.mockResolvedValue([ 35 { 36 avgSize: 21025824, 37 avgSizes: '321.00MB', 38 type: 'allocator_host', 39 maxSize: 9165822, 40 maxSizes: '233.00MB', 41 minSize: 35145824, 42 minSizes: '12.00MB', 43 }, 44 { 45 avgSize: 32133321, 46 avgSizes: '320.00MB', 47 type: '11allocator_host', 48 maxSize: 23265824, 49 maxSizes: '4.00MB', 50 minSize: 32365824, 51 minSizes: '321.00MB', 52 }, 53 { 54 avgSize: 98525824, 55 avgSizes: '3.00MB', 56 type: 'alloca11tor_host', 57 maxSize: 12155824, 58 maxSizes: '6.00MB', 59 minSize: 36545824, 60 minSizes: '66.00MB', 61 }, 62 ]); 63 tabPanePurgTotal.init = jest.fn(() => true); 64 tabPanePurgTotal.data = { 65 anomalyEnergy: [], 66 clockMapData: { size: 321 }, 67 cpuAbilityIds: [], 68 cpuFreqFilterIds: [], 69 cpuFreqLimitDatas: [], 70 diskIOReadIds: [], 71 diskIOWriteIds: [], 72 diskIOipids: [], 73 dmaAbilityData: [], 74 dmaVmTrackerData: [], 75 fsCount: 90, 76 funAsync: [], 77 funTids: [], 78 gpu: { gl: false, gpuWindow: false, gpuTotal: false }, 79 gpuMemoryAbilityData: [], 80 gpuMemoryTrackerData: [], 81 hasFps: false, 82 irqMapData: { size: 630 }, 83 isCurrentPane: false, 84 jankFramesData: [], 85 jsCpuProfilerData: [], 86 jsMemory: [], 87 leftNs: 12120099973, 88 memoryAbilityIds: [], 89 nativeMemory: [], 90 nativeMemoryStatistic: [], 91 networkAbilityIds: [], 92 perfAll: false, 93 cpuStateFilterIds: [], 94 cpus: [], 95 diskAbilityIds: [], 96 diskIOLatency: false, 97 perfCpus: [], 98 perfProcess: [], 99 perfSampleIds: [], 100 perfThread: [], 101 purgeableTotalAbility: [1, 2], 102 purgeableTotalSelection: [], 103 purgeableTotalVM: [4, 1], 104 recordStartNs: 396522210669149, 105 rightNs: 21021096280, 106 sdkCounterIds: [], 107 sdkSliceIds: [], 108 smapsType: [], 109 startup: false, 110 staticInit: false, 111 statisticsSelectData: undefined, 112 powerEnergy: [], 113 processIds: [], 114 processTrackIds: [], 115 promiseList: [], 116 purgeablePinAbility: [], 117 purgeablePinSelection: [], 118 purgeablePinVM: [], 119 }; 120 121 it('TabPanePurgTotalTest01', function () { 122 expect( 123 tabPanePurgTotal.sortByColumn({ 124 key: 'avgSize', 125 }) 126 ).toBeUndefined(); 127 }); 128}); 129