• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {UnitTestUtils} from 'test/unit/utils';
18import {Transition} from 'trace/flickerlib/common';
19import {Parser} from 'trace/parser';
20import {Timestamp, TimestampType} from 'trace/timestamp';
21import {TraceType} from 'trace/trace_type';
22
23describe('ParserTransitions', () => {
24  let parser: Parser<Transition>;
25
26  beforeAll(async () => {
27    parser = await UnitTestUtils.getTracesParser([
28      'traces/elapsed_and_real_timestamp/wm_transition_trace.pb',
29      'traces/elapsed_and_real_timestamp/shell_transition_trace.pb',
30    ]);
31  });
32
33  it('has expected trace type', () => {
34    expect(parser.getTraceType()).toEqual(TraceType.TRANSITION);
35  });
36
37  it('provides elapsed timestamps', () => {
38    const timestamps = parser.getTimestamps(TimestampType.ELAPSED)!;
39
40    expect(timestamps.length).toEqual(4);
41
42    const expected = [
43      new Timestamp(TimestampType.ELAPSED, 57649586217344n),
44      new Timestamp(TimestampType.ELAPSED, 57649691956439n),
45      new Timestamp(TimestampType.ELAPSED, 57651263812071n),
46    ];
47    expect(timestamps.slice(0, 3)).toEqual(expected);
48  });
49
50  it('provides real timestamps', () => {
51    const expected = [
52      new Timestamp(TimestampType.REAL, 1683188477542869667n),
53      new Timestamp(TimestampType.REAL, 1683188477648608762n),
54      new Timestamp(TimestampType.REAL, 1683188479220464394n),
55    ];
56
57    const timestamps = parser.getTimestamps(TimestampType.REAL)!;
58
59    expect(timestamps.length).toEqual(4);
60
61    expect(timestamps.slice(0, 3)).toEqual(expected);
62  });
63});
64