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'; 17 18test.describe.configure({mode: 'serial'}); 19 20let pth: PerfettoTestHelper; 21let page: Page; 22 23const SQL_QUERY = `select id, ts, dur, name, category, track_id from slices 24where category is not null limit 1000`; 25 26test.beforeAll(async ({browser}, _testInfo) => { 27 page = await browser.newPage(); 28 pth = new PerfettoTestHelper(page); 29 await pth.openTraceFile('api34_startup_cold.perfetto-trace'); 30}); 31 32test('debug tracks', async () => { 33 const omnibox = page.locator('input[ref=omnibox]'); 34 await omnibox.focus(); 35 await omnibox.selectText(); 36 await omnibox.press(':'); 37 await pth.waitForPerfettoIdle(); 38 await omnibox.fill(SQL_QUERY); 39 await pth.waitForPerfettoIdle(); 40 await omnibox.press('Enter'); 41 await pth.waitForPerfettoIdle(); 42 43 await page.getByRole('button', {name: 'Show debug track'}).click(); 44 await pth.waitForPerfettoIdle(); 45 await page.keyboard.type('debug track'); // The track name 46 await page.keyboard.press('Enter'); 47 await pth.waitForPerfettoIdle(); 48 await pth.waitForIdleAndScreenshot('debug track added.png'); 49 50 // Click on a slice on the debug track. 51 await page.mouse.click(590, 180); 52 await pth.waitForPerfettoIdle(); 53 await pth.waitForIdleAndScreenshot('debug slice clicked.png'); 54 55 // Close the debug track. 56 await pth.locateTrack('debug track').getByText('close').first().click(); 57 await pth.waitForPerfettoIdle(); 58 await pth.waitForIdleAndScreenshot('debug track removed.png'); 59}); 60 61test('debug tracks pivot', async () => { 62 const omnibox = page.locator('input[ref=omnibox]'); 63 await omnibox.focus(); 64 await omnibox.selectText(); 65 await omnibox.press(':'); 66 await pth.waitForPerfettoIdle(); 67 await omnibox.fill(SQL_QUERY); 68 await pth.waitForPerfettoIdle(); 69 await omnibox.press('Enter'); 70 71 await page.getByRole('button', {name: 'Show debug track'}).click(); 72 await pth.waitForPerfettoIdle(); 73 await page.keyboard.type('pivot'); // The track name 74 await page.locator('.pf-popup-portal #pivot').selectOption('category'); 75 await page.keyboard.press('Enter'); 76 await pth.waitForPerfettoIdle(); 77 await pth.waitForIdleAndScreenshot('debug track pivot.png', { 78 clip: { 79 x: (await pth.sidebarSize()).width, 80 y: 180, 81 width: 1920, 82 height: 600, 83 }, 84 }); 85}); 86