Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile against 3.1 beta 3 #1792

Merged
merged 2 commits into from
Feb 20, 2018
Merged
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
3 changes: 0 additions & 3 deletions flutter-intellij-community.iml
Original file line number Diff line number Diff line change
@@ -44,8 +44,5 @@
</library>
</orderEntry>
<orderEntry type="library" name="snakeyaml" level="project" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
<orderEntry type="module" module-name="testGuiFramework" scope="TEST" />
</component>
</module>
3 changes: 2 additions & 1 deletion flutter-studio/src/io/flutter/FlutterStudioInitializer.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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.
}
}
33 changes: 15 additions & 18 deletions flutter-studio/src/io/flutter/project/FlutterProjectCreator.java
Original file line number Diff line number Diff line change
@@ -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,34 +112,41 @@ 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<File> dirs) {
private static String relativePath(@NotNull File basePath, @NotNull Collection<VirtualFile> 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);
}
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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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<Throwable> 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<Throwable> errors = new ArrayList<>();
try {
base.evaluate();
Original file line number Diff line number Diff line change
@@ -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<FlutterWelcomeFrameFixture, FlatWelcomeFrame> {
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);
Original file line number Diff line number Diff line change
@@ -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<IdeaFrameFixture, IdeFram
private EditorFixture myEditor;
private boolean myIsClosed;

@NotNull
public static IdeaFrameFixture find(@NotNull final Robot robot) {
return new IdeaFrameFixture(robot, GuiTests.waitUntilShowing(robot, Matchers.byType(IdeFrameImpl.class)));
}

IdeaFrameFixture(@NotNull Robot robot, @NotNull IdeFrameImpl target) {
super(IdeaFrameFixture.class, robot, target);
myIdeFrameFixture = IdeFrameFixture.find(robot);
@@ -75,6 +70,11 @@ public static IdeaFrameFixture find(@NotNull final Robot robot) {
Disposer.register(project, disposable);
}

@NotNull
public static IdeaFrameFixture find(@NotNull final Robot robot) {
return new IdeaFrameFixture(robot, GuiTests.waitUntilShowing(robot, Matchers.byType(IdeFrameImpl.class)));
}

@NotNull
public File getProjectPath() {
return new File(target().getProject().getBasePath());
@@ -150,7 +150,7 @@ public IdeaFrameFixture invokeProjectMakeAndSimulateFailure(@NotNull String fail
Runnable failTask = () -> {
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() {
}
}
}
Original file line number Diff line number Diff line change
@@ -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<FlutterProjectStepFixture> {
protected FlutterProjectStepFixture(@NotNull Robot robot, @NotNull JRootPane target) {
super(FlutterProjectStepFixture.class, robot, target);
public class FlutterProjectStepFixture<W extends AbstractWizardFixture> extends AbstractWizardStepFixture<FlutterProjectStepFixture, W> {
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;
}
Loading