1/* 2 * Copyright (C) 2022 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 {WindowManagerState} from 'trace/flickerlib/windows/WindowManagerState'; 18import {Parser} from 'trace/parser'; 19import {Timestamp, TimestampType} from 'trace/timestamp'; 20import {TraceType} from 'trace/trace_type'; 21 22describe('ParserWindowManagerDump', () => { 23 let parser: Parser<WindowManagerState>; 24 25 beforeAll(async () => { 26 parser = await UnitTestUtils.getParser('traces/dump_WindowManager.pb'); 27 }); 28 29 it('has expected trace type', () => { 30 expect(parser.getTraceType()).toEqual(TraceType.WINDOW_MANAGER); 31 }); 32 33 it('provides elapsed timestamp (always zero)', () => { 34 const expected = [new Timestamp(TimestampType.ELAPSED, 0n)]; 35 expect(parser.getTimestamps(TimestampType.ELAPSED)).toEqual(expected); 36 }); 37 38 it('provides real timestamp (always zero)', () => { 39 const expected = [new Timestamp(TimestampType.REAL, 0n)]; 40 expect(parser.getTimestamps(TimestampType.REAL)).toEqual(expected); 41 }); 42 43 it('retrieves trace entry', async () => { 44 const entry = await parser.getEntry(0, TimestampType.ELAPSED); 45 expect(entry).toBeInstanceOf(WindowManagerState); 46 expect(BigInt(entry.timestamp.elapsedNanos.toString())).toEqual(0n); 47 }); 48}); 49