Open bartekpacia opened 2 years ago
I can reproduce this issue.
Stable (3.3.1)
Master (3.4.0-19.0.pre.137)
Code sample: See repo provided here https://github.com/flutter/flutter/issues/111110#issue-1364920035
flutter doctor -v
(Stable)flutter doctor -v
(Master)FWIW, it also occurs on 2.10 and 3.0 (and possibly on the previous versions as well, though I didn't check.)
@jonahwilliams do you know if this workflow is expected to work?
cc @eliasyishak
do you know if this workflow is expected to work?
I'm not @jonahwilliams but I'll ask: why wouldn't it?
I think there are probably two parts to this:
Is the framework sending semantics? If neither the platform nor user code has asked for semantics to be enabled, nothing will be processed. This requires https://api.flutter.dev/flutter/flutter_test/WidgetController/ensureSemantics.html
Is the platform listening? If TalkBack or other accessibility services are not enabled, then it doesn't matter what we produce because all of this information is updated in accessibilityStateChanged listeners.
Yeah but when the app is run with flutter run
, the virtual view hierarchy exists, even when TalkBack is disabled. I'd expect this behavior to be the same when flutter drive
-ing.
Just as a side note, this is a big blocker for us in Patrol, a new Flutter testing framework. See https://github.com/leancodepl/patrol/issues/244 for more details.
@jonahwilliams @christopherfujino Sorry to ping you.
I see this got P4, which means it rather won't be fixed anytime soon. I'd greatly appreciate hearing some more details about this problem, so the person who'll be working to fix this in the future, be it a Googler or a Flutter community member, will have some info to start with:
flutter drive
? Or is this just an oversight?If there's nobody else to fix this, I'm gonna take up the glove.
Have you check if this caused by the any of the flutter_driver bindings taking over flutter run functionality?
err not flutter run
functionality, but the enableFlutterDriverExtension
function overrides some regular binding behavior.
By "flutter_driver bindings" do you mean IntegrationTestWidgetsFlutterBinding
?
If I had to bet, I'd put my cents that this problem is indeed caused by IntegrationTestWidgetsFlutterBinding
, because (afaik) it's the single biggest thing that differs between flutter run
and flutter drive
.
err not flutter run functionality, but the enableFlutterDriverExtension function overrides some regular binding behavior.
When is I think I found it – enableFlutterDriverExtension()
called when the developer does flutter drive <...>
?IntegrationTestWidgetsFlutterBinding.initServiceExtensions()
.
Anyway, thanks a lot, this is already some info to get started with.
TODO
Check if the problem occurs with flutter test integration_test
. I expect it to occur because the same IntegrationTestWidgetsFlutterBinding
is used.
I wonder if https://github.com/flutter/flutter/issues/106327 is a dupe of this, or the other way round.
Were you also able to find out which binding is causing the issue? It might be easier to validate if this is caused by a particular binding by taking flutter drive
out of the equation. For example, you could:
main.dart
, right at the top of main
to set up the binding of interestflutter run
adb shell uiautomator dump
and check the outputYou can repeat (1), for enableFlutterDriverExtension
(though this isn't used in integration tests), and IntegrationTestWidgetsFlutterBinding.ensureInitialized()
. I would also consider going up the class hierarchy and trying LiveTestWIdgetsFlutterBinding()
to try and isolate the particular binding, (and then the override) that causes the issue.
Somewhat orthogonally flutter test integration_test
should be used for running integration tests instead of flutter drive
unless you're targeting web.
Thanks for responding and suggestions. I tried the following:
WidgetsFlutterBinding.ensureInitialized()
(the default): good outputenableFlutterDriverExtension()
: good outputIntegrationTestWidgetsFlutterBinding.ensureInitialized()
: bad outputLiveTestWidgetsFlutterBinding.ensureInitialized()
: bad outputAutomatedTestWidgetsFlutterBinding
: couldn't get it to work, differs too muchFor (3), an assertion was triggered (assert(inTest)
), so I had to manually disable it in the binding's code.
Overall, it looks as if test bindings (3, 4) were missing the feature that is present in the default bindings (1).
Somewhat orthogonally flutter test integration_test should be used for running integration tests instead of flutter drive unless you're targeting web.
We'd really like to (at least for now, we're mobile-only), but unfortunately, it's currently a no-go for our testing framework because of the following problems:
Semantic info about Flutter's widgets is propagated down to the platform so that the platform knows about Flutter widgets and can use this information e.g for accessibility purposes. But during
flutter drive
this process doesn't happen.Steps to Reproduce
See that the native view hierarchy exists during
flutter run
Clone the https://github.com/bartekpacia/missing_a11y repository.
Run the app normally:
While the app is running, open a new terminal tab and dump native Android view hierarchy:
Copy the file containing the hierarchy dump from the Android device to your machine's
$PWD
:Inspect the XML file. It will contain information about the Flutter widgets. See the file here.
See that the native view hierarchy doesn't exist during
flutter drive
Clone the https://github.com/bartekpacia/missing_a11y repository.
Run the app with
flutter_driver
:While the app is running, open a new terminal tab and dump native Android view hierarchy:
Copy the file containing the hierarchy dump from the Android device to your machine's
$PWD
:Inspect the XML file. It contains very little information, e.g about
View
s in the status bar, but no data about Flutter widgets is in it. See the file here.Expected results
I'd expect the view hierarchy dump to be the same no matter if the app is started with
flutter run
orflutter drive
.Device details
I'm pretty sure it occurs on all Android versions, but I verified the above behavior on:
Additional, random context
flutter drive
and which needs access to the native view hierarchy, but this problem prevents me from doing so.flutter drive
. But this is an ugly and annoying workaround.