Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -19,10 +19,7 @@ late Locale locale;
|
||||
/// Waits to find [EditableText] that displays text with misspelled
|
||||
/// words marked the same as the [TextSpan] provided and returns
|
||||
/// true if it is found before timing out at 20 seconds.
|
||||
Future<bool> findTextSpanTree(
|
||||
WidgetTester tester,
|
||||
TextSpan inlineSpan,
|
||||
) async {
|
||||
Future<bool> findTextSpanTree(WidgetTester tester, TextSpan inlineSpan) async {
|
||||
final RenderObject root = tester.renderObject(find.byType(EditableText));
|
||||
expect(root, isNotNull);
|
||||
|
||||
@@ -55,110 +52,92 @@ void main() {
|
||||
locale = const Locale('en', 'us');
|
||||
});
|
||||
|
||||
test(
|
||||
'fetchSpellCheckSuggestions returns null with no misspelled words',
|
||||
() async {
|
||||
test('fetchSpellCheckSuggestions returns null with no misspelled words', () async {
|
||||
const String text = 'Hello, world!';
|
||||
|
||||
final List<SuggestionSpan>? spellCheckSuggestionSpans =
|
||||
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
|
||||
final List<SuggestionSpan>? spellCheckSuggestionSpans = await defaultSpellCheckService
|
||||
.fetchSpellCheckSuggestions(locale, text);
|
||||
|
||||
expect(spellCheckSuggestionSpans!.length, equals(0));
|
||||
expect(
|
||||
defaultSpellCheckService.lastSavedResults!.spellCheckedText,
|
||||
equals(text)
|
||||
);
|
||||
expect(defaultSpellCheckService.lastSavedResults!.spellCheckedText, equals(text));
|
||||
expect(
|
||||
defaultSpellCheckService.lastSavedResults!.suggestionSpans,
|
||||
equals(spellCheckSuggestionSpans)
|
||||
equals(spellCheckSuggestionSpans),
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'fetchSpellCheckSuggestions returns correct ranges with misspelled words',
|
||||
() async {
|
||||
test('fetchSpellCheckSuggestions returns correct ranges with misspelled words', () async {
|
||||
const String text = 'Hlelo, world! Yuou are magnificente';
|
||||
const List<TextRange> misspelledWordRanges = <TextRange>[
|
||||
TextRange(start: 0, end: 5),
|
||||
TextRange(start: 14, end: 18),
|
||||
TextRange(start: 23, end: 35)
|
||||
TextRange(start: 23, end: 35),
|
||||
];
|
||||
|
||||
final List<SuggestionSpan>? spellCheckSuggestionSpans =
|
||||
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
|
||||
final List<SuggestionSpan>? spellCheckSuggestionSpans = await defaultSpellCheckService
|
||||
.fetchSpellCheckSuggestions(locale, text);
|
||||
|
||||
expect(spellCheckSuggestionSpans, isNotNull);
|
||||
expect(
|
||||
spellCheckSuggestionSpans!.length,
|
||||
equals(misspelledWordRanges.length)
|
||||
);
|
||||
expect(spellCheckSuggestionSpans!.length, equals(misspelledWordRanges.length));
|
||||
|
||||
for (int i = 0; i < misspelledWordRanges.length; i += 1) {
|
||||
expect(
|
||||
spellCheckSuggestionSpans[i].range,
|
||||
equals(misspelledWordRanges[i])
|
||||
);
|
||||
expect(spellCheckSuggestionSpans[i].range, equals(misspelledWordRanges[i]));
|
||||
}
|
||||
|
||||
expect(
|
||||
defaultSpellCheckService.lastSavedResults!.spellCheckedText,
|
||||
equals(text)
|
||||
);
|
||||
expect(defaultSpellCheckService.lastSavedResults!.spellCheckedText, equals(text));
|
||||
expect(
|
||||
defaultSpellCheckService.lastSavedResults!.suggestionSpans,
|
||||
equals(spellCheckSuggestionSpans)
|
||||
equals(spellCheckSuggestionSpans),
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'fetchSpellCheckSuggestions does not correct results when Gboard not ignoring composing region',
|
||||
() async {
|
||||
const String text = 'Wwow, whaaett a beautiful day it is!';
|
||||
'fetchSpellCheckSuggestions does not correct results when Gboard not ignoring composing region',
|
||||
() async {
|
||||
const String text = 'Wwow, whaaett a beautiful day it is!';
|
||||
|
||||
final List<SuggestionSpan>? spellCheckSpansWithComposingRegion =
|
||||
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
|
||||
final List<SuggestionSpan>? spellCheckSpansWithComposingRegion =
|
||||
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
|
||||
|
||||
expect(spellCheckSpansWithComposingRegion, isNotNull);
|
||||
expect(spellCheckSpansWithComposingRegion!.length, equals(2));
|
||||
expect(spellCheckSpansWithComposingRegion, isNotNull);
|
||||
expect(spellCheckSpansWithComposingRegion!.length, equals(2));
|
||||
|
||||
final List<SuggestionSpan>? spellCheckSuggestionSpans =
|
||||
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
|
||||
final List<SuggestionSpan>? spellCheckSuggestionSpans = await defaultSpellCheckService
|
||||
.fetchSpellCheckSuggestions(locale, text);
|
||||
|
||||
expect(
|
||||
spellCheckSuggestionSpans,
|
||||
equals(spellCheckSpansWithComposingRegion)
|
||||
);
|
||||
});
|
||||
expect(spellCheckSuggestionSpans, equals(spellCheckSpansWithComposingRegion));
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'fetchSpellCheckSuggestions merges results when Gboard ignoring composing region',
|
||||
() async {
|
||||
test('fetchSpellCheckSuggestions merges results when Gboard ignoring composing region', () async {
|
||||
const String text = 'Wooahha it is an amazzinng dayyebf!';
|
||||
|
||||
final List<SuggestionSpan>? modifiedSpellCheckSuggestionSpans =
|
||||
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
|
||||
final List<SuggestionSpan> expectedSpellCheckSuggestionSpans =
|
||||
List<SuggestionSpan>.from(modifiedSpellCheckSuggestionSpans!);
|
||||
final List<SuggestionSpan>? modifiedSpellCheckSuggestionSpans = await defaultSpellCheckService
|
||||
.fetchSpellCheckSuggestions(locale, text);
|
||||
final List<SuggestionSpan> expectedSpellCheckSuggestionSpans = List<SuggestionSpan>.from(
|
||||
modifiedSpellCheckSuggestionSpans!,
|
||||
);
|
||||
expect(modifiedSpellCheckSuggestionSpans, isNotNull);
|
||||
expect(modifiedSpellCheckSuggestionSpans.length, equals(3));
|
||||
|
||||
// Remove one span to simulate Gboard attempting to un-ignore the composing region, after tapping away from "Yuou".
|
||||
modifiedSpellCheckSuggestionSpans.removeAt(1);
|
||||
|
||||
defaultSpellCheckService.lastSavedResults =
|
||||
SpellCheckResults(text, modifiedSpellCheckSuggestionSpans);
|
||||
defaultSpellCheckService.lastSavedResults = SpellCheckResults(
|
||||
text,
|
||||
modifiedSpellCheckSuggestionSpans,
|
||||
);
|
||||
|
||||
final List<SuggestionSpan>? spellCheckSuggestionSpans =
|
||||
await defaultSpellCheckService.fetchSpellCheckSuggestions(locale, text);
|
||||
final List<SuggestionSpan>? spellCheckSuggestionSpans = await defaultSpellCheckService
|
||||
.fetchSpellCheckSuggestions(locale, text);
|
||||
|
||||
expect(spellCheckSuggestionSpans, isNotNull);
|
||||
expect(
|
||||
spellCheckSuggestionSpans,
|
||||
equals(expectedSpellCheckSuggestionSpans)
|
||||
);
|
||||
expect(spellCheckSuggestionSpans, equals(expectedSpellCheckSuggestionSpans));
|
||||
});
|
||||
|
||||
testWidgets('EditableText spell checks when text is entered and spell check enabled', (WidgetTester tester) async {
|
||||
testWidgets('EditableText spell checks when text is entered and spell check enabled', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
const TextStyle style = TextStyle();
|
||||
const TextStyle misspelledTextStyle = TextField.materialMisspelledTextStyle;
|
||||
|
||||
@@ -174,7 +153,8 @@ void main() {
|
||||
TextSpan(style: style, text: ' '),
|
||||
TextSpan(style: misspelledTextStyle, text: 'qocnakoef'),
|
||||
TextSpan(style: style, text: '! Hey!'),
|
||||
]);
|
||||
],
|
||||
);
|
||||
|
||||
final bool expectedTextSpanTreeFound = await findTextSpanTree(tester, expectedTextSpanTree);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user