-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Engine integration test #16930
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,6 +124,27 @@ task: | |
| - name: web_tests-7_last-linux # last Web shard must end with _last | ||
| << : *WEB_SHARD_TEMPLATE | ||
|
|
||
| - name: web_engine_integration_test_linux | ||
| compile_host_script: | | ||
| cd $ENGINE_PATH/src | ||
| ./flutter/tools/gn --unoptimized --full-dart-sdk | ||
| ninja -C out/host_debug_unopt | ||
| fetch_framework_script: | | ||
| cd $ENGINE_PATH/src/flutter/tools | ||
| ./clone_flutter.sh | ||
| cd $FRAMEWORK_PATH/flutter | ||
| bin/flutter update-packages --local-engine=host_debug_unopt | ||
| script: | ||
| - git clone https://github.com/flutter/web_installers.git | ||
| - cd web_installers/packages/web_drivers/ | ||
| - $ENGINE_PATH/src/third_party/dart/tools/sdks/dart-sdk/bin/pub get | ||
| - $ENGINE_PATH/src/third_party/dart/tools/sdks/dart-sdk/bin/dart lib/web_driver_installer.dart chromedriver --install-only | ||
| - ./chromedriver/chromedriver --port=4444 & | ||
| - cd $ENGINE_PATH/src/flutter/e2etests/web/regular_integration_tests | ||
| - $FRAMEWORK_PATH/flutter/bin/flutter config --local-engine=host_debug_unopt --no-analytics --enable-web | ||
| - $FRAMEWORK_PATH/flutter/bin/flutter pub get --local-engine=host_debug_unopt | ||
nturgut marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - $FRAMEWORK_PATH/flutter/bin/flutter drive -v --target=test_driver/text_editing_e2e.dart -d web-server --release --browser-name=chrome --local-engine=host_debug_unopt | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're expecting to add more test files in the future, right? It might make sense to split this out into a script, and maybe even shard it if the tests take awhile to run. I guess this could be added incrementally in the future.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I agree. This is configuring web as well. I'll make a script with multiple arguments (so we can add mobile there too)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to add running e2e tests into the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I'm planning to that. either felt or a new tool. I'll do it depending on the results of the sheet I sent you. (See my answer to mdebbar's comment) |
||
|
|
||
| - name: build_and_test_web_linux_firefox | ||
| compile_host_script: | | ||
| cd $ENGINE_PATH/src | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| Signature: a0775818831a05f46ce1628c95d834c1 | ||
| Signature: 9ad4afaa43bd81d0e6a011688ca40377 | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| ``` | ||
| This directory is for Flutter Web engine integration tests that does not | ||
| need a specific configuration. If an e2e test needs specialized app | ||
| configuration (e.g. PWA vs non-PWA packaging), please create another | ||
| directory under e2etests/web. Otherwise tests such as text_editing, history, | ||
| scrolling, pointer events... should all go under this package. | ||
|
|
||
| # To run the application under test for traouble shooting purposes. | ||
| flutter run -d web-server lib/text_editing_main.dart --local-engine=host_debug_unopt | ||
|
|
||
| # To run the Text Editing test and use the developer tools in the browser. | ||
| flutter run --target=test_driver/text_editing_e2e.dart -d web-server --web-port=8080 --release --local-engine=host_debug_unopt | ||
|
|
||
| # To test the Text Editing test with driver: | ||
| flutter drive -v --target=test_driver/text_editing_e2e.dart -d web-server --release --browser-name=chrome --local-engine=host_debug_unopt | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // 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 'package:flutter/material.dart'; | ||
|
|
||
| void main() => runApp(MyApp()); | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MaterialApp( | ||
| key: const Key('mainapp'), | ||
| title: 'Integration Test App', | ||
| home: MyHomePage(title: 'Integration Test App'), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class MyHomePage extends StatefulWidget { | ||
| MyHomePage({Key key, this.title}) : super(key: key); | ||
|
|
||
| final String title; | ||
|
|
||
| @override | ||
| _MyHomePageState createState() => _MyHomePageState(); | ||
| } | ||
|
|
||
| class _MyHomePageState extends State<MyHomePage> { | ||
| final TextEditingController _controller = | ||
| TextEditingController(text: 'Text1'); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| appBar: AppBar( | ||
| title: Text(widget.title), | ||
| ), | ||
| body: Center( | ||
| child: Column( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: <Widget>[ | ||
| const Text( | ||
| 'Text Editing Test', | ||
| ), | ||
| TextFormField( | ||
| key: const Key('input'), | ||
| enabled: true, | ||
| controller: _controller, | ||
| //initialValue: 'Text1', | ||
| decoration: const InputDecoration( | ||
| labelText: 'Text Input Field:', | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| name: regular_integration_tests | ||
| publish_to: none | ||
|
|
||
| environment: | ||
| sdk: ">=2.2.2 <3.0.0" | ||
|
|
||
| dependencies: | ||
| flutter: | ||
| sdk: flutter | ||
|
|
||
| dev_dependencies: | ||
| flutter_driver: | ||
| sdk: flutter | ||
| flutter_test: | ||
| sdk: flutter | ||
| e2e: 0.2.4+4 | ||
| http: 0.12.0+2 | ||
| test: any |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // 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:html'; | ||
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:regular_integration_tests/text_editing_main.dart' as app; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import 'package:e2e/e2e.dart'; | ||
|
|
||
| void main() { | ||
| E2EWidgetsFlutterBinding.ensureInitialized() as E2EWidgetsFlutterBinding; | ||
|
|
||
| testWidgets('Focused text field creates a native input element', | ||
| (WidgetTester tester) async { | ||
| app.main(); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| // TODO(nurhan): https://github.com/flutter/flutter/issues/51885 | ||
| SystemChannels.textInput.setMockMethodCallHandler(null); | ||
|
|
||
| // Focus on a TextFormField. | ||
| final Finder finder = find.byKey(const Key('input')); | ||
| expect(finder, findsOneWidget); | ||
| await tester.tap(find.byKey(const Key('input'))); | ||
|
|
||
| // A native input element will be appended to the DOM. | ||
| final List<Node> nodeList = document.getElementsByTagName('input'); | ||
| expect(nodeList.length, equals(1)); | ||
| final InputElement input = | ||
| document.getElementsByTagName('input')[0] as InputElement; | ||
| // The element's value will be the same as the textFormField's value. | ||
| expect(input.value, 'Text1'); | ||
|
|
||
| // Change the value of the TextFormField. | ||
| final TextFormField textFormField = tester.widget(finder); | ||
| textFormField.controller.text = 'New Value'; | ||
| // DOM element's value also changes. | ||
| expect(input.value, 'New Value'); | ||
| }); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // 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:io'; | ||
|
|
||
| import 'package:flutter_driver/flutter_driver.dart'; | ||
|
|
||
| Future<void> main() async { | ||
| final FlutterDriver driver = await FlutterDriver.connect(); | ||
|
|
||
| // TODO(nurhan): https://github.com/flutter/flutter/issues/51940 | ||
| final String dataRequest = | ||
| await driver.requestData(null, timeout: const Duration(seconds: 1)); | ||
| print('result $dataRequest'); | ||
| await driver.close(); | ||
|
|
||
| exit(dataRequest == 'pass' ? 0 : 1); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!DOCTYPE HTML> | ||
| <!-- Copyright 2014 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. --> | ||
| <html> | ||
| <head> | ||
| <title>Web Integration Tests</title> | ||
| </head> | ||
| <body> | ||
| <script src="main.dart.js"></script> | ||
| </body> | ||
| </html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you envision adding more integration tests? Are they supposed to be added here as another step in this
script:section or as a separate entry?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it depends on how these tests will develop. One thing to note is we are able to run these tests in 6 different browsers over 3 different OS. They might be using the same app to test or different apps.
However the setup is different for them (very different in some settings)
I'm planning to setup a meeting for next weeks to identify critical scenarios. If there are over 20 for Chrome Linux I think I will write script which can also be invoked from LUCI recipes.
If they all use the same app (let's say something comprehensive such as gallery) we can add a test runner.
On the other hand if they are all scattered between OSes and devices and apps then I am not planning to invest this tooling effort for each.
This example is particularly important to be as readable as possible cause other team members also asked me how to run integration tests from the engine.