Skip to content

Commit

Permalink
Fix test exclusion logic for nnbd plugins (flutter#3342)
Browse files Browse the repository at this point in the history
  • Loading branch information
amirh committed Dec 20, 2020
1 parent b289e1a commit b4466e7
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 42 deletions.
12 changes: 12 additions & 0 deletions .cirrus.yml
Expand Up @@ -39,8 +39,16 @@ task:
- flutter channel $CHANNEL
- ./script/incremental_build.sh test
- name: analyze
env:
matrix:
CHANNEL: "master"
CHANNEL: "stable"
script: ./script/incremental_build.sh analyze
- name: build_all_plugins_apk
env:
matrix:
CHANNEL: "master"
CHANNEL: "stable"
script:
# TODO(jackson): Allow web plugins once supported on stable
# https://github.com/flutter/flutter/issues/42864
Expand Down Expand Up @@ -144,6 +152,10 @@ task:
- xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-X com.apple.CoreSimulator.SimRuntime.iOS-13-3 | xargs xcrun simctl boot
matrix:
- name: build_all_plugins_ipa
env:
matrix:
CHANNEL: "master"
CHANNEL: "stable"
script:
# TODO(jackson): Allow web plugins once supported on stable
# https://github.com/flutter/flutter/issues/42864
Expand Down
5 changes: 4 additions & 1 deletion packages/android_intent/test/android_intent_test.dart
Expand Up @@ -2,6 +2,8 @@
// 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:android_intent/flag.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
Expand All @@ -11,7 +13,8 @@ import 'package:platform/platform.dart';

void main() {
AndroidIntent androidIntent;
late MockMethodChannel mockChannel;
MockMethodChannel mockChannel;

setUp(() {
mockChannel = MockMethodChannel();
when(mockChannel.invokeMethod<bool>('canResolveActivity', any))
Expand Down
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. 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:flutter_plugin_android_lifecycle_example/main.dart';
Expand Down
@@ -1,3 +1,7 @@
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'package:flutter/material.dart';
Expand Down
14 changes: 6 additions & 8 deletions packages/flutter_plugin_android_lifecycle/example/pubspec.yaml
@@ -1,23 +1,21 @@
name: flutter_plugin_android_lifecycle_example
description: Demonstrates how to use the flutter_plugin_android_lifecycle plugin.
publish_to: 'none'

environment:
sdk: ">=2.12.0-0 <3.0.0"

dependencies:
flutter:
sdk: flutter
integration_test:
path: ../../integration_test
flutter_plugin_android_lifecycle:
path: ../

dev_dependencies:
integration_test:
path: ../../integration_test
flutter_test:
sdk: flutter
pedantic: ^1.8.0

flutter_plugin_android_lifecycle:
path: ../
environment:
sdk: ">=2.12.0-0 <3.0.0"

flutter:
uses-material-design: true
10 changes: 6 additions & 4 deletions packages/local_auth/example/lib/main.dart
Expand Up @@ -21,16 +21,17 @@ class MyApp extends StatefulWidget {

class _MyAppState extends State<MyApp> {
final LocalAuthentication auth = LocalAuthentication();
bool _canCheckBiometrics;
List<BiometricType> _availableBiometrics;
late bool _canCheckBiometrics;
late List<BiometricType> _availableBiometrics;
String _authorized = 'Not Authorized';
bool _isAuthenticating = false;

Future<void> _checkBiometrics() async {
bool canCheckBiometrics;
late bool canCheckBiometrics;
try {
canCheckBiometrics = await auth.canCheckBiometrics;
} on PlatformException catch (e) {
canCheckBiometrics = false;
print(e);
}
if (!mounted) return;
Expand All @@ -41,10 +42,11 @@ class _MyAppState extends State<MyApp> {
}

Future<void> _getAvailableBiometrics() async {
List<BiometricType> availableBiometrics;
late List<BiometricType> availableBiometrics;
try {
availableBiometrics = await auth.getAvailableBiometrics();
} on PlatformException catch (e) {
availableBiometrics = <BiometricType>[];
print(e);
}
if (!mounted) return;
Expand Down
2 changes: 1 addition & 1 deletion packages/local_auth/example/pubspec.yaml
Expand Up @@ -18,5 +18,5 @@ flutter:
uses-material-design: true

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
6 changes: 6 additions & 0 deletions packages/local_auth/integration_test/local_auth_test.dart
@@ -1,3 +1,9 @@
// 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.

// @dart = 2.9

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

Expand Down
2 changes: 2 additions & 0 deletions packages/share/integration_test/share_test.dart
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. 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:share/share.dart';
import 'package:integration_test/integration_test.dart';
Expand Down
4 changes: 3 additions & 1 deletion packages/share/test/share_test.dart
Expand Up @@ -2,6 +2,8 @@
// 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 'dart:ui';

Expand All @@ -15,7 +17,7 @@ import 'package:flutter/services.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();

late MockMethodChannel mockChannel;
MockMethodChannel mockChannel;

setUp(() {
mockChannel = MockMethodChannel();
Expand Down
4 changes: 4 additions & 0 deletions packages/webview_flutter/CHANGELOG.md
@@ -1,3 +1,7 @@
## 2.0.0-nullsafety.3

* Fix `onWebResourceError` on iOS.

## 2.0.0-nullsafety.2

* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276))
Expand Down
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. 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 @@ -358,12 +360,12 @@ void main() {
videoTestBase64 = base64Encode(const Utf8Encoder().convert(videoTest));
});

test('Auto media playback', () async {
testWidgets('Auto media playback', (WidgetTester tester) async {
Completer<WebViewController> controllerCompleter =
Completer<WebViewController>();
Completer<void> pageLoaded = Completer<void>();

await pumpWidget(
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebView(
Expand All @@ -390,7 +392,7 @@ void main() {
pageLoaded = Completer<void>();

// We change the key to re-create a new webview as we change the initialMediaPlaybackPolicy
await pumpWidget(
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebView(
Expand All @@ -414,15 +416,16 @@ void main() {

isPaused = await controller.evaluateJavascript('isPaused();');
expect(isPaused, _webviewBool(true));
});
}, skip: true /* https://github.com/flutter/flutter/issues/72572 */);

test('Changes to initialMediaPlaybackPolicy are ignored', () async {
testWidgets('Changes to initialMediaPlaybackPolicy are ignored',
(WidgetTester tester) async {
final Completer<WebViewController> controllerCompleter =
Completer<WebViewController>();
Completer<void> pageLoaded = Completer<void>();

final GlobalKey key = GlobalKey();
await pumpWidget(
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebView(
Expand All @@ -447,7 +450,7 @@ void main() {

pageLoaded = Completer<void>();

await pumpWidget(
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebView(
Expand All @@ -472,14 +475,15 @@ void main() {

isPaused = await controller.evaluateJavascript('isPaused();');
expect(isPaused, _webviewBool(false));
});
}, skip: true /* https://github.com/flutter/flutter/issues/72572 */);

test('Video plays inline when allowsInlineMediaPlayback is true', () async {
testWidgets('Video plays inline when allowsInlineMediaPlayback is true',
(WidgetTester tester) async {
Completer<WebViewController> controllerCompleter =
Completer<WebViewController>();
Completer<void> pageLoaded = Completer<void>();

await pumpWidget(
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebView(
Expand Down Expand Up @@ -507,7 +511,7 @@ void main() {
controllerCompleter = Completer<WebViewController>();
pageLoaded = Completer<void>();

await pumpWidget(
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebView(
Expand All @@ -531,7 +535,7 @@ void main() {

isFullScreen = await controller.evaluateJavascript('isFullScreen();');
expect(isFullScreen, _webviewBool(true));
});
}, skip: true /* https://github.com/flutter/flutter/issues/72572 */);
});

group('Audio playback policy', () {
Expand Down Expand Up @@ -631,7 +635,7 @@ void main() {

isPaused = await controller.evaluateJavascript('isPaused();');
expect(isPaused, _webviewBool(true));
});
}, skip: true /* https://github.com/flutter/flutter/issues/72572 */);

testWidgets('Changes to initialMediaPlaybackPolocy are ignored',
(WidgetTester tester) async {
Expand Down Expand Up @@ -700,7 +704,7 @@ void main() {

isPaused = await controller.evaluateJavascript('isPaused();');
expect(isPaused, _webviewBool(false));
});
}, skip: true /* https://github.com/flutter/flutter/issues/72572 */);
});

testWidgets('getTitle', (WidgetTester tester) async {
Expand Down
16 changes: 8 additions & 8 deletions packages/webview_flutter/example/lib/main.dart
Expand Up @@ -105,7 +105,7 @@ class _WebViewExampleState extends State<WebViewExample> {
if (controller.hasData) {
return FloatingActionButton(
onPressed: () async {
final String url = await controller.data.currentUrl();
final String url = (await controller.data!.currentUrl())!;
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(
SnackBar(content: Text('Favorited $url')),
Expand Down Expand Up @@ -145,25 +145,25 @@ class SampleMenu extends StatelessWidget {
onSelected: (MenuOptions value) {
switch (value) {
case MenuOptions.showUserAgent:
_onShowUserAgent(controller.data, context);
_onShowUserAgent(controller.data!, context);
break;
case MenuOptions.listCookies:
_onListCookies(controller.data, context);
_onListCookies(controller.data!, context);
break;
case MenuOptions.clearCookies:
_onClearCookies(context);
break;
case MenuOptions.addToCache:
_onAddToCache(controller.data, context);
_onAddToCache(controller.data!, context);
break;
case MenuOptions.listCache:
_onListCache(controller.data, context);
_onListCache(controller.data!, context);
break;
case MenuOptions.clearCache:
_onClearCache(controller.data, context);
_onClearCache(controller.data!, context);
break;
case MenuOptions.navigationDelegate:
_onNavigationDelegateExample(controller.data, context);
_onNavigationDelegateExample(controller.data!, context);
break;
}
},
Expand Down Expand Up @@ -299,7 +299,7 @@ class NavigationControls extends StatelessWidget {
(BuildContext context, AsyncSnapshot<WebViewController> snapshot) {
final bool webViewReady =
snapshot.connectionState == ConnectionState.done;
final WebViewController controller = snapshot.data;
final WebViewController controller = snapshot.data!;
return Row(
children: <Widget>[
IconButton(
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/example/pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_example
description: Demonstrates how to use the webview_flutter plugin.

environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"

dependencies:
flutter:
Expand Down
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. 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
3 changes: 2 additions & 1 deletion packages/webview_flutter/lib/src/webview_method_channel.dart
Expand Up @@ -48,7 +48,8 @@ class MethodChannelWebViewPlatform implements WebViewPlatformController {
WebResourceError(
errorCode: call.arguments['errorCode']!,
description: call.arguments['description']!,
failingUrl: call.arguments['failingUrl']!,
// iOS doesn't support `failingUrl`.
failingUrl: call.arguments['failingUrl'],
domain: call.arguments['domain'],
errorType: call.arguments['errorType'] == null
? null
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/pubspec.yaml
@@ -1,6 +1,6 @@
name: webview_flutter
description: A Flutter plugin that provides a WebView widget on Android and iOS.
version: 2.0.0-nullsafety.2
version: 2.0.0-nullsafety.3
homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter

environment:
Expand Down

0 comments on commit b4466e7

Please sign in to comment.