Skip to content

Commit 6fa0b20

Browse files
authored
Create fixtures for handling project explorer (left side) and build tools pane (right side) (#51)
* Create fixtures for handling project explorer (left side) and build tools pane (right side) Fixes #46
1 parent 6fc0d11 commit 6fa0b20

File tree

26 files changed

+1177
-284
lines changed

26 files changed

+1177
-284
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 92 deletions
This file was deleted.

.github/workflows/linux.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Java CI with Gradle - Linux
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
build-linux:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up JDK 11
19+
uses: actions/setup-java@v1
20+
with:
21+
java-version: 11
22+
- name: Run integration tests
23+
run: |
24+
export DISPLAY=:99.0
25+
Xvfb -ac :99 -screen 0 1920x1080x24 &
26+
cd src/test-project
27+
chmod +x gradlew
28+
./gradlew clean test --warning-mode none
29+
- uses: actions/upload-artifact@v2
30+
with:
31+
name: ${{ runner.os }}-test-reports
32+
path: src/test-project/build/reports/tests/test
33+
if: always()
34+
- name: Archiving screenshots
35+
uses: actions/upload-artifact@v2
36+
with:
37+
name: ${{ runner.os }}-screenshots
38+
path: src/test-project/build/screenshots/*
39+
if: always()

.github/workflows/mac.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Java CI with Gradle - maccOS
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
build-macos:
14+
runs-on: macos-11
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up JDK 11
19+
uses: actions/setup-java@v1
20+
with:
21+
java-version: 11
22+
- name: Run integration tests
23+
run: |
24+
cd src/test-project
25+
chmod +x gradlew
26+
./gradlew clean test --warning-mode none
27+
- uses: actions/upload-artifact@v2
28+
with:
29+
name: ${{ runner.os }}-test-reports
30+
path: src/test-project/build/reports/tests/test
31+
if: always()
32+
- name: Archiving screenshots
33+
uses: actions/upload-artifact@v2
34+
with:
35+
name: ${{ runner.os }}-screenshots
36+
path: src/test-project/build/screenshots/*
37+
if: always()

.github/workflows/windows.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Java CI with Gradle - Windows
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
build-windows:
14+
runs-on: windows-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up JDK 11
19+
uses: actions/setup-java@v1
20+
with:
21+
java-version: 11
22+
- name: Run integration tests
23+
run: |
24+
cd src\test-project
25+
chmod +x gradlew.bat
26+
.\gradlew.bat clean test --warning-mode none
27+
shell: powershell
28+
- uses: actions/upload-artifact@v2
29+
with:
30+
name: ${{ runner.os }}-test-reports
31+
path: src\test-project\build\reports\tests\test
32+
if: always()
33+
- name: Archiving screenshots
34+
uses: actions/upload-artifact@v2
35+
with:
36+
name: ${{ runner.os }}-screenshots
37+
path: src\test-project\build\screenshots\*
38+
if: always()
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 Red Hat, Inc.
3+
* Distributed under license by Red Hat, Inc. All rights reserved.
4+
* This program is made available under the terms of the
5+
* Eclipse Public License v2.0 which accompanies this distribution,
6+
* and is available at https://www.eclipse.org/legal/epl-v20.html
7+
*
8+
* Contributors:
9+
* Red Hat, Inc. - initial API and implementation
10+
******************************************************************************/
11+
package com.redhat.devtools.intellij.commonUiTestLibrary.fixtures.mainIdeWindow.toolWindowsPane;
12+
13+
import com.intellij.remoterobot.RemoteRobot;
14+
import com.intellij.remoterobot.data.RemoteComponent;
15+
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
16+
import com.intellij.remoterobot.fixtures.DefaultXpath;
17+
import com.intellij.remoterobot.fixtures.FixtureName;
18+
import com.intellij.remoterobot.fixtures.JTreeFixture;
19+
import com.intellij.remoterobot.fixtures.TextEditorFixture;
20+
import com.redhat.devtools.intellij.commonUiTestLibrary.utils.textTranformation.TextUtils;
21+
import org.jetbrains.annotations.NotNull;
22+
23+
import java.time.Duration;
24+
25+
import static com.intellij.remoterobot.search.locators.Locators.byXpath;
26+
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor;
27+
28+
/**
29+
* Build View fixture
30+
*
31+
32+
*/
33+
@DefaultXpath(by = "ToolWindowsPane type", xpath = "//div[@class='BuildView']")
34+
@FixtureName(name = "Tool Windows Pane")
35+
public class BuildView extends CommonContainerFixture {
36+
private String lastBuildStatusTreeText;
37+
38+
public BuildView(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
39+
super(remoteRobot, remoteComponent);
40+
}
41+
42+
/**
43+
* Wait until build has finished
44+
*/
45+
public void waitUntilBuildHasFinished() {
46+
waitFor(Duration.ofSeconds(300), Duration.ofSeconds(3), "The build did not finish in 5 minutes.", () -> didBuildStatusTreeTextStopChanging());
47+
}
48+
49+
/**
50+
* Test if build is successful
51+
*
52+
* @return true if the build is successful
53+
*/
54+
public boolean isBuildSuccessful() {
55+
String runConsoleOutput = TextUtils.listOfRemoteTextToString(buildConsole().findAllText());
56+
return runConsoleOutput.contains("BUILD SUCCESS");
57+
}
58+
59+
/**
60+
* Get the Build Status tree fixture
61+
*
62+
* @return Build Status tree fixture
63+
*/
64+
public JTreeFixture buildStatusTree() {
65+
return find(JTreeFixture.class, byXpath("//div[@class='Tree']"));
66+
}
67+
68+
/**
69+
* Get the build console
70+
*
71+
* @return build console fixture
72+
*/
73+
public TextEditorFixture buildConsole() {
74+
return textEditor(byXpath("//div[@accessiblename='Editor']"), Duration.ofSeconds(2));
75+
}
76+
77+
private boolean didBuildStatusTreeTextStopChanging() {
78+
String updatedBuildStatusTreeText = getBuildStatusTreeText();
79+
80+
if (lastBuildStatusTreeText != null && lastBuildStatusTreeText.equals(updatedBuildStatusTreeText)) {
81+
lastBuildStatusTreeText = null;
82+
return true;
83+
} else {
84+
lastBuildStatusTreeText = updatedBuildStatusTreeText;
85+
return false;
86+
}
87+
}
88+
89+
private String getBuildStatusTreeText() {
90+
String buildStatusTreeText = TextUtils.listOfRemoteTextToString(buildStatusTree().findAllText());
91+
return buildStatusTreeText;
92+
}
93+
}

0 commit comments

Comments
 (0)