Skip to content

Commit 50a2172

Browse files
authored
Restore ignored tests (#5826)
* Restore ignored tests * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug
1 parent 210ee72 commit 50a2172

37 files changed

+25755
-33
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ lib/jxbrowser/*
2020
!lib/java-string-similarity-2.0.0.jar
2121
material-design-icons/
2222
out/
23-
packages
2423
pubspec.lock
2524
releases/
2625
resources/jxbrowser/jxbrowser.properties

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ dependencies {
8383
}
8484

8585
sourceSets {
86+
test.resources.srcDirs = [
87+
"flutter-idea/testData"
88+
]
8689
}
8790

8891
//noinspection GroovyAssignabilityCheck

docs/building.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ project in IntelliJ, then delete .idea/modules.xml. You may need to delete other
3636
files in ~/Library/Application Support/Caches/JetBrains/<IDE>/. Look in `conversion`
3737
and `external_build_systrm`. It may take some experimentation. When the project
3838
is opened in IntelliJ, ensure that there are `flutter-idea` and `flutter-studio`
39-
modules in the project structure.
39+
modules in the project structure. Also make sure the project sdk is set to a
40+
JDK-equivalent, not a JRE-equivalent.
4041

4142
To re-open the project as an IntelliJ (not Gradle) project, close it in IntelliJ,
4243
then restore .idea/modules.xml and delete .idea/gradle.xml. Again, you may need to

flutter-idea/testData

Lines changed: 0 additions & 1 deletion
This file was deleted.

flutter-idea/testData/sdk/packages/flutter/lib/src/cupertino/icons.dart

Lines changed: 3553 additions & 0 deletions
Large diffs are not rendered by default.

flutter-idea/testData/sdk/packages/flutter/lib/src/material/icons.dart

Lines changed: 22131 additions & 0 deletions
Large diffs are not rendered by default.

src/io/flutter/editor/FlutterCompletionContributor.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
package io.flutter.editor;
77

88
import com.intellij.codeInsight.lookup.LookupElementBuilder;
9+
import com.intellij.openapi.application.ApplicationManager;
910
import com.intellij.openapi.project.Project;
1011
import com.intellij.util.ui.ColorIcon;
1112
import com.intellij.util.ui.EmptyIcon;
1213
import com.jetbrains.lang.dart.ide.completion.DartCompletionExtension;
1314
import com.jetbrains.lang.dart.ide.completion.DartServerCompletionContributor;
15+
import io.flutter.sdk.FlutterSdk;
1416
import org.apache.commons.lang.StringUtils;
1517
import org.dartlang.analysis.server.protocol.CompletionSuggestion;
1618
import org.dartlang.analysis.server.protocol.Element;
@@ -60,12 +62,12 @@ else if (Objects.equals(declaringType, "CupertinoColors")) {
6062
}
6163
}
6264
else if (Objects.equals(declaringType, "Icons")) {
63-
final Icon icon = FlutterIconLineMarkerProvider.getMaterialIconByName(project, name);
65+
final Icon icon = FlutterIconLineMarkerProvider.getMaterialIconByName(project, getSdkHomePath(project), name);
6466
// If we have no icon, show an empty node (which is preferable to the default "IconData" text).
6567
return icon != null ? icon : EMPTY_ICON;
6668
}
6769
else if (Objects.equals(declaringType, "CupertinoIcons")) {
68-
final Icon icon = FlutterIconLineMarkerProvider.getCupertinoIconByName(project, name);
70+
final Icon icon = FlutterIconLineMarkerProvider.getCupertinoIconByName(project, getSdkHomePath(project), name);
6971
// If we have no icon, show an empty node (which is preferable to the default "IconData" text).
7072
return icon != null ? icon : EMPTY_ICON;
7173
}
@@ -75,4 +77,17 @@ else if (Objects.equals(declaringType, "CupertinoIcons")) {
7577

7678
return null;
7779
}
80+
81+
@NotNull
82+
private static String getSdkHomePath(@NotNull Project project) {
83+
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
84+
if (sdk == null) {
85+
assert ApplicationManager.getApplication() != null;
86+
if (ApplicationManager.getApplication().isUnitTestMode()) {
87+
return "testData/sdk";
88+
}
89+
throw new NullPointerException("Flutter SDK not found");
90+
}
91+
return sdk.getHomePath();
92+
}
7893
}

src/io/flutter/editor/FlutterIconLineMarkerProvider.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.jetbrains.yaml.psi.YamlRecursivePsiElementVisitor;
4343

4444
import javax.swing.*;
45+
import java.io.FileNotFoundException;
4546
import java.util.*;
4647

4748
import static io.flutter.dart.DartPsiUtil.*;
@@ -75,28 +76,24 @@ public static void initialize() {
7576
}
7677

7778
@Nullable
78-
public static Icon getCupertinoIconByName(@Nullable Project project, @NotNull String iconName) {
79+
public static Icon getCupertinoIconByName(@Nullable Project project, @NotNull String sdkHomePath, @NotNull String iconName) {
7980
if (project == null) return null;
80-
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
81-
if (sdk == null) return null;
8281
final IconInfo iconDef =
83-
findStandardDefinition("CupertinoIcons", iconName, project, sdk.getHomePath() + BuiltInPaths.get("CupertinoIcons"), sdk);
82+
findStandardDefinition("CupertinoIcons", iconName, project, sdkHomePath + BuiltInPaths.get("CupertinoIcons"), sdkHomePath);
8483
if (iconDef == null) return null;
8584
final String path = FlutterSdkUtil.getPathToCupertinoIconsPackage(project);
8685
// <pub_cache>/hosted/pub.dartlang.org/cupertino_icons-v.m.n/assets/CupertinoIcons.ttf
8786
return findStandardIconFromDef(iconName, iconDef, path + CupertinoRelativeAssetPath);
8887
}
8988

9089
@Nullable
91-
public static Icon getMaterialIconByName(@Nullable Project project, @NotNull String iconName) {
90+
public static Icon getMaterialIconByName(@Nullable Project project, @NotNull String sdkHomePath, @NotNull String iconName) {
9291
if (project == null) return null;
93-
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
94-
if (sdk == null) return null;
9592
final IconInfo iconDef =
96-
findStandardDefinition("Icons", iconName, project, sdk.getHomePath() + BuiltInPaths.get("Icons"), sdk);
93+
findStandardDefinition("Icons", iconName, project, sdkHomePath + BuiltInPaths.get("Icons"), sdkHomePath);
9794
if (iconDef == null) return null;
9895
// <flutter-sdk>/bin/cache/artifacts/material_fonts/MaterialIcons-Regular.otf
99-
return findStandardIconFromDef(iconName, iconDef, sdk.getHomePath() + MaterialRelativeAssetPath);
96+
return findStandardIconFromDef(iconName, iconDef, sdkHomePath + MaterialRelativeAssetPath);
10097
}
10198

10299
@Nullable
@@ -198,10 +195,10 @@ else if (parentNode.getElementType() == DartTokenTypes.SIMPLE_TYPE) {
198195
final String selector = AstBufferUtil.getTextSkippingWhitespaceComments(selectorNode.getNode());
199196
final Icon icon;
200197
if (name.equals("Icons")) {
201-
icon = getMaterialIconByName(element.getProject(), selector);
198+
icon = getMaterialIconByName(element.getProject(), sdk.getHomePath(), selector);
202199
}
203200
else if (name.equals("CupertinoIcons")) {
204-
icon = getCupertinoIconByName(element.getProject(), selector);
201+
icon = getCupertinoIconByName(element.getProject(), sdk.getHomePath(), selector);
205202
}
206203
else {
207204
// Note: I want to keep this code until I'm sure we won't use pubspec.yaml.
@@ -254,12 +251,12 @@ private static IconInfo findStandardDefinition(@NotNull String className,
254251
@NotNull String iconName,
255252
@NotNull Project project,
256253
@Nullable String path,
257-
@NotNull FlutterSdk sdk) {
254+
@NotNull String sdkHomePath) {
258255
if (path != null) {
259256
return findDefinition(className, iconName, project, path);
260257
}
261258
assert Objects.requireNonNull(ApplicationManager.getApplication()).isUnitTestMode();
262-
return findDefinition(className, iconName, project, sdk.getHomePath() + BuiltInPaths.get(className));
259+
return findDefinition(className, iconName, project, sdkHomePath + BuiltInPaths.get(className));
263260
}
264261

265262
@Nullable
@@ -313,10 +310,10 @@ private static IconInfo findDefinition(@NotNull String className,
313310
@NotNull String path) {
314311
assert LocalFileSystem.getInstance() != null;
315312
final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
316-
if (virtualFile == null) return null;
313+
if (virtualFile == null) throw new Error("FILE NOT FOUND: " + path);//return null;
317314
final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
318315
if (psiFile == null) {
319-
return null;
316+
throw new Error("CANNOT CREATE PSI FILE");//return null;
320317
}
321318
final IconInfoVisitor visitor = new IconInfoVisitor(iconName);
322319
psiFile.accept(visitor);
@@ -327,7 +324,7 @@ private static IconInfo findDefinition(@NotNull String className,
327324
private static Icon findIconFromDef(@NotNull String iconClassName, @NotNull IconInfo iconDef, @NotNull String path) {
328325
assert LocalFileSystem.getInstance() != null;
329326
final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
330-
if (virtualFile == null) return null;
327+
if (virtualFile == null) throw new Error("FILE NOT FOUND: " + path);//return null;
331328
VirtualFile parent = virtualFile;
332329
while (parent != null && !parent.getName().equals("lib")) {
333330
parent = parent.getParent();

src/io/flutter/sdk/FlutterSdkUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ public static String guessFlutterSdkFromPackagesFile(@NotNull Module module) {
295295

296296
@Nullable
297297
public static String getPathToCupertinoIconsPackage(@NotNull Project project) {
298+
//noinspection ConstantConditions
299+
if (ApplicationManager.getApplication().isUnitTestMode()) {
300+
// TODO(messick): Configure the test framework to have proper pub data so we don't need this.
301+
return "testData/sdk";
302+
}
298303
final JsonArray packages = getPackagesFromPackageConfig(PubRoots.forProject(project));
299304
for (int i = 0; i < packages.size(); i++) {
300305
final JsonObject pack = packages.get(i).getAsJsonObject();

src/io/flutter/utils/UIUtils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public static ColorKey getEditorNotificationBackgroundColor() {
3838
return EditorColors.GUTTER_BACKGROUND;
3939
}
4040

41+
/**
42+
* Unstable API warning: only use this in the deprecated inspector.
43+
* @return best-guess for the current project based on the top-most window.
44+
*/
4145
@Nullable
4246
public static Project findVisibleProject() {
4347
final WindowManager wm = WindowManager.getInstance();

testData

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flutter-idea/testData

testSrc/unit/io/flutter/editor/FlutterIconLineMarkerTest.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import io.flutter.sdk.FlutterSdk;
1616
import org.junit.Test;
1717

18+
import java.io.IOException;
19+
1820
import static org.mockito.Mockito.mock;
1921
import static org.mockito.Mockito.when;
2022

@@ -27,17 +29,17 @@ private FlutterSdk getSdk() {
2729
return mockSdk;
2830
}
2931

30-
//@Test
31-
public void xtestLocatesIconsReference() throws Exception {
32+
@Test
33+
public void testLocatesIconsReference() throws Exception {
3234
final PsiElement testIdentifier = setUpDartElement("main() { Icons.access_alarm; }", "Icons", LeafPsiElement.class);
3335
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
3436
assertNotNull(marker);
3537
final DartReferenceExpression element = DartSyntax.findEnclosingReferenceExpression(testIdentifier);
3638
assertNotNull(element);
3739
}
3840

39-
//@Test
40-
public void xtestLocatesIconCtor() throws Exception {
41+
@Test
42+
public void testLocatesIconCtor() throws Exception {
4143
final PsiElement testIdentifier =
4244
setUpDartElement("main() { IconData(0xe190, fontFamily: 'MaterialIcons'); }", "IconData", LeafPsiElement.class);
4345
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
@@ -46,8 +48,8 @@ public void xtestLocatesIconCtor() throws Exception {
4648
assertNotNull(element);
4749
}
4850

49-
//@Test
50-
public void xtestLocatesCupertinoIconCtor() throws Exception {
51+
@Test
52+
public void testLocatesCupertinoIconCtor() throws Exception {
5153
final PsiElement testIdentifier =
5254
setUpDartElement("main() { IconData(0xe190, fontFamily: 'CupertinoIcons'); }", "IconData", LeafPsiElement.class);
5355
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
@@ -56,8 +58,8 @@ public void xtestLocatesCupertinoIconCtor() throws Exception {
5658
assertNotNull(element);
5759
}
5860

59-
//@Test
60-
public void xtestLocatesConstIconCtor() throws Exception {
61+
@Test
62+
public void testLocatesConstIconCtor() throws Exception {
6163
final PsiElement testIdentifier =
6264
setUpDartElement("main() { const IconData(0xe190, fontFamily: 'MaterialIcons'); }", "IconData", LeafPsiElement.class);
6365
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
@@ -66,17 +68,17 @@ public void xtestLocatesConstIconCtor() throws Exception {
6668
assertNotNull(element);
6769
}
6870

69-
//@Test
70-
public void xtestLocatesCupertinoIconsReference() throws Exception {
71+
@Test
72+
public void testLocatesCupertinoIconsReference() throws Exception {
7173
final PsiElement testIdentifier = setUpDartElement("main() { CupertinoIcons.book; }", "CupertinoIcons", LeafPsiElement.class);
7274
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());
7375
assertNotNull(marker);
7476
final DartReferenceExpression element = DartSyntax.findEnclosingReferenceExpression(testIdentifier);
7577
assertNotNull(element);
7678
}
7779

78-
//@Test
79-
public void xtestLocatesCupertinoIconsReferenceWithComment() throws Exception {
80+
@Test
81+
public void testLocatesCupertinoIconsReferenceWithComment() throws Exception {
8082
final PsiElement testIdentifier =
8183
setUpDartElement("main() { CupertinoIcons . /* a book */ book; }", "CupertinoIcons", LeafPsiElement.class);
8284
final LineMarkerInfo<?> marker = new FlutterIconLineMarkerProvider().getLineMarkerInfo(testIdentifier, getSdk());

tool/github.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ elif [ "CHECK_BOT" = "$BOT" ] ; then
6767

6868
elif [ "UNIT_TEST_BOT" = "$BOT" ] ; then
6969

70+
echo `pwd`
71+
echo "ls -lR"
72+
ls -lR > dir-list.txt
73+
cat dir-list.txt
74+
7075
# Run unit tests.
7176
./bin/plugin test
7277

tool/kokoro/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ setup() {
2828
export FLUTTER_KEYSTORE_ID=74840
2929
export FLUTTER_KEYSTORE_NAME=flutter-intellij-plugin-auth-token
3030
export FLUTTER_KEYSTORE_JXBROWSER_KEY_NAME=flutter-intellij-plugin-jxbrowser-license-key
31+
export NO_FS_ROOTS_ACCESS_CHECK=true
3132

3233
(cd tool/plugin; echo "pub get `pwd`"; pub get --no-precompile)
3334
./gradlew --version

tool/kokoro/test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
source ./tool/kokoro/setup.sh
44
setup
55

6+
curl https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_osx-x64_bin.tar.gz > ../java.tar.gz
7+
(cd ..; tar fx java.tar.gz)
8+
export JAVA_HOME=`pwd`/../jdk-11.0.2.jdk/Contents/Home
9+
export PATH=$PATH:$JAVA_HOME/bin
10+
echo "JAVA_HOME=$JAVA_HOME"
11+
612
(cd testData/sample_tests; echo "pub get `pwd`"; pub get --no-precompile)
713

814
echo "kokoro test start"

0 commit comments

Comments
 (0)