Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart

Issue 3001733002: Correctly handle adding imports when pasting into part files (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart
diff --git a/pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart b/pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart
index 46fefc22c444c98644b9748d5fb21c42df84e3eb..f5a98cd99092140e9ad84021927c9731876e2710 100644
--- a/pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart
@@ -5,6 +5,7 @@
import 'dart:async';
import 'package:analysis_server/protocol/protocol_generated.dart';
+import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -37,9 +38,8 @@ class AnalysisGetImportedElementsIntegrationTest
checkElements(String target, List<ImportedElements> expected) async {
bool equals(
ImportedElements actualElements, ImportedElements expectedElements) {
- // We can't test the path because the paths are relative to a generated
- // temporary directory.
- if (actualElements.prefix == expectedElements.prefix) {
+ if (actualElements.path.endsWith(expectedElements.path) &&
+ actualElements.prefix == expectedElements.prefix) {
List<String> actual = actualElements.elements;
List<String> expected = expectedElements.elements;
if (actual.length == expected.length) {
@@ -105,26 +105,31 @@ main() {}
standardAnalysisSetup();
await analysisFinished;
- List<Future> tests = [];
- tests.add(checkNoElements('main() {}'));
- return Future.wait(tests);
+ await checkNoElements('main() {}');
}
test_getImportedElements_some() async {
- text = r'''
+ String selection = r'''
main() {
- String s = '';
+ Random r = new Random();
+ String s = r.nextBool().toString();
print(s);
}
''';
+ text = '''
+import 'dart:math';
+
+$selection
+''';
writeFile(pathname, text);
standardAnalysisSetup();
await analysisFinished;
- List<Future> tests = [];
- tests.add(checkElements(text, [
- new ImportedElements('', '', ['String', 'print'])
- ]));
- return Future.wait(tests);
+ await checkElements(selection, [
+ new ImportedElements(
+ path.join('lib', 'core', 'core.dart'), '', ['String', 'print']),
+ new ImportedElements(
+ path.join('lib', 'math', 'math.dart'), '', ['Random'])
+ ]);
}
}

Powered by Google App Engine
This is Rietveld 408576698