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 23test.beforeAll(async ({browser}, _testInfo) => { 24 page = await browser.newPage(); 25 pth = new PerfettoTestHelper(page); 26 await pth.openTraceFile('api34_startup_cold.perfetto-trace'); 27}); 28 29test('load trace', async () => { 30 await pth.waitForIdleAndScreenshot('loaded.png'); 31}); 32 33test('info and stats', async () => { 34 await pth.navigate('#!/info'); 35 await pth.waitForIdleAndScreenshot('into_and_stats.png'); 36 await pth.navigate('#!/viewer'); 37 await pth.waitForIdleAndScreenshot('back_to_timeline.png'); 38}); 39 40test('omnibox search', async () => { 41 await pth.searchSlice('composite 572441'); 42 await pth.resetFocus(); 43 await page.keyboard.press('f'); 44 await pth.waitForPerfettoIdle(); 45 await pth.waitForIdleAndScreenshot('search_slice.png'); 46 47 // Click on show process details in the details panel. 48 await page.getByText('/system/bin/surfaceflinger [598]').click(); 49 await page.getByText('Show process details').click(); 50 await pth.waitForIdleAndScreenshot('process_details.png'); 51}); 52 53test('mark', async () => { 54 await page.keyboard.press('/'); 55 await pth.waitForPerfettoIdle(); 56 57 await page.keyboard.type('doFrame'); 58 await pth.waitForPerfettoIdle(); 59 60 for (let i = 0; i < 4; i++) { 61 await page.keyboard.press('Enter'); 62 await pth.waitForPerfettoIdle(); 63 64 if (i == 2) { 65 await page.keyboard.press('Shift+M'); 66 } else { 67 await page.keyboard.press('m'); 68 } 69 await pth.waitForIdleAndScreenshot(`mark_${i}.png`); 70 } 71}); 72 73test('track expand and collapse', async () => { 74 const trackGroup = pth.locateTrack('traced_probes 1054'); 75 await trackGroup.scrollIntoViewIfNeeded(); 76 await pth.toggleTrackGroup(trackGroup); 77 await pth.waitForIdleAndScreenshot('traced_probes_expanded.png'); 78 79 // Click 5 times in rapid succession. 80 for (let i = 0; i < 5; i++) { 81 await trackGroup.click(); 82 await pth.waitForPerfettoIdle(50); 83 } 84 await pth.waitForIdleAndScreenshot('traced_probes_compressed.png'); 85}); 86 87test('pin tracks', async () => { 88 const trackGroup = pth.locateTrack('traced 1055'); 89 await pth.toggleTrackGroup(trackGroup); 90 let track = pth.locateTrack('traced 1055/mem.rss', trackGroup); 91 await pth.pinTrackUsingShellBtn(track); 92 await pth.waitForPerfettoIdle(); 93 await pth.waitForIdleAndScreenshot('one_track_pinned.png'); 94 95 track = pth.locateTrack('traced 1055/traced 1055', trackGroup); 96 await pth.pinTrackUsingShellBtn(track); 97 await pth.waitForPerfettoIdle(); 98 await pth.waitForIdleAndScreenshot('two_tracks_pinned.png'); 99}); 100