Skip to content

Commit

Permalink
Move integration test to null safety for multiple plugins (flutter#3932)
Browse files Browse the repository at this point in the history
Cherry-picks flutter#3646 from the NNBD integration test branch, and updates it for changes on master.

Co-authored-by: Chris Yang <[email protected]>
  • Loading branch information
stuartmorgan and Chris Yang authored May 22, 2021
1 parent bca7c9f commit a864de2
Show file tree
Hide file tree
Showing 24 changed files with 25 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(cyanglaz): Remove once https://github.com/flutter/plugins/pull/3158 is landed.
// @dart = 2.9

import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:connectivity/connectivity.dart';
Expand All @@ -13,7 +10,7 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('Connectivity test driver', () {
Connectivity _connectivity;
late Connectivity _connectivity;

setUpAll(() async {
_connectivity = Connectivity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
4 changes: 1 addition & 3 deletions packages/connectivity/connectivity/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ dev_dependencies:
sdk: flutter
flutter_driver:
sdk: flutter
test: ^1.16.3
integration_test:
sdk: flutter
plugin_platform_interface: ^2.0.0
pedantic: ^1.10.0
test: ^1.16.3

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.9
import 'dart:io';
import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
Expand All @@ -12,7 +11,7 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('Connectivity test driver', () {
ConnectivityPlatform _connectivity;
late ConnectivityPlatform _connectivity;

setUpAll(() async {
_connectivity = ConnectivityPlatform.instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(cyanglaz): Remove once https://github.com/flutter/plugins/pull/3158 is landed.
// @dart = 2.9

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:device_info/device_info.dart';
Expand All @@ -13,8 +10,8 @@ import 'package:integration_test/integration_test.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

IosDeviceInfo iosInfo;
AndroidDeviceInfo androidInfo;
late IosDeviceInfo iosInfo;
late AndroidDeviceInfo androidInfo;

setUpAll(() async {
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:integration_test/integration_test.dart';

void main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
2 changes: 0 additions & 2 deletions packages/image_picker/image_picker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
mockito: ^5.0.0-nullsafety.7
pedantic: ^1.10.0
plugin_platform_interface: ^2.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.9
import 'package:flutter_test/flutter_test.dart';
import 'package:in_app_purchase/in_app_purchase.dart';
import 'package:integration_test/integration_test.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.9
import 'package:flutter_test/flutter_test.dart';
import 'package:in_app_purchase_android/in_app_purchase_android.dart';
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.9
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:integration_test/integration_test_driver.dart';

Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String data =
await driver.requestData(null, timeout: const Duration(minutes: 1));
await driver.close();
final Map<String, dynamic> result = jsonDecode(data);
exit(result['result'] == 'true' ? 0 : 1);
}
Future<void> main() => integrationDriver();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.9
import 'package:flutter_test/flutter_test.dart';
import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.9
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:integration_test/integration_test_driver.dart';

Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String data =
await driver.requestData(null, timeout: const Duration(minutes: 1));
await driver.close();
final Map<String, dynamic> result = jsonDecode(data);
exit(result['result'] == 'true' ? 0 : 1);
}
Future<void> main() => integrationDriver();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.9
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:quick_actions/quick_actions.dart';
Expand All @@ -12,7 +11,7 @@ void main() {

testWidgets('Can set shortcuts', (WidgetTester tester) async {
final QuickActions quickActions = QuickActions();
await quickActions.initialize(null);
await quickActions.initialize((String shortcutType) => {});

const ShortcutItem shortCutItem = ShortcutItem(
type: 'action_one',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
4 changes: 1 addition & 3 deletions packages/quick_actions/quick_actions/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
mockito: ^5.0.0-nullsafety.7
mockito: ^5.0.0
pedantic: ^1.11.0
plugin_platform_interface: ^2.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.9

import 'dart:async';
import 'dart:convert';
import 'dart:io';
Expand Down Expand Up @@ -36,7 +34,7 @@ void main() {
),
);
final WebViewController controller = await controllerCompleter.future;
final String currentUrl = await controller.currentUrl();
final String? currentUrl = await controller.currentUrl();
expect(currentUrl, 'https://flutter.dev/');
});

Expand All @@ -57,7 +55,7 @@ void main() {
);
final WebViewController controller = await controllerCompleter.future;
await controller.loadUrl('https://www.google.com/');
final String currentUrl = await controller.currentUrl();
final String? currentUrl = await controller.currentUrl();
expect(currentUrl, 'https://www.google.com/');
});

Expand Down Expand Up @@ -91,7 +89,7 @@ void main() {
};
await controller.loadUrl('https://flutter-header-echo.herokuapp.com/',
headers: headers);
final String currentUrl = await controller.currentUrl();
final String? currentUrl = await controller.currentUrl();
expect(currentUrl, 'https://flutter-header-echo.herokuapp.com/');

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

group('Video playback policy', () {
String videoTestBase64;
late String videoTestBase64;
setUpAll(() async {
final ByteData videoData =
await rootBundle.load('assets/sample_video.mp4');
Expand Down Expand Up @@ -587,7 +585,7 @@ void main() {
});

group('Audio playback policy', () {
String audioTestBase64;
late String audioTestBase64;
setUpAll(() async {
final ByteData audioData =
await rootBundle.load('assets/sample_audio.ogg');
Expand Down Expand Up @@ -793,7 +791,7 @@ void main() {
await pageStarted.future;
await pageLoaded.future;

final String title = await controller.getTitle();
final String? title = await controller.getTitle();
expect(title, 'Some title');
});

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

await pageLoads.stream.first; // Wait for the next page load.
final String currentUrl = await controller.currentUrl();
final String? currentUrl = await controller.currentUrl();
expect(currentUrl, 'https://www.google.com/');
});

Expand Down Expand Up @@ -1123,7 +1121,7 @@ void main() {
expect(error.failingUrl, isNull);
} else if (Platform.isAndroid) {
expect(error.errorType, isNotNull);
expect(error.failingUrl.startsWith('https://www.notawebsite..com'),
expect(error.failingUrl?.startsWith('https://www.notawebsite..com'),
isTrue);
}
});
Expand Down Expand Up @@ -1184,8 +1182,8 @@ void main() {
// blocked. Still wait for a potential page change for some time in order
// to give the test a chance to fail.
await pageLoads.stream.first
.timeout(const Duration(milliseconds: 500), onTimeout: () => null);
final String currentUrl = await controller.currentUrl();
.timeout(const Duration(milliseconds: 500), onTimeout: () => '');
final String? currentUrl = await controller.currentUrl();
expect(currentUrl, isNot(contains('youtube.com')));
});

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

await pageLoads.stream.first; // Wait for second page to load.
final String currentUrl = await controller.currentUrl();
final String? currentUrl = await controller.currentUrl();
expect(currentUrl, 'https://www.google.com/');
});
});
Expand All @@ -1249,7 +1247,7 @@ void main() {
),
);
final WebViewController controller = await controllerCompleter.future;
final String currentUrl = await controller.currentUrl();
final String? currentUrl = await controller.currentUrl();
expect(currentUrl, 'https://flutter.dev/');
});

Expand All @@ -1276,7 +1274,7 @@ void main() {
final WebViewController controller = await controllerCompleter.future;
await controller.evaluateJavascript('window.open("about:blank", "_blank")');
await pageLoaded.future;
final String currentUrl = await controller.currentUrl();
final String? currentUrl = await controller.currentUrl();
expect(currentUrl, 'about:blank');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.9

import 'dart:io';
import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
Expand All @@ -13,7 +11,7 @@ void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('$WifiInfo test driver', () {
WifiInfo _wifiInfo;
late WifiInfo _wifiInfo;

setUpAll(() async {
_wifiInfo = WifiInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
2 changes: 0 additions & 2 deletions packages/wifi_info_flutter/wifi_info_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ dependencies:
wifi_info_flutter_platform_interface: ^2.0.0

dev_dependencies:
integration_test:
sdk: flutter
flutter_test:
sdk: flutter

Expand Down

0 comments on commit a864de2

Please sign in to comment.