Unverified Commit a195bcc0 authored by Abhishek Ghaskata's avatar Abhishek Ghaskata Committed by GitHub

Migrate dev/integration_tests/ui to null safety (#80624)

parent 0379dcd0
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig" #include "Generated.xcconfig"
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig" #include "Generated.xcconfig"
...@@ -11,14 +11,14 @@ void main() { ...@@ -11,14 +11,14 @@ void main() {
} }
class Test extends SingleChildRenderObjectWidget { class Test extends SingleChildRenderObjectWidget {
const Test({ Key key }) : super(key: key); const Test({ Key? key }) : super(key: key);
@override @override
RenderTest createRenderObject(BuildContext context) => RenderTest(); RenderTest createRenderObject(BuildContext context) => RenderTest();
} }
class RenderTest extends RenderProxyBox { class RenderTest extends RenderProxyBox {
RenderTest({ RenderBox child }) : super(child); RenderTest({ RenderBox? child }) : super(child);
@override @override
void debugPaintSize(PaintingContext context, Offset offset) { void debugPaintSize(PaintingContext context, Offset offset) {
......
...@@ -11,7 +11,7 @@ void main() { ...@@ -11,7 +11,7 @@ void main() {
} }
class DriverTestApp extends StatefulWidget { class DriverTestApp extends StatefulWidget {
const DriverTestApp({Key key}) : super(key: key); const DriverTestApp({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
...@@ -59,9 +59,9 @@ class DriverTestAppState extends State<DriverTestApp> { ...@@ -59,9 +59,9 @@ class DriverTestAppState extends State<DriverTestApp> {
DropdownButton<Letter>( DropdownButton<Letter>(
key: const ValueKey<String>('dropdown'), key: const ValueKey<String>('dropdown'),
value: _selectedValue, value: _selectedValue,
onChanged: (Letter newValue) { onChanged: (Letter? newValue) {
setState(() { setState(() {
_selectedValue = newValue; _selectedValue = newValue!;
}); });
}, },
items: const <DropdownMenuItem<Letter>>[ items: const <DropdownMenuItem<Letter>>[
......
...@@ -12,7 +12,7 @@ void main() { ...@@ -12,7 +12,7 @@ void main() {
} }
class Empty extends StatelessWidget { class Empty extends StatelessWidget {
const Empty({Key key}) : super(key: key); const Empty({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) => Container(); Widget build(BuildContext context) => Container();
......
...@@ -8,7 +8,7 @@ import 'package:flutter_driver/driver_extension.dart'; ...@@ -8,7 +8,7 @@ import 'package:flutter_driver/driver_extension.dart';
import 'keys.dart' as keys; import 'keys.dart' as keys;
void main() { void main() {
enableFlutterDriverExtension(handler: (String message) async { enableFlutterDriverExtension(handler: (String? message) async {
// TODO(cbernaschina): remove when test flakiness is resolved // TODO(cbernaschina): remove when test flakiness is resolved
return 'keyboard_resize'; return 'keyboard_resize';
}); });
...@@ -16,7 +16,7 @@ void main() { ...@@ -16,7 +16,7 @@ void main() {
} }
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) {
...@@ -29,7 +29,7 @@ class MyApp extends StatelessWidget { ...@@ -29,7 +29,7 @@ class MyApp extends StatelessWidget {
} }
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
const MyHomePage({Key key}) : super(key: key); const MyHomePage({Key? key}) : super(key: key);
@override @override
_MyHomePageState createState() => _MyHomePageState(); _MyHomePageState createState() => _MyHomePageState();
...@@ -60,7 +60,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -60,7 +60,7 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
key: const Key(keys.kUnfocusButton), key: const Key(keys.kUnfocusButton),
onPressed: () { textField.focusNode.unfocus(); }, onPressed: () { textField.focusNode!.unfocus(); },
tooltip: 'Unfocus', tooltip: 'Unfocus',
child: const Icon(Icons.done), child: const Icon(Icons.done),
), ),
......
...@@ -14,7 +14,7 @@ void main() { ...@@ -14,7 +14,7 @@ void main() {
} }
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) {
...@@ -27,7 +27,7 @@ class MyApp extends StatelessWidget { ...@@ -27,7 +27,7 @@ class MyApp extends StatelessWidget {
} }
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
const MyHomePage({Key key}) : super(key: key); const MyHomePage({Key? key}) : super(key: key);
@override @override
_MyHomePageState createState() => _MyHomePageState(); _MyHomePageState createState() => _MyHomePageState();
......
...@@ -14,13 +14,13 @@ void main() { ...@@ -14,13 +14,13 @@ void main() {
} }
class ShowLicenses extends StatelessWidget { class ShowLicenses extends StatelessWidget {
const ShowLicenses({Key key}) : super(key: key); const ShowLicenses({Key? key}) : super(key: key);
Widget _buildTestResultWidget( Widget _buildTestResultWidget(
BuildContext context, BuildContext context,
AsyncSnapshot<List<LicenseEntry>> snapshot, AsyncSnapshot<List<LicenseEntry>> snapshot,
) { ) {
final List<LicenseEntry> entries = snapshot.data; final List<LicenseEntry> entries = snapshot.data ?? <LicenseEntry>[];
String flutterPackage = ''; String flutterPackage = '';
final List<String> flutterParagraphs = <String>[]; final List<String> flutterParagraphs = <String>[];
String enginePackage = ''; String enginePackage = '';
...@@ -41,17 +41,15 @@ class ShowLicenses extends StatelessWidget { ...@@ -41,17 +41,15 @@ class ShowLicenses extends StatelessWidget {
} }
final List<Widget> result = <Widget>[]; final List<Widget> result = <Widget>[];
if (entries.isNotEmpty) { result.addAll(<Widget>[
result.addAll(<Widget>[ const Text('License Check Test', key: ValueKey<String>('Header')),
const Text('License Check Test', key: ValueKey<String>('Header')), Text(flutterPackage, key: const ValueKey<String>('FlutterPackage')),
Text(flutterPackage, key: const ValueKey<String>('FlutterPackage')), Text(flutterParagraphs.join(' '), key: const ValueKey<String>('FlutterLicense')),
Text(flutterParagraphs.join(' '), key: const ValueKey<String>('FlutterLicense')), Text('${flutterParagraphs.length}', key: const ValueKey<String>('FlutterCount')),
Text('${flutterParagraphs.length}', key: const ValueKey<String>('FlutterCount')), Text(enginePackage, key: const ValueKey<String>('EnginePackage')),
Text(enginePackage, key: const ValueKey<String>('EnginePackage')), Text(engineParagraphs.join(' '), key: const ValueKey<String>('EngineLicense')),
Text(engineParagraphs.join(' '), key: const ValueKey<String>('EngineLicense')), Text('${engineParagraphs.length}', key: const ValueKey<String>('EngineCount')),
Text('${engineParagraphs.length}', key: const ValueKey<String>('EngineCount')), ]);
]);
}
return ListView( return ListView(
children: result, children: result,
......
...@@ -18,9 +18,9 @@ void main() { ...@@ -18,9 +18,9 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
), ),
onPressed: () { onPressed: () {
Navigator.push<Object>( Navigator.push<Object?>(
context, context,
MaterialPageRoute<dynamic>( MaterialPageRoute<Object?>(
builder: (BuildContext context) { builder: (BuildContext context) {
return const Material( return const Material(
child: Center( child: Center(
......
...@@ -9,7 +9,7 @@ void main() { ...@@ -9,7 +9,7 @@ void main() {
} }
class Test extends StatefulWidget { class Test extends StatefulWidget {
const Test({ Key key }) : super(key: key); const Test({ Key? key }) : super(key: key);
@override @override
State<Test> createState() => _TestState(); State<Test> createState() => _TestState();
......
...@@ -9,7 +9,7 @@ import 'package:flutter_driver/driver_extension.dart'; ...@@ -9,7 +9,7 @@ import 'package:flutter_driver/driver_extension.dart';
// To use this test: "flutter drive --route '/smuggle-it' lib/route.dart" // To use this test: "flutter drive --route '/smuggle-it' lib/route.dart"
void main() { void main() {
enableFlutterDriverExtension(handler: (String message) async { enableFlutterDriverExtension(handler: (String? message) async {
return ui.window.defaultRouteName; return ui.window.defaultRouteName;
}); });
} }
...@@ -16,7 +16,7 @@ void main() { ...@@ -16,7 +16,7 @@ void main() {
} }
class Toggler extends StatefulWidget { class Toggler extends StatefulWidget {
const Toggler({Key key}) : super(key: key); const Toggler({Key? key}) : super(key: key);
@override @override
State<Toggler> createState() => TogglerState(); State<Toggler> createState() => TogglerState();
......
...@@ -2,7 +2,7 @@ name: integration_ui ...@@ -2,7 +2,7 @@ name: integration_ui
description: Flutter non-plugin UI integration tests. description: Flutter non-plugin UI integration tests.
environment: environment:
sdk: ">=2.8.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"
# The "image" dependency below seems to only be needed for test_driver/screenshot_test.dart # The "image" dependency below seems to only be needed for test_driver/screenshot_test.dart
# It can probably be removed, see the comment in that file. # It can probably be removed, see the comment in that file.
......
...@@ -6,14 +6,14 @@ import 'package:flutter_driver/flutter_driver.dart'; ...@@ -6,14 +6,14 @@ import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
}); });
tearDownAll(() async { tearDownAll(() async {
await driver?.close(); await driver.close();
}); });
test('check that we are painting in debugPaintSize mode', () async { test('check that we are painting in debugPaintSize mode', () async {
......
...@@ -6,14 +6,14 @@ import 'package:flutter_driver/flutter_driver.dart'; ...@@ -6,14 +6,14 @@ import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
}); });
tearDownAll(() async { tearDownAll(() async {
await driver?.close(); await driver.close();
}); });
test('check that we are in normal mode', () async { test('check that we are in normal mode', () async {
......
...@@ -6,14 +6,14 @@ import 'package:flutter_driver/flutter_driver.dart'; ...@@ -6,14 +6,14 @@ import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
}); });
tearDownAll(() async { tearDownAll(() async {
await driver?.close(); await driver.close();
}); });
test('check that we are showing the performance overlay', () async { test('check that we are showing the performance overlay', () async {
......
...@@ -6,7 +6,7 @@ import 'package:flutter_driver/flutter_driver.dart'; ...@@ -6,7 +6,7 @@ import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
......
...@@ -11,7 +11,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; ...@@ -11,7 +11,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
group('FlutterDriver', () { group('FlutterDriver', () {
final SerializableFinder presentText = find.text('present'); final SerializableFinder presentText = find.text('present');
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
......
...@@ -8,7 +8,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; ...@@ -8,7 +8,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
// Connect and disconnect from the empty app. // Connect and disconnect from the empty app.
void main() { void main() {
group('FlutterDriver', () { group('FlutterDriver', () {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
......
...@@ -8,14 +8,14 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; ...@@ -8,14 +8,14 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
group('end-to-end test', () { group('end-to-end test', () {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
}); });
tearDownAll(() async { tearDownAll(() async {
await driver?.close(); await driver.close();
}); });
test('Ensure keyboard dismissal resizes the view to original size', () async { test('Ensure keyboard dismissal resizes the view to original size', () async {
......
...@@ -8,14 +8,14 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; ...@@ -8,14 +8,14 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
group('end-to-end test', () { group('end-to-end test', () {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
}); });
tearDownAll(() async { tearDownAll(() async {
await driver?.close(); await driver.close();
}); });
test('Textfield scrolls back into view after covered by keyboard', () async { test('Textfield scrolls back into view after covered by keyboard', () async {
......
...@@ -20,7 +20,7 @@ void main() { ...@@ -20,7 +20,7 @@ void main() {
final String license = licenseFile.readAsStringSync().split(newlineSplit).join(' ').trim(); final String license = licenseFile.readAsStringSync().split(newlineSplit).join(' ').trim();
group('License file check', () { group('License file check', () {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
...@@ -28,9 +28,7 @@ void main() { ...@@ -28,9 +28,7 @@ void main() {
}); });
tearDownAll(() async { tearDownAll(() async {
if (driver != null) { await driver.close();
await driver.close();
}
}); });
test('flutter license', () async { test('flutter license', () async {
......
...@@ -8,14 +8,14 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; ...@@ -8,14 +8,14 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
group('flutter run test --route', () { group('flutter run test --route', () {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
}); });
tearDownAll(() async { tearDownAll(() async {
await driver?.close(); await driver.close();
}); });
test('sanity check flutter drive --route', () async { test('sanity check flutter drive --route', () async {
......
...@@ -15,7 +15,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; ...@@ -15,7 +15,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
group('FlutterDriver', () { group('FlutterDriver', () {
FlutterDriver driver; late FlutterDriver driver;
setUpAll(() async { setUpAll(() async {
driver = await FlutterDriver.connect(); driver = await FlutterDriver.connect();
...@@ -32,18 +32,18 @@ void main() { ...@@ -32,18 +32,18 @@ void main() {
await driver.waitFor(toggleBtn); await driver.waitFor(toggleBtn);
bool cardsShouldBeVisible = false; bool cardsShouldBeVisible = false;
Image imageBefore = decodePng(await driver.screenshot()); Image? imageBefore = decodePng(await driver.screenshot());
for (int i = 0; i < 10; i += 1) { for (int i = 0; i < 10; i += 1) {
await driver.tap(toggleBtn); await driver.tap(toggleBtn);
cardsShouldBeVisible = !cardsShouldBeVisible; cardsShouldBeVisible = !cardsShouldBeVisible;
final Image imageAfter = decodePng(await driver.screenshot()); final Image? imageAfter = decodePng(await driver.screenshot());
if (cardsShouldBeVisible) { if (cardsShouldBeVisible) {
expect(imageBefore.data, isNot(cardsAreVisible)); expect(imageBefore?.data, isNot(cardsAreVisible));
expect(imageAfter.data, cardsAreVisible); expect(imageAfter?.data, cardsAreVisible);
} else { } else {
expect(imageBefore.data, cardsAreVisible); expect(imageBefore?.data, cardsAreVisible);
expect(imageAfter.data, isNot(cardsAreVisible)); expect(imageAfter?.data, isNot(cardsAreVisible));
} }
imageBefore = imageAfter; imageBefore = imageAfter;
......
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