mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Migrate web_e2e_tests to null safety (#80628)
This commit is contained in:
parent
fe57037ad7
commit
5d37df13f9
@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
|
|||||||
void main() => runApp(const MyApp());
|
void main() => runApp(const MyApp());
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({Key key}) : super(key: key);
|
const MyApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -20,9 +20,9 @@ class MyApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
const MyHomePage({Key key, this.title}) : super(key: key);
|
const MyHomePage({Key? key, this.title}) : super(key: key);
|
||||||
|
|
||||||
final String title;
|
final String? title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MyHomePageState createState() => _MyHomePageState();
|
_MyHomePageState createState() => _MyHomePageState();
|
||||||
@ -44,7 +44,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(widget.title),
|
title: Text(widget.title ?? ''),
|
||||||
),
|
),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -2,7 +2,7 @@ name: web_e2e_tests
|
|||||||
publish_to: none
|
publish_to: none
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.2.2 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.9
|
|
||||||
import 'dart:html';
|
import 'dart:html';
|
||||||
import 'dart:js_util' as js_util;
|
import 'dart:js_util' as js_util;
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ void main() {
|
|||||||
|
|
||||||
// Change the value of the TextFormField.
|
// Change the value of the TextFormField.
|
||||||
final TextFormField textFormField = tester.widget(finder);
|
final TextFormField textFormField = tester.widget(finder);
|
||||||
textFormField.controller.text = 'New Value';
|
textFormField.controller?.text = 'New Value';
|
||||||
// DOM element's value also changes.
|
// DOM element's value also changes.
|
||||||
expect(input.value, 'New Value');
|
expect(input.value, 'New Value');
|
||||||
});
|
});
|
||||||
@ -67,7 +66,7 @@ void main() {
|
|||||||
|
|
||||||
// Change the value of the TextFormField.
|
// Change the value of the TextFormField.
|
||||||
final TextFormField textFormField = tester.widget(finder);
|
final TextFormField textFormField = tester.widget(finder);
|
||||||
textFormField.controller.text = 'New Value';
|
textFormField.controller?.text = 'New Value';
|
||||||
// DOM element's value also changes.
|
// DOM element's value also changes.
|
||||||
expect(input.value, 'New Value');
|
expect(input.value, 'New Value');
|
||||||
});
|
});
|
||||||
@ -225,8 +224,8 @@ void main() {
|
|||||||
expect(input.hasAttribute('readonly'), isTrue);
|
expect(input.hasAttribute('readonly'), isTrue);
|
||||||
|
|
||||||
// Make sure the entire text is selected.
|
// Make sure the entire text is selected.
|
||||||
TextRange range =
|
TextRange? range =
|
||||||
TextRange(start: input.selectionStart, end: input.selectionEnd);
|
TextRange(start: input.selectionStart!, end: input.selectionEnd!);
|
||||||
expect(range.textInside(text), text);
|
expect(range.textInside(text), text);
|
||||||
|
|
||||||
// Double tap to select the first word.
|
// Double tap to select the first word.
|
||||||
@ -239,7 +238,7 @@ void main() {
|
|||||||
await gesture.up();
|
await gesture.up();
|
||||||
await gesture.down(firstWordOffset);
|
await gesture.down(firstWordOffset);
|
||||||
await gesture.up();
|
await gesture.up();
|
||||||
range = TextRange(start: input.selectionStart, end: input.selectionEnd);
|
range = TextRange(start: input.selectionStart!, end: input.selectionEnd!);
|
||||||
expect(range.textInside(text), 'Lorem');
|
expect(range.textInside(text), 'Lorem');
|
||||||
|
|
||||||
// Double tap to select the last word.
|
// Double tap to select the last word.
|
||||||
@ -252,14 +251,14 @@ void main() {
|
|||||||
await gesture.up();
|
await gesture.up();
|
||||||
await gesture.down(lastWordOffset);
|
await gesture.down(lastWordOffset);
|
||||||
await gesture.up();
|
await gesture.up();
|
||||||
range = TextRange(start: input.selectionStart, end: input.selectionEnd);
|
range = TextRange(start: input.selectionStart!, end: input.selectionEnd!);
|
||||||
expect(range.textInside(text), 'amet');
|
expect(range.textInside(text), 'amet');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardEvent dispatchKeyboardEvent(
|
KeyboardEvent dispatchKeyboardEvent(
|
||||||
EventTarget target, String type, Map<String, dynamic> args) {
|
EventTarget target, String type, Map<String, dynamic> args) {
|
||||||
final dynamic jsKeyboardEvent = js_util.getProperty(window, 'KeyboardEvent');
|
final Object jsKeyboardEvent = js_util.getProperty(window, 'KeyboardEvent') as Object;
|
||||||
final List<dynamic> eventArgs = <dynamic>[
|
final List<dynamic> eventArgs = <dynamic>[
|
||||||
type,
|
type,
|
||||||
args,
|
args,
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.9
|
|
||||||
import 'package:integration_test/integration_test_driver.dart' as test;
|
import 'package:integration_test/integration_test_driver.dart' as test;
|
||||||
|
|
||||||
Future<void> main() async => test.integrationDriver();
|
Future<void> main() async => test.integrationDriver();
|
||||||
|
Loading…
Reference in New Issue
Block a user