Skip to content

Commit a864de2

Browse files
stuartmorgan-gChris Yang
and
Chris Yang
authored
Move integration test to null safety for multiple plugins (flutter#3932)
Cherry-picks flutter#3646 from the NNBD integration test branch, and updates it for changes on master. Co-authored-by: Chris Yang <[email protected]>
1 parent bca7c9f commit a864de2

File tree

24 files changed

+25
-88
lines changed

24 files changed

+25
-88
lines changed

packages/connectivity/connectivity/example/integration_test/connectivity_test.dart

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// TODO(cyanglaz): Remove once https://github.com/flutter/plugins/pull/3158 is landed.
6-
// @dart = 2.9
7-
85
import 'package:integration_test/integration_test.dart';
96
import 'package:flutter_test/flutter_test.dart';
107
import 'package:connectivity/connectivity.dart';
@@ -13,7 +10,7 @@ void main() {
1310
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1411

1512
group('Connectivity test driver', () {
16-
Connectivity _connectivity;
13+
late Connectivity _connectivity;
1714

1815
setUpAll(() async {
1916
_connectivity = Connectivity();

packages/connectivity/connectivity/example/test_driver/integration_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:integration_test/integration_test_driver.dart';
86

97
Future<void> main() => integrationDriver();

packages/connectivity/connectivity/pubspec.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ dev_dependencies:
3030
sdk: flutter
3131
flutter_driver:
3232
sdk: flutter
33-
test: ^1.16.3
34-
integration_test:
35-
sdk: flutter
3633
plugin_platform_interface: ^2.0.0
3734
pedantic: ^1.10.0
35+
test: ^1.16.3
3836

3937
environment:
4038
sdk: ">=2.12.0 <3.0.0"

packages/connectivity/connectivity_macos/example/integration_test/connectivity_test.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
65
import 'dart:io';
76
import 'package:integration_test/integration_test.dart';
87
import 'package:flutter_test/flutter_test.dart';
@@ -12,7 +11,7 @@ void main() {
1211
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1312

1413
group('Connectivity test driver', () {
15-
ConnectivityPlatform _connectivity;
14+
late ConnectivityPlatform _connectivity;
1615

1716
setUpAll(() async {
1817
_connectivity = ConnectivityPlatform.instance;

packages/connectivity/connectivity_macos/example/test_driver/integration_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:integration_test/integration_test_driver.dart';
86

97
Future<void> main() => integrationDriver();

packages/device_info/device_info/example/integration_test/device_info_test.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// TODO(cyanglaz): Remove once https://github.com/flutter/plugins/pull/3158 is landed.
6-
// @dart = 2.9
7-
85
import 'dart:io';
96
import 'package:flutter_test/flutter_test.dart';
107
import 'package:device_info/device_info.dart';
@@ -13,8 +10,8 @@ import 'package:integration_test/integration_test.dart';
1310
void main() {
1411
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1512

16-
IosDeviceInfo iosInfo;
17-
AndroidDeviceInfo androidInfo;
13+
late IosDeviceInfo iosInfo;
14+
late AndroidDeviceInfo androidInfo;
1815

1916
setUpAll(() async {
2017
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();

packages/device_info/device_info/example/test_driver/integration_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:integration_test/integration_test_driver.dart';
86

97
Future<void> main() => integrationDriver();

packages/image_picker/image_picker/example/integration_test/old_image_picker_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:integration_test/integration_test.dart';
86

97
void main() {

packages/image_picker/image_picker/example/test_driver/integration_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:integration_test/integration_test_driver.dart';
86

97
Future<void> main() => integrationDriver();

packages/image_picker/image_picker/pubspec.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ dependencies:
3030
dev_dependencies:
3131
flutter_test:
3232
sdk: flutter
33-
integration_test:
34-
sdk: flutter
3533
mockito: ^5.0.0-nullsafety.7
3634
pedantic: ^1.10.0
3735
plugin_platform_interface: ^2.0.0

packages/in_app_purchase/in_app_purchase/example/integration_test/in_app_purchase_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
65
import 'package:flutter_test/flutter_test.dart';
76
import 'package:in_app_purchase/in_app_purchase.dart';
87
import 'package:integration_test/integration_test.dart';

packages/in_app_purchase/in_app_purchase/example/test_driver/integration_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:integration_test/integration_test_driver.dart';
86

97
Future<void> main() => integrationDriver();

packages/in_app_purchase/in_app_purchase_android/example/integration_test/in_app_purchase_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
65
import 'package:flutter_test/flutter_test.dart';
76
import 'package:in_app_purchase_android/in_app_purchase_android.dart';
87
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';

packages/in_app_purchase/in_app_purchase_android/example/test_driver/test/integration_test.dart

+2-13
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
6-
import 'dart:async';
7-
import 'dart:convert';
8-
import 'dart:io';
9-
import 'package:flutter_driver/flutter_driver.dart';
5+
import 'package:integration_test/integration_test_driver.dart';
106

11-
Future<void> main() async {
12-
final FlutterDriver driver = await FlutterDriver.connect();
13-
final String data =
14-
await driver.requestData(null, timeout: const Duration(minutes: 1));
15-
await driver.close();
16-
final Map<String, dynamic> result = jsonDecode(data);
17-
exit(result['result'] == 'true' ? 0 : 1);
18-
}
7+
Future<void> main() => integrationDriver();

packages/in_app_purchase/in_app_purchase_ios/example/integration_test/in_app_purchase_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
65
import 'package:flutter_test/flutter_test.dart';
76
import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';
87
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';

packages/in_app_purchase/in_app_purchase_ios/example/test_driver/test/integration_test.dart

+2-13
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
6-
import 'dart:async';
7-
import 'dart:convert';
8-
import 'dart:io';
9-
import 'package:flutter_driver/flutter_driver.dart';
5+
import 'package:integration_test/integration_test_driver.dart';
106

11-
Future<void> main() async {
12-
final FlutterDriver driver = await FlutterDriver.connect();
13-
final String data =
14-
await driver.requestData(null, timeout: const Duration(minutes: 1));
15-
await driver.close();
16-
final Map<String, dynamic> result = jsonDecode(data);
17-
exit(result['result'] == 'true' ? 0 : 1);
18-
}
7+
Future<void> main() => integrationDriver();

packages/quick_actions/quick_actions/example/integration_test/quick_actions_test.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
65
import 'package:flutter_test/flutter_test.dart';
76
import 'package:integration_test/integration_test.dart';
87
import 'package:quick_actions/quick_actions.dart';
@@ -12,7 +11,7 @@ void main() {
1211

1312
testWidgets('Can set shortcuts', (WidgetTester tester) async {
1413
final QuickActions quickActions = QuickActions();
15-
await quickActions.initialize(null);
14+
await quickActions.initialize((String shortcutType) => {});
1615

1716
const ShortcutItem shortCutItem = ShortcutItem(
1817
type: 'action_one',

packages/quick_actions/quick_actions/example/test_driver/integration_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:integration_test/integration_test_driver.dart';
86

97
Future<void> main() => integrationDriver();

packages/quick_actions/quick_actions/pubspec.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ dependencies:
2727
dev_dependencies:
2828
flutter_test:
2929
sdk: flutter
30-
integration_test:
31-
sdk: flutter
32-
mockito: ^5.0.0-nullsafety.7
30+
mockito: ^5.0.0
3331
pedantic: ^1.11.0
3432
plugin_platform_interface: ^2.0.0

packages/webview_flutter/example/integration_test/webview_flutter_test.dart

+13-15
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
import 'dart:async';
86
import 'dart:convert';
97
import 'dart:io';
@@ -36,7 +34,7 @@ void main() {
3634
),
3735
);
3836
final WebViewController controller = await controllerCompleter.future;
39-
final String currentUrl = await controller.currentUrl();
37+
final String? currentUrl = await controller.currentUrl();
4038
expect(currentUrl, 'https://flutter.dev/');
4139
});
4240

@@ -57,7 +55,7 @@ void main() {
5755
);
5856
final WebViewController controller = await controllerCompleter.future;
5957
await controller.loadUrl('https://www.google.com/');
60-
final String currentUrl = await controller.currentUrl();
58+
final String? currentUrl = await controller.currentUrl();
6159
expect(currentUrl, 'https://www.google.com/');
6260
});
6361

@@ -91,7 +89,7 @@ void main() {
9189
};
9290
await controller.loadUrl('https://flutter-header-echo.herokuapp.com/',
9391
headers: headers);
94-
final String currentUrl = await controller.currentUrl();
92+
final String? currentUrl = await controller.currentUrl();
9593
expect(currentUrl, 'https://flutter-header-echo.herokuapp.com/');
9694

9795
await pageStarts.stream.firstWhere((String url) => url == currentUrl);
@@ -328,7 +326,7 @@ void main() {
328326
});
329327

330328
group('Video playback policy', () {
331-
String videoTestBase64;
329+
late String videoTestBase64;
332330
setUpAll(() async {
333331
final ByteData videoData =
334332
await rootBundle.load('assets/sample_video.mp4');
@@ -587,7 +585,7 @@ void main() {
587585
});
588586

589587
group('Audio playback policy', () {
590-
String audioTestBase64;
588+
late String audioTestBase64;
591589
setUpAll(() async {
592590
final ByteData audioData =
593591
await rootBundle.load('assets/sample_audio.ogg');
@@ -793,7 +791,7 @@ void main() {
793791
await pageStarted.future;
794792
await pageLoaded.future;
795793

796-
final String title = await controller.getTitle();
794+
final String? title = await controller.getTitle();
797795
expect(title, 'Some title');
798796
});
799797

@@ -1094,7 +1092,7 @@ void main() {
10941092
.evaluateJavascript('location.href = "https://www.google.com/"');
10951093

10961094
await pageLoads.stream.first; // Wait for the next page load.
1097-
final String currentUrl = await controller.currentUrl();
1095+
final String? currentUrl = await controller.currentUrl();
10981096
expect(currentUrl, 'https://www.google.com/');
10991097
});
11001098

@@ -1123,7 +1121,7 @@ void main() {
11231121
expect(error.failingUrl, isNull);
11241122
} else if (Platform.isAndroid) {
11251123
expect(error.errorType, isNotNull);
1126-
expect(error.failingUrl.startsWith('https://www.notawebsite..com'),
1124+
expect(error.failingUrl?.startsWith('https://www.notawebsite..com'),
11271125
isTrue);
11281126
}
11291127
});
@@ -1184,8 +1182,8 @@ void main() {
11841182
// blocked. Still wait for a potential page change for some time in order
11851183
// to give the test a chance to fail.
11861184
await pageLoads.stream.first
1187-
.timeout(const Duration(milliseconds: 500), onTimeout: () => null);
1188-
final String currentUrl = await controller.currentUrl();
1185+
.timeout(const Duration(milliseconds: 500), onTimeout: () => '');
1186+
final String? currentUrl = await controller.currentUrl();
11891187
expect(currentUrl, isNot(contains('youtube.com')));
11901188
});
11911189

@@ -1222,7 +1220,7 @@ void main() {
12221220
.evaluateJavascript('location.href = "https://www.google.com"');
12231221

12241222
await pageLoads.stream.first; // Wait for second page to load.
1225-
final String currentUrl = await controller.currentUrl();
1223+
final String? currentUrl = await controller.currentUrl();
12261224
expect(currentUrl, 'https://www.google.com/');
12271225
});
12281226
});
@@ -1249,7 +1247,7 @@ void main() {
12491247
),
12501248
);
12511249
final WebViewController controller = await controllerCompleter.future;
1252-
final String currentUrl = await controller.currentUrl();
1250+
final String? currentUrl = await controller.currentUrl();
12531251
expect(currentUrl, 'https://flutter.dev/');
12541252
});
12551253

@@ -1276,7 +1274,7 @@ void main() {
12761274
final WebViewController controller = await controllerCompleter.future;
12771275
await controller.evaluateJavascript('window.open("about:blank", "_blank")');
12781276
await pageLoaded.future;
1279-
final String currentUrl = await controller.currentUrl();
1277+
final String? currentUrl = await controller.currentUrl();
12801278
expect(currentUrl, 'about:blank');
12811279
});
12821280

packages/webview_flutter/example/test_driver/integration_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:integration_test/integration_test_driver.dart';
86

97
Future<void> main() => integrationDriver();

packages/wifi_info_flutter/wifi_info_flutter/example/integration_test/wifi_info_test.dart

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
import 'dart:io';
86
import 'package:integration_test/integration_test.dart';
97
import 'package:flutter_test/flutter_test.dart';
@@ -13,7 +11,7 @@ void main() {
1311
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1412

1513
group('$WifiInfo test driver', () {
16-
WifiInfo _wifiInfo;
14+
late WifiInfo _wifiInfo;
1715

1816
setUpAll(() async {
1917
_wifiInfo = WifiInfo();

packages/wifi_info_flutter/wifi_info_flutter/example/test_driver/integration_test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
import 'package:integration_test/integration_test_driver.dart';
86

97
Future<void> main() => integrationDriver();

packages/wifi_info_flutter/wifi_info_flutter/pubspec.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ dependencies:
1313
wifi_info_flutter_platform_interface: ^2.0.0
1414

1515
dev_dependencies:
16-
integration_test:
17-
sdk: flutter
1816
flutter_test:
1917
sdk: flutter
2018

0 commit comments

Comments
 (0)