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
@@ -21,7 +21,7 @@ web.NodeList findElements(String selector) {
|
||||
fail(
|
||||
'Failed to locate <flutter-view>. Possible reasons:\n'
|
||||
' - The application failed to start'
|
||||
' - `findElements` was called before the application started'
|
||||
' - `findElements` was called before the application started',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,14 +18,17 @@ Future<void> runTestWithScreenshots({
|
||||
int browserWidth = _kScreenshotWidth,
|
||||
int browserHeight = _kScreenshotHeight,
|
||||
}) async {
|
||||
final WebFlutterDriver driver =
|
||||
await FlutterDriver.connect() as WebFlutterDriver;
|
||||
final WebFlutterDriver driver = await FlutterDriver.connect() as WebFlutterDriver;
|
||||
|
||||
(await driver.webDriver.window).setSize(Rectangle<int>(0, 0, browserWidth, browserHeight));
|
||||
|
||||
test.integrationDriver(
|
||||
driver: driver,
|
||||
onScreenshot: (String screenshotName, List<int> screenshotBytes, [Map<String, Object?>? args]) async {
|
||||
onScreenshot: (
|
||||
String screenshotName,
|
||||
List<int> screenshotBytes, [
|
||||
Map<String, Object?>? args,
|
||||
]) async {
|
||||
// TODO(yjbanov): implement, see https://github.com/flutter/flutter/issues/86120
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -39,21 +39,18 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title),
|
||||
),
|
||||
appBar: AppBar(title: Text(widget.title)),
|
||||
body: ListView.builder(
|
||||
itemCount: 1000,
|
||||
itemBuilder: (BuildContext context, int index) => Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Container(
|
||||
height: 100,
|
||||
color: Colors.lightBlue,
|
||||
child: Center(
|
||||
child: Text('Item $index'),
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) => Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Container(
|
||||
height: 100,
|
||||
color: Colors.lightBlue,
|
||||
child: Center(child: Text('Item $index')),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
key: const Key('scroll-button'),
|
||||
@@ -77,27 +74,27 @@ abstract class DeltaMode {
|
||||
static const int kLine = 0x01;
|
||||
}
|
||||
|
||||
void dispatchMouseWheelEvent(int mouseX, int mouseY,
|
||||
int deltaMode, double deltaX, double deltaY) {
|
||||
void dispatchMouseWheelEvent(int mouseX, int mouseY, int deltaMode, double deltaX, double deltaY) {
|
||||
final web.EventTarget target = web.document.elementFromPoint(mouseX, mouseY)!;
|
||||
|
||||
target.dispatchEvent(web.MouseEvent('mouseover', web.MouseEventInit(
|
||||
screenX: mouseX,
|
||||
screenY: mouseY,
|
||||
clientX: mouseX,
|
||||
clientY: mouseY,
|
||||
)));
|
||||
target.dispatchEvent(
|
||||
web.MouseEvent(
|
||||
'mouseover',
|
||||
web.MouseEventInit(screenX: mouseX, screenY: mouseY, clientX: mouseX, clientY: mouseY),
|
||||
),
|
||||
);
|
||||
|
||||
target.dispatchEvent(web.MouseEvent('mousemove', web.MouseEventInit(
|
||||
screenX: mouseX,
|
||||
screenY: mouseY,
|
||||
clientX: mouseX,
|
||||
clientY: mouseY,
|
||||
)));
|
||||
target.dispatchEvent(
|
||||
web.MouseEvent(
|
||||
'mousemove',
|
||||
web.MouseEventInit(screenX: mouseX, screenY: mouseY, clientX: mouseX, clientY: mouseY),
|
||||
),
|
||||
);
|
||||
|
||||
target.dispatchEvent(web.WheelEvent('wheel', web.WheelEventInit(
|
||||
deltaMode: deltaMode,
|
||||
deltaX : deltaX,
|
||||
deltaY : deltaY,
|
||||
)));
|
||||
target.dispatchEvent(
|
||||
web.WheelEvent(
|
||||
'wheel',
|
||||
web.WheelEventInit(deltaMode: deltaMode, deltaX: deltaX, deltaY: deltaY),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,7 @@ class MyApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
key: Key('mainapp'),
|
||||
title: 'Platform Test',
|
||||
home: MyHomePage(),
|
||||
);
|
||||
return const MaterialApp(key: Key('mainapp'), title: 'Platform Test', home: MyHomePage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,20 +27,11 @@ class MyHomePage extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
if (defaultTargetPlatform == TargetPlatform.macOS)
|
||||
const Text(
|
||||
'I am running on MacOS',
|
||||
key: Key('macOSKey'),
|
||||
),
|
||||
const Text('I am running on MacOS', key: Key('macOSKey')),
|
||||
if (defaultTargetPlatform == TargetPlatform.iOS)
|
||||
const Text(
|
||||
'I am running on MacOS',
|
||||
key: Key('iOSKey'),
|
||||
),
|
||||
const Text('I am running on MacOS', key: Key('iOSKey')),
|
||||
if (defaultTargetPlatform == TargetPlatform.android)
|
||||
const Text(
|
||||
'I am running on Android',
|
||||
key: Key('androidKey'),
|
||||
),
|
||||
const Text('I am running on Android', key: Key('androidKey')),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -34,25 +34,19 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
// Controller with no initial value;
|
||||
final TextEditingController _emptyController = TextEditingController();
|
||||
|
||||
final TextEditingController _controller =
|
||||
TextEditingController(text: 'Text1');
|
||||
final TextEditingController _controller = TextEditingController(text: 'Text1');
|
||||
|
||||
final TextEditingController _controller2 =
|
||||
TextEditingController(text: 'Text2');
|
||||
final TextEditingController _controller2 = TextEditingController(text: 'Text2');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title ?? ''),
|
||||
),
|
||||
appBar: AppBar(title: Text(widget.title ?? '')),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
'Text Editing Test 1',
|
||||
),
|
||||
const Text('Text Editing Test 1'),
|
||||
TextFormField(
|
||||
key: const Key('empty-input'),
|
||||
enabled: true,
|
||||
@@ -62,9 +56,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
labelText: 'Empty Input Field:',
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
'Text Editing Test 2',
|
||||
),
|
||||
const Text('Text Editing Test 2'),
|
||||
TextFormField(
|
||||
key: const Key('input'),
|
||||
enabled: true,
|
||||
@@ -74,9 +66,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
labelText: 'Text Input Field:',
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
'Text Editing Test 3',
|
||||
),
|
||||
const Text('Text Editing Test 3'),
|
||||
TextFormField(
|
||||
key: const Key('input2'),
|
||||
enabled: true,
|
||||
@@ -90,10 +80,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
setState(() => infoText = 'enter pressed');
|
||||
},
|
||||
),
|
||||
Text(
|
||||
infoText,
|
||||
key: const Key('text'),
|
||||
),
|
||||
Text(infoText, key: const Key('text')),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(12.0),
|
||||
child: SelectableText(
|
||||
|
||||
@@ -32,12 +32,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: const Center(
|
||||
child: Text('TreeshakingThings'),
|
||||
),
|
||||
appBar: AppBar(title: Text(widget.title)),
|
||||
body: const Center(child: Text('TreeshakingThings')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,31 +47,42 @@ void main() {
|
||||
|
||||
bool called = false;
|
||||
|
||||
Future<ui.Codec> decode(ui.ImmutableBuffer buffer, {ui.TargetImageSizeCallback? getTargetSize}) {
|
||||
return PaintingBinding.instance.instantiateImageCodecWithSize(buffer, getTargetSize: (int intrinsicWidth, int intrinsicHeight) {
|
||||
expect(getTargetSize, isNotNull);
|
||||
final ui.TargetImageSize targetSize = getTargetSize!(intrinsicWidth, intrinsicHeight);
|
||||
expect(targetSize.width, expectedCacheWidth);
|
||||
expect(targetSize.height, expectedCacheHeight);
|
||||
called = true;
|
||||
return targetSize;
|
||||
});
|
||||
Future<ui.Codec> decode(
|
||||
ui.ImmutableBuffer buffer, {
|
||||
ui.TargetImageSizeCallback? getTargetSize,
|
||||
}) {
|
||||
return PaintingBinding.instance.instantiateImageCodecWithSize(
|
||||
buffer,
|
||||
getTargetSize: (int intrinsicWidth, int intrinsicHeight) {
|
||||
expect(getTargetSize, isNotNull);
|
||||
final ui.TargetImageSize targetSize = getTargetSize!(intrinsicWidth, intrinsicHeight);
|
||||
expect(targetSize.width, expectedCacheWidth);
|
||||
expect(targetSize.height, expectedCacheHeight);
|
||||
called = true;
|
||||
return targetSize;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
final ImageProvider resizeImage = image.image;
|
||||
expect(image.image, isA<ResizeImage>());
|
||||
|
||||
final LoadTestImageProvider testProvider = LoadTestImageProvider(image.image);
|
||||
final ImageStreamCompleter streamCompleter = testProvider.testLoad(await resizeImage.obtainKey(ImageConfiguration.empty), decode);
|
||||
final ImageStreamCompleter streamCompleter = testProvider.testLoad(
|
||||
await resizeImage.obtainKey(ImageConfiguration.empty),
|
||||
decode,
|
||||
);
|
||||
|
||||
final Completer<void> completer = Completer<void>();
|
||||
int? imageInfoCachedWidth;
|
||||
int? imageInfoCachedHeight;
|
||||
streamCompleter.addListener(ImageStreamListener((ImageInfo imageInfo, bool syncCall) {
|
||||
imageInfoCachedWidth = imageInfo.image.width;
|
||||
imageInfoCachedHeight = imageInfo.image.height;
|
||||
completer.complete();
|
||||
}));
|
||||
streamCompleter.addListener(
|
||||
ImageStreamListener((ImageInfo imageInfo, bool syncCall) {
|
||||
imageInfoCachedWidth = imageInfo.image.width;
|
||||
imageInfoCachedHeight = imageInfo.image.height;
|
||||
completer.complete();
|
||||
}),
|
||||
);
|
||||
await completer.future;
|
||||
|
||||
expect(imageInfoCachedHeight, isNotNull);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@ import 'package:web_e2e_tests/profile_diagnostics_main.dart' as app;
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
testWidgets('App build method exception should form valid FlutterErrorDetails',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('App build method exception should form valid FlutterErrorDetails', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
app.main();
|
||||
await tester.pumpAndSettle();
|
||||
final dynamic appError = tester.takeException();
|
||||
|
||||
@@ -21,9 +21,6 @@ void main() {
|
||||
await tester.tap(finder);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await expectLater(
|
||||
find.byType(app.MyApp),
|
||||
matchesGoldenFile('scroll_wheel_by_line'),
|
||||
);
|
||||
await expectLater(find.byType(app.MyApp), matchesGoldenFile('scroll_wheel_by_line'));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ import 'package:web_e2e_tests/text_editing_main.dart' as app;
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
testWidgets('Focused text field creates a native input element',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Focused text field creates a native input element', (WidgetTester tester) async {
|
||||
app.main();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -39,8 +38,7 @@ void main() {
|
||||
expect(input.value, 'New Value');
|
||||
}, semanticsEnabled: false);
|
||||
|
||||
testWidgets('Input field with no initial value works',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Input field with no initial value works', (WidgetTester tester) async {
|
||||
app.main();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -63,8 +61,7 @@ void main() {
|
||||
expect(input.value, 'New Value');
|
||||
}, semanticsEnabled: false);
|
||||
|
||||
testWidgets('Pressing enter on the text field triggers submit',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Pressing enter on the text field triggers submit', (WidgetTester tester) async {
|
||||
app.main();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -100,8 +97,7 @@ void main() {
|
||||
expect(text2.data, 'enter pressed');
|
||||
}, semanticsEnabled: false);
|
||||
|
||||
testWidgets('Jump between TextFormFields with tab key',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Jump between TextFormFields with tab key', (WidgetTester tester) async {
|
||||
app.main();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -140,7 +136,9 @@ void main() {
|
||||
expect(input2.value, 'Text2');
|
||||
}, semanticsEnabled: false);
|
||||
|
||||
testWidgets('Jump between TextFormFields with tab key after CapsLock is activated', (WidgetTester tester) async {
|
||||
testWidgets('Jump between TextFormFields with tab key after CapsLock is activated', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
app.main();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -205,12 +203,10 @@ void main() {
|
||||
expect(finder, findsOneWidget);
|
||||
final RenderBox selectable = tester.renderObject(finder);
|
||||
final Offset topLeft = selectable.localToGlobal(Offset.zero);
|
||||
final Offset topRight =
|
||||
selectable.localToGlobal(Offset(selectable.size.width, 0.0));
|
||||
final Offset topRight = selectable.localToGlobal(Offset(selectable.size.width, 0.0));
|
||||
|
||||
// Drag by mouse to select the entire selectable text.
|
||||
TestGesture gesture =
|
||||
await tester.startGesture(topLeft, kind: PointerDeviceKind.mouse);
|
||||
TestGesture gesture = await tester.startGesture(topLeft, kind: PointerDeviceKind.mouse);
|
||||
await gesture.moveTo(topRight);
|
||||
await gesture.up();
|
||||
|
||||
@@ -223,16 +219,12 @@ void main() {
|
||||
expect(input.hasAttribute('readonly'), isTrue);
|
||||
|
||||
// Make sure the entire text is selected.
|
||||
TextRange? range =
|
||||
TextRange(start: input.selectionStart, end: input.selectionEnd);
|
||||
TextRange? range = TextRange(start: input.selectionStart, end: input.selectionEnd);
|
||||
expect(range.textInside(text), text);
|
||||
|
||||
// Double tap to select the first word.
|
||||
final Offset firstWordOffset = topLeft.translate(10.0, 0.0);
|
||||
gesture = await tester.startGesture(
|
||||
firstWordOffset,
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
gesture = await tester.startGesture(firstWordOffset, kind: PointerDeviceKind.mouse);
|
||||
await gesture.up();
|
||||
await gesture.down(firstWordOffset);
|
||||
await gesture.up();
|
||||
@@ -241,10 +233,7 @@ void main() {
|
||||
|
||||
// Double tap to select the last word.
|
||||
final Offset lastWordOffset = topRight.translate(-10.0, 0.0);
|
||||
gesture = await tester.startGesture(
|
||||
lastWordOffset,
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
gesture = await tester.startGesture(lastWordOffset, kind: PointerDeviceKind.mouse);
|
||||
await gesture.up();
|
||||
await gesture.down(lastWordOffset);
|
||||
await gesture.up();
|
||||
@@ -254,15 +243,15 @@ void main() {
|
||||
}
|
||||
|
||||
web.KeyboardEvent dispatchKeyboardEvent(
|
||||
web.EventTarget target, String type, Map<String, dynamic> args) {
|
||||
web.EventTarget target,
|
||||
String type,
|
||||
Map<String, dynamic> args,
|
||||
) {
|
||||
final Object jsKeyboardEvent = js_util.getProperty(web.window, 'KeyboardEvent') as Object;
|
||||
final List<dynamic> eventArgs = <dynamic>[
|
||||
type,
|
||||
args,
|
||||
];
|
||||
final web.KeyboardEvent event = js_util.callConstructor(
|
||||
jsKeyboardEvent, js_util.jsify(eventArgs) as List<dynamic>)
|
||||
as web.KeyboardEvent;
|
||||
final List<dynamic> eventArgs = <dynamic>[type, args];
|
||||
final web.KeyboardEvent event =
|
||||
js_util.callConstructor(jsKeyboardEvent, js_util.jsify(eventArgs) as List<dynamic>)
|
||||
as web.KeyboardEvent;
|
||||
target.dispatchEvent(event);
|
||||
|
||||
return event;
|
||||
|
||||
@@ -52,8 +52,8 @@ class TestUrlStrategy extends UrlStrategy {
|
||||
/// Creates an instance of [TestUrlStrategy] and populates it with a list
|
||||
/// that has [initialEntry] as the only item.
|
||||
TestUrlStrategy.fromEntry(TestHistoryEntry initialEntry)
|
||||
: _currentEntryIndex = 0,
|
||||
history = <TestHistoryEntry>[initialEntry];
|
||||
: _currentEntryIndex = 0,
|
||||
history = <TestHistoryEntry>[initialEntry];
|
||||
|
||||
@override
|
||||
String getPath() => currentEntry.url;
|
||||
|
||||
Reference in New Issue
Block a user