1/* 2 * Copyright (C) 2022 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} from 'protractor'; 18import {E2eTestUtils} from './utils'; 19 20describe('Upload traces', () => { 21 const DEFAULT_TIMEOUT_MS = 20000; 22 23 beforeAll(async () => { 24 jasmine.DEFAULT_TIMEOUT_INTERVAL = DEFAULT_TIMEOUT_MS; 25 }); 26 27 beforeEach(async () => { 28 await E2eTestUtils.beforeEach(DEFAULT_TIMEOUT_MS); 29 await browser.get(E2eTestUtils.WINSCOPE_URL); 30 }); 31 32 it('can clear all files', async () => { 33 await E2eTestUtils.loadBugReport(DEFAULT_TIMEOUT_MS); 34 await E2eTestUtils.clickClearAllButton(); 35 await checkNoFilesUploaded(); 36 }); 37 38 it('can remove a file using the close icon', async () => { 39 await E2eTestUtils.loadBugReport(DEFAULT_TIMEOUT_MS); 40 await E2eTestUtils.clickCloseIcon(); 41 await checkFileRemoved(); 42 }); 43 44 it('can replace an uploaded file with a new file', async () => { 45 await E2eTestUtils.loadBugReport(DEFAULT_TIMEOUT_MS); 46 await E2eTestUtils.uploadFixture( 47 'traces/perfetto/layers_trace.perfetto-trace', 48 ); 49 await checkFileReplaced(); 50 }); 51 52 it('can process bugreport', async () => { 53 await E2eTestUtils.loadBugReport(DEFAULT_TIMEOUT_MS); 54 await E2eTestUtils.clickViewTracesButton(); 55 await checkRendersSurfaceFlingerView(); 56 }); 57 58 async function checkRendersSurfaceFlingerView() { 59 const viewerPresent = await element( 60 by.css('viewer-surface-flinger'), 61 ).isPresent(); 62 expect(viewerPresent).toBeTruthy(); 63 } 64 65 it("doesn't emit messages for valid trace file", async () => { 66 await E2eTestUtils.uploadFixture( 67 'traces/elapsed_and_real_timestamp/SurfaceFlinger.pb', 68 ); 69 expect( 70 await E2eTestUtils.areMessagesEmitted(DEFAULT_TIMEOUT_MS), 71 ).toBeFalsy(); 72 }); 73 74 async function checkNoFilesUploaded() { 75 // default timeout to understand whether the messages where emitted or not. 76 await browser.manage().timeouts().implicitlyWait(1000); 77 const filesUploaded = await element(by.css('.uploaded-files')).isPresent(); 78 await browser.manage().timeouts().implicitlyWait(DEFAULT_TIMEOUT_MS); 79 expect(filesUploaded).toBeFalsy(); 80 } 81 82 async function checkFileRemoved() { 83 const text = await element(by.css('.uploaded-files')).getText(); 84 expect(text).toContain('Window Manager'); 85 expect(text).not.toContain('Surface Flinger'); 86 expect(text).toContain('Transactions'); 87 expect(text).toContain('Transitions'); 88 } 89 90 async function checkFileReplaced() { 91 const text = await element(by.css('.uploaded-files')).getText(); 92 expect(text).toContain('Surface Flinger'); 93 94 expect(text).not.toContain('layers_trace_from_transactions.winscope'); 95 expect(text).toContain('layers_trace.perfetto-trace'); 96 } 97}); 98