Skip to content

Commit e8c2bb1

Browse files
authored
Reland "Update framework_test.dart to remove ButtonBar usage and remove references from other clases (#137550) (#137753)
This PR removes `ButtonBar` usage from `framework_test.dart` class and update other references in preparation for `ButtonBar` deprecation related to flutter/flutter#127955 reland flutter/flutter#137550
1 parent 07d7363 commit e8c2bb1

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

packages/flutter/lib/src/material/banner.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class _MaterialBannerState extends State<MaterialBanner> {
318318
?? bannerTheme.leadingPadding
319319
?? const EdgeInsetsDirectional.only(end: 16.0);
320320

321-
final Widget buttonBar = Container(
321+
final Widget actionsBar = Container(
322322
alignment: AlignmentDirectional.centerEnd,
323323
constraints: const BoxConstraints(minHeight: 52.0),
324324
padding: const EdgeInsets.symmetric(horizontal: 8),
@@ -372,12 +372,12 @@ class _MaterialBannerState extends State<MaterialBanner> {
372372
),
373373
),
374374
if (isSingleRow)
375-
buttonBar,
375+
actionsBar,
376376
],
377377
),
378378
),
379379
if (!isSingleRow)
380-
buttonBar,
380+
actionsBar,
381381
if (elevation == 0)
382382
Divider(height: 0, color: dividerColor),
383383
],

packages/flutter/test/material/dialog_test.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ RenderParagraph _getTextRenderObjectFromDialog(WidgetTester tester, String text)
5757
// What was the AlertDialog's ButtonBar when many of these tests were written,
5858
// is now a Padding widget with an OverflowBar child. The Padding widget's size
5959
// and location match the original ButtonBar's size and location.
60-
Finder _findButtonBar() {
60+
Finder _findOverflowBar() {
6161
return find.ancestor(of: find.byType(OverflowBar), matching: find.byType(Padding)).first;
6262
}
6363

@@ -610,7 +610,7 @@ void main() {
610610
matching: find.byType(Material),
611611
).first,
612612
);
613-
final Size actionsSize = tester.getSize(_findButtonBar());
613+
final Size actionsSize = tester.getSize(_findOverflowBar());
614614

615615
expect(actionsSize.width, dialogSize.width);
616616
});
@@ -687,25 +687,25 @@ void main() {
687687
// First button
688688
expect(
689689
tester.getTopRight(find.byKey(key1)).dy,
690-
tester.getTopRight(_findButtonBar()).dy + 8.0,
690+
tester.getTopRight(_findOverflowBar()).dy + 8.0,
691691
); // top
692692
expect(
693693
tester.getBottomRight(find.byKey(key1)).dy,
694-
tester.getBottomRight(_findButtonBar()).dy - 8.0,
694+
tester.getBottomRight(_findOverflowBar()).dy - 8.0,
695695
); // bottom
696696

697697
// Second button
698698
expect(
699699
tester.getTopRight(find.byKey(key2)).dy,
700-
tester.getTopRight(_findButtonBar()).dy + 8.0,
700+
tester.getTopRight(_findOverflowBar()).dy + 8.0,
701701
); // top
702702
expect(
703703
tester.getBottomRight(find.byKey(key2)).dy,
704-
tester.getBottomRight(_findButtonBar()).dy - 8.0,
704+
tester.getBottomRight(_findOverflowBar()).dy - 8.0,
705705
); // bottom
706706
expect(
707707
tester.getBottomRight(find.byKey(key2)).dx,
708-
tester.getBottomRight(_findButtonBar()).dx - 8.0,
708+
tester.getBottomRight(_findOverflowBar()).dx - 8.0,
709709
); // right
710710
});
711711

@@ -745,25 +745,25 @@ void main() {
745745
// First button
746746
expect(
747747
tester.getTopRight(find.byKey(key1)).dy,
748-
tester.getTopRight(_findButtonBar()).dy,
748+
tester.getTopRight(_findOverflowBar()).dy,
749749
); // top
750750
expect(
751751
tester.getBottomRight(find.byKey(key1)).dy,
752-
tester.getBottomRight(_findButtonBar()).dy - 24.0,
752+
tester.getBottomRight(_findOverflowBar()).dy - 24.0,
753753
); // bottom
754754

755755
// // Second button
756756
expect(
757757
tester.getTopRight(find.byKey(key2)).dy,
758-
tester.getTopRight(_findButtonBar()).dy,
758+
tester.getTopRight(_findOverflowBar()).dy,
759759
); // top
760760
expect(
761761
tester.getBottomRight(find.byKey(key2)).dy,
762-
tester.getBottomRight(_findButtonBar()).dy - 24.0,
762+
tester.getBottomRight(_findOverflowBar()).dy - 24.0,
763763
); // bottom
764764
expect(
765765
tester.getBottomRight(find.byKey(key2)).dx,
766-
tester.getBottomRight(_findButtonBar()).dx - 24.0,
766+
tester.getBottomRight(_findOverflowBar()).dx - 24.0,
767767
); // right
768768
});
769769

