@@ -960,18 +960,17 @@ void main() {
960960
961961 final WebViewController controller = await controllerCompleter.future;
962962 await pageLoaded.future;
963-
964- final String viewportRectJSON = await controller.evaluateJavascript (
965- 'JSON.stringify(viewport.getBoundingClientRect())' );
963+ final String viewportRectJSON = await _evaluateJavascript (
964+ controller, 'JSON.stringify(viewport.getBoundingClientRect())' );
966965 final Map <String , dynamic > viewportRectRelativeToViewport =
967- jsonDecode (jsonDecode ( viewportRectJSON) );
966+ jsonDecode (viewportRectJSON);
968967
969968 // Check that the input is originally outside of the viewport.
970969 {
971- final String inputClientRectJSON = await controller. evaluateJavascript (
972- 'JSON.stringify(inputEl.getBoundingClientRect())' );
970+ final String inputClientRectJSON = await _evaluateJavascript (
971+ controller, 'JSON.stringify(inputEl.getBoundingClientRect())' );
973972 final Map <String , dynamic > inputClientRectRelativeToViewport =
974- jsonDecode (jsonDecode ( inputClientRectJSON) );
973+ jsonDecode (inputClientRectJSON);
975974
976975 expect (
977976 inputClientRectRelativeToViewport['bottom' ] <=
@@ -983,10 +982,10 @@ void main() {
983982
984983 // Check that focusing the input brought it into view.
985984 {
986- final String inputClientRectJSON = await controller. evaluateJavascript (
987- 'JSON.stringify(inputEl.getBoundingClientRect())' );
985+ final String inputClientRectJSON = await _evaluateJavascript (
986+ controller, 'JSON.stringify(inputEl.getBoundingClientRect())' );
988987 final Map <String , dynamic > inputClientRectRelativeToViewport =
989- jsonDecode (jsonDecode ( inputClientRectJSON) );
988+ jsonDecode (inputClientRectJSON);
990989
991990 expect (
992991 inputClientRectRelativeToViewport['top' ] >=
@@ -1007,7 +1006,7 @@ void main() {
10071006 isTrue);
10081007 }
10091008 });
1010- }, skip: defaultTargetPlatform != TargetPlatform .android );
1009+ }, skip: true );
10111010
10121011 group ('NavigationDelegate' , () {
10131012 final String blankPage = "<!DOCTYPE html><head></head><body></body></html>" ;
@@ -1261,7 +1260,7 @@ void main() {
12611260 await controller.goBack ();
12621261 expect (controller.currentUrl (), completion ('https://www.flutter.dev' ));
12631262 },
1264- skip: defaultTargetPlatform != TargetPlatform .android ,
1263+ skip: ! Platform .isAndroid ,
12651264 );
12661265
12671266 testWidgets (
@@ -1329,7 +1328,7 @@ void main() {
13291328 completion ('null' ),
13301329 );
13311330 },
1332- skip: defaultTargetPlatform != TargetPlatform .android ,
1331+ skip: ! Platform .isAndroid ,
13331332 );
13341333}
13351334
@@ -1344,9 +1343,13 @@ String _webviewBool(bool value) {
13441343
13451344/// Returns the value used for the HTTP User-Agent: request header in subsequent HTTP requests.
13461345Future <String > _getUserAgent (WebViewController controller) async {
1346+ return _evaluateJavascript (controller, 'navigator.userAgent;' );
1347+ }
1348+
1349+ Future <String > _evaluateJavascript (
1350+ WebViewController controller, String js) async {
13471351 if (defaultTargetPlatform == TargetPlatform .iOS) {
1348- return await controller.evaluateJavascript ('navigator.userAgent;' );
1352+ return await controller.evaluateJavascript (js );
13491353 }
1350- return jsonDecode (
1351- await controller.evaluateJavascript ('navigator.userAgent;' ));
1354+ return jsonDecode (await controller.evaluateJavascript (js));
13521355}
0 commit comments