@@ -960,18 +960,17 @@ void main() {
960
960
961
961
final WebViewController controller = await controllerCompleter.future;
962
962
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())' );
966
965
final Map <String , dynamic > viewportRectRelativeToViewport =
967
- jsonDecode (jsonDecode ( viewportRectJSON) );
966
+ jsonDecode (viewportRectJSON);
968
967
969
968
// Check that the input is originally outside of the viewport.
970
969
{
971
- final String inputClientRectJSON = await controller. evaluateJavascript (
972
- 'JSON.stringify(inputEl.getBoundingClientRect())' );
970
+ final String inputClientRectJSON = await _evaluateJavascript (
971
+ controller, 'JSON.stringify(inputEl.getBoundingClientRect())' );
973
972
final Map <String , dynamic > inputClientRectRelativeToViewport =
974
- jsonDecode (jsonDecode ( inputClientRectJSON) );
973
+ jsonDecode (inputClientRectJSON);
975
974
976
975
expect (
977
976
inputClientRectRelativeToViewport['bottom' ] <=
@@ -983,10 +982,10 @@ void main() {
983
982
984
983
// Check that focusing the input brought it into view.
985
984
{
986
- final String inputClientRectJSON = await controller. evaluateJavascript (
987
- 'JSON.stringify(inputEl.getBoundingClientRect())' );
985
+ final String inputClientRectJSON = await _evaluateJavascript (
986
+ controller, 'JSON.stringify(inputEl.getBoundingClientRect())' );
988
987
final Map <String , dynamic > inputClientRectRelativeToViewport =
989
- jsonDecode (jsonDecode ( inputClientRectJSON) );
988
+ jsonDecode (inputClientRectJSON);
990
989
991
990
expect (
992
991
inputClientRectRelativeToViewport['top' ] >=
@@ -1007,7 +1006,7 @@ void main() {
1007
1006
isTrue);
1008
1007
}
1009
1008
});
1010
- }, skip: defaultTargetPlatform != TargetPlatform .android );
1009
+ }, skip: true );
1011
1010
1012
1011
group ('NavigationDelegate' , () {
1013
1012
final String blankPage = "<!DOCTYPE html><head></head><body></body></html>" ;
@@ -1261,7 +1260,7 @@ void main() {
1261
1260
await controller.goBack ();
1262
1261
expect (controller.currentUrl (), completion ('https://www.flutter.dev' ));
1263
1262
},
1264
- skip: defaultTargetPlatform != TargetPlatform .android ,
1263
+ skip: ! Platform .isAndroid ,
1265
1264
);
1266
1265
1267
1266
testWidgets (
@@ -1329,7 +1328,7 @@ void main() {
1329
1328
completion ('null' ),
1330
1329
);
1331
1330
},
1332
- skip: defaultTargetPlatform != TargetPlatform .android ,
1331
+ skip: ! Platform .isAndroid ,
1333
1332
);
1334
1333
}
1335
1334
@@ -1344,9 +1343,13 @@ String _webviewBool(bool value) {
1344
1343
1345
1344
/// Returns the value used for the HTTP User-Agent: request header in subsequent HTTP requests.
1346
1345
Future <String > _getUserAgent (WebViewController controller) async {
1346
+ return _evaluateJavascript (controller, 'navigator.userAgent;' );
1347
+ }
1348
+
1349
+ Future <String > _evaluateJavascript (
1350
+ WebViewController controller, String js) async {
1347
1351
if (defaultTargetPlatform == TargetPlatform .iOS) {
1348
- return await controller.evaluateJavascript ('navigator.userAgent;' );
1352
+ return await controller.evaluateJavascript (js );
1349
1353
}
1350
- return jsonDecode (
1351
- await controller.evaluateJavascript ('navigator.userAgent;' ));
1354
+ return jsonDecode (await controller.evaluateJavascript (js));
1352
1355
}
0 commit comments