Fix line-dependent tests for formatting (#160389)
These tests are dependent on line numbers. This formats them and updates the line number to take them off the critical path.
This commit is contained in:
parent
43ee8029c9
commit
e19e117c37
@ -25,25 +25,27 @@ void _tests() {
|
||||
});
|
||||
|
||||
Future<void> pumpTestWidget(WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: ListView(
|
||||
children: <Widget>[
|
||||
const Text('Plain text'),
|
||||
Semantics(
|
||||
selected: true,
|
||||
checked: true,
|
||||
onTap: () { },
|
||||
onDecrease: () { },
|
||||
value: 'test-value',
|
||||
increasedValue: 'test-increasedValue',
|
||||
decreasedValue: 'test-decreasedValue',
|
||||
hint: 'test-hint',
|
||||
textDirection: TextDirection.rtl,
|
||||
child: const Text('Interactive text'),
|
||||
),
|
||||
],
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: ListView(
|
||||
children: <Widget>[
|
||||
const Text('Plain text'),
|
||||
Semantics(
|
||||
selected: true,
|
||||
checked: true,
|
||||
onTap: () {},
|
||||
onDecrease: () {},
|
||||
value: 'test-value',
|
||||
increasedValue: 'test-increasedValue',
|
||||
decreasedValue: 'test-decreasedValue',
|
||||
hint: 'test-hint',
|
||||
textDirection: TextDirection.rtl,
|
||||
child: const Text('Interactive text'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
// This test generates code using generateTestSemanticsExpressionForCurrentSemanticsTree
|
||||
@ -55,12 +57,15 @@ void _tests() {
|
||||
testWidgets('generates code', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
await pumpTestWidget(tester);
|
||||
final String code = semantics
|
||||
.generateTestSemanticsExpressionForCurrentSemanticsTree(DebugSemanticsDumpOrder.inverseHitTest)
|
||||
.split('\n')
|
||||
.map<String>((String line) => line.trim())
|
||||
.join('\n')
|
||||
.trim();
|
||||
final String code =
|
||||
semantics
|
||||
.generateTestSemanticsExpressionForCurrentSemanticsTree(
|
||||
DebugSemanticsDumpOrder.inverseHitTest,
|
||||
)
|
||||
.split('\n')
|
||||
.map<String>((String line) => line.trim())
|
||||
.join('\n')
|
||||
.trim();
|
||||
|
||||
File? findThisTestFile(Directory directory) {
|
||||
for (final FileSystemEntity entity in directory.listSync()) {
|
||||
@ -69,7 +74,10 @@ void _tests() {
|
||||
if (childSearch != null) {
|
||||
return childSearch;
|
||||
}
|
||||
} else if (entity is File && entity.path.endsWith('semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart')) {
|
||||
} else if (entity is File &&
|
||||
entity.path.endsWith(
|
||||
'semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart',
|
||||
)) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@ -79,14 +87,13 @@ void _tests() {
|
||||
final File thisTestFile = findThisTestFile(Directory.current)!;
|
||||
expect(thisTestFile, isNotNull);
|
||||
String expectedCode = thisTestFile.readAsStringSync();
|
||||
expectedCode = expectedCode.substring(
|
||||
expectedCode.indexOf('v' * 12) + 12,
|
||||
expectedCode.indexOf('^' * 12) - 3,
|
||||
)
|
||||
.split('\n')
|
||||
.map<String>((String line) => line.trim())
|
||||
.join('\n')
|
||||
.trim();
|
||||
expectedCode =
|
||||
expectedCode
|
||||
.substring(expectedCode.indexOf('v' * 12) + 12, expectedCode.indexOf('^' * 12) - 3)
|
||||
.split('\n')
|
||||
.map<String>((String line) => line.trim())
|
||||
.join('\n')
|
||||
.trim();
|
||||
semantics.dispose();
|
||||
expect('$code,', expectedCode);
|
||||
});
|
||||
@ -102,6 +109,7 @@ void _tests() {
|
||||
// You must update it when changing the output generated by
|
||||
// generateTestSemanticsExpressionForCurrentSemanticsTree. Otherwise,
|
||||
// the test 'generates code', defined above, will fail.
|
||||
// dart format off
|
||||
// vvvvvvvvvvvv
|
||||
TestSemantics.root(
|
||||
children: <TestSemantics>[
|
||||
@ -154,6 +162,7 @@ void _tests() {
|
||||
],
|
||||
),
|
||||
// ^^^^^^^^^^^^
|
||||
// dart format on
|
||||
ignoreRect: true,
|
||||
ignoreTransform: true,
|
||||
ignoreId: true,
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user