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 16// @ts-ignore 17import {SelectionParam, BoxJumpParam, SelectionData, Counter, Fps} from "../../../dist/trace/bean/BoxSelection.js" 18 19describe('BoxSelection Test', ()=>{ 20 let selectionParam = new SelectionParam(); 21 let boxJumpParam = new BoxJumpParam(); 22 let selectionData = new SelectionData(); 23 let counter = new Counter(); 24 let fps = new Fps(); 25 it('BoxSelectionTest01', function () { 26 selectionParam = { 27 cpus: 1, 28 threadIds: 2, 29 trackIds: 1, 30 funTids: 2, 31 heapIds: 1, 32 nativeMemory: 3, 33 leftNs: 1, 34 rightNs: 1, 35 hasFps: true, 36 statisticsSelectData: 1, 37 }; 38 39 expect(selectionParam).not.toBeUndefined() 40 expect(selectionParam).toMatchInlineSnapshot({ 41 cpus: expect.any(Number), 42 threadIds: expect.any(Number), 43 trackIds: expect.any(Number), 44 funTids: expect.any(Number), 45 heapIds: expect.any(Number), 46 nativeMemory: expect.any(Number), 47 leftNs: expect.any(Number), 48 rightNs: expect.any(Number), 49 hasFps: expect.any(Boolean) }, ` 50Object { 51 "cpus": Any<Number>, 52 "funTids": Any<Number>, 53 "hasFps": Any<Boolean>, 54 "heapIds": Any<Number>, 55 "leftNs": Any<Number>, 56 "nativeMemory": Any<Number>, 57 "rightNs": Any<Number>, 58 "statisticsSelectData": 1, 59 "threadIds": Any<Number>, 60 "trackIds": Any<Number>, 61} 62`); 63 }); 64 65 it('BoxSelectionTest02', function () { 66 boxJumpParam = { 67 leftNs: 0, 68 rightNs: 0, 69 state: "", 70 processId: 0, 71 threadId: 0, 72 }; 73 expect(boxJumpParam).not.toBeUndefined() 74 expect(boxJumpParam).toMatchInlineSnapshot({ 75 leftNs: expect.any(Number), 76 rightNs: expect.any(Number), 77 state: expect.any(String), 78 processId: expect.any(Number), 79 threadId: expect.any(Number) }, ` 80Object { 81 "leftNs": Any<Number>, 82 "processId": Any<Number>, 83 "rightNs": Any<Number>, 84 "state": Any<String>, 85 "threadId": Any<Number>, 86} 87`); 88 }); 89 90 it('BoxSelectionTest03', function () { 91 selectionData = { 92 name: "name", 93 process: "process", 94 pid: "pid", 95 thread: "thread", 96 tid: "tid", 97 wallDuration: 0, 98 avgDuration: "avgDuration", 99 occurrences: 0, 100 state: "state", 101 trackId: 0, 102 delta: "delta", 103 rate: "rate", 104 avgWeight: "avgWeight", 105 count: "count", 106 first: "first", 107 last: "last", 108 min: "min", 109 max: "max", 110 stateJX: "stateJX", 111 }; 112 expect(selectionData).not.toBeUndefined() 113 expect(selectionData).toMatchInlineSnapshot({ 114 process: expect.any(String), 115 pid: expect.any(String), 116 thread: expect.any(String), 117 tid: expect.any(String), 118 wallDuration: expect.any(Number), 119 avgDuration: expect.any(String), 120 occurrences: expect.any(Number), 121 state: expect.any(String), 122 trackId: expect.any(Number), 123 delta: expect.any(String), 124 rate: expect.any(String), 125 avgWeight: expect.any(String), 126 count: expect.any(String), 127 first: expect.any(String), 128 last: expect.any(String), 129 min: expect.any(String), 130 max: expect.any(String), 131 stateJX: expect.any(String) }, ` 132Object { 133 "avgDuration": Any<String>, 134 "avgWeight": Any<String>, 135 "count": Any<String>, 136 "delta": Any<String>, 137 "first": Any<String>, 138 "last": Any<String>, 139 "max": Any<String>, 140 "min": Any<String>, 141 "name": "name", 142 "occurrences": Any<Number>, 143 "pid": Any<String>, 144 "process": Any<String>, 145 "rate": Any<String>, 146 "state": Any<String>, 147 "stateJX": Any<String>, 148 "thread": Any<String>, 149 "tid": Any<String>, 150 "trackId": Any<Number>, 151 "wallDuration": Any<Number>, 152} 153`); 154 }); 155 156 it('BoxSelectionTest04', function () { 157 counter = { 158 id: 0, 159 trackId: 0, 160 name: "", 161 value: 0, 162 startTime: 0, 163 }; 164 expect(counter).not.toBeUndefined() 165 expect(counter).toMatchInlineSnapshot({ 166 id: expect.any(Number), 167 trackId: expect.any(Number), 168 name: expect.any(String), 169 value: expect.any(Number), 170 startTime: expect.any(Number) }, ` 171Object { 172 "id": Any<Number>, 173 "name": Any<String>, 174 "startTime": Any<Number>, 175 "trackId": Any<Number>, 176 "value": Any<Number>, 177} 178`) 179 }); 180 181 it('BoxSelectionTest05', function () { 182 fps = { 183 startNS: 0, 184 timeStr: "", 185 fps: 0, 186 }; 187 expect(fps).not.toBeUndefined() 188 expect(fps).toMatchInlineSnapshot({ 189 startNS: expect.any(Number), 190 timeStr: expect.any(String), 191 fps: expect.any(Number) }, ` 192Object { 193 "fps": Any<Number>, 194 "startNS": Any<Number>, 195 "timeStr": Any<String>, 196} 197`); 198 }); 199}) 200