Skip to content

Commit fc5963d

Browse files
author
Nurhan Turgut
authored
[web] Engine integration test (flutter#16930)
* squashing the commits together * directory rename, project rename. addressing reviewer comments * update cirrus file * change tool signature
1 parent e1ba7a1 commit fc5963d

10 files changed

Lines changed: 292 additions & 1 deletion

File tree

.cirrus.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,27 @@ task:
124124
- name: web_tests-7_last-linux # last Web shard must end with _last
125125
<< : *WEB_SHARD_TEMPLATE
126126

127+
- name: web_engine_integration_test_linux
128+
compile_host_script: |
129+
cd $ENGINE_PATH/src
130+
./flutter/tools/gn --unoptimized --full-dart-sdk
131+
ninja -C out/host_debug_unopt
132+
fetch_framework_script: |
133+
cd $ENGINE_PATH/src/flutter/tools
134+
./clone_flutter.sh
135+
cd $FRAMEWORK_PATH/flutter
136+
bin/flutter update-packages --local-engine=host_debug_unopt
137+
script:
138+
- git clone https://github.com/flutter/web_installers.git
139+
- cd web_installers/packages/web_drivers/
140+
- $ENGINE_PATH/src/third_party/dart/tools/sdks/dart-sdk/bin/pub get
141+
- $ENGINE_PATH/src/third_party/dart/tools/sdks/dart-sdk/bin/dart lib/web_driver_installer.dart chromedriver --install-only
142+
- ./chromedriver/chromedriver --port=4444 &
143+
- cd $ENGINE_PATH/src/flutter/e2etests/web/regular_integration_tests
144+
- $FRAMEWORK_PATH/flutter/bin/flutter config --local-engine=host_debug_unopt --no-analytics --enable-web
145+
- $FRAMEWORK_PATH/flutter/bin/flutter pub get --local-engine=host_debug_unopt
146+
- $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
147+
127148
- name: build_and_test_web_linux_firefox
128149
compile_host_script: |
129150
cd $ENGINE_PATH/src

.gitignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,102 @@ xcuserdata
2929

3030
third_party/gn/
3131

32+
# Miscellaneous
33+
*.class
34+
*.lock
35+
*.log
36+
*.pyc
37+
*.swp
38+
.DS_Store
39+
.atom/
40+
.buildlog/
41+
.history
42+
.svn/
43+
44+
# IntelliJ related
45+
*.iml
46+
*.ipr
47+
*.iws
48+
.idea/
49+
50+
# Visual Studio Code related
51+
.classpath
52+
.project
53+
.settings/
54+
.vscode/
55+
56+
# packages file containing multi-root paths
57+
.packages.generated
58+
59+
# Flutter/Dart/Pub related
60+
**/doc/api/
61+
.dart_tool/
62+
.flutter-plugins
63+
.flutter-plugins-dependencies
64+
.packages
65+
.pub-cache/
66+
.pub/
67+
build/
68+
flutter_*.png
69+
linked_*.ds
70+
unlinked.ds
71+
unlinked_spec.ds
72+
73+
# Android related
74+
**/android/**/gradle-wrapper.jar
75+
**/android/.gradle
76+
**/android/captures/
77+
**/android/gradlew
78+
**/android/gradlew.bat
79+
**/android/local.properties
80+
**/android/**/GeneratedPluginRegistrant.java
81+
**/android/key.properties
82+
*.jks
83+
84+
# iOS/XCode related
85+
**/ios/**/*.mode1v3
86+
**/ios/**/*.mode2v3
87+
**/ios/**/*.moved-aside
88+
**/ios/**/*.pbxuser
89+
**/ios/**/*.perspectivev3
90+
**/ios/**/*sync/
91+
**/ios/**/.sconsign.dblite
92+
**/ios/**/.tags*
93+
**/ios/**/.vagrant/
94+
**/ios/**/DerivedData/
95+
**/ios/**/Icon?
96+
**/ios/**/Pods/
97+
**/ios/**/.symlinks/
98+
**/ios/**/profile
99+
**/ios/**/xcuserdata
100+
**/ios/.generated/
101+
**/ios/Flutter/App.framework
102+
**/ios/Flutter/Flutter.framework
103+
**/ios/Flutter/Flutter.podspec
104+
**/ios/Flutter/Generated.xcconfig
105+
**/ios/Flutter/app.flx
106+
**/ios/Flutter/app.zip
107+
**/ios/Flutter/flutter_assets/
108+
**/ios/Flutter/flutter_export_environment.sh
109+
**/ios/ServiceDefinitions.json
110+
**/ios/Runner/GeneratedPluginRegistrant.*
111+
112+
# macOS
113+
**/macos/Flutter/GeneratedPluginRegistrant.swift
114+
**/macos/Flutter/Flutter-Debug.xcconfig
115+
**/macos/Flutter/Flutter-Release.xcconfig
116+
**/macos/Flutter/Flutter-Profile.xcconfig
117+
118+
# Coverage
119+
coverage/
120+
121+
# Symbols
122+
app.*.symbols
123+
124+
# Exceptions to above rules.
125+
!**/ios/**/default.mode1v3
126+
!**/ios/**/default.mode2v3
127+
!**/ios/**/default.pbxuser
128+
!**/ios/**/default.perspectivev3
129+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
130+
!/dev/ci/**/Gemfile.lock

ci/licenses_golden/tool_signature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Signature: a0775818831a05f46ce1628c95d834c1
1+
Signature: 9ad4afaa43bd81d0e6a011688ca40377
22

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
```
2+
This directory is for Flutter Web engine integration tests that does not
3+
need a specific configuration. If an e2e test needs specialized app
4+
configuration (e.g. PWA vs non-PWA packaging), please create another
5+
directory under e2etests/web. Otherwise tests such as text_editing, history,
6+
scrolling, pointer events... should all go under this package.
7+
8+
# To run the application under test for traouble shooting purposes.
9+
flutter run -d web-server lib/text_editing_main.dart --local-engine=host_debug_unopt
10+
11+
# To run the Text Editing test and use the developer tools in the browser.
12+
flutter run --target=test_driver/text_editing_e2e.dart -d web-server --web-port=8080 --release --local-engine=host_debug_unopt
13+
14+
# To test the Text Editing test with driver:
15+
flutter drive -v --target=test_driver/text_editing_e2e.dart -d web-server --release --browser-name=chrome --local-engine=host_debug_unopt
16+
```
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/material.dart';
6+
7+
void main() => runApp(MyApp());
8+
9+
class MyApp extends StatelessWidget {
10+
@override
11+
Widget build(BuildContext context) {
12+
return MaterialApp(
13+
key: const Key('mainapp'),
14+
title: 'Integration Test App',
15+
home: MyHomePage(title: 'Integration Test App'),
16+
);
17+
}
18+
}
19+
20+
class MyHomePage extends StatefulWidget {
21+
MyHomePage({Key key, this.title}) : super(key: key);
22+
23+
final String title;
24+
25+
@override
26+
_MyHomePageState createState() => _MyHomePageState();
27+
}
28+
29+
class _MyHomePageState extends State<MyHomePage> {
30+
final TextEditingController _controller =
31+
TextEditingController(text: 'Text1');
32+
33+
@override
34+
Widget build(BuildContext context) {
35+
return Scaffold(
36+
appBar: AppBar(
37+
title: Text(widget.title),
38+
),
39+
body: Center(
40+
child: Column(
41+
mainAxisAlignment: MainAxisAlignment.center,
42+
children: <Widget>[
43+
const Text(
44+
'Text Editing Test',
45+
),
46+
TextFormField(
47+
key: const Key('input'),
48+
enabled: true,
49+
controller: _controller,
50+
//initialValue: 'Text1',
51+
decoration: const InputDecoration(
52+
labelText: 'Text Input Field:',
53+
),
54+
),
55+
],
56+
),
57+
),
58+
);
59+
}
60+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: regular_integration_tests
2+
publish_to: none
3+
4+
environment:
5+
sdk: ">=2.2.2 <3.0.0"
6+
7+
dependencies:
8+
flutter:
9+
sdk: flutter
10+
11+
dev_dependencies:
12+
flutter_driver:
13+
sdk: flutter
14+
flutter_test:
15+
sdk: flutter
16+
e2e: 0.2.4+4
17+
http: 0.12.0+2
18+
test: any
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:html';
6+
import 'package:flutter/services.dart';
7+
import 'package:flutter_test/flutter_test.dart';
8+
import 'package:regular_integration_tests/text_editing_main.dart' as app;
9+
import 'package:flutter/material.dart';
10+
11+
import 'package:e2e/e2e.dart';
12+
13+
void main() {
14+
E2EWidgetsFlutterBinding.ensureInitialized() as E2EWidgetsFlutterBinding;
15+
16+
testWidgets('Focused text field creates a native input element',
17+
(WidgetTester tester) async {
18+
app.main();
19+
await tester.pumpAndSettle();
20+
21+
// TODO(nurhan): https://github.com/flutter/flutter/issues/51885
22+
SystemChannels.textInput.setMockMethodCallHandler(null);
23+
24+
// Focus on a TextFormField.
25+
final Finder finder = find.byKey(const Key('input'));
26+
expect(finder, findsOneWidget);
27+
await tester.tap(find.byKey(const Key('input')));
28+
29+
// A native input element will be appended to the DOM.
30+
final List<Node> nodeList = document.getElementsByTagName('input');
31+
expect(nodeList.length, equals(1));
32+
final InputElement input =
33+
document.getElementsByTagName('input')[0] as InputElement;
34+
// The element's value will be the same as the textFormField's value.
35+
expect(input.value, 'Text1');
36+
37+
// Change the value of the TextFormField.
38+
final TextFormField textFormField = tester.widget(finder);
39+
textFormField.controller.text = 'New Value';
40+
// DOM element's value also changes.
41+
expect(input.value, 'New Value');
42+
});
43+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:io';
6+
7+
import 'package:flutter_driver/flutter_driver.dart';
8+
9+
Future<void> main() async {
10+
final FlutterDriver driver = await FlutterDriver.connect();
11+
12+
// TODO(nurhan): https://github.com/flutter/flutter/issues/51940
13+
final String dataRequest =
14+
await driver.requestData(null, timeout: const Duration(seconds: 1));
15+
print('result $dataRequest');
16+
await driver.close();
17+
18+
exit(dataRequest == 'pass' ? 0 : 1);
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE HTML>
2+
<!-- Copyright 2014 The Flutter Authors. All rights reserved.
3+
Use of this source code is governed by a BSD-style license that can be
4+
found in the LICENSE file. -->
5+
<html>
6+
<head>
7+
<title>Web Integration Tests</title>
8+
</head>
9+
<body>
10+
<script src="main.dart.js"></script>
11+
</body>
12+
</html>

tools/licenses/lib/main.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,9 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
930930
entry.name != 'tests' &&
931931
entry.name != 'javatests' &&
932932
entry.name != 'testing' &&
933+
// The directory that containts end to end tests.
934+
// Shoul be excluded from the licence checks.
935+
entry.name != 'e2etests' &&
933936
entry.name != '.dart_tool'; // Generated by various Dart tools, such as pub and
934937
// build_runner. Skip it because it does not contain
935938
// source code.

0 commit comments

Comments
 (0)