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// @ts-ignore 16import { TabPaneCpuAbility } from '../../../../../../dist/trace/component/trace/sheet/ability/TabPaneCpuAbility.js'; 17const sqlite = require('../../../../../../dist/trace/database/SqlLite.js'); 18jest.mock('../../../../../../dist/trace/database/SqlLite.js'); 19 20window.ResizeObserver = 21 window.ResizeObserver || 22 jest.fn().mockImplementation(() => ({ 23 disconnect: jest.fn(), 24 observe: jest.fn(), 25 unobserve: jest.fn(), 26 })); 27 28describe('TabPaneCpuAbility Test', () => { 29 let tabPaneCpuAbility = new TabPaneCpuAbility(); 30 let val = [ 31 { 32 startNs: 0, 33 rightNs: 1000, 34 leftNs:0, 35 } 36 ]; 37 let getTabCpuData = sqlite.getTabCpuAbilityData; 38 let cpuData = [ 39 { 40 startTime: 0, 41 duration: 1000, 42 totalLoad:2, 43 userLoad:2, 44 systemLoad:3, 45 threads:1, 46 } 47 ]; 48 getTabCpuData.mockResolvedValue(cpuData); 49 it('TabPaneCpuAbilityTest01', function () { 50 tabPaneCpuAbility.queryCpuResult.length = 2; 51 expect(tabPaneCpuAbility.filterData()).toBeUndefined(); 52 }); 53 54 it('TabPaneCpuAbilityTest02', function () { 55 const systemCpuSummary = { 56 startTimeStr: '', 57 durationStr: '', 58 totalLoadStr: '', 59 userLoadStr: '', 60 systemLoadStr: '', 61 threadsStr: '', 62 }; 63 expect(tabPaneCpuAbility.toCpuAbilityArray(systemCpuSummary)).not.toBeUndefined(); 64 }); 65 66 it('TabPaneCpuAbilityTest03 ', function () { 67 expect( 68 tabPaneCpuAbility.sortByColumn({ 69 key: 'startTime', 70 }) 71 ).toBeUndefined(); 72 }); 73 74 it('TabPaneCpuAbilityTest04 ', function () { 75 expect( 76 tabPaneCpuAbility.sortByColumn({ 77 key: !'startTime', 78 }) 79 ).toBeUndefined(); 80 }); 81 82 it('TabPaneCpuAbilityTest05 ', function () { 83 expect( 84 tabPaneCpuAbility.sortByColumn({ 85 key: 'totalLoadStr', 86 }) 87 ).toBeUndefined(); 88 }); 89 90 it('TabPaneCpuAbilityTest06 ', function () { 91 expect( 92 tabPaneCpuAbility.sortByColumn({ 93 key: 'userLoadStr', 94 }) 95 ).toBeUndefined(); 96 }); 97 98 it('TabPaneCpuAbilityTest07 ', function () { 99 expect( 100 tabPaneCpuAbility.sortByColumn({ 101 key: 'systemLoadStr', 102 }) 103 ).toBeUndefined(); 104 }); 105 106 it('TabPaneCpuAbilityTest08 ', function () { 107 expect( 108 tabPaneCpuAbility.sortByColumn({ 109 key: 'durationStr', 110 }) 111 ).toBeUndefined(); 112 }); 113 it('TabPaneCpuAbilityTest09 ', function () { 114 expect( 115 tabPaneCpuAbility.queryDataByDB({val 116 }) 117 ).toBeUndefined(); 118 }); 119}); 120