forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webview_flutter_web] Copies web implementation of webview_flutter fr…
…om v4_webview (flutter#6854) * v4 web impl * add breaking change * fix lints * exclude web plugin
- Loading branch information
1 parent
9c34c74
commit 8870dd1
Showing
22 changed files
with
1,136 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...iew_flutter/webview_flutter_web/example/integration_test/legacy/webview_flutter_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:async'; | ||
import 'dart:html' as html; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:webview_flutter_web_example/legacy/web_view.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
// URLs to navigate to in tests. These need to be URLs that we are confident will | ||
// always be accessible, and won't do redirection. (E.g., just | ||
// 'https://www.google.com/' will sometimes redirect traffic that looks | ||
// like it's coming from a bot, which is true of these tests). | ||
const String primaryUrl = 'https://flutter.dev/'; | ||
const String secondaryUrl = 'https://www.google.com/robots.txt'; | ||
|
||
testWidgets('initialUrl', (WidgetTester tester) async { | ||
final Completer<WebViewController> controllerCompleter = | ||
Completer<WebViewController>(); | ||
await tester.pumpWidget( | ||
Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: WebView( | ||
key: GlobalKey(), | ||
initialUrl: primaryUrl, | ||
onWebViewCreated: (WebViewController controller) { | ||
controllerCompleter.complete(controller); | ||
}, | ||
), | ||
), | ||
); | ||
await controllerCompleter.future; | ||
|
||
// Assert an iframe has been rendered to the DOM with the correct src attribute. | ||
final html.IFrameElement? element = | ||
html.document.querySelector('iframe') as html.IFrameElement?; | ||
expect(element, isNotNull); | ||
expect(element!.src, primaryUrl); | ||
}); | ||
|
||
testWidgets('loadUrl', (WidgetTester tester) async { | ||
final Completer<WebViewController> controllerCompleter = | ||
Completer<WebViewController>(); | ||
await tester.pumpWidget( | ||
Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: WebView( | ||
key: GlobalKey(), | ||
initialUrl: primaryUrl, | ||
onWebViewCreated: (WebViewController controller) { | ||
controllerCompleter.complete(controller); | ||
}, | ||
), | ||
), | ||
); | ||
final WebViewController controller = await controllerCompleter.future; | ||
await controller.loadUrl(secondaryUrl); | ||
|
||
// Assert an iframe has been rendered to the DOM with the correct src attribute. | ||
final html.IFrameElement? element = | ||
html.document.querySelector('iframe') as html.IFrameElement?; | ||
expect(element, isNotNull); | ||
expect(element!.src, secondaryUrl); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.