Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
}

repositories {
mavenLocal()
mavenCentral()
flatDir {
dirs buildDir
Expand All @@ -16,6 +17,15 @@ repositories {
password = project.findProperty("gpr.token") ?: System.getenv("GITHUB_TOKEN")
}
}
maven {
url 'https://repository.jboss.org/nexus/content/repositories/snapshots'
}
maven {
url 'https://repository.jboss.org/nexus/content/groups/public'
}
maven {
url 'https://packages.jetbrains.team/maven/p/ij/intellij-dependencies'
}
}

apply plugin: 'idea'
Expand Down Expand Up @@ -62,6 +72,7 @@ dependencies {
implementation 'org.apache.commons:commons-compress:1.21'
implementation 'com.redhat.crda:crda-java-api:0.0.1-SNAPSHOT'
testImplementation('junit:junit:4.13.1')
implementation 'com.redhat.devtools.intellij:intellij-common-ui-test-library:0.2.0'
}

runIde {
Expand All @@ -72,5 +83,24 @@ runIdeForUiTests {
systemProperties['com.redhat.devtools.intellij.telemetry.mode'] = 'debug'
}

sourceSets {
integrationTest {
java.srcDir file('src/it/java')
resources.srcDir file('src/it/resources')
compileClasspath += sourceSets.main.output + configurations.runtimeClasspath
runtimeClasspath += output + compileClasspath
}
}

task integrationTest(type: Test) {
useJUnitPlatform()
description = 'Runs the integration tests.'
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
mustRunAfter test
}

group 'org.jboss.tools.intellij'
version projectVersion // Plugin version
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.intellij.analytics.test.ui;


import com.intellij.remoterobot.RemoteRobot;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.idestatusbar.IdeStatusBar;
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane;
import org.jboss.tools.intellij.analytics.test.ui.annotations.UITest;
import org.jboss.tools.intellij.analytics.test.ui.junit.TestRunnerExtension;
import org.jboss.tools.intellij.analytics.test.ui.runner.IdeaRunner;
import org.jboss.tools.intellij.analytics.test.ui.utils.ProjectUtility;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;

import java.time.Duration;

/**
* @author Ondrej Dockal, [email protected]
*/
@ExtendWith(TestRunnerExtension.class)
@UITest
abstract public class AbstractBaseTest {

private static RemoteRobot robot;
@BeforeAll
public static void connect() {
robot = IdeaRunner.getInstance().getRemoteRobot();
ProjectUtility.copyProjectFromVSC(robot);
ProjectUtility.closeTipDialogIfItAppears(robot);
//ProjectStructureDialog.cancelProjectStructureDialogIfItAppears(robot);
ProjectUtility.closeGotItPopup(robot);
IdeStatusBar ideStatusBar = robot.find(IdeStatusBar.class, Duration.ofSeconds(5));
ideStatusBar.waitUntilAllBgTasksFinish();
}

public RemoteRobot getRobotReference() {
return robot;
}

public boolean isStripeButtonAvailable(String label) {
try {
ToolWindowsPane toolWindowsPane = robot.find(ToolWindowsPane.class);
toolWindowsPane.stripeButton(label, false);
} catch (WaitForConditionTimeoutException e) {
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.intellij.analytics.test.ui;

import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ProjectExplorer;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author Richard Kocian
*/
public class BaseUITest extends AbstractBaseTest {

@Test
public void checkIfPomExists() {
ProjectExplorer projectExplorer = getRobotReference().find(ProjectExplorer.class);
String[] path = new String[]{"pom.xml"};
assertTrue(projectExplorer.projectViewTree().isPathExists(path, true));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.intellij.analytics.test.ui.annotations;

import org.junit.jupiter.api.Tag;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @author Ondrej Dockal
* Annotation represent UI Test class, using @Tag annotation
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Tag("ui-test")
public @interface UITest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at https://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.intellij.analytics.test.ui.dialogs;

import com.intellij.remoterobot.RemoteRobot;
import com.intellij.remoterobot.data.RemoteComponent;
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
import com.intellij.remoterobot.fixtures.DefaultXpath;
import com.intellij.remoterobot.fixtures.FixtureName;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
import org.jetbrains.annotations.NotNull;

import java.time.Duration;

/**
* Project Structure dialog fixture
*
* @author [email protected]
*/
@DefaultXpath(by = "MyDialog type", xpath = "//div[@accessiblename='Project Structure' and @class='MyDialog']")
@FixtureName(name = "Project Structure Dialog")
public class ProjectStructureDialog extends CommonContainerFixture {
public ProjectStructureDialog(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
super(remoteRobot, remoteComponent);
}

/**
* Cancel the 'Project Structure' dialog if it appears
*
* @param remoteRobot reference to the RemoteRobot instance
*/
public static void cancelProjectStructureDialogIfItAppears(RemoteRobot remoteRobot) {
try {
ProjectStructureDialog projectStructureDialog = remoteRobot.find(ProjectStructureDialog.class, Duration.ofSeconds(20));
projectStructureDialog.button("Cancel").click();
} catch (WaitForConditionTimeoutException e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.intellij.analytics.test.ui.junit;

import com.redhat.devtools.intellij.commonuitest.UITestRunner;
import com.redhat.devtools.intellij.commonuitest.utils.runner.IntelliJVersion;
import org.jboss.tools.intellij.analytics.test.ui.runner.IdeaRunner;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
import org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource;

/**
* JUnit 5 test extension providing wrapper for tests and initiate connection to IDEA under test
* @author Ondrej Dockal
*
*/
public class TestRunnerExtension implements BeforeAllCallback, CloseableResource {

@Override
public void beforeAll(ExtensionContext context) {
System.out.println("Initialize IdeaRunner and start IDE");
// need to initialize store, so that close method will be called at the testing end
context.getRoot().getStore(Namespace.GLOBAL).put("InitializeTest", this);
IdeaRunner.getInstance().startIDE(IntelliJVersion.COMMUNITY_V_2022_1, 8580);
}

@Override
public void close() {
System.out.println("Closing IDE");
UITestRunner.closeIde();

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.intellij.analytics.test.ui.runner;

import com.intellij.remoterobot.RemoteRobot;
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
import com.redhat.devtools.intellij.commonuitest.utils.runner.IntelliJVersion;

/**
* Idea Runner singleton to keep track of running IDE
* @author Ondrej Dockal
*
*/
public class IdeaRunner {

private static IdeaRunner ideaRunner = null;
private static boolean ideaIsStarted = false;
private static int port = 8580;

private RemoteRobot robot;

private IdeaRunner() {}

public static IdeaRunner getInstance() {
if (ideaRunner == null) {
ideaRunner = new IdeaRunner();
}
return ideaRunner;
}

public void startIDE(IntelliJVersion ideaVersion, int portNumber) {
if (!ideaIsStarted) {
System.out.println("Starting IDE, setting ideaIsStarted to true");
robot = UITestRunner.runIde(ideaVersion, port);
port = portNumber;
System.out.println("IDEA port for remote robot: " + port);
ideaIsStarted = true;
}
}

public RemoteRobot getRemoteRobot() {
return robot;
}

}
Loading