diff --git a/test/data/ui-screenshots/aggregation.test.ts/frametimeline/frame-timeline-aggregation.png.sha256 b/test/data/ui-screenshots/aggregation.test.ts/frametimeline/frame-timeline-aggregation.png.sha256 new file mode 100644 index 0000000000..1fad109eb3 --- /dev/null +++ b/test/data/ui-screenshots/aggregation.test.ts/frametimeline/frame-timeline-aggregation.png.sha256 @@ -0,0 +1 @@ +0e784faccf85b5c08465495053c9a4114ff3162c2d4d8a8bc78bbcf95469d0d2 \ No newline at end of file diff --git a/test/data/ui-screenshots/aggregation.test.ts/gpu-counter/gpu-counter-aggregation.png.sha256 b/test/data/ui-screenshots/aggregation.test.ts/gpu-counter/gpu-counter-aggregation.png.sha256 new file mode 100644 index 0000000000..0afb8150e4 --- /dev/null +++ b/test/data/ui-screenshots/aggregation.test.ts/gpu-counter/gpu-counter-aggregation.png.sha256 @@ -0,0 +1 @@ +f7bb521a4590836dfeb5671c8cdda8b49ebea6cd6a44d4a1ea9c4e921076be92 \ No newline at end of file diff --git a/test/data/ui-screenshots/aggregation.test.ts/sched/cpu-by-process.png.sha256 b/test/data/ui-screenshots/aggregation.test.ts/sched/cpu-by-process.png.sha256 new file mode 100644 index 0000000000..5efcbd050c --- /dev/null +++ b/test/data/ui-screenshots/aggregation.test.ts/sched/cpu-by-process.png.sha256 @@ -0,0 +1 @@ +f72742ac692767575a225ca2067e4fa4f285548dea2f9b187ea081325717edb1 \ No newline at end of file diff --git a/test/data/ui-screenshots/aggregation.test.ts/sched/cpu-by-thread.png.sha256 b/test/data/ui-screenshots/aggregation.test.ts/sched/cpu-by-thread.png.sha256 new file mode 100644 index 0000000000..2006c4fe00 --- /dev/null +++ b/test/data/ui-screenshots/aggregation.test.ts/sched/cpu-by-thread.png.sha256 @@ -0,0 +1 @@ +8d15ffc392959dcaecf7544f530b7d73ff255b6cd904138060858c46fdc49517 \ No newline at end of file diff --git a/test/data/ui-screenshots/aggregation.test.ts/sched/sort-by-occurrences.png.sha256 b/test/data/ui-screenshots/aggregation.test.ts/sched/sort-by-occurrences.png.sha256 new file mode 100644 index 0000000000..5e18a34553 --- /dev/null +++ b/test/data/ui-screenshots/aggregation.test.ts/sched/sort-by-occurrences.png.sha256 @@ -0,0 +1 @@ +026a1a1a9606b55cc60f389c1f39ff0e004cbe784c88679e6c491cf332f0ea66 \ No newline at end of file diff --git a/test/data/ui-screenshots/aggregation.test.ts/sched/sort-by-wall-duration-desc.png.sha256 b/test/data/ui-screenshots/aggregation.test.ts/sched/sort-by-wall-duration-desc.png.sha256 new file mode 100644 index 0000000000..d4b5a98361 --- /dev/null +++ b/test/data/ui-screenshots/aggregation.test.ts/sched/sort-by-wall-duration-desc.png.sha256 @@ -0,0 +1 @@ +0cf9d54fcc5276d4e7ad083d9d5e00dabf0b72bfeabebcf799e1ba09dde54074 \ No newline at end of file diff --git a/test/data/ui-screenshots/aggregation.test.ts/sched/sort-by-wall-duration.png.sha256 b/test/data/ui-screenshots/aggregation.test.ts/sched/sort-by-wall-duration.png.sha256 new file mode 100644 index 0000000000..2f255e40af --- /dev/null +++ b/test/data/ui-screenshots/aggregation.test.ts/sched/sort-by-wall-duration.png.sha256 @@ -0,0 +1 @@ +d5a12d3d1e9be18adc04d74bf8e73f249184f4741087473858ca1395e4140881 \ No newline at end of file diff --git a/test/data/ui-screenshots/aggregation.test.ts/slices/slice-aggregation.png.sha256 b/test/data/ui-screenshots/aggregation.test.ts/slices/slice-aggregation.png.sha256 new file mode 100644 index 0000000000..6b7adbda69 --- /dev/null +++ b/test/data/ui-screenshots/aggregation.test.ts/slices/slice-aggregation.png.sha256 @@ -0,0 +1 @@ +b659347d66b25d0be1da24782d700e8a4d9d7ce1396ed7f4a6255773f5fb16fa \ No newline at end of file diff --git a/test/data/ui-screenshots/chrome_rendering_desktop.test.ts/expand-browser/browser-expanded.png.sha256 b/test/data/ui-screenshots/chrome_rendering_desktop.test.ts/expand-browser/browser-expanded.png.sha256 index 63f69e0c8e..c63bd9276d 100644 --- a/test/data/ui-screenshots/chrome_rendering_desktop.test.ts/expand-browser/browser-expanded.png.sha256 +++ b/test/data/ui-screenshots/chrome_rendering_desktop.test.ts/expand-browser/browser-expanded.png.sha256 @@ -1 +1 @@ -575a4afab85e14f66cce2e38d5097a15e0ad1293bac686fdb999baf78ee4b313 \ No newline at end of file +7a70ac4a6166da36663ef7e79366e512fe84d9ec516e0d7f2b1b934661139767 \ No newline at end of file diff --git a/ui/src/test/aggregation.test.ts b/ui/src/test/aggregation.test.ts new file mode 100644 index 0000000000..449d23b1d1 --- /dev/null +++ b/ui/src/test/aggregation.test.ts @@ -0,0 +1,98 @@ +// Copyright (C) 2024 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import {test, Page} from '@playwright/test'; +import {PerfettoTestHelper} from './perfetto_ui_test_helper'; +import {assertExists} from '../base/logging'; + +test.describe.configure({mode: 'serial'}); + +let pth: PerfettoTestHelper; +let page: Page; + +test.beforeAll(async ({browser}, _testInfo) => { + page = await browser.newPage(); + pth = new PerfettoTestHelper(page); + await pth.openTraceFile('api34_startup_cold.perfetto-trace'); +}); + +test('sched', async () => { + await page.mouse.move(600, 250); + await page.mouse.down(); + await page.mouse.move(800, 350); + await page.mouse.up(); + await pth.waitForPerfettoIdle(); + await pth.waitForIdleAndScreenshot('cpu-by-thread.png'); + + await page.click('button[label="CPU by process"]'); + await pth.waitForIdleAndScreenshot('cpu-by-process.png'); + + // Now test sorting. + + const hdr = page.getByRole('cell', {name: 'Avg Wall duration (ms)'}); + await hdr.click(); + await pth.waitForIdleAndScreenshot('sort-by-wall-duration.png'); + + await hdr.click(); + await pth.waitForIdleAndScreenshot('sort-by-wall-duration-desc.png'); + + await page.getByRole('cell', {name: 'Occurrences'}).click(); + await pth.waitForIdleAndScreenshot('sort-by-occurrences.png'); +}); + +test('gpu counter', async () => { + await page.keyboard.press('Escape'); + const gpuTrack = pth.locateTrack('Gpu 0 Frequency'); + const coords = assertExists(await gpuTrack.boundingBox()); + await page.mouse.move(600, coords.y + 10); + await page.mouse.down(); + await page.mouse.move(800, coords.y + 60); + await page.mouse.up(); + await pth.waitForIdleAndScreenshot('gpu-counter-aggregation.png'); +}); + +test('frametimeline', async () => { + await page.keyboard.press('Escape'); + const sysui = pth.locateTrackGroup('com.android.systemui 25348'); + await sysui.scrollIntoViewIfNeeded(); + await pth.toggleTrackGroup(sysui); + const actualTimeline = pth.locateTrack( + 'com.android.systemui 25348/Actual Timeline', + sysui, + ); + const coords = assertExists(await actualTimeline.boundingBox()); + await page.mouse.move(600, coords.y + 10); + await page.mouse.down(); + await page.mouse.move(1000, coords.y + 20); + await page.mouse.up(); + await pth.waitForIdleAndScreenshot('frame-timeline-aggregation.png'); +}); + +test('slices', async () => { + await page.keyboard.press('Escape'); + const syssrv = pth.locateTrackGroup('system_server 1719'); + await syssrv.scrollIntoViewIfNeeded(); + await pth.toggleTrackGroup(syssrv); + const animThread = pth + .locateTrack('system_server 1719/android.anim 1754', syssrv) + .nth(1); + await animThread.scrollIntoViewIfNeeded(); + await pth.waitForPerfettoIdle(); + const coords = assertExists(await animThread.boundingBox()); + await page.mouse.move(600, coords.y + 10); + await page.mouse.down(); + await page.mouse.move(1000, coords.y + 20); + await page.mouse.up(); + await pth.waitForIdleAndScreenshot('slice-aggregation.png'); +}); diff --git a/ui/src/test/chrome_rendering_desktop.test.ts b/ui/src/test/chrome_rendering_desktop.test.ts index 9293c185ae..11c96cc4fe 100644 --- a/ui/src/test/chrome_rendering_desktop.test.ts +++ b/ui/src/test/chrome_rendering_desktop.test.ts @@ -31,13 +31,11 @@ test('load trace', async () => { }); test('expand browser', async () => { - const title = page.locator( - `h1.pf-track-title.pf-clickable[ref="Browser 12685"]`, - ); - title.scrollIntoViewIfNeeded(); - await title.click(); + const grp = pth.locateTrackGroup('Browser 12685'); + grp.scrollIntoViewIfNeeded(); + await pth.toggleTrackGroup(grp); await pth.waitForIdleAndScreenshot('browser_expanded.png'); - await title.click(); + await pth.toggleTrackGroup(grp); }); test('slice with flows', async () => { diff --git a/ui/src/test/independent_features.test.ts b/ui/src/test/independent_features.test.ts index 98e945fbb5..329493ce33 100644 --- a/ui/src/test/independent_features.test.ts +++ b/ui/src/test/independent_features.test.ts @@ -29,6 +29,6 @@ test('debuggable chip', async ({browser}) => { await trackGroup.scrollIntoViewIfNeeded(); await pth.waitForIdleAndScreenshot('track_with_debuggable_chip.png'); - await trackGroup.locator('.pf-track-title').click(); + await pth.toggleTrackGroup(trackGroup); await pth.waitForIdleAndScreenshot('track_with_debuggable_chip_expanded.png'); }); diff --git a/ui/src/test/load_and_tracks.test.ts b/ui/src/test/load_and_tracks.test.ts index 50557e966e..cc95a8aa79 100644 --- a/ui/src/test/load_and_tracks.test.ts +++ b/ui/src/test/load_and_tracks.test.ts @@ -93,8 +93,7 @@ test('track expand and collapse', async () => { test('pin tracks', async () => { const trackGroup = pth.locateTrackGroup('traced 1055'); - await trackGroup.locator('.pf-track-title').click(); - await pth.waitForPerfettoIdle(); + await pth.toggleTrackGroup(trackGroup); let track = pth.locateTrack('traced 1055/mem.rss', trackGroup); await pth.pinTrackUsingShellBtn(track); await pth.waitForPerfettoIdle(); diff --git a/ui/src/test/perfetto_ui_test_helper.ts b/ui/src/test/perfetto_ui_test_helper.ts index 878dd6401d..40bbe40310 100644 --- a/ui/src/test/perfetto_ui_test_helper.ts +++ b/ui/src/test/perfetto_ui_test_helper.ts @@ -52,6 +52,9 @@ export class PerfettoTestHelper { const file = await this.page.waitForSelector('input.trace_file', { state: 'attached', }); + await this.page.evaluate(() => + localStorage.setItem('dismissedPanningHint', 'true'), + ); const tracePath = this.getTestTracePath(traceName); assertExists(file).setInputFiles(tracePath); await this.waitForPerfettoIdle(); @@ -82,6 +85,11 @@ export class PerfettoTestHelper { .filter({has: this.page.locator(`h1[ref="${name}"]`)}); } + async toggleTrackGroup(locator: Locator) { + await locator.locator('.pf-track-title').first().click(); + await this.waitForPerfettoIdle(); + } + locateTrack(name: string, trackGroup?: Locator): Locator { return (trackGroup ?? this.page) .locator('.pf-track')