mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
gui-tests-framework: removing redundant *TestSuite* classes; removing TestGroups annotation; removing unused libraries from community-tests module
This commit is contained in:
@@ -12,15 +12,6 @@
|
||||
<orderEntry type="library" name="fest" level="project" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="module" module-name="testFramework" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../plugins/gradle/lib/guava-jdk5-17.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="java-psi-api" />
|
||||
<orderEntry type="module" module-name="bootstrap" />
|
||||
<orderEntry type="module" module-name="external-system-rt" />
|
||||
@@ -29,17 +20,6 @@
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
<orderEntry type="module" module-name="lint-api" />
|
||||
<orderEntry type="module" module-name="testRunner" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../plugins/gradle/lib/jsr305-1.3.9.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MODULE_DIR$/../plugins/gradle/lib/jsr305-1.3.9.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="idea-ui" />
|
||||
<orderEntry type="module" module-name="dvcs-impl" />
|
||||
<orderEntry type="module" module-name="annotations" />
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.tests.gui;
|
||||
|
||||
import com.intellij.tests.gui.framework.TestGroup;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface BelongsToTestGroups {
|
||||
TestGroup[] value();
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.tests.gui;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(GuiTestSuiteRunner.class)
|
||||
public class GuiTestSuite {
|
||||
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.tests.gui;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.tests.gui.framework.GuiTestCase;
|
||||
import com.intellij.tests.gui.framework.IdeTestApplication;
|
||||
import com.intellij.tests.gui.framework.TestGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.runner.Runner;
|
||||
import org.junit.runner.notification.RunNotifier;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.model.InitializationError;
|
||||
import org.junit.runners.model.RunnerBuilder;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.openapi.util.io.FileUtil.notNullize;
|
||||
import static com.intellij.tests.gui.framework.GuiTests.GUI_TESTS_RUNNING_IN_SUITE_PROPERTY;
|
||||
import static org.fest.assertions.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test runner that automatically includes all test classes that extend {@link GuiTestCase}, or if specified, the tests belonging to
|
||||
* specific groups.
|
||||
*/
|
||||
public class GuiTestSuiteRunner extends Suite {
|
||||
|
||||
final public static String DOT_CLASS = ".class";
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface IncludeTestGroups {
|
||||
TestGroup[] value();
|
||||
}
|
||||
|
||||
public GuiTestSuiteRunner(Class<?> suiteClass, RunnerBuilder builder) throws InitializationError {
|
||||
super(builder, suiteClass, getGuiTestClasses(suiteClass));
|
||||
System.setProperty(GUI_TESTS_RUNNING_IN_SUITE_PROPERTY, "true");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Class<?>[] getGuiTestClasses(@NotNull Class<?> suiteClass) throws InitializationError {
|
||||
List<File> guiTestClassFiles = Lists.newArrayList();
|
||||
List<TestGroup> suiteGroups = getSuiteGroups(suiteClass);
|
||||
File parentDir = getParentDir(suiteClass);
|
||||
|
||||
String packagePath = suiteClass.getPackage().getName().replace('.', File.separatorChar);
|
||||
int packagePathIndex = parentDir.getPath().indexOf(packagePath);
|
||||
assertThat(packagePathIndex).isGreaterThan(-1);
|
||||
String testDirPath = parentDir.getPath().substring(0, packagePathIndex);
|
||||
|
||||
findPotentialGuiTestClassFiles(parentDir, guiTestClassFiles);
|
||||
List<Class<?>> guiTestClasses = Lists.newArrayList();
|
||||
ClassLoader classLoader = suiteClass.getClassLoader();
|
||||
for (File classFile : guiTestClassFiles) {
|
||||
String path = classFile.getPath();
|
||||
String className = path.substring(testDirPath.length(), path.indexOf(DOT_CLASS)).replace(File.separatorChar, '.');
|
||||
try {
|
||||
Class<?> testClass = classLoader.loadClass(className);
|
||||
if (GuiTestCase.class.isAssignableFrom(testClass) && isInGroup(testClass, suiteGroups)) {
|
||||
guiTestClasses.add(testClass);
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new InitializationError(e);
|
||||
}
|
||||
}
|
||||
return guiTestClasses.toArray(new Class<?>[guiTestClasses.size()]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<TestGroup> getSuiteGroups(@NotNull Class<?> suiteClass) {
|
||||
for (Annotation annotation : suiteClass.getAnnotations()) {
|
||||
if (annotation instanceof IncludeTestGroups) {
|
||||
TestGroup[] values = ((IncludeTestGroups)annotation).value();
|
||||
if (values != null) {
|
||||
return Lists.newArrayList(values);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private static void findPotentialGuiTestClassFiles(@NotNull File directory, @NotNull List<File> guiTestClassFiles) {
|
||||
File[] children = notNullize(directory.listFiles());
|
||||
for (File child : children) {
|
||||
if (child.isDirectory()) {
|
||||
findPotentialGuiTestClassFiles(child, guiTestClassFiles);
|
||||
continue;
|
||||
}
|
||||
if (child.isFile() && !child.isHidden() && child.getName().endsWith("Test.class")) {
|
||||
guiTestClassFiles.add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static File getParentDir(@NotNull Class<?> clazz) throws InitializationError {
|
||||
URL classUrl = clazz.getResource(clazz.getSimpleName() + DOT_CLASS);
|
||||
try {
|
||||
return new File(classUrl.toURI()).getParentFile();
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
throw new InitializationError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isInGroup(@NotNull Class<?> testClass, List<TestGroup> suiteGroups) {
|
||||
if (suiteGroups.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (TestGroup testGroup : getGroups(testClass)) {
|
||||
if (suiteGroups.contains(testGroup)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<TestGroup> getGroups(@NotNull Class<?> suiteClass) {
|
||||
for (Annotation annotation : suiteClass.getAnnotations()) {
|
||||
if (annotation instanceof BelongsToTestGroups) {
|
||||
TestGroup[] values = ((BelongsToTestGroups)annotation).value();
|
||||
if (values != null) {
|
||||
return Lists.newArrayList(values);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected Statement childrenInvoker(final RunNotifier notifier) {
|
||||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() {
|
||||
// Run all the tests and dispose IdeTestApplication at the end.
|
||||
for (final Runner child : getChildren()) {
|
||||
runChild(child, notifier);
|
||||
}
|
||||
IdeTestApplication.disposeInstance();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,9 @@ import com.intellij.dvcs.ui.CloneDvcsDialog
|
||||
import com.intellij.dvcs.ui.DvcsBundle
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.vcs.VcsBundle
|
||||
import com.intellij.tests.gui.BelongsToTestGroups
|
||||
import com.intellij.tests.gui.fixtures.*
|
||||
import com.intellij.tests.gui.framework.GuiTestCase
|
||||
import com.intellij.tests.gui.framework.GuiTests
|
||||
import com.intellij.tests.gui.framework.TestGroup
|
||||
import com.intellij.ui.EditorComboBox
|
||||
import org.fest.swing.edt.GuiActionRunner
|
||||
import org.fest.swing.edt.GuiTask
|
||||
@@ -33,7 +31,6 @@ import org.junit.Test
|
||||
/**
|
||||
* Created by karashevich on 18/06/16.
|
||||
*/
|
||||
@BelongsToTestGroups(TestGroup.PROJECT)
|
||||
class GitGuiTest : GuiTestCase() {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.tests.gui.test;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.tests.gui.BelongsToTestGroups;
|
||||
import com.intellij.tests.gui.fixtures.ProjectViewFixture;
|
||||
import com.intellij.tests.gui.fixtures.ToolWindowFixture;
|
||||
import com.intellij.tests.gui.fixtures.WelcomeFrameFixture;
|
||||
@@ -26,7 +25,6 @@ import com.intellij.tests.gui.fixtures.newProjectWizard.NewProjectWizardFixture;
|
||||
import com.intellij.tests.gui.framework.GuiTestCase;
|
||||
import com.intellij.tests.gui.framework.GuiTests;
|
||||
import com.intellij.tests.gui.framework.IdeGuiTest;
|
||||
import com.intellij.tests.gui.framework.TestGroup;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -41,7 +39,6 @@ import static com.intellij.tests.gui.framework.GuiTests.getSystemJdk;
|
||||
/**
|
||||
* Created by karashevich on 27/05/16.
|
||||
*/
|
||||
@BelongsToTestGroups({TestGroup.PROJECT})
|
||||
public class JavaEEProjectTest extends GuiTestCase {
|
||||
|
||||
|
||||
|
||||
@@ -15,12 +15,10 @@
|
||||
*/
|
||||
package com.intellij.tests.gui.test
|
||||
|
||||
import com.intellij.tests.gui.BelongsToTestGroups
|
||||
import com.intellij.tests.gui.fixtures.DialogFixtures.CreateDialogFixture
|
||||
import com.intellij.tests.gui.fixtures.EditorFixture
|
||||
import com.intellij.tests.gui.fixtures.JBPopupFixture
|
||||
import com.intellij.tests.gui.framework.GuiTestCase
|
||||
import com.intellij.tests.gui.framework.TestGroup
|
||||
import com.intellij.tests.gui.framework.clickListItem
|
||||
import com.intellij.tests.gui.framework.createNewProject
|
||||
import org.junit.Ignore
|
||||
@@ -31,7 +29,6 @@ import javax.swing.text.JTextComponent
|
||||
/**
|
||||
* Created by karashevich on 18/06/16.
|
||||
*/
|
||||
@BelongsToTestGroups(TestGroup.PROJECT)
|
||||
class JavaProjectTest: GuiTestCase() {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,13 +17,11 @@ package com.intellij.tests.gui.test;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.tests.gui.BelongsToTestGroups;
|
||||
import com.intellij.tests.gui.fixtures.ProjectViewFixture;
|
||||
import com.intellij.tests.gui.fixtures.newProjectWizard.NewProjectWizardFixture;
|
||||
import com.intellij.tests.gui.framework.GuiTestCase;
|
||||
import com.intellij.tests.gui.framework.GuiTests;
|
||||
import com.intellij.tests.gui.framework.IdeGuiTest;
|
||||
import com.intellij.tests.gui.framework.TestGroup;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -40,7 +38,6 @@ import static com.intellij.tests.gui.framework.GuiTests.getSystemJdk;
|
||||
/**
|
||||
* Created by karashevich on 27/05/16.
|
||||
*/
|
||||
@BelongsToTestGroups({TestGroup.PROJECT})
|
||||
public class NewProjectTest extends GuiTestCase {
|
||||
|
||||
|
||||
|
||||
@@ -15,10 +15,8 @@
|
||||
*/
|
||||
package com.intellij.tests.gui.test
|
||||
|
||||
import com.intellij.tests.gui.BelongsToTestGroups
|
||||
import com.intellij.tests.gui.fixtures.WelcomeFrameFixture
|
||||
import com.intellij.tests.gui.framework.GuiTestCase
|
||||
import com.intellij.tests.gui.framework.TestGroup
|
||||
import com.intellij.tests.gui.framework.createNewProject
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
@@ -26,7 +24,6 @@ import org.junit.Test
|
||||
/**
|
||||
* Created by karashevich on 18/06/16.
|
||||
*/
|
||||
@BelongsToTestGroups(TestGroup.PROJECT)
|
||||
class ShortGuiTest: GuiTestCase() {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -15,16 +15,13 @@
|
||||
*/
|
||||
package com.intellij.tests.gui.test
|
||||
|
||||
import com.intellij.tests.gui.BelongsToTestGroups
|
||||
import com.intellij.tests.gui.framework.GuiTestCase
|
||||
import com.intellij.tests.gui.framework.IdeGuiTest
|
||||
import com.intellij.tests.gui.framework.TestGroup
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Created by karashevich on 21/06/16.
|
||||
*/
|
||||
@BelongsToTestGroups(TestGroup.PROJECT)
|
||||
class SimpleApplicationImportTest: GuiTestCase() {
|
||||
|
||||
@Test @IdeGuiTest
|
||||
|
||||
Reference in New Issue
Block a user