@@ -809,25 +809,25 @@ void main() {
809809
// First button
810810
expect(
811811
tester.getTopRight(find.byKey(key1)).dy,
812-
tester.getTopRight(_findButtonBar()).dy + ((10.0 + 20.0) / 2),
812+
tester.getTopRight(_findOverflowBar()).dy + ((10.0 + 20.0) / 2),
813813
); // top
814814
expect(
815815
tester.getBottomRight(find.byKey(key1)).dy,
816-
tester.getBottomRight(_findButtonBar()).dy - ((10.0 + 20.0) / 2),
816+
tester.getBottomRight(_findOverflowBar()).dy - ((10.0 + 20.0) / 2),
817817
); // bottom
818818

819819
// Second button
820820
expect(
821821
tester.getTopRight(find.byKey(key2)).dy,
822-
tester.getTopRight(_findButtonBar()).dy + ((10.0 + 20.0) / 2),
822+
tester.getTopRight(_findOverflowBar()).dy + ((10.0 + 20.0) / 2),
823823
); // top
824824
expect(
825825
tester.getBottomRight(find.byKey(key2)).dy,
826-
tester.getBottomRight(_findButtonBar()).dy - ((10.0 + 20.0) / 2),
826+
tester.getBottomRight(_findOverflowBar()).dy - ((10.0 + 20.0) / 2),
827827
); // bottom
828828
expect(
829829
tester.getBottomRight(find.byKey(key2)).dx,
830-
tester.getBottomRight(_findButtonBar()).dx - ((10.0 + 20.0) / 2),
830+
tester.getBottomRight(_findOverflowBar()).dx - ((10.0 + 20.0) / 2),
831831
); // right
832832
});
833833

@@ -850,7 +850,7 @@ void main() {
850850
final Finder iconFinder = find.byKey(iconKey);
851851
final Finder titleFinder = find.byKey(titleKey);
852852
final Finder contentFinder = find.byKey(contentKey);
853-
final Finder actionsFinder = _findButtonBar();
853+
final Finder actionsFinder = _findOverflowBar();
854854
final Finder childrenFinder = find.byKey(childrenKey);
855855

856856
Future<void> openDialog(WidgetTester tester, Widget dialog, double textScaleFactor, {bool isM3 = false}) async {

packages/flutter/test/widgets/framework_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,10 +1580,10 @@ void main() {
15801580
textDirection: TextDirection.ltr,
15811581
child: Placeholder(),
15821582
));
1583-
final _TestInheritedElement buttonBarTheme =
1584-
_TestInheritedElement(const ButtonBarTheme(
1585-
data: ButtonBarThemeData(
1586-
alignment: MainAxisAlignment.center,
1583+
final _TestInheritedElement navigationBarTheme =
1584+
_TestInheritedElement(const NavigationBarTheme(
1585+
data: NavigationBarThemeData(
1586+
indicatorColor: Color(0xff00ff00),
15871587
),
15881588
child: Placeholder(),
15891589
));
@@ -1592,7 +1592,7 @@ void main() {
15921592
element
15931593
..dependOnInheritedElement(focusTraversalOrder)
15941594
..dependOnInheritedElement(directionality)
1595-
..dependOnInheritedElement(buttonBarTheme);
1595+
..dependOnInheritedElement(navigationBarTheme);
15961596

15971597
// Dependencies will be sorted by [debugFillProperties].
15981598
element.debugFillProperties(builder);
@@ -1607,7 +1607,7 @@ void main() {
16071607

16081608
final Set<InheritedElement> dependencies = dependenciesProperty.value!;
16091609
expect(dependencies.length, equals(3));
1610-
expect(dependenciesProperty.toDescription(), '[ButtonBarTheme, Directionality, FocusTraversalOrder]');
1610+
expect(dependenciesProperty.toDescription(), '[Directionality, FocusTraversalOrder, NavigationBarTheme]');
16111611
});
16121612

16131613
testWidgetsWithLeakTracking('BuildOwner.globalKeyCount keeps track of in-use global keys', (WidgetTester tester) async {

0 commit comments

Comments
 (0)