Patrick Brosset | dd3309c | 2020-05-18 13:35:25 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Patrick Brosset | 0805f4a | 2020-06-11 09:34:32 | [diff] [blame] | 5 | import {$, click, goToResource, waitFor} from '../../shared/helper.js'; |
Patrick Brosset | dd3309c | 2020-05-18 13:35:25 | [diff] [blame] | 6 | |
| 7 | const RECORD_BUTTON_SELECTOR = '[aria-label="Record"]'; |
| 8 | const STOP_BUTTON_SELECTOR = '[aria-label="Stop"]'; |
| 9 | |
Patrick Brosset | 60bf7bf | 2020-06-08 17:04:29 | [diff] [blame] | 10 | export async function navigateToPerformanceTab(testName?: string) { |
| 11 | if (testName) { |
Patrick Brosset | 0805f4a | 2020-06-11 09:34:32 | [diff] [blame] | 12 | await goToResource(`performance/${testName}.html`); |
Patrick Brosset | 60bf7bf | 2020-06-08 17:04:29 | [diff] [blame] | 13 | } |
Patrick Brosset | dd3309c | 2020-05-18 13:35:25 | [diff] [blame] | 14 | |
| 15 | // Click on the tab. |
| 16 | await click('#tab-timeline'); |
| 17 | |
| 18 | // Make sure the landing page is shown. |
| 19 | await waitFor('.timeline-landing-page'); |
| 20 | } |
| 21 | |
| 22 | export async function startRecording() { |
| 23 | await click(RECORD_BUTTON_SELECTOR); |
| 24 | |
Patrick Brosset | 60bf7bf | 2020-06-08 17:04:29 | [diff] [blame] | 25 | // Wait for the button to turn to its stop state. |
| 26 | await waitFor(STOP_BUTTON_SELECTOR); |
Patrick Brosset | dd3309c | 2020-05-18 13:35:25 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | export async function stopRecording() { |
| 30 | await click(STOP_BUTTON_SELECTOR); |
| 31 | |
| 32 | // Make sure the timeline details panel appears. It's a sure way to assert |
| 33 | // that a recording is actually displayed as some of the other elements in |
| 34 | // the timeline remain in the DOM even after the recording has been cleared. |
| 35 | await waitFor('.timeline-details-chip-body'); |
| 36 | } |
| 37 | |
| 38 | export async function getTotalTimeFromSummary(): Promise<number> { |
| 39 | const pieChartTotal = await $('.pie-chart-total'); |
Johan Bay | e824571 | 2020-08-04 13:32:10 | [diff] [blame^] | 40 | const totalText = await pieChartTotal.evaluate(node => node.textContent as string); |
Patrick Brosset | dd3309c | 2020-05-18 13:35:25 | [diff] [blame] | 41 | return parseInt(totalText, 10); |
| 42 | } |
Patrick Brosset | 60bf7bf | 2020-06-08 17:04:29 | [diff] [blame] | 43 | |
| 44 | export async function navigateToPerformanceSidebarTab(tabName: string) { |
| 45 | await click(`[aria-label="${tabName}"]`); |
| 46 | } |
| 47 | |
| 48 | export async function waitForSourceLinkAndFollowIt() { |
| 49 | const link = await waitFor('.devtools-link'); |
| 50 | await click(link); |
| 51 | await waitFor('.panel[aria-label="sources"]'); |
| 52 | } |