Commit 11de1a51 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Fix capitalization in gallery RegExp (#12035)

parent e2c6ba1b
......@@ -53,7 +53,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
_formWasEdited = true;
if (value.isEmpty)
return 'Name is required.';
final RegExp nameExp = new RegExp(r'^[A-za-z ]+$');
final RegExp nameExp = new RegExp(r'^[A-Za-z ]+$');
if (!nameExp.hasMatch(value))
return 'Please enter only alphabetical characters.';
return null;
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_gallery/demo/material/text_form_field_demo.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('validates name field correctly', (WidgetTester tester) async {
await tester.pumpWidget(new MaterialApp(home: const TextFormFieldDemo()));
final Finder submitButton = find.widgetWithText(RaisedButton, 'SUBMIT');
expect(submitButton, findsOneWidget);
final Finder nameField = find.widgetWithText(TextFormField, 'Name *');
expect(nameField, findsOneWidget);
await tester.enterText(nameField, '');
await tester.tap(submitButton);
await tester.pump();
expect(find.text('Name is required.'), findsOneWidget);
expect(find.text('Please enter only alphabetical characters.'), findsNothing);
await tester.enterText(nameField, '#');
await tester.tap(submitButton);
await tester.pump();
expect(find.text('Name is required.'), findsNothing);
expect(find.text('Please enter only alphabetical characters.'), findsOneWidget);
await tester.enterText(nameField, 'Jane Doe');
await tester.tap(submitButton);
await tester.pump();
expect(find.text('Name is required.'), findsNothing);
expect(find.text('Please enter only alphabetical characters.'), findsNothing);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment