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:
Michael Goderbauer 2024-12-16 16:29:51 -08:00 committed by GitHub
parent 43ee8029c9
commit e19e117c37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2767 additions and 2821 deletions

View File

@ -25,7 +25,8 @@ void _tests() {
});
Future<void> pumpTestWidget(WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
await tester.pumpWidget(
MaterialApp(
home: ListView(
children: <Widget>[
const Text('Plain text'),
@ -43,7 +44,8 @@ void _tests() {
),
],
),
));
),
);
}
// This test generates code using generateTestSemanticsExpressionForCurrentSemanticsTree
@ -55,8 +57,11 @@ void _tests() {
testWidgets('generates code', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await pumpTestWidget(tester);
final String code = semantics
.generateTestSemanticsExpressionForCurrentSemanticsTree(DebugSemanticsDumpOrder.inverseHitTest)
final String code =
semantics
.generateTestSemanticsExpressionForCurrentSemanticsTree(
DebugSemanticsDumpOrder.inverseHitTest,
)
.split('\n')
.map<String>((String line) => line.trim())
.join('\n')
@ -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,10 +87,9 @@ 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,
)
expectedCode =
expectedCode
.substring(expectedCode.indexOf('v' * 12) + 12, expectedCode.indexOf('^' * 12) - 3)
.split('\n')
.map<String>((String line) => line.trim())
.join('\n')
@ -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