diff --git a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart index f95af3e56b9e2..2977f6d353f9d 100644 --- a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart +++ b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart @@ -31,13 +31,16 @@ class _AccountPictures extends StatelessWidget { end: 0.0, child: new Row( children: (otherAccountsPictures ?? []).take(3).map((Widget picture) { - return new Semantics( - explicitChildNodes: true, - child: new Container( - margin: const EdgeInsetsDirectional.only(start: 16.0), - width: 40.0, - height: 40.0, - child: picture + return new Container( + margin: const EdgeInsetsDirectional.only(start: 8.0), + width: 48.0, + height: 48.0, + child: new Semantics( + container: true, + child: new Padding( + child: picture, + padding: const EdgeInsets.all(4.0), + ), ), ); }).toList(), diff --git a/packages/flutter/test/material/user_accounts_drawer_header_test.dart b/packages/flutter/test/material/user_accounts_drawer_header_test.dart index 734840c795d8e..e2f90254c9fe2 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -98,8 +98,8 @@ void main() { expect(avatarATopLeft.dx - topLeft.dx, equals(16.0 + 10.0)); // left padding expect(avatarATopLeft.dy - topLeft.dy, equals(16.0 + 20.0)); // add top padding - expect(topRight.dx - avatarDTopRight.dx, equals(16.0 + 30.0)); // right padding - expect(avatarDTopRight.dy - topRight.dy, equals(16.0 + 20.0)); // add top padding + expect(topRight.dx - avatarDTopRight.dx, equals(16.0 + 34.0)); // right padding + expect(avatarDTopRight.dy - topRight.dy, equals(16.0 + 24.0)); // add top padding expect(avatarDTopRight.dx - avatarCTopRight.dx, equals(40.0 + 16.0)); // size + space between }); @@ -374,6 +374,27 @@ void main() { semantics.dispose(); }); + testWidgets('alternative account selectors have sufficient tap targets', (WidgetTester tester) async { + final SemanticsHandle handle = tester.ensureSemantics(); + await pumpTestWidget(tester); + + expect(tester.getSemanticsData(find.text('B')), matchesSemanticsData( + label: 'B', + size: const Size(48.0, 48.0), + )); + + expect(tester.getSemanticsData(find.text('C')), matchesSemanticsData( + label: 'C', + size: const Size(48.0, 48.0), + )); + + expect(tester.getSemanticsData(find.text('D')), matchesSemanticsData( + label: 'D', + size: const Size(48.0, 48.0), + )); + handle.dispose(); + }); + testWidgets('UserAccountsDrawerHeader provides semantics with missing properties', (WidgetTester tester) async { final SemanticsTester semantics = new SemanticsTester(tester); await pumpTestWidget( diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 58841f405ce24..be568a1e8b57d 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -306,6 +306,7 @@ Matcher matchesSemanticsData({ String value, TextDirection textDirection, Rect rect, + Size size, // Flags // bool hasCheckedState = false, bool isChecked = false, @@ -447,6 +448,7 @@ Matcher matchesSemanticsData({ flags: flags, textDirection: textDirection, rect: rect, + size: size, customActions: customActions, hintOverrides: hintOverrides, ); @@ -1478,6 +1480,7 @@ class _MatchesSemanticsData extends Matcher { this.actions, this.textDirection, this.rect, + this.size, this.customActions, this.hintOverrides, }); @@ -1491,6 +1494,7 @@ class _MatchesSemanticsData extends Matcher { final List flags; final TextDirection textDirection; final Rect rect; + final Size size; @override Description describe(Description description) { @@ -1509,6 +1513,8 @@ class _MatchesSemanticsData extends Matcher { description.add('with textDirection: $textDirection '); if (rect != null) description.add('with rect: $rect'); + if (size != null) + description.add('with size: $size'); if (customActions != null) description.add('with custom actions: $customActions'); if (hintOverrides != null) @@ -1530,9 +1536,10 @@ class _MatchesSemanticsData extends Matcher { return failWithDescription(matchState, 'value was: ${data.value}'); if (textDirection != null && textDirection != data.textDirection) return failWithDescription(matchState, 'textDirection was: $textDirection'); - if (rect != null && rect != data.rect) { - return failWithDescription(matchState, 'rect was: $rect'); - } + if (rect != null && rect != data.rect) + return failWithDescription(matchState, 'rect was: ${data.rect}'); + if (size != null && size != data.rect.size) + return failWithDescription(matchState, 'size was: ${data.rect.size}'); if (actions != null) { int actionBits = 0; for (SemanticsAction action in actions) diff --git a/packages/flutter_test/test/matchers_test.dart b/packages/flutter_test/test/matchers_test.dart index efeb3bd3dd0d1..3cad0f7954b5b 100644 --- a/packages/flutter_test/test/matchers_test.dart +++ b/packages/flutter_test/test/matchers_test.dart @@ -483,11 +483,11 @@ void main() { final SemanticsData data = new SemanticsData( flags: flags, actions: actions, - label: '', - increasedValue: '', - value: '', - decreasedValue: '', - hint: '', + label: 'a', + increasedValue: 'b', + value: 'c', + decreasedValue: 'd', + hint: 'e', textDirection: TextDirection.ltr, rect: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), textSelection: null, @@ -498,6 +498,8 @@ void main() { ); expect(data, matchesSemanticsData( + rect: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), + size: const Size(10.0, 10.0), /* Flags */ hasCheckedState: true, isChecked: true,