Commit graph

37 commits

Author SHA1 Message Date
Michael Goderbauer 10a7c9ba22
Unify analysis options (#108462) 2022-07-28 09:07:49 -07:00
Greg Spencer ab2b0851a2
Add smoke tests for all the examples, fix 17 broken examples. (#89021)
This adds a smoke test for every single API example. It also fixes 17 tests that had bugs in them, or were otherwise broken, and even fixes one actual bug in the framework, and one limitation in the framework.

The bug in the framework is that NetworkImage's _loadAsync method had await response.drain<List<int>>();, but if the response is null, it will throw a cryptic exception saying that Null can't be assigned to List<int>. The fix was just to use await response.drain<void>(); instead.

The limitation is that RelativePositionedTransition takes an Animation<Rect> rect parameter, and if you want to use a RectTween with it, the value emitted there is Rect?, and one of the examples was just casting from Animation<Rect> to Animation<Rect?>, which is invalid, so I modified RelativePositionedTransition to take a Rect? and just use Rect.zero if the rect is null.
2021-09-28 09:32:06 -07:00
Alexandre Ardhuin 80990c21e2
code formatting (#85783) 2021-07-07 23:06:05 -07:00
Abhishek Ghaskata a8e2606963
Migrate manual_tests to null safety (#82611) 2021-05-27 10:49:02 -07:00
Jonah Williams c6dbb6f2b5
Update mockito dep and remove usage in manual tests and localizations (#77945) 2021-03-11 11:25:02 -08:00
Michael Goderbauer 0f568298d8
enable use_key_in_widget_constructors lint (#77032) 2021-03-02 10:14:02 -08:00
Alexandre Ardhuin d546e1d311
fix for upcoming lint use_named_constants (#74788) 2021-01-27 20:20:44 +01:00
Sam Rawlins 2b63181116
Remove "unnecessary" imports. (#74385) 2021-01-25 19:09:05 -08:00
Jason Simmons e6b9b5efb7
Add a compressionState value to HttpResponse mocks (#66679)
The Dart SDK now requires non-null enum values if the enum is used in an
exhaustive switch statement on a non-nullable type.

See https://github.com/flutter/flutter/issues/66674
2020-09-25 14:14:45 -07:00
Dan Field 7eb8447485
Allow new methods to be added to ui.Image for tests (#65876)
Remove fake image implementations, add createTestImage to flutter_test
2020-09-22 11:55:39 -07:00
Michael R Fairhurst 7f3c9b6bda
Remove unused 'dart:async' imports. (#65568) 2020-09-16 14:14:06 -07:00
Alexandre Ardhuin ec1a015045
implicit-casts:false in dev (#45787) 2019-12-05 22:34:06 +01:00
Ian Hickson 449f4a6673
License update (#45373)
* Update project.pbxproj files to say Flutter rather than Chromium

Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright.

* Update the copyright notice checker to require a standard notice on all files

* Update copyrights on Dart files. (This was a mechanical commit.)

* Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine.

Some were already marked "The Flutter Authors", not clear why. Their
dates have been normalized. Some were missing the blank line after the
license. Some were randomly different in trivial ways for no apparent
reason (e.g. missing the trailing period).

* Clean up the copyrights in non-Dart files. (Manual edits.)

Also, make sure templates don't have copyrights.

* Fix some more ORGANIZATIONNAMEs
2019-11-27 15:04:02 -08:00
Ian Hickson 1ce4a4f36f
Make sure all our .dart files have license headers (#44467) 2019-11-08 16:53:21 -08:00
Alexandre Ardhuin f62afdcf57
add missing type parameter on methods (#22096) 2018-10-01 21:29:08 +02:00
Alexandre Ardhuin d927c93310
Unnecessary new (#20138)
* enable lint unnecessary_new

* fix tests

* fix tests

* fix tests
2018-09-12 08:29:29 +02:00
Sam Rawlins 9f8a70be4c Bump mockito to 3.0.0-beta (#18462)
* Bump mockito to 3.0.0-beta

* Few fixes

* fix test

* Bump image

* Fix

* New packages update

* With matcher pinned

* No more typed
2018-06-21 16:23:47 -07:00
Greg Spencer 08d1ec36de Roll engine to 0c119932c0d6cb30dafd75ec717d1eda76fd7651 (#18575) 2018-06-19 09:58:20 +02:00
Alexander Aprelev bffae21571
Again move mockito to 300plus2 (#15981)
* Revert "Revert "Move mockito to 3.0.0-alpha. (#15949)" (#15979)"

This reverts commit e59651f925.

* More thenReturn to thenAnswer when mocking Futures

* Revert "More thenReturn to thenAnswer when mocking Futures"

This reverts commit 194d2cf417 as we are reverting engine roll.

* Revert "Revert "More thenReturn to thenAnswer when mocking Futures""

This reverts commit 52c9e96b30.

* Add dependency override

* Fix issue
2018-03-28 12:07:12 -07:00
Alexander Aprelev e59651f925
Revert "Move mockito to 3.0.0-alpha. (#15949)" (#15979)
This reverts commit a7e6225820 as there are failing tests.
2018-03-27 10:38:20 -07:00
Alexander Aprelev a7e6225820
Move mockito to 3.0.0-alpha. (#15949)
* Move mockito to 3.0.0-alpha.

This is needed so it matches mockito version used internally.

* Pick up +2 for the fixes

* Fix whenReturn in fuchsia_remote_debug_protocol

* more thenReturn becomes thenAnswer

* more thenReturn becomes thenAnswer

* more thenReturn becomes thenAnswer
2018-03-27 10:05:16 -07:00
Jonah Williams 88cc977384
Remove package:http from Flutter (#15416)
* use HttpOverrides and dart:io HttpClient in flutter

* add missing package:http dependency

* update flutter packages and remove comment about createHttpClient from flutter_test

* move byte loading logic to common class, move string parsing logic to base class

* addAll doesn't work for a Uint8List

* use bytes.setRange

* undo addition to hello_world

* add newline to end of binding.dart

* and a newline for hello world

* refactor to function and add tests

* address comments on unknown length case

* alignment

* sort alaphabetically

* rename convertResponse to consolidateClientHttpClientResponseBytes.  Add header

* fix alignment in test
2018-03-22 08:21:01 -07:00
Alexandre Ardhuin 061352918b
enable lint avoid_relative_lib_imports (#15780) 2018-03-22 07:56:18 +01:00
Ian Hickson 44e228eb9e
Move image logic from services/ to painting/. (#13409)
This allows the scheduler library to depend on the services library
and the painting library to depend on the scheduler library without
the services library having to depend on the scheduler library.

While I was at it I also cleaned up some of the binding logic: the
licenses logic can now be overridden (and the test library does so),
and the image cache can now be overridden as well.
2017-12-07 14:53:08 -08:00
Ian Hickson da5be60130
Fix overlay_geometry manual test. (#13315)
Somehow the test ended up checking for notification messages at the wrong depth.
2017-12-04 13:53:23 -08:00
amirh 5fc8eb8263
Use MultiFrameImageStreamProvider in the various image providers. (#12997) 2017-11-17 13:48:28 -08:00
Alexandre Ardhuin 1fce14a31c enable lint prefer_single_quotes (#12665) 2017-10-22 18:11:36 +02:00
mattsarett 5b5aa25457 Add manual test for color space rendering behavior (#10000)
* Add manual test for color space rendering behavior

* Remove unneeded assets

* Add test for color demo

* Drag up to scroll down
2017-05-18 10:07:45 -07:00
Jason Simmons 457b8c05df Repackage manual_tests with the current project template (#10057)
See https://github.com/flutter/flutter/pull/10000
2017-05-15 10:40:03 -07:00
Ian Hickson 4773a8cd4b Re-enable test since underlying issue is fixed (#10008) 2017-05-12 15:51:13 -07:00
Ian Hickson 896ffcdf17 Disable test that is turning the tree red. (#9204)
This issue is being tracked at: https://github.com/dart-lang/sdk/issues/29230
2017-04-04 17:01:38 -07:00
Chris Bracken 6c97dd2c6c Declare locals as final where not reassigned (dev) (#8574) 2017-03-03 18:06:08 -08:00
Ian Hickson 3252701753 Make it possible to run tests live on a device (#3936)
This makes it possible to substitute 'flutter run' for 'flutter test'
and actually watch a test run on a device.

For any test that depends on flutter_test:

1. Remove any import of 'package:test/test.dart'.

2. Replace `testWidgets('...', (WidgetTester tester) {`
      with `testWidgets('...', (WidgetTester tester) async {`

3. Add an "await" in front of calls to any of the following:
    * tap()
    * tapAt()
    * fling()
    * flingFrom()
    * scroll()
    * scrollAt()
    * pump()
    * pumpWidget()

4. Replace any calls to `tester.flushMicrotasks()` with calls to
   `await tester.idle()`.

There's a guarding API that you can use, if you have particularly
complicated tests, to get better error messages. Search for
TestAsyncUtils.
2016-05-16 12:53:13 -07:00
Ian Hickson 91dd969966 Refactor the test framework (#3622)
* 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
2016-04-29 13:23:27 -07:00
Ian Hickson c167efca17 Minor widget_tester refactoring and docs (#3472)
This reorders some classes so that this file makes more sense, and adds
a bunch of docs. It also makes the following changes:

* Move allElements from Instrumentation to TestWidgets. (Instrumentation
  is going away.)

* Remove findElements.

* Rename byElement to byElementPredicate

* Rename byPredicate to byWidgetPredicate

* Implement _WidgetPredicateFinder so that byWidgetPredicate has good
  messages

* Fix one use of byElementPredicate to use byWidgetPredicate.
2016-04-21 16:35:46 -07:00
Yegor f3a4f722c4 [flutter_test] new WidgetTester API based on finder objects (#3288) 2016-04-13 23:40:15 -07:00
Ian Hickson 7861d02943 Fix dependency skew. (#3306)
...by adding tests to our examples that don't import flutter_test, which
pins the relevant dependencies.

Also, provide more information when complaining about leaked transient
callbacks in tests.

Also, make tests display full information when they have an exception,
by bypassing the throttling we have for Android logging in tests.

Also, make the word wrapping not wrap stack traces if they happen to
be included in exception output.

Also, fix a leaked transient callback in the checkbox code.
2016-04-13 13:53:39 -07:00