@@ -321,16 +321,44 @@ void main() {
321321 final TestApp app = TestApp (appbar);
322322 await tester.pumpWidget (app);
323323
324+ // find appbar by key
325+ expect (find.byKey (appbarKey), findsOneWidget);
326+ // find appbar title text
324327 expect (find.text ('Appbar' ), findsOneWidget);
328+ // find appbar action button icon
325329 expect (find.byIcon (Icons .favorite), findsOneWidget);
330+ // set appbar.searchBar = true state to enable search bar
326331 expect (app.appbar.searchBar, isTrue);
327- expect (find.byKey (appbarKey), findsOneWidget);
332+ // tap the search icon
333+ await tester.tap (find.byIcon (Icons .search));
334+ // rebuild the widget
335+ await tester.pump ();
336+ // enter 'flutter' to the textField
328337 await tester.enterText (find.byWidget (appbar), 'flutter' );
338+ // find the text 'flutter' to test onChanged
339+ expect (find.text ('flutter' ), findsOneWidget);
340+ // to test onSubmitted when TextInputAction.done
329341 await tester.testTextInput.receiveAction (TextInputAction .done);
342+ // rebuild the widget
330343 await tester.pump ();
344+ // find the text 'flutter' in textField
331345 expect (find.text ('flutter' ), findsOneWidget);
332-
333-
346+ // tap the close icon to close the searchBar
347+ await tester.tap (find.byIcon (Icons .close));
348+ // rebuild the widget
349+ await tester.pump ();
350+ // try to find textField
351+ expect (find.byType (TextField ), findsNothing);
352+ // tap the search icon to reopen the searchBar
353+ await tester.tap (find.byIcon (Icons .search));
354+ // rebuild the widget
355+ await tester.pump ();
356+ // find the text 'flutter' in textField
357+ expect (find.text ('flutter' ), findsOneWidget);
358+ // tap the textField to test onTap
359+ await tester.tap (find.byType (TextField ));
360+ // rebuild the widget
361+ await tester.pump ();
334362 });
335363}
336364
0 commit comments