xref: /aosp_15_r20/external/perfetto/ui/src/test/wattson.test.ts (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1// Copyright (C) 2024 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15import {test, Page} from '@playwright/test';
16import {PerfettoTestHelper} from './perfetto_ui_test_helper';
17import {assertExists} from '../base/logging';
18
19test.describe.configure({mode: 'serial'});
20
21let pth: PerfettoTestHelper;
22let page: Page;
23
24// Clip only the bottom half of the UI. When dealing with area selection, the
25// time-width of the mouse-based region (which then is showed up in the upper
26// ruler) is not 100% reproducible.
27const SCREEN_CLIP = {
28  clip: {
29    x: 230,
30    y: 500,
31    width: 1920,
32    height: 1080,
33  },
34};
35
36test.beforeAll(async ({browser}, _testInfo) => {
37  page = await browser.newPage();
38  pth = new PerfettoTestHelper(page);
39  await pth.openTraceFile('wattson_dsu_pmu.pb');
40});
41
42test('wattson aggregations', async () => {
43  const wattsonGrp = pth.locateTrackGroup('Wattson');
44  await wattsonGrp.scrollIntoViewIfNeeded();
45  await pth.toggleTrackGroup(wattsonGrp);
46  const cpuEstimate = pth.locateTrack('Wattson/Cpu0 Estimate', wattsonGrp);
47  const coords = assertExists(await cpuEstimate.boundingBox());
48  await page.keyboard.press('Escape');
49  await page.mouse.move(600, coords.y + 10);
50  await page.mouse.down();
51  await page.mouse.move(1000, coords.y + 80);
52  await page.mouse.up();
53  await pth.waitForIdleAndScreenshot('wattson-estimate-aggr.png', SCREEN_CLIP);
54  await page.keyboard.press('Escape');
55});
56
57test('sched aggregations', async () => {
58  await page.keyboard.press('Escape');
59  await page.mouse.move(600, 250);
60  await page.mouse.down();
61  await page.mouse.move(800, 350);
62  await page.mouse.up();
63  await pth.waitForPerfettoIdle();
64
65  await page.click('button[label="Wattson by thread"]');
66  await pth.waitForIdleAndScreenshot('sched-aggr-thread.png', SCREEN_CLIP);
67
68  await page.click('button[label="Wattson by process"]');
69  await pth.waitForIdleAndScreenshot('sched-aggr-process.png', SCREEN_CLIP);
70
71  await page.keyboard.press('Escape');
72});
73