Skip to content

Commit

Permalink
[webview_flutter] Minor test cleanup (flutter#6031)
Browse files Browse the repository at this point in the history
- Remove an iOS-only integration test from the app-facing package; there's already a copy in the iOS implementation package, and it's not relevant to the app-facing API.
- Remove dead iOS native test code; the actual iOS native tests are all in the iOS package now, and this code isn't being run (since the repo tooling doesn't try to run native tests for plugins that don't have inline native implementations)

Fixes flutter/flutter#91004
  • Loading branch information
stuartmorgan authored and arc-yong committed Jun 14, 2024
1 parent 6981503 commit 2354280
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 644 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,57 +520,6 @@ Future<void> main() async {
await controller.runJavascriptReturningResult('isFullScreen();');
expect(fullScreen, _webviewBool(false));
});

// allowsInlineMediaPlayback is a noop on Android, so it is skipped.
testWidgets(
'Video plays full screen when allowsInlineMediaPlayback is false',
(WidgetTester tester) async {
final Completer<WebViewController> controllerCompleter =
Completer<WebViewController>();
final Completer<void> pageLoaded = Completer<void>();
final Completer<void> videoPlaying = Completer<void>();

await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: WebView(
initialUrl: 'data:text/html;charset=utf-8;base64,$videoTestBase64',
onWebViewCreated: (WebViewController controller) {
controllerCompleter.complete(controller);
},
javascriptMode: JavascriptMode.unrestricted,
javascriptChannels: <JavascriptChannel>{
JavascriptChannel(
name: 'VideoTestTime',
onMessageReceived: (JavascriptMessage message) {
final double currentTime = double.parse(message.message);
// Let it play for at least 1 second to make sure the related video's properties are set.
if (currentTime > 1 && !videoPlaying.isCompleted) {
videoPlaying.complete(null);
}
},
),
},
onPageFinished: (String url) {
pageLoaded.complete(null);
},
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow,
),
),
);
final WebViewController controller = await controllerCompleter.future;
await pageLoaded.future;

// Pump once to trigger the video play.
await tester.pump();

// Makes sure we get the correct event that indicates the video is actually playing.
await videoPlaying.future;

final String fullScreen =
await controller.runJavascriptReturningResult('isFullScreen();');
expect(fullScreen, _webviewBool(true));
}, skip: Platform.isAndroid);
});

group('Audio playback policy', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,52 +348,6 @@ Future<void> main() async {
.runJavaScriptReturningResult('isFullScreen();') as bool;
expect(fullScreen, false);
});

// allowsInlineMediaPlayback is a noop on Android, so it is skipped.
testWidgets(
'Video plays full screen when allowsInlineMediaPlayback is false',
(WidgetTester tester) async {
final Completer<void> pageLoaded = Completer<void>();
final Completer<void> videoPlaying = Completer<void>();

final WebViewController controller =
WebViewController.fromPlatformCreationParams(
WebKitWebViewControllerCreationParams(
mediaTypesRequiringUserAction: const <PlaybackMediaTypes>{},
),
);
unawaited(controller.setJavaScriptMode(JavaScriptMode.unrestricted));
unawaited(controller.setNavigationDelegate(
NavigationDelegate(onPageFinished: (_) => pageLoaded.complete()),
));
unawaited(controller.addJavaScriptChannel(
'VideoTestTime',
onMessageReceived: (JavaScriptMessage message) {
final double currentTime = double.parse(message.message);
// Let it play for at least 1 second to make sure the related video's properties are set.
if (currentTime > 1 && !videoPlaying.isCompleted) {
videoPlaying.complete(null);
}
},
));
unawaited(controller.loadRequest(
Uri.parse(
'data:text/html;charset=utf-8;base64,$videoTestBase64',
),
));

await tester.pumpWidget(WebViewWidget(controller: controller));
await tester.pumpAndSettle();

await pageLoaded.future;

// Makes sure we get the correct event that indicates the video is actually playing.
await videoPlaying.future;

final bool fullScreen = await controller
.runJavaScriptReturningResult('isFullScreen();') as bool;
expect(fullScreen, true);
}, skip: Platform.isAndroid);
});

group('Audio playback policy', () {
Expand Down
7 changes: 0 additions & 7 deletions packages/webview_flutter/webview_flutter/example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ flutter_ios_podfile_setup

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

target 'RunnerTests' do
inherit! :search_paths

# Matches test_spec dependency.
pod 'OCMock', '3.5'
end
end

post_install do |installer|
Expand Down
Loading

0 comments on commit 2354280

Please sign in to comment.