1/* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import {browser, by, element, ElementFinder} from 'protractor'; 18import {E2eTestUtils} from './utils'; 19 20describe('Trace navigation', () => { 21 const DEFAULT_TIMEOUT_MS = 1000; 22 23 beforeEach(async () => { 24 await E2eTestUtils.beforeEach(DEFAULT_TIMEOUT_MS); 25 await browser.get(E2eTestUtils.WINSCOPE_URL); 26 }); 27 28 it('can go between home and trace view pages correctly', async () => { 29 await E2eTestUtils.uploadFixture( 30 'traces/perfetto/layers_trace.perfetto-trace', 31 ); 32 await checkHomepage(); 33 await E2eTestUtils.closeSnackBar(); 34 await E2eTestUtils.clickViewTracesButton(); 35 await checkTraceViewPage(); 36 37 await E2eTestUtils.clickUploadNewButton(); 38 await checkHomepage(); 39 }); 40 41 async function checkHomepage() { 42 const toolbar = element(by.css('.toolbar')); 43 const elements = [ 44 toolbar.element(by.css('.app-title')), 45 toolbar.element(by.css('.documentation')), 46 toolbar.element(by.css('.report-bug')), 47 toolbar.element(by.css('.dark-mode')), 48 element(by.css('.welcome-info')), 49 element(by.css('collect-traces')), 50 element(by.css('upload-traces')), 51 ]; 52 await checkElementsPresent(elements); 53 } 54 55 async function checkTraceViewPage() { 56 const toolbar = element(by.css('.toolbar')); 57 const elements = [ 58 toolbar.element(by.css('.app-title')), 59 toolbar.element(by.css('.file-descriptor')), 60 toolbar.element(by.css('.upload-new')), 61 toolbar.element(by.css('.save-button')), 62 toolbar.element(by.css('.documentation')), 63 toolbar.element(by.css('.report-bug')), 64 toolbar.element(by.css('.dark-mode')), 65 element(by.css('viewer-surface-flinger')), 66 element(by.css('timeline')), 67 ]; 68 await checkElementsPresent(elements); 69 } 70 71 async function checkElementsPresent(elements: ElementFinder[]) { 72 for (const element of elements) { 73 expect(await element.isPresent()).toBeTruthy(); 74 } 75 } 76}); 77