• Ian Hickson's avatar
    Refactor the test framework (#3622) · 91dd9699
    Ian Hickson authored
    * Refactor widget test framework
    
    Instead of:
    
    ```dart
      test("Card Collection smoke test", () {
        testWidgets((WidgetTester tester) {
    ```
    
    ...you now say:
    
    ```dart
      testWidgets("Card Collection smoke test", (WidgetTester tester) {
    ```
    
    Instead of:
    
    ```dart
      expect(tester, hasWidget(find.text('hello')));
    ```
    
    ...you now say:
    
    ```dart
      expect(find.text('hello'), findsOneWidget);
    ```
    
    Instead of the previous API (exists, widgets, widget, stateOf,
    elementOf, etc), you now have the following comprehensive API. All these
    are functions that take a Finder, except the all* properties.
    
    * `any()` - true if anything matches, c.f. `Iterable.any`
    * `allWidgets` - all the widgets in the tree
    * `widget()` - the one and only widget that matches the finder
    * `firstWidget()` - the first widget that matches the finder
    * `allElements` - all the elements in the tree
    * `element()` - the one and only element that matches the finder
    * `firstElement()` - the first element that matches the finder
    * `allStates` - all the `State`s in the tree
    * `state()` - the one and only state that matches the finder
    * `firstState()` - the first state that matches the finder
    * `allRenderObjects` - all the render objects in the tree
    * `renderObject()` - the one and only render object that matches the finder
    * `firstRenderObject()` - the first render object that matches the finder
    
    There's also `layers' which returns the list of current layers.
    
    `tap`, `fling`, getCenter, getSize, etc, take Finders, like the APIs
    above, and expect there to only be one matching widget.
    
    The finders are:
    
     * `find.text(String text)`
     * `find.widgetWithText(Type widgetType, String text)`
     * `find.byKey(Key key)`
     * `find.byType(Type type)`
     * `find.byElementType(Type type)`
     * `find.byConfig(Widget config)`
     * `find.byWidgetPredicate(WidgetPredicate predicate)`
     * `find.byElementPredicate(ElementPredicate predicate)`
    
    The matchers (for `expect`) are:
    
     * `findsNothing`
     * `findsWidgets`
     * `findsOneWidget`
     * `findsNWidgets(n)`
     * `isOnStage`
     * `isOffStage`
     * `isInCard`
     * `isNotInCard`
    
    Benchmarks now use benchmarkWidgets instead of testWidgets.
    
    Also, for those of you using mockers, `serviceMocker` now automatically
    handles the binding initialization.
    
    This patch also:
    
    * changes how tests are run so that we can more easily swap the logic
      out for a "real" mode instead of FakeAsync.
    
    * introduces CachingIterable.
    
    * changes how flutter_driver interacts with the widget tree to use the
      aforementioned new API rather than ElementTreeTester, which is gone.
    
    * removes ElementTreeTester.
    
    * changes the semantics of a test for scrollables because we couldn't
      convince ourselves that the old semantics made sense; it only worked
      before because flushing the microtasks after every event was broken.
    
    * fixes the flushing of microtasks after every event.
    
    * Reindent the tests
    
    * Fix review comments
    91dd9699
Name
Last commit
Last update
..
align_test.dart Loading commit data...
animated_container_test.dart Loading commit data...
animated_positioned_test.dart Loading commit data...
aspect_ratio_test.dart Loading commit data...
asset_vendor_test.dart Loading commit data...
banner_test.dart Loading commit data...
block_test.dart Loading commit data...
bottom_sheet_rebuild_test.dart Loading commit data...
bottom_sheet_test.dart Loading commit data...
box_decoration_test.dart Loading commit data...
build_scope_test.dart Loading commit data...
buttons_test.dart Loading commit data...
center_test.dart Loading commit data...
coordinates_test.dart Loading commit data...
custom_multi_child_layout_test.dart Loading commit data...
custom_one_child_layout_test.dart Loading commit data...
custom_paint_test.dart Loading commit data...
date_picker_test_disabled.dart Loading commit data...
dismissable_test.dart Loading commit data...
draggable_test.dart Loading commit data...
drawer_test.dart Loading commit data...
duplicate_key_test.dart Loading commit data...
flex_test.dart Loading commit data...
flow_test.dart Loading commit data...
focus_test.dart Loading commit data...
form_test.dart Loading commit data...
fractionally_sized_box_test.dart Loading commit data...
gesture_detector_test.dart Loading commit data...
heroes_test.dart Loading commit data...
hyperlink_test.dart Loading commit data...
icon_test.dart Loading commit data...
image_test.dart Loading commit data...
independent_widget_layout_test.dart Loading commit data...
inherited_test.dart Loading commit data...
init_state_test.dart Loading commit data...
input_test.dart Loading commit data...
lazy_block_test.dart Loading commit data...
lazy_block_viewport_test.dart Loading commit data...
listener_test.dart Loading commit data...
media_query_test.dart Loading commit data...
modal_barrier_test.dart Loading commit data...
multichild_test.dart Loading commit data...
navigator_test.dart Loading commit data...
overflow_box_test.dart Loading commit data...
page_forward_transitions_test.dart Loading commit data...
page_transitions_test.dart Loading commit data...
pageable_list_test.dart Loading commit data...
parent_data_test.dart Loading commit data...
positioned_test.dart Loading commit data...
raw_keyboard_listener_test.dart Loading commit data...
remember_scroll_position_test.dart Loading commit data...
render_object_widget_test.dart Loading commit data...
reparent_state_test.dart Loading commit data...
rotated_box_test.dart Loading commit data...
routes_test.dart Loading commit data...
scroll_behavior_test.dart Loading commit data...
scroll_events_test.dart Loading commit data...
scroll_interaction_test.dart Loading commit data...
scrollable_lazy_list_test.dart Loading commit data...
scrollable_list_hit_testing_test.dart Loading commit data...
scrollable_list_horizontal_test.dart Loading commit data...
scrollable_list_vertical_test.dart Loading commit data...
scrollable_list_with_inherited_test.dart Loading commit data...
semantics_1_test.dart Loading commit data...
semantics_2_test.dart Loading commit data...
semantics_3_test.dart Loading commit data...
semantics_4_test.dart Loading commit data...
semantics_5_test.dart Loading commit data...
semantics_6_test.dart Loading commit data...
semantics_7_test.dart Loading commit data...
semantics_8_test.dart Loading commit data...
set_state_2_test.dart Loading commit data...
set_state_3_test.dart Loading commit data...
set_state_test.dart Loading commit data...
shader_mask_test.dart Loading commit data...
snap_scrolling_test.dart Loading commit data...
stack_test.dart Loading commit data...
stateful_component_test.dart Loading commit data...
stateful_components_test.dart Loading commit data...
syncing_test.dart Loading commit data...
table_test.dart Loading commit data...
test_semantics.dart Loading commit data...
test_widgets.dart Loading commit data...
transform_test.dart Loading commit data...
two_level_list_test.dart Loading commit data...