@@ -273,6 +273,62 @@ void main() {
273
273
expect (findOverflowBackButton (), findsNothing);
274
274
}, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web.
275
275
276
+ testWidgets ('correctly sizes large toolbar buttons' , (WidgetTester tester) async {
277
+ final GlobalKey firstBoxKey = GlobalKey ();
278
+ final GlobalKey secondBoxKey = GlobalKey ();
279
+ final GlobalKey thirdBoxKey = GlobalKey ();
280
+ final GlobalKey fourthBoxKey = GlobalKey ();
281
+
282
+ await tester.pumpWidget (
283
+ CupertinoApp (
284
+ home: Center (
285
+ child: SizedBox (
286
+ width: 420 ,
287
+ child: CupertinoTextSelectionToolbar (
288
+ anchorAbove: const Offset (50.0 , 100.0 ),
289
+ anchorBelow: const Offset (50.0 , 200.0 ),
290
+ children: < Widget > [
291
+ SizedBox (key: firstBoxKey, width: 100 ),
292
+ SizedBox (key: secondBoxKey, width: 300 ),
293
+ SizedBox (key: thirdBoxKey, width: 100 ),
294
+ SizedBox (key: fourthBoxKey, width: 100 ),
295
+ ],
296
+ ),
297
+ ),
298
+ ),
299
+ ),
300
+ );
301
+
302
+ // The first page isn't wide enough to show the second button.
303
+ expect (find.byKey (firstBoxKey), findsOneWidget);
304
+ expect (find.byKey (secondBoxKey), findsNothing);
305
+ expect (find.byKey (thirdBoxKey), findsNothing);
306
+ expect (find.byKey (fourthBoxKey), findsNothing);
307
+
308
+ // Show the next page.
309
+ await tester.tapAt (tester.getCenter (findOverflowNextButton ()));
310
+ await tester.pumpAndSettle ();
311
+
312
+ // The second page should show only the second button.
313
+ expect (find.byKey (firstBoxKey), findsNothing);
314
+ expect (find.byKey (secondBoxKey), findsOneWidget);
315
+ expect (find.byKey (thirdBoxKey), findsNothing);
316
+ expect (find.byKey (fourthBoxKey), findsNothing);
317
+
318
+ // The button's width shouldn't be limited by the first page's width.
319
+ expect (tester.getSize (find.byKey (secondBoxKey)).width, 300 );
320
+
321
+ // Show the next page.
322
+ await tester.tapAt (tester.getCenter (findOverflowNextButton ()));
323
+ await tester.pumpAndSettle ();
324
+
325
+ // The third page should show the last two items.
326
+ expect (find.byKey (firstBoxKey), findsNothing);
327
+ expect (find.byKey (secondBoxKey), findsNothing);
328
+ expect (find.byKey (thirdBoxKey), findsOneWidget);
329
+ expect (find.byKey (fourthBoxKey), findsOneWidget);
330
+ }, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web.
331
+
276
332
testWidgets ('positions itself at anchorAbove if it fits' , (WidgetTester tester) async {
277
333
late StateSetter setState;
278
334
const double height = 50.0 ;
0 commit comments