Skip to content

Commit

Permalink
Update integration_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Swanseo0 committed Nov 16, 2023
1 parent 1d3761d commit 8d32adb
Showing 1 changed file with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:webview_flutter/webview_flutter.dart';
Expand Down Expand Up @@ -176,7 +177,7 @@ Future<void> main() async {

await pageFinished.future;

final String customUserAgent = await _getUserAgent(controller);
final String? customUserAgent = await controller.getUserAgent();
expect(customUserAgent, 'Custom_User_Agent1');
});

Expand Down Expand Up @@ -477,23 +478,6 @@ Future<void> main() async {
});
}

/// Returns the value used for the HTTP User-Agent: request header in subsequent HTTP requests.
Future<String> _getUserAgent(WebViewController controller) async {
return _runJavascriptReturningResult(controller, 'navigator.userAgent;');
}

Future<String> _runJavascriptReturningResult(
WebViewController controller,
String js,
) async {
if (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.linux) {
return await controller.runJavaScriptReturningResult(js) as String;
}
return jsonDecode(await controller.runJavaScriptReturningResult(js) as String)
as String;
}

class ResizableWebView extends StatefulWidget {
const ResizableWebView({
super.key,
Expand Down

0 comments on commit 8d32adb

Please sign in to comment.