mirror of
https://github.com/flutter/flutter
synced 2024-10-02 14:34:22 +00:00
parent
c0b2645b8a
commit
bc0134d3d6
|
@ -32,6 +32,7 @@ class _MainWidget extends StatelessWidget {
|
|||
children: <Widget>[
|
||||
const TextField(
|
||||
key: Key('enabled text field'),
|
||||
maxLines: null,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Email',
|
||||
suffixText: '@gmail.com',
|
||||
|
@ -40,6 +41,7 @@ class _MainWidget extends StatelessWidget {
|
|||
),
|
||||
TextField(
|
||||
key: const Key('disabled text field'),
|
||||
maxLines: null,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
suffixText: '@gmail.com',
|
||||
|
|
|
@ -34,7 +34,6 @@ class _MainWidget extends StatelessWidget {
|
|||
key: Key('enabled password'),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password',
|
||||
hintText: 'Enter your password',
|
||||
),
|
||||
obscureText: true,
|
||||
),
|
||||
|
@ -42,7 +41,6 @@ class _MainWidget extends StatelessWidget {
|
|||
key: Key('disabled password'),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password',
|
||||
hintText: 'Enter your password',
|
||||
),
|
||||
enabled: false,
|
||||
obscureText: true,
|
||||
|
|
|
@ -30,4 +30,24 @@ void main() {
|
|||
expect(passwordField.enabled, isFalse);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('text field passwords do not have hint text', (WidgetTester tester) async {
|
||||
await pumpsUseCase(tester, TextFieldPasswordUseCase());
|
||||
expect(find.byType(TextField), findsExactly(2));
|
||||
|
||||
// Test the enabled password
|
||||
{
|
||||
final Finder finder = find.byKey(const Key('enabled password'));
|
||||
final TextField textField = tester.widget<TextField>(finder);
|
||||
expect(textField.decoration?.hintText, isNull);
|
||||
|
||||
}
|
||||
|
||||
// Test the disabled password
|
||||
{
|
||||
final Finder finder = find.byKey(const Key('disabled password'));
|
||||
final TextField textField = tester.widget<TextField>(finder);
|
||||
expect(textField.decoration?.hintText, isNull);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -30,4 +30,28 @@ void main() {
|
|||
expect(textField.enabled, isFalse);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('font size increase does not ellipsize hint text', (WidgetTester tester) async {
|
||||
await pumpsUseCase(tester, TextFieldUseCase());
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: MediaQuery.withClampedTextScaling(
|
||||
minScaleFactor: 3,
|
||||
maxScaleFactor: 3,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return TextFieldUseCase().build(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
));
|
||||
// Test the enabled text field
|
||||
{
|
||||
final Finder finder = find.byKey(const Key('enabled text field'));
|
||||
await tester.tap(finder);
|
||||
await tester.pumpAndSettle();
|
||||
final Size size = tester.getSize(finder);
|
||||
// Should have a multi-line height.
|
||||
expect(size.height, 280);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue