Commit graph

92 commits

Author SHA1 Message Date
YoungSeok Yoon 486b783076 Fix the documentation for find.byElementPredicate (#4935) 2016-07-25 12:23:00 -07:00
pq cb4f01ae3d Bump Dart SDK to 1.18.0-dev.4.0.
Last dev push for `1.18`.
2016-07-06 14:43:40 -07:00
Adam Barth 5ed8f1a1fd Add semantics for Sliders (#4808)
Also, make SemanticsOwner into a real class and use it instead of a static in
several places.
2016-07-01 13:38:24 -07:00
pq a417786d77 Update to latest analyzer (w/ cleanup).
Bye-bye `@protected `trampolines! :)
2016-06-30 10:39:45 -07:00
Adam Barth 2898768dde Add some missing docs (#4772)
These docs complete the dartdocs for their respective libraries.
2016-06-27 14:42:25 -07:00
Adam Barth 46da9e8498 Add a simple way of merging coverage data (#4726)
`flutter test` now has a `--merge-coverage` flag that can be used to merge
coverage data from previous runs, enabling faster iteration cycles.
2016-06-23 18:02:55 -07:00
Adam Barth 56039c0e64 Improve test coverage for animation.dart (#4718)
We now have 100% coverage of animation.dart and animation_controller.dart.
Also, add some basic tools for working with lcov files. These tools need much
more polish.
2016-06-23 13:43:42 -07:00
pq 352e2f573b Update to latest analyzer (0.27.4-alpha.14) and misc. analysis fixes.
* brings in analyzer version (`0.27.4-alpha.14`) corresponding to current Dart SDK (`1.18.0-dev.2.0`).
* updates analysis to use prefered API for embedder URI resolution
* adds trampolines to `State` and `StatelessWidget` to allow for warning-free within-library @protected access (needed since we closed off access to @protected closures from outside subclasses).
* turns off cache dependency tracking for analysis (in DDC this amounted to a 10% speed improvement).
2016-06-22 14:34:30 -07:00
Todd Volkert 2e48c1a1bb Simplify SystemChrome.setSystemUIOverlayStyle() (#4653)
* Only schedule overlay style update microtask if needed

* Simplify API
2016-06-21 08:28:29 -07:00
Devon Carew 415324f2f0 bump our dep on the test package (#4625)
* bump out dep on the test package

* add other pubspecs
2016-06-19 08:10:03 -07:00
pq 3e9067a4ec Dead code and switch cleanup (continued).
Prep to get us ready to pull in a new dev SDK and bump our analyzer DEP.

* updates `crypto` (required by fresh analyzer)
* fixes newly flagged dead code warnings
* fixes switches that fall through and don't return
2016-06-16 09:45:37 -07:00
pq 985a7b91cf Update analyzer dep to 0.27.4-alpha.9
Update analyzer dep to 0.27.4-alpha.9 to enjoy analyzer perf improvements (https://codereview.chromium.org/2011183004/) (and keep in sync with the SDK).

(This is a revisit to https://github.com/flutter/flutter/pull/4253.)
2016-05-31 06:59:56 -07:00
Adam Barth d1cb026a65 Update engine and Mojo usage (#4258)
The new mojom.dart code makes mocking services a bit tricky. I've filed
https://github.com/domokit/mojo/issues/786 about improving that.
2016-05-28 18:28:21 -07:00
Adam Barth c69cff9428 Update test package (#4198) 2016-05-25 17:45:23 -07:00
Adam Barth b1b6271683 Use "call" instead of "invoke" (#4177)
For consistency.

Fixes #4142
2016-05-24 17:53:04 -07:00
Ian Hickson 390c7ce23f Use debugPrint instead of print in test lib (#4122) 2016-05-23 16:19:51 -07:00
Ian Hickson b5c6da105c Port our microbenchmarks to the new world (#4121)
Our microbenchmarks now run on real devices.
2016-05-23 15:04:50 -07:00
Ian Hickson 06d80f22f0 Identify the widgets you tap on in live tests (#4079) 2016-05-20 14:21:38 -07:00
Ian Hickson 07719ad5ba Improve error reporting (#4025)
Don't suggest filing an issue when we can definitively say that the
assertion in question was not thrown from within the flutter package.
Fixes https://github.com/flutter/flutter/issues/3812.

Put the stack trace first after the message, with more details below the
stack trace, since the stack is often very useful and the stacks are no
longer stupidly long.

Better document the 'rescheduling' feature, and improve the error
handling asserts when it is misused.
Fixes https://github.com/flutter/flutter/issues/3888.

Improve the wording around the stack dump for exceptions during
callbacks.

Improve the color and font size of messages in live tests.
Fixes https://github.com/flutter/flutter/issues/4018.
2016-05-18 16:39:27 -07:00
Ian Hickson ef563c485e Handle stack traces that don't give column numbers (#4016) 2016-05-18 12:34:43 -07:00
Ian Hickson dacfdb64cf Track fake pointers in live test runs (#4011) 2016-05-18 12:09:39 -07:00
pq addc888926 Update to new analyzer and linter.
Notably, this will allow us to play with

* the fixed `public_member_api_docs` that now checks for documented getters when checking setters (https://github.com/dart-lang/linter/issues/237), and
* the new `comment_references` lint that ensures identifiers referenced in docs are in scope (https://github.com/dart-lang/linter/issues/240).
2016-05-18 11:47:44 -07:00
pq 7163cf115d Revert "Update to new analyzer and linter."
This reverts commit f91cf1c450.
2016-05-18 11:45:25 -07:00
pq f91cf1c450 Update to new analyzer and linter.
Notably, this will allow us to play with

* the fixed `public_member_api_docs` that now checks for documented getters when checking setters (https://github.com/dart-lang/linter/issues/237), and
* the new `comment_references` lint that ensures identifiers referenced in docs are in scope (https://github.com/dart-lang/linter/issues/240).
2016-05-18 11:44:43 -07:00
Ian Hickson d2c8c82f4b Some cleanup of the test framework (#4001)
* Add a "build" phase to EnginePhase for completeness.
* Ignore events from the device during test execution.
* More dartdocs
* Slightly more helpful messages about Timers in verifyInvariants.
* Add widgetList, elementList, stateList, renderObjectList.
* Send test events asynchronously for consistency with other APIs.
* Fix a test that was depending on test events being synchronous (or
  rather, scheduled in a microtask that came before the microtask for
  the completer of the future that the tap() function returned).
2016-05-17 17:12:03 -07:00
Ian Hickson f284c1a049 Fix tests (#3977)
Also, make sure that broken tests actually break the bots.

And add a test to make sure that keeps happening.
2016-05-17 12:45:37 -07:00
Ian Hickson 7d2519f073 Make it easier to disable print throttling. (#3941)
This exposes the default throttling implementation, and an alternative
non-throttling implementation, of `debugPrint`.
2016-05-16 13:24:06 -07: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
pq eb215c14ac Review cleanup. 2016-05-05 15:16:27 -07:00
pq 71203e9a89 Analyzer dep commentary fix. 2016-05-05 12:15:26 -07:00
pq a59a713f75 Analysis re-work to use analyzer APIs.
Introduces a new Dart analysis wrapper that works directly with the analyzer API (in favor of shelling out to a separate process).

Some consequences:

  * we no longer need to fear parts (simplifying our dart file gathering)
  * we can filter by error code (when needed), rather than by error strings
  * no more IO scraping
  * no need to generate `main()` or to run with `--package-warnings`
  * we now specify an analyzer (and linter) version in the pubspec (we’ll want to make sure this doesn’t diverge too far from the analyzer shipped with the SDK but it does give us some room to play with experimental builds)
  * no more (re)scanning of error source files (and so no more source cache)
  * should generally be a bit simpler and easier to maintain
  * runs a bit faster :)
2016-05-05 12:08:58 -07:00
Adam Barth 8da98105b4 Skip the gallery smoke test (#3736)
This test hangs occationally on the bots and the bots aren't smart enough to
recover, which means the whole project gets blocked.

Filed #3735 about the hang.
2016-05-04 13:42:29 -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
Devon Carew 50b1b16db6 rev test to 0.12.13+1 to support 1.17.0-dev dart sdks (#3613) 2016-04-28 12:56:55 -07:00
Adam Barth b7fd5426b5 Enable avoid_as lint (#3612)
Related to #3608
2016-04-28 11:07:39 -07:00
Adam Barth 51b1550df7 Delay win-by-default in gesture arena (#3552)
Wait until the end of the microtask to tell gesture recognizers that
they've won in the gesture arena. This lets recognizers dispose reject
themselves at arbitrary times without triggering gestures in awkward
call stacks.

Fixes #3183
2016-04-26 14:52:31 -07:00
Devon Carew 86723ab99e Better devices text (#3519)
* improve text for devices

* nit

* tweak text
2016-04-25 10:14:38 -07:00
Ian Hickson e968d91ca4 Rename binding abstract classes (#3482)
The old names were getting silly and started stepping on valuable namespace.

The new names are consistent and clear.
2016-04-21 17:18:46 -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
Ian Hickson 0e11b0e6e3 Make the widgets binding reusable. (#3479)
Previously the widgets layer only provided a concrete binding, which
makes it awkward to extend it compared to other bindings. This moves
widgets to the same style as the other layers.

In a subsequent patch I'll use this to make the tests layer saner.
2016-04-21 16:06:51 -07:00
Ian Hickson b7af64ee50 Refactor TestGesture (#3461)
Moves TestGesture into test_pointer.dart and makes it more
self-contained.

This is part of a general refactoring of flutter_test.

Depends on https://github.com/flutter/flutter/pull/3459
2016-04-21 13:18:02 -07:00
Hans Muller 22e8d85d16 Enhance Finder toString() (#3458)
* Enhance Finder toString()
2016-04-21 12:13:51 -07:00
Adam Barth 248960a734 Add a route table to Material Gallery (#3457)
Use the route table to generate the list of screens to test in the smoke test.
2016-04-21 10:24:22 -07:00
Ian Hickson 112f2cc37b Reset _simulation at the end of a fling (#3435)
Also a bit of code cleanup.

The key part of this patch is the addition in `_endScroll` to reset
`_simulation`. It seems like this was the one place where it's possible
for us to end the animation but not reset our state. Since we assert
that are state is coherent, we were hitting asserts when a fling
finished and then you interacted with the widget again.
2016-04-20 11:02:20 -07:00
Hans Muller c4ae13ed22 Refresh indicator (#3354) 2016-04-15 18:39:18 -07:00
Yegor db2f66aab1 [test] make CommonFinders constructor private to disallow extensions (#3371) 2016-04-15 16:49:51 -07:00
Ian Hickson e41c1c0b06 Split services/ into services/ and foundation/ (#3350)
We're getting back to the point where we have a bunch of foundation APIs
and it's getting confusing having them mixed with services/.
2016-04-15 13:18:29 -07:00
Ian Hickson 0f1dee5f46 Always dump (unwanted) exceptions during tests (#3344)
...even if the test fails.
2016-04-15 09:38:04 -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