mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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>
75 lines
3.2 KiB
Dart
75 lines
3.2 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('Padding RTL', (WidgetTester tester) async {
|
|
const Widget child = Padding(
|
|
padding: EdgeInsetsDirectional.only(start: 10.0),
|
|
child: Placeholder(),
|
|
);
|
|
await tester.pumpWidget(const Directionality(textDirection: TextDirection.ltr, child: child));
|
|
expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(10.0, 0.0));
|
|
await tester.pumpWidget(const Directionality(textDirection: TextDirection.rtl, child: child));
|
|
expect(tester.getTopLeft(find.byType(Placeholder)), Offset.zero);
|
|
|
|
await tester.pumpWidget(
|
|
const Padding(
|
|
key: GlobalObjectKey<State<StatefulWidget>>(Object()),
|
|
padding: EdgeInsets.only(left: 1.0),
|
|
),
|
|
);
|
|
await tester.pumpWidget(
|
|
const Directionality(
|
|
textDirection: TextDirection.rtl,
|
|
child: Padding(
|
|
key: GlobalObjectKey<State<StatefulWidget>>(Object()),
|
|
padding: EdgeInsetsDirectional.only(start: 1.0),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpWidget(
|
|
const Padding(
|
|
key: GlobalObjectKey<State<StatefulWidget>>(Object()),
|
|
padding: EdgeInsets.only(left: 1.0),
|
|
),
|
|
);
|
|
});
|
|
|
|
testWidgets('Container padding/margin RTL', (WidgetTester tester) async {
|
|
final Widget child = Container(
|
|
padding: const EdgeInsetsDirectional.only(start: 6.0),
|
|
margin: const EdgeInsetsDirectional.only(end: 20.0, start: 4.0),
|
|
child: const Placeholder(),
|
|
);
|
|
await tester.pumpWidget(Directionality(textDirection: TextDirection.ltr, child: child));
|
|
expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(10.0, 0.0));
|
|
expect(tester.getTopRight(find.byType(Placeholder)), const Offset(780.0, 0.0));
|
|
await tester.pumpWidget(Directionality(textDirection: TextDirection.rtl, child: child));
|
|
expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(20.0, 0.0));
|
|
expect(tester.getTopRight(find.byType(Placeholder)), const Offset(790.0, 0.0));
|
|
});
|
|
|
|
testWidgets('Container padding/margin mixed RTL/absolute', (WidgetTester tester) async {
|
|
final Widget child = Container(
|
|
padding: const EdgeInsets.only(left: 6.0),
|
|
margin: const EdgeInsetsDirectional.only(end: 20.0, start: 4.0),
|
|
child: const Placeholder(),
|
|
);
|
|
await tester.pumpWidget(Directionality(textDirection: TextDirection.ltr, child: child));
|
|
expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(10.0, 0.0));
|
|
expect(tester.getTopRight(find.byType(Placeholder)), const Offset(780.0, 0.0));
|
|
await tester.pumpWidget(Directionality(textDirection: TextDirection.rtl, child: child));
|
|
expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(26.0, 0.0));
|
|
expect(tester.getTopRight(find.byType(Placeholder)), const Offset(796.0, 0.0));
|
|
});
|
|
|
|
testWidgets('EdgeInsetsDirectional without Directionality', (WidgetTester tester) async {
|
|
await tester.pumpWidget(const Padding(padding: EdgeInsetsDirectional.zero));
|
|
expect(tester.takeException(), isAssertionError);
|
|
});
|
|
}
|