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

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

Issue 2972833002: Initial implementation of copy/paste support (Closed)
Patch Set: Created 3 years, 5 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
new file mode 100644
index 0000000000000000000000000000000000000000..0ab67809cd5f942963160e021e0443e75a2cea24
--- /dev/null
+++ b/pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+
+import 'package:analysis_server/protocol/protocol_generated.dart';
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../support/integration_tests.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(AnalysisGetImportedElementsIntegrationTest);
+ });
+}
+
+@reflectiveTest
+class AnalysisGetImportedElementsIntegrationTest
+ extends AbstractAnalysisServerIntegrationTest {
+ /**
+ * Pathname of the file containing Dart code.
+ */
+ String pathname;
+
+ /**
+ * Dart code under test.
+ */
+ final String text = r'''
+main() {}
+''';
+
+ /**
+ * Check that an analysis.getImportedElements request on the region starting
+ * with the first character that matches [target] and having the given
+ * [length] matches the given list of [expected] imported elements.
+ */
+ checkElements(
+ String target, int length, List<ImportedElements> expected) async {
+ int offset = text.indexOf(target);
+ AnalysisGetImportedElementsResult result =
+ await sendAnalysisGetImportedElements(pathname, offset, length);
+
+ expect(result.elements, hasLength(expected.length));
+ // TODO(brianwilkerson) Finish implementing this.
+ }
+
+ /**
+ * Check that an analysis.getImportedElements request on the region matching
+ * [target] produces an empty list of elements.
+ */
+ Future<Null> checkNoElements(String target) async {
+ int offset = text.indexOf(target);
+ AnalysisGetImportedElementsResult result =
+ await sendAnalysisGetImportedElements(pathname, offset, target.length);
+
+ expect(result.elements, hasLength(0));
+ }
+
+ setUp() {
+ return super.setUp().then((_) {
+ pathname = sourcePath('test.dart');
+ });
+ }
+
+ test_getImportedElements() async {
+ writeFile(pathname, text);
+ standardAnalysisSetup();
+ await analysisFinished;
+
+ List<Future> tests = [];
+ tests.add(checkNoElements('main() {}'));
+ return Future.wait(tests);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698