Unverified Commit 42924e27 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Update `Divider`/`VerticalDivider` and theme tests for M2/M3 (#130415)

Updated unit tests for `Divider`/ `VerticalDivider`  and theme to have M2 and M3 versions.

More info in https://github.com/flutter/flutter/pull/128725
parent 58acd609
......@@ -4,16 +4,29 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart';
void main() {
testWidgets('Divider control test', (WidgetTester tester) async {
testWidgets('Material3 - Divider control test', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Center(
child: Divider(),
theme: ThemeData(useMaterial3: true),
home: const Center(child: Divider()),
),
);
final RenderBox box = tester.firstRenderObject(find.byType(Divider));
expect(box.size.height, 16.0);
final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration! as BoxDecoration;
expect(decoration.border!.bottom.width, 1.0);
});
testWidgets('Material2 - Divider control test', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Center(child: Divider()),
),
);
final RenderBox box = tester.firstRenderObject(find.byType(Divider));
......@@ -27,11 +40,7 @@ void main() {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: Divider(
thickness: 5.0,
),
),
child: Center(child: Divider(thickness: 5.0)),
),
);
final Container container = tester.widget(find.byType(Container));
......@@ -47,11 +56,7 @@ void main() {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: Divider(
indent: customIndent,
),
),
child: Center(child: Divider(indent: customIndent)),
),
);
// The divider line is drawn with a DecoratedBox with a border
......@@ -63,11 +68,7 @@ void main() {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: Divider(
endIndent: customIndent,
),
),
child: Center(child: Divider(endIndent: customIndent)),
),
);
dividerRect = tester.getRect(find.byType(Divider));
......@@ -92,13 +93,26 @@ void main() {
expect(lineRect.right, dividerRect.right - customIndent);
});
testWidgets('Vertical Divider Test', (WidgetTester tester) async {
testWidgets('Material3 - Vertical Divider Test', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Center(
child: VerticalDivider(),
theme: ThemeData(useMaterial3: true),
home: const Center(child: VerticalDivider()),
),
);
final RenderBox box = tester.firstRenderObject(find.byType(VerticalDivider));
expect(box.size.width, 16.0);
final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration! as BoxDecoration;
final Border border = decoration.border! as Border;
expect(border.left.width, 1.0);
});
testWidgets('Material2 - Vertical Divider Test', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Center(child: VerticalDivider()),
),
);
final RenderBox box = tester.firstRenderObject(find.byType(VerticalDivider));
......@@ -113,11 +127,7 @@ void main() {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: VerticalDivider(
thickness: 5.0,
),
),
child: Center(child: VerticalDivider(thickness: 5.0)),
),
);
final Container container = tester.widget(find.byType(Container));
......@@ -158,11 +168,7 @@ void main() {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: VerticalDivider(
indent: customIndent,
),
),
child: Center(child: VerticalDivider(indent: customIndent)),
),
);
// The divider line is drawn with a DecoratedBox with a border
......@@ -174,11 +180,7 @@ void main() {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: VerticalDivider(
endIndent: customIndent,
),
),
child: Center(child: VerticalDivider(endIndent: customIndent)),
),
);
dividerRect = tester.getRect(find.byType(VerticalDivider));
......
......@@ -57,7 +57,7 @@ void main() {
]);
});
group('Horizontal Divider', () {
group('Material3 - Horizontal Divider', () {
testWidgets('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(MaterialApp(
......@@ -159,7 +159,7 @@ void main() {
});
});
group('Vertical Divider', () {
group('Material3 - Vertical Divider', () {
testWidgets('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(MaterialApp(
......@@ -270,7 +270,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests
// can be deleted.
group('Horizontal Divider', () {
group('Material2 - Horizontal Divider', () {
testWidgets('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
......@@ -313,7 +313,7 @@ void main() {
});
});
group('Vertical Divider', () {
group('Material2 - Vertical Divider', () {
testWidgets('Passing no DividerThemeData returns defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment