forked from firka/flutter
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
@@ -9,21 +9,14 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Verify correct labels are displayed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OnChangedExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OnChangedExampleApp());
|
||||
|
||||
expect(
|
||||
find.text('What number comes next in the sequence?'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('What number comes next in the sequence?'), findsOneWidget);
|
||||
expect(find.text('1, 1, 2, 3, 5, 8...?'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Does not show dialog when answer is not correct', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OnChangedExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OnChangedExampleApp());
|
||||
|
||||
await tester.enterText(find.byType(TextField), '33');
|
||||
await tester.pumpAndSettle();
|
||||
@@ -32,9 +25,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Shows dialog when answer is correct', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OnChangedExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OnChangedExampleApp());
|
||||
|
||||
await tester.enterText(find.byType(TextField), '13');
|
||||
await tester.pumpAndSettle();
|
||||
@@ -46,21 +37,14 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Closes dialog on OK button tap', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OnChangedExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OnChangedExampleApp());
|
||||
|
||||
await tester.enterText(find.byType(TextField), '13');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
|
||||
await tester.tap(
|
||||
find.ancestor(
|
||||
of: find.text('OK'),
|
||||
matching: find.byType(TextButton),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.ancestor(of: find.text('OK'), matching: find.byType(TextButton)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(AlertDialog), findsNothing);
|
||||
|
||||
@@ -6,14 +6,13 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_api_samples/widgets/editable_text/editable_text.on_content_inserted.0.dart' as example;
|
||||
import 'package:flutter_api_samples/widgets/editable_text/editable_text.on_content_inserted.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Image.memory displays inserted content', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.KeyboardInsertedContentApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.KeyboardInsertedContentApp());
|
||||
|
||||
expect(find.text('Keyboard Inserted Content Sample'), findsOneWidget);
|
||||
|
||||
@@ -23,16 +22,135 @@ void main() {
|
||||
|
||||
const String uri = 'content://com.google.android.inputmethod.latin.fileprovider/test.png';
|
||||
const List<int> kBlueSquarePng = <int>[
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,
|
||||
0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x32, 0x08, 0x06,
|
||||
0x00, 0x00, 0x00, 0x1e, 0x3f, 0x88, 0xb1, 0x00, 0x00, 0x00, 0x48, 0x49, 0x44,
|
||||
0x41, 0x54, 0x78, 0xda, 0xed, 0xcf, 0x31, 0x0d, 0x00, 0x30, 0x08, 0x00, 0xb0,
|
||||
0x61, 0x63, 0x2f, 0xfe, 0x2d, 0x61, 0x05, 0x34, 0xf0, 0x92, 0xd6, 0x41, 0x23,
|
||||
0x7f, 0xf5, 0x3b, 0x20, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
|
||||
0x44, 0x44, 0x44, 0x36, 0x06, 0x03, 0x6e, 0x69, 0x47, 0x12, 0x8e, 0xea, 0xaa,
|
||||
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
|
||||
0x89,
|
||||
0x50,
|
||||
0x4e,
|
||||
0x47,
|
||||
0x0d,
|
||||
0x0a,
|
||||
0x1a,
|
||||
0x0a,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x0d,
|
||||
0x49,
|
||||
0x48,
|
||||
0x44,
|
||||
0x52,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x32,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x32,
|
||||
0x08,
|
||||
0x06,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x1e,
|
||||
0x3f,
|
||||
0x88,
|
||||
0xb1,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x48,
|
||||
0x49,
|
||||
0x44,
|
||||
0x41,
|
||||
0x54,
|
||||
0x78,
|
||||
0xda,
|
||||
0xed,
|
||||
0xcf,
|
||||
0x31,
|
||||
0x0d,
|
||||
0x00,
|
||||
0x30,
|
||||
0x08,
|
||||
0x00,
|
||||
0xb0,
|
||||
0x61,
|
||||
0x63,
|
||||
0x2f,
|
||||
0xfe,
|
||||
0x2d,
|
||||
0x61,
|
||||
0x05,
|
||||
0x34,
|
||||
0xf0,
|
||||
0x92,
|
||||
0xd6,
|
||||
0x41,
|
||||
0x23,
|
||||
0x7f,
|
||||
0xf5,
|
||||
0x3b,
|
||||
0x20,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x44,
|
||||
0x36,
|
||||
0x06,
|
||||
0x03,
|
||||
0x6e,
|
||||
0x69,
|
||||
0x47,
|
||||
0x12,
|
||||
0x8e,
|
||||
0xea,
|
||||
0xaa,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x49,
|
||||
0x45,
|
||||
0x4e,
|
||||
0x44,
|
||||
0xae,
|
||||
0x42,
|
||||
0x60,
|
||||
0x82,
|
||||
];
|
||||
final ByteData? messageBytes = const JSONMessageCodec().encodeMessage(<String, dynamic>{
|
||||
'args': <dynamic>[
|
||||
@@ -47,7 +165,7 @@ void main() {
|
||||
await tester.binding.defaultBinaryMessenger.handlePlatformMessage(
|
||||
'flutter/textinput',
|
||||
messageBytes,
|
||||
(ByteData? _) {},
|
||||
(ByteData? _) {},
|
||||
);
|
||||
} catch (_) {}
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Forces text to be lower case', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.TextEditingControllerExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.TextEditingControllerExampleApp());
|
||||
|
||||
const String input = 'Almost Everything Is a WIDGET! 💙';
|
||||
|
||||
@@ -26,9 +24,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Keeps the caret at the end of the input', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.TextEditingControllerExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.TextEditingControllerExampleApp());
|
||||
|
||||
const String input = 'flutter';
|
||||
|
||||
@@ -41,17 +37,12 @@ void main() {
|
||||
final TextEditingController controller = textField.controller!;
|
||||
|
||||
// Verify that the caret positioned at the end of the input.
|
||||
expect(
|
||||
controller.selection,
|
||||
const TextSelection.collapsed(offset: input.length),
|
||||
);
|
||||
expect(controller.selection, const TextSelection.collapsed(offset: input.length));
|
||||
|
||||
final RenderBox box = tester.renderObject(find.byType(TextFormField));
|
||||
|
||||
// Calculate the center-left point of the field.
|
||||
final Offset centerLeftPoint = box.localToGlobal(
|
||||
Offset(0, box.size.height / 2),
|
||||
);
|
||||
final Offset centerLeftPoint = box.localToGlobal(Offset(0, box.size.height / 2));
|
||||
|
||||
// Tap on the center-left point of the field to try to change the caret
|
||||
// position.
|
||||
@@ -59,9 +50,6 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
// Verify that the caret position remains unchanged.
|
||||
expect(
|
||||
controller.selection,
|
||||
const TextSelection.collapsed(offset: input.length),
|
||||
);
|
||||
expect(controller.selection, const TextSelection.collapsed(offset: input.length));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/editable_text/text_editing_controller.1.dart' as example;
|
||||
import 'package:flutter_api_samples/widgets/editable_text/text_editing_controller.1.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Initial selection is collapsed at offset 0', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.TextEditingControllerExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.TextEditingControllerExampleApp());
|
||||
|
||||
final EditableText editableText = tester.widget(find.byType(EditableText));
|
||||
final TextEditingController controller = editableText.controller;
|
||||
|
||||
Reference in New Issue
Block a user