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 */ 16 17import {assertDefined} from 'common/assert_utils'; 18import { 19 TimestampConverterUtils, 20 timestampEqualityTester, 21} from 'common/time/test_utils'; 22import {UnitTestUtils} from 'test/unit/utils'; 23import {CoarseVersion} from 'trace/coarse_version'; 24import {Parser} from 'trace/parser'; 25import {TraceType} from 'trace/trace_type'; 26import {PropertyTreeNode} from 'trace/tree_node/property_tree_node'; 27 28describe('ParserTransitionsWm', () => { 29 let parser: Parser<PropertyTreeNode>; 30 31 beforeAll(async () => { 32 jasmine.addCustomEqualityTester(timestampEqualityTester); 33 parser = (await UnitTestUtils.getParser( 34 'traces/elapsed_and_real_timestamp/wm_transition_trace.pb', 35 )) as Parser<PropertyTreeNode>; 36 }); 37 38 it('has expected trace type', () => { 39 expect(parser.getTraceType()).toEqual(TraceType.WM_TRANSITION); 40 }); 41 42 it('has expected coarse version', () => { 43 expect(parser.getCoarseVersion()).toEqual(CoarseVersion.LEGACY); 44 }); 45 46 it('provides timestamps', () => { 47 const timestamps = assertDefined(parser.getTimestamps()); 48 expect(timestamps.length).toEqual(8); 49 const expected = TimestampConverterUtils.makeZeroTimestamp(); 50 timestamps.forEach((timestamp) => expect(timestamp).toEqual(expected)); 51 }); 52 53 it('translates flags', async () => { 54 const entry = await parser.getEntry(4); 55 expect( 56 entry.getChildByName('wmData')?.getChildByName('flags')?.formattedValue(), 57 ).toEqual('TRANSIT_FLAG_IS_RECENTS'); 58 59 const targets = entry.getChildByName('wmData')?.getChildByName('targets'); 60 expect( 61 targets?.getChildByName('0')?.getChildByName('flags')?.formattedValue(), 62 ).toEqual('FLAG_MOVED_TO_TOP | FLAG_SHOW_WALLPAPER'); 63 expect( 64 targets?.getChildByName('1')?.getChildByName('flags')?.formattedValue(), 65 ).toEqual('FLAG_NONE'); 66 }); 67}); 68