• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2024 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 {CujType} from 'parsers/events/cuj_type';
18import {EventTag} from 'parsers/events/event_tag';
19import {PropertyTreeBuilder} from 'test/unit/property_tree_builder';
20import {AddCujProperties} from './add_cuj_properties';
21
22describe('AddCujProperties', () => {
23  let operation: AddCujProperties;
24
25  beforeEach(() => {
26    operation = new AddCujProperties();
27  });
28
29  it('adds all cuj properties', () => {
30    const propertyRoot = new PropertyTreeBuilder()
31      .setRootId('EventLogTrace')
32      .setName('event')
33      .setIsRoot(true)
34      .setChildren([
35        {name: 'eventTimestamp', value: 1681207048025596830n},
36        {name: 'pid', value: 2806},
37        {name: 'uid', value: 10227},
38        {name: 'tid', value: 3604},
39        {name: 'tag', value: EventTag.JANK_CUJ_BEGIN_TAG},
40        {
41          name: 'eventData',
42          value: '[66,1681207048025580000,2661012903966,2661012904007,]',
43        },
44      ])
45      .build();
46
47    const expectedRoot = new PropertyTreeBuilder()
48      .setRootId('EventLogTrace')
49      .setName('event')
50      .setIsRoot(true)
51      .setChildren([
52        {name: 'eventTimestamp', value: 1681207048025596830n},
53        {name: 'pid', value: 2806},
54        {name: 'uid', value: 10227},
55        {name: 'tid', value: 3604},
56        {name: 'tag', value: EventTag.JANK_CUJ_BEGIN_TAG},
57        {
58          name: 'eventData',
59          value: '[66,1681207048025580000,2661012903966,2661012904007,]',
60        },
61        {name: 'cujType', value: CujType.CUJ_LAUNCHER_APP_SWIPE_TO_RECENTS},
62        {
63          name: 'cujTimestamp',
64          children: [
65            {name: 'unixNanos', value: 1681207048025580000n},
66            {name: 'elapsedNanos', value: 2661012903966n},
67            {name: 'systemUptimeNanos', value: 2661012904007n},
68          ],
69        },
70        {name: 'cujTag', value: undefined},
71      ])
72      .build();
73
74    operation.apply(propertyRoot);
75    expect(propertyRoot).toEqual(expectedRoot);
76  });
77});
78