This adds the ability to define variants of tests with different environmental values for a particular testWidgets test.
This allows you to run the same test multiple times with a different test environment. One test variant has been implemented that allows running a test with different settings of the TargetPlatform.
This PR rewrites MouseTracker's lifecycle, so that mouse callbacks are all triggered in post frame, instead of the current one where some are triggered during the build phase. This PR also changes the onExit callback to MouseRegion, RenderMouseRegion, and MouseTrackerAnnotation, so that it is no longer triggered on dispose.
* 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
Currently, we listen to keyboard events to find out which keys should be represented in RawKeyboard.instance.keysPressed, but that's not sufficient to represent the physical state of the keys, since modifier keys could have been pressed when the overall app did not have keyboard focus (especially on desktop platforms).
This PR synchronizes the list of modifier keys in keysPressed with the modifier key flags that are present in the raw key event so that they can be relied upon to represent the current state of the keyboard. When synchronizing these states, we don't send any new key events, since they didn't happen when the app had keyboard focus, but if you ask "is this key down", we'll give the right answer
* Adding handling of TextInputClient.onConnectionClosed messages handling to Framework
* Adding more test cases for closing connection to editable_text_test
* fixing analyze error.
* Fixing analyze error in the test file
* Fixing comments on the new method
* Adding more closing connection examples.
* Indentation change
* Remove auto-add white space
* Changing the oncloseconnection behaviour to stop editing. Updating the tests
* Addressing PR comments. Added explicit log for method channnels to the tests. Added comments to the interfaces.
* add more documentation
This fixes https://github.com/flutter/flutter/issues/39277
The following tests cover this change:
- packages/flutter/test/foundation/service_extensions_test.dart
- packages/flutter/test/scheduler/scheduler_test.dart
* Add structured errors in Animations, TabView, ChangeNotifier
* Add structured error on MaterialPageRoute, BoxBorder, DecorationImagePainter, TextSpan
* Add structured errors in Debug
* Fix test errors
* Add structured errors in Scaffold and Stepper
* Add structured errors in part of Rendering Layer
* Fix failing test due to FloatingPoint precision
* Fix failing tests due to precision error and not using final
* Fix failing test due to floating precision error with RegEx instead
* Add structured error in CustomLayout and increase test coverage
* Add structured error & its test in ListBody
* Add structured error in ProxyBox and increase test coverage
* Add structured error message in Viewport
* Fix styles and add more assertions on ErrorHint and DiagnosticProperty
* Add structured error in scheduler/binding and scheduler/ticker
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add structured error in AssetBundle and TextInput
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add structured errors in several widgets #1
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Remove unused import
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add assertions on hint messages
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Fix catch spacing
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add structured error in several widgets part 2 and increase code coverage
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Add structured error in flutter_test/widget_tester
* Fix floating precision accuracy by using RegExp
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Remove todo to add tests in Scaffold showBottomSheet
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Fix reviews by indenting lines and fixing the assertion orders
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Fix failing tests due to renaming class
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Try skipping the NetworkBundleTest
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
* Remove leading space in material/debug error hint
Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
This fixes the mouse hover code to not schedule frames with every mouse move.
Before this, it would schedule a post frame callback, and then schedule a frame immediately, even if there was nothing that needed to be updated. Now it will schedule checks for mouse position updates synchronously, unless there's a new annotation, and skip scheduling a new frame in all cases. It has to be async in the case of a new annotation (i.e. a new MouseRegion is added), since when the annotation is added, it hasn't yet painted, and it can't hit test against the new layer until after the paint, so in that case it schedules a post frame callback, but since it's already building a frame when it does that, it doesn't need to schedule a frame.
The code also used to do mouse position checks for all mice if only one mouse changed position. I fixed this part too, so that it will only check position for the mouse that changed.
There were four or five different implementations in various tests for sendFakeKeyEvent, which roughly all did the same thing. I was going to add yet another one, and decided that it needed to be generalized and centralized. This replaces those instances with something that just takes a LogicalKeyboardKey so that it's self-documenting, and can be used with multiple platforms.
This adds two functions to widget tester: sendKeyDownEvent and sendKeyUpEvent which simulate key up/down from a physical keyboard. It also adds global functions simulateKeyDownEvent and simulateKeyUpEvent that can be called without a widget tester. All are async functions protected by the async guard.
* Fixing LocalFileComparator output
* Fixing path separators for windows failures
* Windows path issues
* Testing
* ++
* ++
* Fixing base directory - windows
* Clean up
* Minor improvements to framework documentation.
* maybePop documentation fix
* Mark some flutter_test arguments required.
Without these set, we get a crash.
* Minor correction to ListView docs
* WIP on web plugin registry
* WIP on registering plugins
* WIP on web plugin registration
* Only generate `package:flutter_web_plugins` imports if plugins are
defined
* Add parsing test
* Add documentation
* Fix analyzer warnings
* add license headers
* Add tests for package:flutter_web_plugins
* Run `flutter update-packages --force-upgrade`
* Fix analyzer errors
* Fix analyzer error in test
* Update copyright and remove flutter SDK constraints
* Enable tests since engine has rolled
* add flutter_web_plugins tests to bots
* Create an empty .packages file for WebFs test
* Moved the default BinaryMessenger instance to ServicesBinding
This reverts commit 821602aef3.
* Added assertion in defaultBinaryMessenger. Also fixed the devicelab tests.
Flutter widget tests assert if a test completes with timers still
pending. However, it can be hard to diagnose where a pending timer
came from. For example, a widget might consume a third-party library
that internally uses a timer.
I added a FakeAsync.pendingTimersDebugInfo getter to quiver
(https://github.com/google/quiver-dart/pull/500). Make flutter_test
use it.
Additionally modify Flutter's debugPrintStack to take an optional
StackTrace argument instead of always printing StackTrace.current.
Fixes#4237.
Teach Layer and its implementations, RenderObject and its implementations, and PaintingContext to reuse engine layers. The idea is that a concrete RenderObject creates a Layer and holds on to it as long as it needs it (i.e. when it is composited, and the layer type does not change). In return, each Layer object holds on to an EngineLayer and reports it to the engine via addRetained and oldLayer. This allows the Web engine to reuse DOM elements across frames. Without it, each frame drops all previously rendered HTML and regenerates it from scratch.
* Broadcasting popRoute and pushRoute methods via SystemChannels.navigation. These messages will be used in flutter_web to detect the route
* Broadcasting popRoute and pushRoute methods via SystemChannels.navigation. These messages will be used in flutter_web to detect the route
* Reverting all unrelated formatting changes.
* Adding unit tests. Adding more comments.
* Changing string method names with constant strings.
* Fixing a constant strings.
* Fixing analyzer error.
* Fixing more white space.
* Changing the method names. Adding comments to the SystemChannels
* Comment and code name fixes
* replacing the comment with reviewer suggestion.
* addinf systemchannels.navigation mock to test bindings
* Adding a new class for sending route change notrifications. The nottifications are only sent on web. This should fix breaking android/ios
* using new class RouteNotificationMessages in navigator
* Fixing analyzer issues.
* fixing cycle dependency
* fixing github analyze error
* dartfmt two new classes. trying to fix anayze errors
* Update route_notification_messages.dart
* trying to fix white space errors
This reverts commit 92ef2b9ce1.
This requires either runApp() or
WidgetsFlutterBinding.ensureInitialized() to have been called before
using any MethodChannels. Plugins broadly rely on MethodChannels and
right now there's no general requirements that they be constructed
within the runApp call, so the ecosystem breakages from this are broader
than originally thought. Reverting for now.
* Make it possible to override the FLUTTER_TEST env variable without unsetting it.
* Switch to using platform instead of Platform.
* Document the bindings, and introduce tests that initialize multiple WidgetsBindings with different environments.
* Add tests for the flutter platform test.
* Add license headers
* Fix lints
* Remove trailing whitespace
* Respond to Jonahs comments
* Respond to Ians comments
* Mock out the HttpServer in flutter_platform_test
* Mock out the HttpServer in flutter_platform_test
* Explain why we mock out the HttpServer in flutter_platform_test
* Prepare for HttpClientResponse Uint8List SDK change
An upcoming change in the Dart SDK will change `HttpClientResponse`
from implementing `Stream<List<int>>` to instead implement
`Stream<Uint8List>`.
This forwards-compatible change to `_MockHttpClientResponse` is being
made to allow for a smooth rollout of that SDK breaking change. The
current structure of the class is as follows:
```dart
_MockHttpClientResponse extends Stream<List<int>> implements HttpClientResponse {
...
}
```
This structure would require that the Dart SDK change land atomically
a change to the class (`extends Stream<Uint8List>`). This atomic landing
requirement doesn't play well at all with Flutter's roll model vis-a-vis
the Dart SDK's roll model to Google's internal repo. As such, this commit
changes the structure of `_MockHttpClientResponse` to be:
```dart
_MockHttpClientResponse implements HttpClientResponse {
final Stream<Uint8List> _delegate;
...
}
```
Once the Dart SDK change has fully rolled out, we can simplify this class
back to its former structure.
https://github.com/dart-lang/sdk/issues/36900
* Review comment
# Description
Currently the benchmarks test prints a scary warning message, even when it passes, that a benchmark is being run with asserts enabled.
Normally we don't want developers to do this, because the performance of code with asserts is not characteristic of what end-users will experience. However, we need to unit-test benchmarkWidgets, so I've added a contraindicated option to suppress the warning for the test.
# Related Issues
25049 (comment)
This PR solves two problems: currently, the onExit is called for a mouse pointer the moment the removal message is received, except that by the time it actually calls it, there is no _lastEvent for it in the mouse tracker (it's already been removed), resulting in an event being passed to the onExit that contains nulls for the position. Also, removePointer events don't actually get created with a position, although they easily could be, so that even the the _lastEvent in the mouse tracker were still populated, it would still give a null position and delta.
This PR adds support for the position and delta in a PointerRemovedEvent, and populates them. In addition, when a remove event is received, it doesn't actually remove the pointer until the mouse position check that gets scheduled actually happens.
* Deprecates `BinaryMessages` in favor of a default instance of `BinaryMessenger`, called `defaultBinaryMessenger`
* Platform channels use the `defaultBinaryMessenger` for their binaryMessenger default argument.
* Clean up some flutter_tools tests
* Remove arbitrary retry that happens even for fundamental errors, and generally clean up _DevFSHttpWriter.
* Update dependencies (requires fixes; see next commit)
* Fixes for new dependencies.
This fixes#32525, because it now marks the compositing bits as needing to be recalculated if the mouse tracker changes its idea of whether or not a mouse is attached.
This bug occurred because the test framework was leaking state from one test to the next (the state about whether a mouse pointer was active), and so even though there was a "passing" test when run in order with the other tests in the file, when the test was run individually (or first), it would have failed and caught the bug.
This adds an assert to make sure that after each test there are no simulated mouse pointers connected, and now calls removePointer in all of the tests where this was a problem.
Instead of using a custom WidgetController, which is very brittle, we just use the usual infrastructure.
Also, use structured data instead of an array.
This adds offsetMoreOrLessEquals to handle small floating point errors in offsets.
This is a re-land of #31561, after fixing performance regressions.
Added change listening to the MouseTracker so that the Listener and tooltip can react to whether or not a mouse is connected at all. Added a change check to make sure Listener only repaints when something changed.
Fixes#22817
* Revert "Revert "Add buttons to gestures (#30339)" (#31801)"
This reverts commit 8fd7fa492a.
* Synthesise kPrimaryButton for unknown devices
* Change TestPointer to a better API
* Callbacks of tap, long press, drag, and double tap GR respond to only primary events.
* Add "secondary" callbacks to tap.
* Recognizers only compete on events if there are any related callbacks.
* Add "kSecondaryButton" constant.
This re-lands the Focus changes in #30040. Correctness changes in routes.dart, and removes the automatic requesting of focus on reparent when there is no current focus, which caused undesirable selections.
Addresses #11344, #1608, #13264, and #1678Fixes#30084Fixes#26704
Implements focus traversal for desktop platforms, including re-implementing the existing focus manager and focus tree.
This implements a Focus widget that can be put into a widget tree to allow input focus to be given to a particular part of a widget tree.
It incorporates with the existing FocusScope and FocusNode infrastructure, and has minimal breakage to the API, although FocusScope.reparentIfNeeded is removed, replaced by a call to FocusAttachment.reparent(), so this is a breaking change:
FocusScopeNodes must now be attached to the focus tree using FocusScopeNode.attach, which takes a context and an optional onKey callback, and returns a FocusAttachment that should be kept by the widget that hosts the FocusScopeNode. This is necessary because of the need to make sure that the focus tree reflects the widget hierarchy.
Callers that used to call FocusScope(context).reparentIfNeeded in their build method will call reparent on a FocusAttachment instead, which they will obtain by calling FocusScopeNode.attach in their initState method. Widgets that own FocusNodes will need to call dispose on the focus node in their dispose method.
Addresses #11344, #1608, #13264, and #1678Fixes#30084Fixes#26704
* some space formattings
* always use blocks in if-else if a block is used
* format spaces in for and while
* allow multiline if conditions
* fix missing space
Adds support for discrete scroll events, such as those sent by a scroll wheel.
Includes the plumbing to convert, dispatch, and handle these events, as well as
Scrollable support for consuming them.
* add trailing commas on list/map/parameters
* add trailing commas on Invocation with nb of arg>1
* add commas for widget containing widgets
* add trailing commas if instantiation contains trailing comma
* revert bad change
* Breaking change which sets the default DragStartBehavior to DragStartBehavior.start and changes WidgetTester.drag and WidgetTester.dragFrom by breaking the moveBy function call into multiple pieces.