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 '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree'; 16import { TabpaneNMCalltree } from '../../../../../../src/trace/component/trace/sheet/native-memory/TabPaneNMCallTree'; 17import { FrameChart } from '../../../../../../src/trace/component/chart/FrameChart'; 18jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => { 19 return {}; 20}); 21jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => { 22 return {}; 23}); 24jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => { 25 return {}; 26}); 27jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {}); 28 29// @ts-ignore 30window.ResizeObserver = 31 window.ResizeObserver || 32 jest.fn().mockImplementation(() => ({ 33 observe: jest.fn(), 34 unobserve: jest.fn(), 35 disconnect: jest.fn(), 36 })); 37 38describe('TabPaneNMCallTree Test', () => { 39 document.body.innerHTML = '<div><tabpane-nm-calltree id="tree"></tabpane-nm-calltree></div>'; 40 let tabPaneNMCallTree = document.querySelector<TabpaneNMCalltree>('#tree'); 41 let dom = new FrameChart(); 42 dom.setAttribute('id', 'framechart'); 43 44 it('TabPaneNMCallTreeTest01', function () { 45 let hookLeft = { 46 ip: '', 47 symbolsId: 0, 48 pathId: 0, 49 processName: '', 50 type: 0, 51 children: [], 52 }; 53 let groupByWithTid = tabPaneNMCallTree.setRightTableData(hookLeft); 54 expect(groupByWithTid).toBeUndefined(); 55 }); 56 57 it('TabPaneNMCallTreeTest02', function () { 58 let data = [ 59 { size: 10, count: 20, children: [] }, 60 { size: 11, count: 21, children: [] }, 61 { size: 21, count: 31, children: [] }, 62 ]; 63 expect(tabPaneNMCallTree.sortTree(data).length).toBe(3); 64 }); 65 66 it('TabPaneNMCallTreeTest03', function () {}); 67 68 it('TabPaneNMCallTreeTest05', function () { 69 let hook = { 70 id: '1', 71 dur: 1, 72 children: [], 73 }; 74 let id = '1'; 75 expect(tabPaneNMCallTree.getParentTree([hook], { id }, [])).not.toBeUndefined(); 76 }); 77 it('TabPaneNMCallInfoTest06', function () { 78 let hook = { 79 eventId: '1', 80 dur: 1, 81 children: [], 82 }; 83 expect(tabPaneNMCallTree.getChildTree([hook], '1', [])).not.toBeUndefined(); 84 }); 85 it('TabPaneNMCallInfoTest07', function () { 86 document.body.innerHTML = "<div id='filter' tree></div>"; 87 let table = document.querySelector('#filter'); 88 table!.setAttribute('tree', '1'); 89 expect(tabPaneNMCallTree.showBottomMenu()).toBeUndefined(); 90 }); 91 it('TabPaneNMCallInfoTest08', function () { 92 let isShow = 1; 93 document.body.innerHTML = "<div id='filter' tree></div>"; 94 let table = document.querySelector('#filter'); 95 table!.setAttribute('tree', '1'); 96 expect(tabPaneNMCallTree.showBottomMenu(isShow)).toBeUndefined(); 97 }); 98 99 it('TabPaneNMCallInfoTest09', function () { 100 tabPaneNMCallTree.initFilterTypes = jest.fn(); 101 tabPaneNMCallTree.getDataByWorkerQuery = jest.fn(); 102 tabPaneNMCallTree.data = { 103 leftNs: 0, 104 rightNs: 500, 105 nativeMemory: 'All Heap & Anonymous VM', 106 }; 107 expect(tabPaneNMCallTree.data).toBeUndefined(); 108 }); 109 it('TabPaneNMCallTreeTest10', function () { 110 let data = [ 111 { size: 10, count: 20, children: [] }, 112 { size: 11, count: 21, children: [] }, 113 { size: 21, count: 31, children: [] }, 114 ]; 115 expect(tabPaneNMCallTree.setLTableData(data)).toBeUndefined(); 116 }); 117 it('TabPaneNMCallTreeTest12', function () { 118 expect(tabPaneNMCallTree.initFilterTypes()).toBeUndefined(); 119 }); 120 it('TabPaneNMCallTreeTest14', function () { 121 expect(tabPaneNMCallTree.getDataByWorkerQuery({}, {})).toBeUndefined(); 122 }); 123 124 it('TabPaneNMCallTreeTest15', function () { 125 let data = [ 126 { 127 callTreeConstraints: { 128 inputs: [1], 129 }, 130 dataMining: 20, 131 callTree: [], 132 icon: 'tree', 133 }, 134 ]; 135 expect(tabPaneNMCallTree.switchFlameChart(data)).toBeUndefined(); 136 }); 137 it('TabPaneNMCallTreeTest16', function () { 138 let filterData = { 139 callTree: [{}, {}], 140 dataMining: { 141 concat: jest.fn(() => true), 142 }, 143 callTreeConstraints: { 144 checked: false, 145 }, 146 }; 147 tabPaneNMCallTree.currentSelection = jest.fn(() => true); 148 tabPaneNMCallTree.currentSelection.nativeMemory = jest.fn(() => true); 149 expect(tabPaneNMCallTree.refreshAllNode(filterData)).toBeUndefined(); 150 }); 151}); 152