Allow developers to run flutter driver web test directly#51084
Allow developers to run flutter driver web test directly#51084fluttergithubbot merged 13 commits intoflutter:masterfrom
Conversation
| import '../base/file_system.dart'; | ||
| import '../base/process.dart'; | ||
| import '../build_info.dart'; | ||
| import '../build_runner/devfs_web.dart'; |
There was a problem hiding this comment.
We cant let this implementation leak into the rest of the tool. There is an interface that flutter run uses, this needs to go through the same indirection
There was a problem hiding this comment.
Good to know. Have this fixed by creating a getter on ResidentRunner.
| // TODO(angjieli): remove this once running against | ||
| // target under test_driver in debug mode is supported | ||
| throwToolExit( | ||
| 'Flutter Driver web does not support running in debug mode.\n' |
There was a problem hiding this comment.
nit: align and indent 2 spaces
| if (result != 0) { | ||
| throwToolExit(null, exitCode: result); | ||
| } | ||
| final WebDevFS webDevFS = (runner as ResidentWebRunner).device.devFS as WebDevFS; |
There was a problem hiding this comment.
We should have a better way to surface this URI
| bool get isRunningRelease => debuggingOptions.buildInfo.isRelease; | ||
| bool get supportsServiceProtocol => isRunningDebug || isRunningProfile; | ||
|
|
||
| Uri get uri => flutterDevices.first.devFS.baseUri; |
There was a problem hiding this comment.
nit: document as the URI of the first connected device for mobile, and only connected device for web.
There was a problem hiding this comment.
Also when it will be null
|
|
||
| @override | ||
| Uri get baseUri => null; | ||
| Uri get baseUri => _baseUri; |
There was a problem hiding this comment.
Could you add a simple unit test for the run_hot tests and the resident web runner tests?
| entrypoint, | ||
| ); | ||
| return Uri.parse('http://$hostname:$port'); | ||
| _baseUri = Uri.parse('http://$hostname:$port'); |
There was a problem hiding this comment.
This might not be the correct information depending on what you need to connect to. For example, hostname might be something like a corp workstation hostname that needs to be resolved to an actual network address
There was a problem hiding this comment.
For our use case, the application and test will be on the same machine so this should be fine.
|
Thanks a lot @angjieli /cc @yjbanov I also added a new repository which has code for downloading the drivers: flutter/web_installers#1 I'll combine these in a smoke test so that we will have flutter web engine end to end tested: #51003 |
| ResidentRunner runner; | ||
| final FlutterProject flutterProject = FlutterProject.current(); | ||
| final FlutterDevice flutterDevice = await FlutterDevice.create( | ||
| device, |
| // need to know about analytics. | ||
| // | ||
| // Do not add more operations to the future. | ||
| final Completer<void> appStartedTimeRecorder = Completer<void>.sync(); |
There was a problem hiding this comment.
Should you be awaiting this so that you're sure runner.uri is not null? Also, make it a regular completer and rename to reflect its current purpose
| urlTunneller: null, | ||
| ); | ||
|
|
||
| // Sync completer so the completing agent attaching to the resident doesn't |
There was a problem hiding this comment.
This comment isn't relevant to this code anymore
There was a problem hiding this comment.
Code is not updated yet..Seems like there are something wrong with Github.
| } | ||
|
|
||
| @override | ||
| Future<void> exitApp() async { |
There was a problem hiding this comment.
Sorry, I just noticed these changes here. Shutting down a web app is a bit complicated - does this change modify the behavior of flutter run -d chrome or flutter run -d chrome --release when quiting?
There was a problem hiding this comment.
No, it does not. We got the same behavior.
|
This pull request is not suitable for automatic merging in its current state.
|
| 'Flutter Driver web does not support running in debug mode.\n' | ||
| '\n' | ||
| 'Use --profile mode for testing application performance.\n' | ||
| 'Use --release mode for testing correctness (with assertions).' |
There was a problem hiding this comment.
Are we going to address this in the next PRs?
As a team we are also have usecase for the driver tests in the debug mode as well. Thanks!
There was a problem hiding this comment.
This is not a driver bug so @jonahwilliams probably knows more about it.
Currently, you will also get an error when running flutter run --target=test_driver/scroll_perf_web.dart --debug.
There was a problem hiding this comment.
Actually, this should probably work at ToT
|
|
||
| if (webUri != null) { | ||
| platformArgs['uri'] = webUri.toString(); | ||
| // For web device, startApp will be triggered twice |
There was a problem hiding this comment.
I think --start-paused only works in debug mode, so this only needs to happen in profile/release mode
… app. Clean flutter run command from cirrus.yml
* smoke test for web * fix comments and remove logs * addressing reviewer comments * fix analyzer issue * running the test on cirrus * cirrus yaml syntax error * pub get for web_drivers * go to the examples directory before running the flutter app * cirrus is not able to find chromedriver. add a sleep to see if timing is the issue. * run chrome driver in the background * After PR #51084, flutter drive command can build and run a web app. Clean flutter run command from cirrus.yml * enable web
Description
Previously, running
flutter drivecommand against web devices would require developer to runflutter runto start the application first and specify--use-existing-appargument.This PR is going to support running
flutter drivecommand against web platform without starting the application.For example, you can run
flutter drive --target=test_driver/scroll_perf_web.dart -d web-server --release --browser-name=firefoxunderexamples/flutter_gallery.Note that it does not support
debugmode for now (due to compiler error).Related Issues
#51083
Tests
I added the following tests:
Updated test flutter_tools/test/commands.shard/hermetic/drive_test.dart.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.