Skip to content

Commit fb03a18

Browse files
srawlinsCommit Queue
authored andcommitted
DAS: switch ConfigurationFilesMixin to use package getters
Change-Id: I4931f2b7598ea96313fb00963e5e154101d51c24 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429829 Reviewed-by: Keerti Parthasarathy <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent ded5f0b commit fb03a18

File tree

5 files changed

+118
-85
lines changed

5 files changed

+118
-85
lines changed

pkg/analysis_server/test/services/snippets/dart/test_definition_test.dart

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'test_support.dart';
1212
void main() {
1313
defineReflectiveSuite(() {
1414
defineReflectiveTests(TestDefinitionTest);
15+
defineReflectiveTests(TestWithFlutterDefinitionTest);
1516
});
1617
}
1718

@@ -68,33 +69,67 @@ void f() {
6869
''');
6970
}
7071

71-
Future<void> test_import_flutter() async {
72-
writeTestPackageConfig(flutter_test: true);
72+
Future<void> test_inTestFile() async {
7373
testFilePath = convertPath('$testPackageLibPath/test/foo_test.dart');
7474
var code = TestCode.parse(r'''
7575
void f() {
7676
test^
7777
}
7878
''');
7979
var snippet = await expectValidSnippet(code);
80+
expect(snippet.prefix, prefix);
81+
expect(snippet.label, label);
82+
expect(snippet.change.edits, hasLength(1));
8083
var result = applySnippet(code, snippet);
8184
expect(result, '''
82-
import 'package:flutter_test/flutter_test.dart';
85+
import 'package:test/test.dart';
8386
8487
void f() {
8588
test('test name', () {
8689
8790
});
8891
}
8992
''');
93+
expect(snippet.change.selection!.file, testFile.path);
94+
expect(snippet.change.selection!.offset, 74);
95+
expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
96+
{
97+
'positions': [
98+
{'file': testFile.path, 'offset': 53},
99+
],
100+
'length': 9,
101+
'suggestions': [],
102+
},
103+
]);
90104
}
91105

92-
Future<void> test_import_flutter_existing() async {
93-
writeTestPackageConfig(flutter_test: true);
106+
Future<void> test_notTestFile() async {
107+
var code = r'''
108+
void f() {
109+
test^
110+
}
111+
''';
112+
await expectNotValidSnippet(code);
113+
}
114+
}
115+
116+
@reflectiveTest
117+
class TestWithFlutterDefinitionTest extends DartSnippetProducerTest {
118+
@override
119+
final generator = TestDefinition.new;
120+
121+
@override
122+
bool get addFlutterTestPackageDep => true;
123+
124+
@override
125+
String get label => TestDefinition.label;
126+
127+
@override
128+
String get prefix => TestDefinition.prefix;
129+
130+
Future<void> test_import_flutter() async {
94131
testFilePath = convertPath('$testPackageLibPath/test/foo_test.dart');
95132
var code = TestCode.parse(r'''
96-
import 'package:flutter_test/flutter_test.dart';
97-
98133
void f() {
99134
test^
100135
}
@@ -112,13 +147,10 @@ void f() {
112147
''');
113148
}
114149

115-
/// Ensure we don't import package:flutter_test if package:test is already
116-
/// imported.
117-
Future<void> test_import_flutter_existingDart() async {
118-
writeTestPackageConfig(flutter_test: true);
150+
Future<void> test_import_flutter_existing() async {
119151
testFilePath = convertPath('$testPackageLibPath/test/foo_test.dart');
120152
var code = TestCode.parse(r'''
121-
import 'package:test/test.dart';
153+
import 'package:flutter_test/flutter_test.dart';
122154
123155
void f() {
124156
test^
@@ -127,7 +159,7 @@ void f() {
127159
var snippet = await expectValidSnippet(code);
128160
var result = applySnippet(code, snippet);
129161
expect(result, '''
130-
import 'package:test/test.dart';
162+
import 'package:flutter_test/flutter_test.dart';
131163
132164
void f() {
133165
test('test name', () {
@@ -137,17 +169,18 @@ void f() {
137169
''');
138170
}
139171

140-
Future<void> test_inTestFile() async {
172+
/// Ensure we don't import package:flutter_test if package:test is already
173+
/// imported.
174+
Future<void> test_import_flutter_existingDart() async {
141175
testFilePath = convertPath('$testPackageLibPath/test/foo_test.dart');
142176
var code = TestCode.parse(r'''
177+
import 'package:test/test.dart';
178+
143179
void f() {
144180
test^
145181
}
146182
''');
147183
var snippet = await expectValidSnippet(code);
148-
expect(snippet.prefix, prefix);
149-
expect(snippet.label, label);
150-
expect(snippet.change.edits, hasLength(1));
151184
var result = applySnippet(code, snippet);
152185
expect(result, '''
153186
import 'package:test/test.dart';
@@ -158,25 +191,5 @@ void f() {
158191
});
159192
}
160193
''');
161-
expect(snippet.change.selection!.file, testFile.path);
162-
expect(snippet.change.selection!.offset, 74);
163-
expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
164-
{
165-
'positions': [
166-
{'file': testFile.path, 'offset': 53},
167-
],
168-
'length': 9,
169-
'suggestions': [],
170-
},
171-
]);
172-
}
173-
174-
Future<void> test_notTestFile() async {
175-
var code = r'''
176-
void f() {
177-
test^
178-
}
179-
''';
180-
await expectNotValidSnippet(code);
181194
}
182195
}

pkg/analysis_server/test/services/snippets/dart/test_group_definition_test.dart

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'test_support.dart';
1212
void main() {
1313
defineReflectiveSuite(() {
1414
defineReflectiveTests(TestGroupDefinitionTest);
15+
defineReflectiveTests(TestGroupWithFlutterDefinitionTest);
1516
});
1617
}
1718

@@ -68,33 +69,67 @@ void f() {
6869
''');
6970
}
7071

71-
Future<void> test_import_flutter() async {
72-
writeTestPackageConfig(flutter_test: true);
72+
Future<void> test_inTestFile() async {
7373
testFilePath = convertPath('$testPackageLibPath/test/foo_test.dart');
7474
var code = TestCode.parse(r'''
7575
void f() {
7676
group^
7777
}
7878
''');
7979
var snippet = await expectValidSnippet(code);
80+
expect(snippet.prefix, prefix);
81+
expect(snippet.label, label);
82+
expect(snippet.change.edits, hasLength(1));
8083
var result = applySnippet(code, snippet);
8184
expect(result, '''
82-
import 'package:flutter_test/flutter_test.dart';
85+
import 'package:test/test.dart';
8386
8487
void f() {
8588
group('group name', () {
8689
8790
});
8891
}
8992
''');
93+
expect(snippet.change.selection!.file, testFile.path);
94+
expect(snippet.change.selection!.offset, 76);
95+
expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
96+
{
97+
'positions': [
98+
{'file': testFile.path, 'offset': 54},
99+
],
100+
'length': 10,
101+
'suggestions': [],
102+
},
103+
]);
90104
}
91105

92-
Future<void> test_import_flutter_existing() async {
93-
writeTestPackageConfig(flutter_test: true);
106+
Future<void> test_notTestFile() async {
107+
var code = r'''
108+
void f() {
109+
group^
110+
}
111+
''';
112+
await expectNotValidSnippet(code);
113+
}
114+
}
115+
116+
@reflectiveTest
117+
class TestGroupWithFlutterDefinitionTest extends DartSnippetProducerTest {
118+
@override
119+
final generator = TestGroupDefinition.new;
120+
121+
@override
122+
bool get addFlutterTestPackageDep => true;
123+
124+
@override
125+
String get label => TestGroupDefinition.label;
126+
127+
@override
128+
String get prefix => TestGroupDefinition.prefix;
129+
130+
Future<void> test_import_flutter() async {
94131
testFilePath = convertPath('$testPackageLibPath/test/foo_test.dart');
95132
var code = TestCode.parse(r'''
96-
import 'package:flutter_test/flutter_test.dart';
97-
98133
void f() {
99134
group^
100135
}
@@ -112,13 +147,10 @@ void f() {
112147
''');
113148
}
114149

115-
/// Ensure we don't import package:flutter_test if package:test is already
116-
/// imported.
117-
Future<void> test_import_flutter_existingDart() async {
118-
writeTestPackageConfig(flutter_test: true);
150+
Future<void> test_import_flutter_existing() async {
119151
testFilePath = convertPath('$testPackageLibPath/test/foo_test.dart');
120152
var code = TestCode.parse(r'''
121-
import 'package:test/test.dart';
153+
import 'package:flutter_test/flutter_test.dart';
122154
123155
void f() {
124156
group^
@@ -127,7 +159,7 @@ void f() {
127159
var snippet = await expectValidSnippet(code);
128160
var result = applySnippet(code, snippet);
129161
expect(result, '''
130-
import 'package:test/test.dart';
162+
import 'package:flutter_test/flutter_test.dart';
131163
132164
void f() {
133165
group('group name', () {
@@ -137,17 +169,18 @@ void f() {
137169
''');
138170
}
139171

140-
Future<void> test_inTestFile() async {
172+
/// Ensure we don't import package:flutter_test if package:test is already
173+
/// imported.
174+
Future<void> test_import_flutter_existingDart() async {
141175
testFilePath = convertPath('$testPackageLibPath/test/foo_test.dart');
142176
var code = TestCode.parse(r'''
177+
import 'package:test/test.dart';
178+
143179
void f() {
144180
group^
145181
}
146182
''');
147183
var snippet = await expectValidSnippet(code);
148-
expect(snippet.prefix, prefix);
149-
expect(snippet.label, label);
150-
expect(snippet.change.edits, hasLength(1));
151184
var result = applySnippet(code, snippet);
152185
expect(result, '''
153186
import 'package:test/test.dart';
@@ -158,25 +191,5 @@ void f() {
158191
});
159192
}
160193
''');
161-
expect(snippet.change.selection!.file, testFile.path);
162-
expect(snippet.change.selection!.offset, 76);
163-
expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
164-
{
165-
'positions': [
166-
{'file': testFile.path, 'offset': 54},
167-
],
168-
'length': 10,
169-
'suggestions': [],
170-
},
171-
]);
172-
}
173-
174-
Future<void> test_notTestFile() async {
175-
var code = r'''
176-
void f() {
177-
group^
178-
}
179-
''';
180-
await expectNotValidSnippet(code);
181194
}
182195
}

pkg/analysis_server/test/shared/shared_test_interface.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ abstract interface class SharedTestInterface {
7979
PackageConfigFileBuilder? config,
8080
String? languageVersion,
8181
bool flutter = false,
82-
bool flutter_test = false,
8382
bool meta = false,
8483
bool pedantic = false,
85-
bool vector_math = false,
8684
});
8785
}

pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ class D extends Widget with Diagnosticable {
157157

158158
@reflectiveTest
159159
class AddDiagnosticPropertyReferenceTest extends FixProcessorLintTest {
160+
@override
161+
bool get addVectorMathPackageDep => true;
162+
160163
@override
161164
FixKind get kind => DartFixKind.ADD_DIAGNOSTIC_PROPERTY_REFERENCE;
162165

@@ -515,7 +518,7 @@ class C extends Widget with Diagnosticable {
515518
}
516519

517520
Future<void> test_matrix4Field() async {
518-
writeTestPackageConfig(flutter: true, vector_math: true);
521+
writeTestPackageConfig(flutter: true);
519522
await resolveTestCode('''
520523
import 'package:flutter/foundation.dart';
521524
import 'package:flutter/widgets.dart';

0 commit comments

Comments
 (0)