-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Widget test] Tapping DropdownMenuItem fails hit test #82908
Comments
@Tregan |
@darshankawar This is included in the flutter_test package (Flutter 2.2.0) and makes it so that any hit test failures during tests fail the test, instead of just printing the warning. |
Ah. Thanks. I was on 2.0.6 on which it gives that error. Running the test fails with below log: console error log
flutter doctor -v
|
I have a lot of false positives for hit test failures after 2.2.0 upgrade, in Dropdowns, in Dialogs and in TextInputs. |
This is still the case in Flutter 2.5.0 (stable) as well as master (2.6.0), even after these fixes: #80856 #86449 Logs
flutter doctor -v
|
Trying to hit the text of options in a PopupMenuButton also gets flagged with the warnIfMissed warning sometimes. |
It's weird, this isn't always reliably a problem. For example, the first case below passes, but the second fails: import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
WidgetController.hitTestWarningShouldBeFatal = true;
testWidgets('Clicking DropdownMenuItem should not fail', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Center(
child: Material(
child: DropdownButton<int>(
key: Key('button'),
onChanged: (int? result) { },
items: <DropdownMenuItem<int>>[
const DropdownMenuItem<int>(
key: Key('item'),
value: 1,
child: Text('111111111111111111'),
),
],
),
),
),
));
await tester.tap(find.byKey(Key('button')));
await tester.pump();
await tester.pump(const Duration(seconds: 1));
await tester.tap(find.byKey(Key('item')).at(1));
});
testWidgets('Clicking DropdownMenuItem should not fail', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Center(
child: Material(
child: DropdownButton<int>(
onChanged: (int? value) { },
key: Key('button'),
items: <DropdownMenuItem<int>>[
DropdownMenuItem(
key: Key('item'),
value: 1,
child: Text('1'),
),
],
),
),
),
),
);
await tester.tap(find.byKey(Key('button')));
await tester.pump();
await tester.pump(const Duration(seconds: 1));
await tester.tap(find.byKey(Key('item')).at(1));
});
} (I believe the only difference is the length of the text.) |
Still seeing this, and yes, it seems like the length of the text matters. In my test case it failed with the text 'Foo' but passed with 'FooFoo'. |
I decided to check this again, and the issue seems to have been fixed.
|
Steps to Reproduce
widget_test.dart
toExpected results:
The test is expected to succeed without any warnings or errors being thrown around
Actual results:
The test fails because the hit test for the line
await tester.tap(find.byKey(Key('2')));
fails.Logs
The text was updated successfully, but these errors were encountered: