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 */ 16import {browser, by, element} from 'protractor'; 17import {E2eTestUtils} from './utils'; 18 19describe('Viewer Screenshot', () => { 20 const viewerSelector = 'viewer-media-based'; 21 22 beforeEach(async () => { 23 await E2eTestUtils.beforeEach(1000); 24 await browser.get(E2eTestUtils.WINSCOPE_URL); 25 }); 26 27 it('processes file and renders view', async () => { 28 await E2eTestUtils.uploadFixture('traces/screenshot.png'); 29 await E2eTestUtils.closeSnackBar(); 30 await E2eTestUtils.clickViewTracesButton(); 31 32 const viewer = element(by.css(viewerSelector)); 33 expect(await viewer.isPresent()).toBeTruthy(); 34 35 const img = element(by.css(`${viewerSelector} img`)); 36 expect(await img.isPresent()).toBeTruthy(); 37 expect(await img.getAttribute('src')).toContain('blob:'); 38 }); 39 40 it('processes files and renders view with multiple screenshots', async () => { 41 await E2eTestUtils.uploadFixture( 42 'traces/screenshot.png', 43 'traces/screenshot_2.png', 44 ); 45 await E2eTestUtils.closeSnackBar(); 46 await E2eTestUtils.clickViewTracesButton(); 47 48 const viewer = element(by.css(viewerSelector)); 49 expect(await viewer.isPresent()).toBeTruthy(); 50 51 const img = element(by.css(`${viewerSelector} img`)); 52 expect(await img.isPresent()).toBeTruthy(); 53 const src = await img.getAttribute('src'); 54 expect(src).toContain('blob:'); 55 56 const overlayTitle = element(by.css(`${viewerSelector} .overlay-title`)); 57 expect(await overlayTitle.getText()).toEqual('screenshot'); 58 59 const selectTrigger = element( 60 by.css(`${viewerSelector} .mat-select-trigger`), 61 ); 62 expect(await selectTrigger.isPresent()).toBeTruthy(); 63 await selectTrigger.click(); 64 const option2 = element.all(by.css('.mat-option')).last(); 65 await option2.click(); 66 67 expect(await img.isPresent()).toBeTruthy(); 68 const newSrc = await img.getAttribute('src'); 69 expect(newSrc).toContain('blob:'); 70 expect(newSrc).not.toEqual(src); 71 expect(await overlayTitle.getText()).toEqual('screenshot_2'); 72 }); 73}); 74