• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
16import {browser, by, element} from 'protractor';
17import {CommonTestUtils} from '../common/utils';
18
19class E2eTestUtils extends CommonTestUtils {
20  static readonly WINSCOPE_URL = 'http://localhost:8080';
21  static readonly REMOTE_TOOL_MOCK_URL = 'http://localhost:8081';
22
23  static async checkServerIsUp(name: string, url: string) {
24    try {
25      await browser.get(url);
26    } catch (error) {
27      fail(`${name} server (${url}) looks down. Did you start it?`);
28    }
29  }
30
31  static async uploadFixture(...paths: string[]) {
32    const inputFile = element(by.css('input[type="file"]'));
33
34    // Uploading multiple files is not properly supported but
35    // chrome handles file paths joined with new lines
36    await inputFile.sendKeys(paths.map((it) => E2eTestUtils.getFixturePath(it)).join('\n'));
37  }
38
39  static async clickViewTracesButton() {
40    const button = element(by.css('.load-btn'));
41    await button.click();
42  }
43
44  static async closeSnackBarIfNeeded() {
45    const closeButton = element(by.css('.snack-bar-action'));
46    const isPresent = await closeButton.isPresent();
47    if (isPresent) {
48      await closeButton.click();
49    }
50  }
51}
52
53export {E2eTestUtils};
54