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

Unified Diff: pkg/analysis_server/test/services/correction/organize_directives_test.dart

Issue 2859993004: Convert some tests to use the driver and prepare for others to be converted (Closed)
Patch Set: Created 3 years, 7 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/services/correction/organize_directives_test.dart
diff --git a/pkg/analysis_server/test/services/correction/organize_directives_test.dart b/pkg/analysis_server/test/services/correction/organize_directives_test.dart
index 96fc16ebc5d3bef3323c02d94c7213adbebc84a7..26f9fe1fa0d3dfa11217ca77695f94c276317ffc 100644
--- a/pkg/analysis_server/test/services/correction/organize_directives_test.dart
+++ b/pkg/analysis_server/test/services/correction/organize_directives_test.dart
@@ -2,10 +2,13 @@
// 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'
hide AnalysisError;
import 'package:analysis_server/src/services/correction/organize_directives.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -21,8 +24,11 @@ main() {
class OrganizeDirectivesTest extends AbstractSingleUnitTest {
List<AnalysisError> testErrors;
- void test_keep_duplicateImports_withDifferentPrefix() {
- _computeUnitAndErrors(r'''
+ @override
+ bool get enableNewAnalysisDriver => true;
+
+ test_keep_duplicateImports_withDifferentPrefix() async {
+ await _computeUnitAndErrors(r'''
import 'dart:async' as async1;
import 'dart:async' as async2;
@@ -44,8 +50,8 @@ main() {
removeUnused: true);
}
- void test_remove_duplicateImports() {
- _computeUnitAndErrors(r'''
+ test_remove_duplicateImports() async {
+ await _computeUnitAndErrors(r'''
import 'dart:async';
import 'dart:async';
@@ -64,8 +70,8 @@ main() {
removeUnused: true);
}
- void test_remove_duplicateImports_differentText_uri() {
- _computeUnitAndErrors(r'''
+ test_remove_duplicateImports_differentText_uri() async {
+ await _computeUnitAndErrors(r'''
import 'dart:async' as async;
import "dart:async" as async;
@@ -84,8 +90,8 @@ main() {
removeUnused: true);
}
- void test_remove_duplicateImports_withSamePrefix() {
- _computeUnitAndErrors(r'''
+ test_remove_duplicateImports_withSamePrefix() async {
+ await _computeUnitAndErrors(r'''
import 'dart:async' as async;
import 'dart:async' as async;
@@ -104,10 +110,10 @@ main() {
removeUnused: true);
}
- void test_remove_unresolvedDirectives() {
+ test_remove_unresolvedDirectives() async {
addSource('/existing_part1.dart', 'part of lib;');
addSource('/existing_part2.dart', 'part of lib;');
- _computeUnitAndErrors(r'''
+ await _computeUnitAndErrors(r'''
library lib;
import 'dart:async';
@@ -147,8 +153,8 @@ main() {
removeUnresolved: true);
}
- void test_remove_unusedImports() {
- _computeUnitAndErrors(r'''
+ test_remove_unusedImports() async {
+ await _computeUnitAndErrors(r'''
library lib;
import 'dart:async';
@@ -177,8 +183,8 @@ main() {
removeUnused: true);
}
- void test_remove_unusedImports2() {
- _computeUnitAndErrors(r'''
+ test_remove_unusedImports2() async {
+ await _computeUnitAndErrors(r'''
import 'dart:async';
import 'dart:math';
@@ -201,8 +207,8 @@ main() {
removeUnused: true);
}
- void test_sort() {
- _computeUnitAndErrors(r'''
+ test_sort() async {
+ await _computeUnitAndErrors(r'''
library lib;
export 'dart:bbb';
@@ -263,8 +269,8 @@ main() {
''');
}
- void test_sort_hasComments() {
- _computeUnitAndErrors(r'''
+ test_sort_hasComments() async {
+ await _computeUnitAndErrors(r'''
// header
library lib;
@@ -294,8 +300,8 @@ main() {
''');
}
- void test_sort_imports_packageAndPath() {
- _computeUnitAndErrors(r'''
+ test_sort_imports_packageAndPath() async {
+ await _computeUnitAndErrors(r'''
library lib;
import 'package:product.ui.api.bbb/manager1.dart';
@@ -328,9 +334,10 @@ import 'package:product2.client/entity.dart';
expect(result, expectedCode);
}
- void _computeUnitAndErrors(String code) {
+ Future<Null> _computeUnitAndErrors(String code) async {
addTestSource(code);
- testUnit = context.resolveCompilationUnit2(testSource, testSource);
- testErrors = context.computeErrors(testSource);
+ AnalysisResult result = await driver.getResult(testSource.fullName);
+ testUnit = result.unit;
+ testErrors = result.errors;
}
}

Powered by Google App Engine
This is Rietveld 408576698