1/* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16import {UnitTestUtils} from 'test/unit/utils'; 17import {CustomQueryType} from 'trace/custom_query'; 18import {TraceType} from 'trace/trace_type'; 19 20describe('WmCustomQueryUtils', () => 21 (async () => { 22 it('parseWindowsTokenAndTitle()', async () => { 23 const trace = await UnitTestUtils.getTrace( 24 TraceType.WINDOW_MANAGER, 25 'traces/elapsed_and_real_timestamp/WindowManager.pb', 26 ); 27 const tokenAndTitles = await trace 28 .sliceEntries(0, 1) 29 .customQuery(CustomQueryType.WM_WINDOWS_TOKEN_AND_TITLE); 30 31 expect(tokenAndTitles.length).toEqual(69); 32 33 // RootWindowContainerProto 34 expect(tokenAndTitles).toContain({ 35 token: '478edff', 36 title: 'WindowContainer', 37 }); 38 // DisplayContentProto 39 expect(tokenAndTitles).toContain({ 40 token: '1f3454e', 41 title: 'Built-in Screen', 42 }); 43 // DisplayAreaProto 44 expect(tokenAndTitles).toContain({token: 'c06766f', title: 'Leaf:36:36'}); 45 // WindowTokenProto 46 expect(tokenAndTitles).toContain({token: '509ad2f', title: '509ad2f'}); 47 // WindowStateProto 48 expect(tokenAndTitles).toContain({ 49 token: 'b3b210d', 50 title: 'ScreenDecorOverlay', 51 }); 52 // TaskProto 53 expect(tokenAndTitles).toContain({token: '7493986', title: 'Task'}); 54 // ActivityRecordProto 55 expect(tokenAndTitles).toContain({ 56 token: 'f7092ed', 57 title: 'com.google.android.apps.nexuslauncher/.NexusLauncherActivity', 58 }); 59 }); 60 })()); 61