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, expect} from '@playwright/test'; 16import {PerfettoTestHelper} from './perfetto_ui_test_helper'; 17 18test('multiple traces via url and local_cache_key', async ({browser}) => { 19 const page = await browser.newPage(); 20 const pth = new PerfettoTestHelper(page); 21 22 // Open first trace. 23 await pth.navigate( 24 '#!/?url=http://127.0.0.1:10000/test/data/perf_sample_annotations.pftrace', 25 ); 26 const cacheKey1 = page.url().match(/local_cache_key=([a-z0-9-]+)/)![1]; 27 await pth.waitForIdleAndScreenshot('trace_1.png'); 28 29 // Open second trace. 30 await pth.navigate( 31 '#!/?url=http://127.0.0.1:10000/test/data/atrace_compressed.ctrace', 32 ); 33 const cacheKey2 = page.url().match(/local_cache_key=([a-z0-9-]+)/)![1]; 34 expect(cacheKey1).not.toEqual(cacheKey2); 35 await pth.waitForIdleAndScreenshot('trace_2.png'); 36 37 // Navigate back to the first trace. A confirmation dialog will be shown 38 await pth.navigate('#!/viewer?local_cache_key=' + cacheKey1); 39 await pth.waitForIdleAndScreenshot('confirmation_dialog.png'); 40 41 await page.locator('button.modal-btn-primary').click(); 42 await pth.waitForPerfettoIdle(); 43 await pth.waitForIdleAndScreenshot('back_to_trace_1.png'); 44}); 45