Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor

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?

Copy link
Contributor Author

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.

- 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
- $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
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add running e2e tests into the felt tool? We do that already for unit-tests and goldens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
99 changes: 99 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,102 @@ xcuserdata

third_party/gn/

# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code related
.classpath
.project
.settings/
.vscode/

# packages file containing multi-root paths
.packages.generated

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
build/
flutter_*.png
linked_*.ds
unlinked.ds
unlinked_spec.ds

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
**/android/key.properties
*.jks

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# macOS
**/macos/Flutter/GeneratedPluginRegistrant.swift
**/macos/Flutter/Flutter-Debug.xcconfig
**/macos/Flutter/Flutter-Release.xcconfig
**/macos/Flutter/Flutter-Profile.xcconfig

# Coverage
coverage/

# Symbols
app.*.symbols

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/dev/ci/**/Gemfile.lock
2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: a0775818831a05f46ce1628c95d834c1
Signature: 9ad4afaa43bd81d0e6a011688ca40377

16 changes: 16 additions & 0 deletions e2etests/web/regular_integration_tests/README.md
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
```
60 changes: 60 additions & 0 deletions e2etests/web/regular_integration_tests/lib/text_editing_main.dart
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:',
),
),
],
),
),
);
}
}
18 changes: 18 additions & 0 deletions e2etests/web/regular_integration_tests/pubspec.yaml
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);
}
12 changes: 12 additions & 0 deletions e2etests/web/regular_integration_tests/web/index.html
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>
3 changes: 3 additions & 0 deletions tools/licenses/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,9 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
entry.name != 'tests' &&
entry.name != 'javatests' &&
entry.name != 'testing' &&
// The directory that containts end to end tests.
// Shoul be excluded from the licence checks.
entry.name != 'e2etests' &&
entry.name != '.dart_tool'; // Generated by various Dart tools, such as pub and
// build_runner. Skip it because it does not contain
// source code.
Expand Down