xref: /aosp_15_r20/development/tools/winscope/src/test/e2e/viewer_transactions_test.ts (revision 90c8c64db3049935a07c6143d7fd006e26f8ecca)
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 */
16
17import {browser, by, element} from 'protractor';
18import {E2eTestUtils} from './utils';
19
20describe('Viewer Transactions', () => {
21  const viewerSelector = 'viewer-transactions';
22  const totalEntries = 9534;
23
24  beforeEach(async () => {
25    await E2eTestUtils.beforeEach(2000);
26    await browser.get(E2eTestUtils.WINSCOPE_URL);
27  });
28
29  it('processes trace from zip and navigates correctly', async () => {
30    await E2eTestUtils.loadTraceAndCheckViewer(
31      'traces/deployment_full_trace_phone.zip',
32      'Transactions',
33      viewerSelector,
34    );
35    await E2eTestUtils.checkTotalScrollEntries(
36      viewerSelector,
37      totalEntries,
38      true,
39    );
40    await E2eTestUtils.checkTimelineTraceSelector({
41      icon: 'show_chart',
42      color: 'rgba(13, 101, 45, 1)',
43    });
44    await E2eTestUtils.checkFinalRealTimestamp('2022-11-21, 18:05:19.592');
45    await E2eTestUtils.checkInitialRealTimestamp('2022-11-21, 11:36:19.513');
46
47    await E2eTestUtils.changeRealTimestampInWinscope(
48      '2022-11-21, 18:05:17.505',
49    );
50    await E2eTestUtils.checkWinscopeRealTimestamp('18:05:17.505');
51    await checkSelectedEntry();
52    await checkSelectFilter('.pid', ['6914'], 2);
53    await checkSelectFilter('.uid', ['10161'], 16);
54    await checkSelectFilter('.flags', ['eBackgroundBlurRadiusChanged'], 10);
55    await new Promise<void>((resolve) => setTimeout(resolve, 1000));
56  });
57
58  async function checkSelectedEntry() {
59    const selectedEntry = element(by.css(`${viewerSelector} .scroll .current`));
60    expect(await selectedEntry.isPresent()).toBeTruthy();
61
62    const transactionId = selectedEntry.element(by.css('.transaction-id'));
63    expect(await transactionId.getText()).toEqual('7975754272149');
64
65    const vsyncId = selectedEntry.element(by.css('.vsyncid'));
66    expect(await vsyncId.getText()).toEqual('93389');
67
68    const pid = selectedEntry.element(by.css('.pid'));
69    expect(await pid.getText()).toEqual('1857');
70
71    const uid = selectedEntry.element(by.css('.uid'));
72    expect(await uid.getText()).toEqual('1000');
73
74    const type = selectedEntry.element(by.css('.transaction-type'));
75    expect(await type.getText()).toEqual('LAYER_CHANGED');
76
77    const layerOrDisplayId = selectedEntry.element(
78      by.css('.layer-or-display-id'),
79    );
80    expect(await layerOrDisplayId.getText()).toEqual('798');
81
82    const whatString =
83      'eLayerChanged | eAlphaChanged | eFlagsChanged | eReparent | eColorChanged | eHasListenerCallbacksChanged';
84    const what = selectedEntry.element(by.css('.flags'));
85    expect(await what.getText()).toEqual(whatString);
86
87    await E2eTestUtils.checkItemInPropertiesTree(
88      viewerSelector,
89      'what',
90      'what:\n' + whatString,
91    );
92    await E2eTestUtils.checkItemInPropertiesTree(
93      viewerSelector,
94      'color',
95      'color:\n(0.106, 0.106, 0.106)',
96    );
97  }
98
99  async function checkSelectFilter(
100    filterSelector: string,
101    options: string[],
102    expectedFilteredEntries: number,
103  ) {
104    await E2eTestUtils.toggleSelectFilterOptions(
105      viewerSelector,
106      filterSelector,
107      options,
108    );
109    await E2eTestUtils.checkTotalScrollEntries(
110      viewerSelector,
111      expectedFilteredEntries,
112    );
113
114    await E2eTestUtils.toggleSelectFilterOptions(
115      viewerSelector,
116      filterSelector,
117      options,
118    );
119    await E2eTestUtils.checkTotalScrollEntries(
120      viewerSelector,
121      totalEntries,
122      true,
123    );
124  }
125});
126