diff --git a/flutter-intellij-community.iml b/flutter-intellij-community.iml index d163e2739b..1d762824cc 100644 --- a/flutter-intellij-community.iml +++ b/flutter-intellij-community.iml @@ -44,8 +44,5 @@ - - - \ No newline at end of file diff --git a/flutter-studio/src/io/flutter/FlutterStudioInitializer.java b/flutter-studio/src/io/flutter/FlutterStudioInitializer.java index 930a081cde..000caf2bc4 100644 --- a/flutter-studio/src/io/flutter/FlutterStudioInitializer.java +++ b/flutter-studio/src/io/flutter/FlutterStudioInitializer.java @@ -27,7 +27,8 @@ public void run() { String version = info.getFullVersion(); if (version.startsWith("2.") || (version.contains("Beta") && !version.endsWith("7"))) { reportVersionIncompatibility(info); - } else if (version.contains("Canary")) { + } + else if (version.contains("Canary")) { reportCanaryIncompatibility(); } } diff --git a/flutter-studio/src/io/flutter/actions/FlutterNewProjectAction.java b/flutter-studio/src/io/flutter/actions/FlutterNewProjectAction.java index 394b5de63e..95256071ff 100644 --- a/flutter-studio/src/io/flutter/actions/FlutterNewProjectAction.java +++ b/flutter-studio/src/io/flutter/actions/FlutterNewProjectAction.java @@ -6,21 +6,15 @@ package io.flutter.actions; -import com.android.tools.idea.sdk.wizard.SdkQuickfixUtils; import com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder; import com.android.tools.idea.wizard.model.ModelWizard; import com.android.tools.idea.wizard.model.ModelWizardDialog; -import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.wm.impl.welcomeScreen.NewWelcomeScreen; import io.flutter.module.FlutterProjectType; import io.flutter.project.ChoseProjectTypeStep; import io.flutter.project.FlutterProjectModel; -import io.flutter.sdk.FlutterSdkUtil; -import org.jetbrains.android.sdk.AndroidSdkUtils; import org.jetbrains.annotations.NotNull; import java.util.NoSuchElementException; @@ -49,7 +43,8 @@ public void actionPerformed(AnActionEvent e) { new StudioWizardDialogBuilder(wizard, "Create New Flutter Project").setUseNewUx(true).build(); try { dialog.show(); - } catch (NoSuchElementException ex) { + } + catch (NoSuchElementException ex) { // This happens if no Flutter SDK is installed and the user cancels the FlutterProjectStep. } } diff --git a/flutter-studio/src/io/flutter/project/FlutterProjectCreator.java b/flutter-studio/src/io/flutter/project/FlutterProjectCreator.java index 093a45d29f..20e5e66ded 100644 --- a/flutter-studio/src/io/flutter/project/FlutterProjectCreator.java +++ b/flutter-studio/src/io/flutter/project/FlutterProjectCreator.java @@ -5,10 +5,7 @@ */ package io.flutter.project; -import com.android.builder.model.SourceProvider; import com.android.repository.io.FileOpUtils; -import com.android.tools.idea.gradle.npw.project.GradleAndroidProjectPaths; -import com.android.tools.idea.npw.project.AndroidSourceSet; import com.intellij.facet.FacetManager; import com.intellij.facet.ModifiableFacetModel; import com.intellij.ide.RecentProjectsManager; @@ -48,6 +45,7 @@ import io.flutter.sdk.FlutterSdk; import org.jetbrains.android.facet.AndroidFacet; import org.jetbrains.android.facet.AndroidFacetType; +import org.jetbrains.android.facet.IdeaSourceProvider; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties; @@ -114,27 +112,26 @@ private static void deleteDirectoryContents(File location) { } } - private static void configureFacet(@NotNull AndroidFacet facet, @NotNull FlutterProjectModel androidModel, @NotNull File location) { + private static void configureFacet(@NotNull AndroidFacet facet, @NotNull File location) { JpsAndroidModuleProperties facetProperties = facet.getProperties(); File modulePath = new File(location, "android"); - AndroidSourceSet sources = GradleAndroidProjectPaths.createDefaultSourceSetAt(modulePath); - SourceProvider sourceProvider = sources.toSourceProvider(); + IdeaSourceProvider sourceProvider = IdeaSourceProvider.create(facet); facetProperties.MANIFEST_FILE_RELATIVE_PATH = relativePath(modulePath, sourceProvider.getManifestFile()); facetProperties.RES_FOLDER_RELATIVE_PATH = relativePath(modulePath, sourceProvider.getResDirectories()); facetProperties.ASSETS_FOLDER_RELATIVE_PATH = relativePath(modulePath, sourceProvider.getAssetsDirectories()); } @NotNull - private static String relativePath(@NotNull File basePath, @NotNull Collection dirs) { + private static String relativePath(@NotNull File basePath, @NotNull Collection dirs) { return relativePath(basePath, getFirstItem(dirs)); } @NotNull - private static String relativePath(@NotNull File basePath, @Nullable File file) { + private static String relativePath(@NotNull File basePath, @Nullable VirtualFile file) { String relativePath = null; if (file != null) { - relativePath = getRelativePath(basePath, file); + relativePath = getRelativePath(basePath, new File(file.getPath())); } if (relativePath != null && !relativePath.startsWith(SEPARATOR)) { return SEPARATOR + toSystemIndependentName(relativePath); @@ -142,6 +139,14 @@ private static String relativePath(@NotNull File basePath, @Nullable File file) return ""; } + private static String reversedOrgFromPackage(@NotNull String packageName) { + int idx = packageName.lastIndexOf('.'); + if (idx <= 0) { + return packageName; + } + return packageName.substring(0, idx); + } + public void createModule() { Project project = myModel.project().getValue(); VirtualFile baseDir = project.getBaseDir(); @@ -228,7 +233,7 @@ public void run(@NotNull ProgressIndicator indicator) { AndroidFacetType facetType = AndroidFacet.getFacetType(); AndroidFacet facet = facetType.createFacet(module, AndroidFacet.NAME, facetType.createDefaultConfiguration(), null); model.addFacet(facet); - configureFacet(facet, myModel, location); + configureFacet(facet, location); } // The IDE has already created some files. Fluter won't overwrite them, but we want the versions provided by Flutter. @@ -262,12 +267,4 @@ private FlutterCreateAdditionalSettings makeAdditionalSettings() { .setSwift(myModel.useSwift().get() ? true : null) .build(); } - - private static String reversedOrgFromPackage(@NotNull String packageName) { - int idx = packageName.lastIndexOf('.'); - if (idx <= 0) { - return packageName; - } - return packageName.substring(0, idx); - } } diff --git a/flutter-studio/src/io/flutter/project/FlutterProjectSystemProvider.java b/flutter-studio/src/io/flutter/project/FlutterProjectSystemProvider.java index d4f441dbb1..f4935fced6 100644 --- a/flutter-studio/src/io/flutter/project/FlutterProjectSystemProvider.java +++ b/flutter-studio/src/io/flutter/project/FlutterProjectSystemProvider.java @@ -7,6 +7,7 @@ //import com.android.tools.idea.projectsystem.*; //import com.android.tools.idea.projectsystem.gradle.GradleProjectSystem; + import com.intellij.openapi.project.Project; import io.flutter.utils.FlutterModuleUtils; import org.jetbrains.annotations.NotNull; diff --git a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/FlutterGuiTestRule.java b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/FlutterGuiTestRule.java index 6d9675ec9a..766d6f3a3b 100644 --- a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/FlutterGuiTestRule.java +++ b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/FlutterGuiTestRule.java @@ -9,7 +9,6 @@ import com.android.tools.idea.sdk.IdeSdks; import com.android.tools.idea.tests.gui.framework.fixture.FlutterFrameFixture; import com.android.tools.idea.tests.gui.framework.fixture.FlutterWelcomeFrameFixture; -import com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture; import com.android.tools.idea.tests.gui.framework.fixture.IdeaFrameFixture; import com.android.tools.idea.tests.gui.framework.matcher.Matchers; import com.google.common.collect.ImmutableList; @@ -28,6 +27,7 @@ import org.jdom.input.SAXBuilder; import org.jdom.xpath.XPath; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.junit.AssumptionViolatedException; import org.junit.rules.RuleChain; import org.junit.rules.TestRule; @@ -46,7 +46,9 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import static com.android.tools.idea.tests.gui.framework.GuiTests.setUpDefaultProjectCreationLocationPath; import static com.google.common.truth.TruthJUnit.assume; +import static com.intellij.openapi.util.io.FileUtil.sanitizeFileName; import static org.fest.reflect.core.Reflection.*; /** @@ -55,12 +57,12 @@ * are open). * * For example: - * FlutterGuiTestRule myGuiTest = new FlutterGuiTestRule(); - * WizardUtils.createNewApplication(myGuiTest); - * FlutterFrameFixture ideFrame = myGuiTest.ideFrame(); - * EditorFixture editor = ideFrame.getEditor(); - * editor.waitUntilErrorAnalysisFinishes(); - * ... + * FlutterGuiTestRule myGuiTest = new FlutterGuiTestRule(); + * WizardUtils.createNewApplication(myGuiTest); + * FlutterFrameFixture ideFrame = myGuiTest.ideFrame(); + * EditorFixture editor = ideFrame.getEditor(); + * editor.waitUntilErrorAnalysisFinishes(); + * ... * * {@link TestRule}s can do everything that could be done previously with * methods annotated with {@link org.junit.Before}, @@ -91,6 +93,7 @@ public class FlutterGuiTestRule implements TestRule { } }; private FlutterFrameFixture myIdeFrameFixture; + @Nullable private String myTestDirectory; private Timeout myTimeout = new Timeout(5, TimeUnit.MINUTES); private static ImmutableList thrownFromRunning(Runnable r) { @@ -128,7 +131,6 @@ public Statement apply(final Statement base, final Description description) { .around(myRobotTestRule) .around(myLeakCheck) .around(new IdeHandling()) - .around(new TestPerformance()) .around(new ScreenshotOnFailure()) .around(myTimeout) .apply(base, description); @@ -144,8 +146,9 @@ private void assumeOnlyWelcomeFrameShowing() { assume().that(GuiTests.windowsShowing()).named("windows showing").hasSize(1); } - private void setUp() { - GuiTests.setUpDefaultProjectCreationLocationPath(); + private void setUp(@NotNull String methodName) { + myTestDirectory = methodName != null ? sanitizeFileName(methodName) : null; + setUpDefaultProjectCreationLocationPath(myTestDirectory); GuiTests.setIdeSettings(); GuiTests.setUpSdks(); @@ -255,7 +258,7 @@ protected File getMasterProjectDirPath(@NotNull String projectDirName) { @NotNull protected File getTestProjectDirPath(@NotNull String projectDirName) { - return new File(GuiTests.getProjectCreationDirPath(), projectDirName); + return new File(GuiTests.getProjectCreationDirPath(myTestDirectory), projectDirName); } public void cleanUpProjectForImport(@NotNull File projectPath) { @@ -339,7 +342,7 @@ public void evaluate() throws Throwable { System.out.println("Starting " + description.getDisplayName()); assume().that(GuiTests.fatalErrorsFromIde()).named("IDE errors").isEmpty(); assumeOnlyWelcomeFrameShowing(); - setUp(); + setUp(description.getMethodName()); List errors = new ArrayList<>(); try { base.evaluate(); diff --git a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/FlutterWelcomeFrameFixture.java b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/FlutterWelcomeFrameFixture.java index ce7fe1941d..7c6670ead0 100644 --- a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/FlutterWelcomeFrameFixture.java +++ b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/FlutterWelcomeFrameFixture.java @@ -7,6 +7,7 @@ import com.android.tools.idea.tests.gui.framework.GuiTests; import com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.NewFlutterProjectWizardFixture; +import com.android.tools.idea.tests.gui.framework.fixture.sdk.SdkProblemDialogFixture; import com.android.tools.idea.tests.gui.framework.matcher.Matchers; import com.intellij.openapi.wm.impl.welcomeScreen.FlatWelcomeFrame; import org.fest.swing.core.Robot; @@ -16,6 +17,10 @@ public class FlutterWelcomeFrameFixture extends ComponentFixture { private static final String NEW_PROJECT_WELCOME_ID = "flutter.NewProject.welcome"; // See META-INF/studio-contribs.xml + private FlutterWelcomeFrameFixture(@NotNull Robot robot, @NotNull FlatWelcomeFrame target) { + super(FlutterWelcomeFrameFixture.class, robot, target); + } + @SuppressWarnings("WeakerAccess") @NotNull public static FlutterWelcomeFrameFixture find(@NotNull Robot robot) { @@ -27,10 +32,6 @@ public static FlutterWelcomeFrameFixture find(@NotNull IdeaFrameFixture ideFrame return find(ideFrameFixture.robot()); } - private FlutterWelcomeFrameFixture(@NotNull Robot robot, @NotNull FlatWelcomeFrame target) { - super(FlutterWelcomeFrameFixture.class, robot, target); - } - public SdkProblemDialogFixture createNewProjectWhenSdkIsInvalid() { findActionLinkByActionId(NEW_PROJECT_WELCOME_ID).click(); return SdkProblemDialogFixture.find(this); diff --git a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/IdeaFrameFixture.java b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/IdeaFrameFixture.java index b901f447c1..72ba2ca1b6 100644 --- a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/IdeaFrameFixture.java +++ b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/IdeaFrameFixture.java @@ -9,6 +9,7 @@ import com.android.tools.idea.testing.Modules; import com.android.tools.idea.tests.gui.framework.GuiTests; import com.android.tools.idea.tests.gui.framework.matcher.Matchers; +import com.android.tools.idea.ui.GuiTestingService; import com.google.common.collect.Lists; import com.intellij.ide.actions.ShowSettingsUtilImpl; import com.intellij.openapi.Disposable; @@ -49,7 +50,6 @@ import static java.awt.event.InputEvent.META_MASK; import static junit.framework.Assert.assertNotNull; import static org.fest.util.Strings.quote; -import static org.jetbrains.android.AndroidPlugin.EXECUTE_BEFORE_PROJECT_BUILD_IN_GUI_TEST_KEY; import static org.junit.Assert.assertFalse; @SuppressWarnings("Duplicates") // Adapted from IdeFrameFixture in uitest-framework module, due to private constructor. @@ -60,11 +60,6 @@ public class IdeaFrameFixture extends ComponentFixture { throw new ExternalSystemException(failure); }; - ApplicationManager.getApplication().putUserData(EXECUTE_BEFORE_PROJECT_BUILD_IN_GUI_TEST_KEY, failTask); + ApplicationManager.getApplication().putUserData(GuiTestingService.EXECUTE_BEFORE_PROJECT_BUILD_IN_GUI_TEST_KEY, failTask); selectProjectMakeAction(); return this; } @@ -357,12 +357,6 @@ public DialogFixture waitForDialog(@NotNull String title) { return new DialogFixture(robot(), GuiTests.waitUntilShowing(robot(), Matchers.byTitle(JDialog.class, title))); } - private static class NoOpDisposable implements Disposable { - @Override - public void dispose() { - } - } - public void selectApp(@NotNull String appName) { ActionButtonFixture runButton = findRunApplicationButton(); Container actionToolbarContainer = GuiQuery.getNonNull(() -> runButton.target().getParent()); @@ -404,4 +398,10 @@ protected boolean isMatching(@NotNull JLabel header) { }); robot().pressAndReleaseKey(KeyEvent.VK_ENTER, 0); } + + private static class NoOpDisposable implements Disposable { + @Override + public void dispose() { + } + } } diff --git a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/FlutterProjectStepFixture.java b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/FlutterProjectStepFixture.java index 27415fe853..1f7c8e25e9 100644 --- a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/FlutterProjectStepFixture.java +++ b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/FlutterProjectStepFixture.java @@ -5,10 +5,11 @@ */ package com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard; +import com.android.tools.idea.tests.gui.framework.fixture.wizard.AbstractWizardFixture; +import com.android.tools.idea.tests.gui.framework.fixture.wizard.AbstractWizardStepFixture; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.ui.components.JBLabel; import io.flutter.project.FlutterProjectStep; -import org.fest.swing.core.Robot; import org.fest.swing.edt.GuiQuery; import org.fest.swing.exception.ComponentLookupException; import org.fest.swing.fixture.JComboBoxFixture; @@ -24,9 +25,9 @@ import static org.fest.swing.edt.GuiActionRunner.execute; // TODO(messick): Browse button for SDK; "Install SDK" button -public class FlutterProjectStepFixture extends AbstractWizardStepFixture { - protected FlutterProjectStepFixture(@NotNull Robot robot, @NotNull JRootPane target) { - super(FlutterProjectStepFixture.class, robot, target); +public class FlutterProjectStepFixture extends AbstractWizardStepFixture { + protected FlutterProjectStepFixture(@NotNull W wizard, @NotNull JRootPane target) { + super(FlutterProjectStepFixture.class, wizard, target); } private static boolean isShown(JComponent field) { @@ -95,7 +96,7 @@ protected File executeInEDT() throws Throwable { public String getErrorMessage() { Component comp = robot().finder().findByName("ValidationLabel"); if (comp instanceof JBLabel) { - JBLabel label = (JBLabel) comp; + JBLabel label = (JBLabel)comp; return label.getText(); } return null; @@ -113,7 +114,8 @@ public boolean isConfiguredForModules() { isShown(findTextFieldWithLabel("Description")) && isShown(findComboBox().target()) && !isShown(getLocationField()); - } catch (ComponentLookupException ex) { + } + catch (ComponentLookupException ex) { // Expect this exception when the location field is not found. return true; } diff --git a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/FlutterSettingsStepFixture.java b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/FlutterSettingsStepFixture.java index c0164ee3bb..dcbcb63415 100644 --- a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/FlutterSettingsStepFixture.java +++ b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/FlutterSettingsStepFixture.java @@ -6,8 +6,9 @@ package com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard; import com.android.tools.adtui.LabelWithEditButton; +import com.android.tools.idea.tests.gui.framework.fixture.wizard.AbstractWizardFixture; +import com.android.tools.idea.tests.gui.framework.fixture.wizard.AbstractWizardStepFixture; import io.flutter.FlutterBundle; -import org.fest.swing.core.Robot; import org.fest.swing.edt.GuiQuery; import org.fest.swing.fixture.JCheckBoxFixture; import org.jetbrains.annotations.NotNull; @@ -18,9 +19,10 @@ import static com.google.common.truth.Truth.assertThat; import static org.fest.swing.edt.GuiActionRunner.execute; -public class FlutterSettingsStepFixture extends AbstractWizardStepFixture { - protected FlutterSettingsStepFixture(@NotNull Robot robot, @NotNull JRootPane target) { - super(FlutterSettingsStepFixture.class, robot, target); +public class FlutterSettingsStepFixture + extends AbstractWizardStepFixture { + protected FlutterSettingsStepFixture(@NotNull W wizard, @NotNull JRootPane target) { + super(FlutterSettingsStepFixture.class, wizard, target); } @NotNull diff --git a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/NewFlutterModuleWizardFixture.java b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/NewFlutterModuleWizardFixture.java index b6972aeaec..10d2fcb8b5 100644 --- a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/NewFlutterModuleWizardFixture.java +++ b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/NewFlutterModuleWizardFixture.java @@ -7,10 +7,9 @@ import com.android.tools.adtui.ASGallery; import com.android.tools.idea.tests.gui.framework.GuiTests; -import com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture; import com.android.tools.idea.tests.gui.framework.fixture.IdeaFrameFixture; +import com.android.tools.idea.tests.gui.framework.fixture.wizard.AbstractWizardFixture; import com.android.tools.idea.tests.gui.framework.matcher.Matchers; -import com.intellij.openapi.progress.ProgressManager; import io.flutter.module.FlutterProjectType; import org.fest.swing.core.Robot; import org.fest.swing.fixture.JListFixture; @@ -41,7 +40,7 @@ public NewFlutterModuleWizardFixture chooseModuleType(@NotNull String activity) } @NotNull - public FlutterProjectStepFixture getFlutterProjectStep(@NotNull FlutterProjectType type) { + public FlutterProjectStepFixture getFlutterProjectStep(@NotNull FlutterProjectType type) { String projectType; switch (type) { case APP: @@ -57,17 +56,16 @@ public FlutterProjectStepFixture getFlutterProjectStep(@NotNull FlutterProjectTy throw new IllegalArgumentException(); } JRootPane rootPane = findStepWithTitle("Configure the new Flutter " + projectType); - return new FlutterProjectStepFixture(robot(), rootPane); + return new FlutterProjectStepFixture<>(this, rootPane); } @NotNull public FlutterSettingsStepFixture getFlutterSettingsStep() { JRootPane rootPane = findStepWithTitle("Set the package name"); - return new FlutterSettingsStepFixture(robot(), rootPane); + return new FlutterSettingsStepFixture<>(this, rootPane); } @NotNull - @Override public NewFlutterModuleWizardFixture clickFinish() { // Do not user superclass method. When the project/module wizard is run from the IDE (not the Welcome scren) // the dialog does not disappear within the time allotted by the superclass method. diff --git a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/NewFlutterProjectWizardFixture.java b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/NewFlutterProjectWizardFixture.java index 4b0c137f7b..bac4921000 100644 --- a/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/NewFlutterProjectWizardFixture.java +++ b/flutter-studio/testSrc/com/android/tools/idea/tests/gui/framework/fixture/newProjectWizard/NewFlutterProjectWizardFixture.java @@ -7,8 +7,11 @@ import com.android.tools.adtui.ASGallery; import com.android.tools.idea.tests.gui.framework.GuiTests; +import com.android.tools.idea.tests.gui.framework.fixture.wizard.AbstractWizardFixture; import com.android.tools.idea.tests.gui.framework.matcher.Matchers; import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectManager; import io.flutter.module.FlutterProjectType; import org.fest.swing.core.Robot; import org.fest.swing.fixture.JListFixture; @@ -16,20 +19,23 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.util.List; + +import static com.google.common.collect.Lists.newArrayList; // Adapted from com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.NewProjectWizardFixture public class NewFlutterProjectWizardFixture extends AbstractWizardFixture { + private NewFlutterProjectWizardFixture(@NotNull Robot robot, @NotNull JDialog target) { + super(NewFlutterProjectWizardFixture.class, robot, target); + } + @NotNull public static NewFlutterProjectWizardFixture find(@NotNull Robot robot) { JDialog dialog = GuiTests.waitUntilShowing(robot, Matchers.byTitle(JDialog.class, "Create New Flutter Project")); return new NewFlutterProjectWizardFixture(robot, dialog); } - private NewFlutterProjectWizardFixture(@NotNull Robot robot, @NotNull JDialog target) { - super(NewFlutterProjectWizardFixture.class, robot, target); - } - public NewFlutterProjectWizardFixture chooseProjectType(@NotNull String activity) { JListFixture listFixture = new JListFixture(robot(), robot().finder().findByType(target(), ASGallery.class)); listFixture.replaceCellReader((jList, index) -> String.valueOf(jList.getModel().getElementAt(index))); @@ -38,7 +44,7 @@ public NewFlutterProjectWizardFixture chooseProjectType(@NotNull String activity } @NotNull - public FlutterProjectStepFixture getFlutterProjectStep(@NotNull FlutterProjectType type) { + public FlutterProjectStepFixture getFlutterProjectStep(@NotNull FlutterProjectType type) { String projectType; switch (type) { case APP: @@ -54,19 +60,27 @@ public FlutterProjectStepFixture getFlutterProjectStep(@NotNull FlutterProjectTy throw new IllegalArgumentException(); } JRootPane rootPane = findStepWithTitle("Configure the new Flutter " + projectType); - return new FlutterProjectStepFixture(robot(), rootPane); + return new FlutterProjectStepFixture<>(this, rootPane); } @NotNull public FlutterSettingsStepFixture getFlutterSettingsStep() { JRootPane rootPane = findStepWithTitle("Set the package name"); - return new FlutterSettingsStepFixture(robot(), rootPane); + return new FlutterSettingsStepFixture<>(this, rootPane); } @NotNull - @Override public NewFlutterProjectWizardFixture clickFinish() { - super.clickFinish(); + List previouslyOpenProjects = newArrayList(ProjectManager.getInstance().getOpenProjects()); + super.clickFinish(Wait.seconds(10)); + + List newOpenProjects = newArrayList(); + Wait.seconds(5).expecting("Project to be created") + .until(() -> { + newOpenProjects.addAll(newArrayList(ProjectManager.getInstance().getOpenProjects())); + newOpenProjects.removeAll(previouslyOpenProjects); + return !newOpenProjects.isEmpty(); + }); // Wait for 'flutter create' to finish Wait.seconds(30).expecting("Modal Progress Indicator to finish") diff --git a/flutter-studio/testSrc/io/flutter/tests/gui/NewModuleTest.java b/flutter-studio/testSrc/io/flutter/tests/gui/NewModuleTest.java index 47fcc01cf1..e706979487 100644 --- a/flutter-studio/testSrc/io/flutter/tests/gui/NewModuleTest.java +++ b/flutter-studio/testSrc/io/flutter/tests/gui/NewModuleTest.java @@ -9,10 +9,10 @@ import com.android.tools.idea.tests.gui.framework.GuiTestRunner; import com.android.tools.idea.tests.gui.framework.fixture.EditorFixture; import com.android.tools.idea.tests.gui.framework.fixture.FlutterFrameFixture; -import com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture; -import com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.*; +import com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.FlutterProjectStepFixture; +import com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.FlutterSettingsStepFixture; +import com.android.tools.idea.tests.gui.framework.fixture.newProjectWizard.NewFlutterModuleWizardFixture; import io.flutter.module.FlutterProjectType; -import io.flutter.project.FlutterSettingsStep; import io.flutter.tests.util.WizardUtils; import org.junit.Rule; import org.junit.Test; @@ -31,7 +31,8 @@ public void createNewAppModule() { EditorFixture editor = ideFrame.getEditor(); editor.waitUntilErrorAnalysisFinishes(); - NewFlutterModuleWizardFixture wizardFixture = ideFrame.openFromMenu(NewFlutterModuleWizardFixture::find, "File", "New", "New Module..."); + NewFlutterModuleWizardFixture wizardFixture = + ideFrame.openFromMenu(NewFlutterModuleWizardFixture::find, "File", "New", "New Module..."); wizardFixture.chooseModuleType("Flutter Application").clickNext(); NewFlutterModuleWizardFixture wizard = ideFrame.findNewModuleWizard(); diff --git a/product-matrix.json b/product-matrix.json index af5a04055c..1f9c9517d8 100644 --- a/product-matrix.json +++ b/product-matrix.json @@ -9,6 +9,15 @@ "sinceBuild": "171.1", "untilBuild": "171.*" }, + { + "name": "Android Studio", + "version": "3.1", + "ideaProduct": "android-studio", + "ideaVersion": "173.4595152", + "dartPluginVersion": "173.4301.22", + "sinceBuild": "173.0", + "untilBuild": "173.*" + }, { "name": "IntelliJ", "version": "2017.3",