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

Unified Diff: pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart

Issue 2965243002: Add unit tests for 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/src/computer/imported_elements_computer_test.dart
diff --git a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e9f7d0d25835832d9321d79e3383f4d3444012db
--- /dev/null
+++ b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
@@ -0,0 +1,51 @@
+// 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:analysis_server/src/computer/imported_elements_computer.dart';
+import 'package:analyzer/dart/analysis/results.dart';
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../../abstract_context.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(ImportElementsComputerTest);
+ });
+}
+
+@reflectiveTest
+class ImportElementsComputerTest extends AbstractContextTest {
+ String sourcePath;
+
+ setUp() {
+ super.setUp();
+ sourcePath = provider.convertPath('/p/lib/source.dart');
+ }
+
+ test_none() async {
+ String selection = 'x + y + 1';
+ String content = """
+plusThree(int x) {
+ int y = 2;
+ print($selection);
+}
+""";
+ List<ImportedElements> elements = await _computeElements(
+ content, content.indexOf(selection), selection.length);
+ expect(elements, hasLength(0));
+ }
+
+ Future<List<ImportedElements>> _computeElements(
+ String sourceContent, int offset, int length) async {
+ provider.newFile(sourcePath, sourceContent);
+ ResolveResult result = await driver.getResult(sourcePath);
+ ImportedElementsComputer computer =
+ new ImportedElementsComputer(result.unit, offset, length);
+ return computer.compute();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698