diff --git a/flutter-idea/testSrc/integration/io/flutter/sdk/FlutterSdkUtilTest.java b/flutter-idea/testSrc/integration/io/flutter/sdk/FlutterSdkUtilTest.java deleted file mode 100644 index 88f1a0bb7f..0000000000 --- a/flutter-idea/testSrc/integration/io/flutter/sdk/FlutterSdkUtilTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2016 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -package io.flutter.sdk; - -import com.intellij.execution.ExecutionException; -import com.jetbrains.lang.dart.sdk.DartSdk; -import io.flutter.dart.DartPlugin; -import io.flutter.testing.FlutterModuleFixture; -import io.flutter.testing.ProjectFixture; -import io.flutter.testing.Testing; -import org.junit.Rule; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class FlutterSdkUtilTest { - @Rule - public ProjectFixture projectFixture = Testing.makeCodeInsightModule(); - - @Rule - public FlutterModuleFixture flutterFixture = new FlutterModuleFixture(projectFixture); - - @Test - public void shouldInstallFlutterSDK() throws ExecutionException { - // All of FlutterTestUtils is exercised before getting here. - assertTrue("Test jig setup failed", true); - - // Verify Flutter SDK is installed correctly. - final FlutterSdk flutterSdk = FlutterSdk.getFlutterSdk(projectFixture.getProject()); - assertNotNull(flutterSdk); - final String path = System.getProperty("flutter.sdk"); - assertEquals("Incorrect Flutter SDK path", flutterSdk.getHomePath(), path); - - // Verify Dart SDK is the one distributed with Flutter. - final DartSdk dartSdk = DartPlugin.getDartSdk(projectFixture.getProject()); - assertNotNull(dartSdk); - assertTrue("Dart SDK not found in Flutter SDK installation", dartSdk.getHomePath().startsWith(flutterSdk.getHomePath())); - - // Check SDK utilities. - final String toolPath = FlutterSdkUtil.pathToFlutterTool(flutterSdk.getHomePath()); - assertEquals("Incorrect path to flutter command", toolPath, path + "/bin/flutter"); - assertTrue(FlutterSdkUtil.isFlutterSdkHome(path)); - } -} diff --git a/flutter-idea/testSrc/integration/io/flutter/testing/FlutterModuleFixture.java b/flutter-idea/testSrc/integration/io/flutter/testing/FlutterModuleFixture.java deleted file mode 100644 index bfd2916c7a..0000000000 --- a/flutter-idea/testSrc/integration/io/flutter/testing/FlutterModuleFixture.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2017 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -package io.flutter.testing; - -import com.intellij.openapi.Disposable; -import com.intellij.openapi.module.Module; -import com.jetbrains.lang.dart.util.DartTestUtils; -import io.flutter.sdk.FlutterSdk; -import org.junit.rules.ExternalResource; - -/** - * Provides a Flutter Module with the Flutter SDK configured. - * - *

Depends on a {@link ProjectFixture} already being installed. - */ -public class FlutterModuleFixture extends ExternalResource { - private final ProjectFixture parent; - private final Disposable testRoot = () -> {}; - private final boolean realSdk; - - public FlutterModuleFixture(ProjectFixture parent) { - this(parent, true); - } - - public FlutterModuleFixture(ProjectFixture parent, boolean realSdk) { - this.parent = parent; - this.realSdk = realSdk; - } - - @Override - protected void before() throws Exception { - Testing.runOnDispatchThread(() -> { - FlutterTestUtils.configureFlutterSdk(parent.getModule(), testRoot, realSdk); - if (realSdk) { - final FlutterSdk sdk = FlutterSdk.getFlutterSdk(parent.getProject()); - assert (sdk != null); - final String path = sdk.getHomePath(); - final String dartSdkPath = path + "/bin/cache/dart-sdk"; - System.setProperty("dart.sdk", dartSdkPath); - } - DartTestUtils.configureDartSdk(parent.getModule(), testRoot, realSdk); - }); - } - - @Override - protected void after() { - testRoot.dispose(); - } - - public Module getModule() { - return parent.getModule(); - } -} diff --git a/flutter-idea/testSrc/integration/io/flutter/testing/FlutterTestUtils.java b/flutter-idea/testSrc/integration/io/flutter/testing/FlutterTestUtils.java deleted file mode 100644 index 12ee6fe3ee..0000000000 --- a/flutter-idea/testSrc/integration/io/flutter/testing/FlutterTestUtils.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2017 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -package io.flutter.testing; - -import com.intellij.openapi.Disposable; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.PathManager; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.roots.impl.libraries.ApplicationLibraryTable; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess; -import com.intellij.util.PathUtil; -import io.flutter.dart.DartPlugin; -import io.flutter.sdk.FlutterSdk; -import io.flutter.sdk.FlutterSdkUtil; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; - -import java.io.File; -import java.util.Collections; - -public class FlutterTestUtils { - public static final String BASE_TEST_DATA_PATH = findTestDataPath(); - public static final String SDK_HOME_PATH = BASE_TEST_DATA_PATH + "/sdk"; - - public static void configureFlutterSdk(@NotNull final Module module, @NotNull final Disposable disposable, final boolean realSdk) { - final String sdkHome; - if (realSdk) { - sdkHome = System.getProperty("flutter.sdk"); - if (sdkHome == null) { - Assert.fail("To run tests that use the flutter tools you need to add '-Dflutter.sdk=[real SDK home]' to the VM Options field of " + - "the corresponding JUnit run configuration (Run | Edit Configurations)"); - } - if (!FlutterSdkUtil.isFlutterSdkHome(sdkHome)) { - Assert.fail("Incorrect path to the Flutter SDK (" + sdkHome + ") is set as '-Dflutter.sdk' VM option of " + - "the corresponding JUnit run configuration (Run | Edit Configurations)"); - } - VfsRootAccess.allowRootAccess(disposable, sdkHome); - } - else { - sdkHome = SDK_HOME_PATH; - } - - ApplicationManager.getApplication().runWriteAction(() -> { - FlutterSdkUtil.setFlutterSdkPath(module.getProject(), sdkHome); - DartPlugin.enableDartSdk(module); - }); - - Disposer.register(disposable, () -> ApplicationManager.getApplication().runWriteAction(() -> { - if (!module.isDisposed()) { - DartPlugin.disableDartSdk(Collections.singletonList(module)); - } - - final ApplicationLibraryTable libraryTable = ApplicationLibraryTable.getApplicationTable(); - final Library library = libraryTable.getLibraryByName(FlutterSdk.FLUTTER_SDK_GLOBAL_LIB_NAME); - if (library != null) { - libraryTable.removeLibrary(library); - } - })); - } - - private static String findTestDataPath() { - if (new File(PathManager.getHomePath() + "/contrib").isDirectory()) { - // started from IntelliJ IDEA Ultimate project - return FileUtil.toSystemIndependentName(PathManager.getHomePath() + "/contrib/flutter-intellij/testData"); - } - - final File f = new File("testData"); - if (f.isDirectory()) { - // started from flutter plugin project - return FileUtil.toSystemIndependentName(f.getAbsolutePath()); - } - - final String parentPath = PathUtil.getParentPath(PathManager.getHomePath()); - - if (new File(parentPath + "/intellij-plugins").isDirectory()) { - // started from IntelliJ IDEA Community Edition + flutter plugin project - return FileUtil.toSystemIndependentName(parentPath + "/intellij-plugins/flutter-intellij/testData"); - } - - if (new File(parentPath + "/contrib").isDirectory()) { - // started from IntelliJ IDEA Community + flutter plugin project - return FileUtil.toSystemIndependentName(parentPath + "/contrib/flutter-intellij/testData"); - } - - return ""; - } -}