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