File tree 17 files changed +223
-46
lines changed
17 files changed +223
-46
lines changed Original file line number Diff line number Diff line change 6
6
dockerfile : .ci/Dockerfile
7
7
cpu : 8
8
8
memory : 16G
9
+ env :
10
+ E2E_PATH : " ./packages/e2e"
9
11
upgrade_script :
10
12
- flutter channel stable
11
13
- flutter upgrade
45
47
- if [[ "$CHANNEL" -eq "stable" ]]; then find . | grep _web$ | xargs rm -rf; fi
46
48
- flutter channel $CHANNEL
47
49
- ./script/build_all_plugins_app.sh apk
50
+ - name : e2e_web_smoke_test
51
+ # Tests e2e example test in web.
52
+ only_if : " changesInclude('.cirrus.yml', 'packages/e2e/**') || $CIRRUS_PR == ''"
53
+ install_script :
54
+ - flutter config --enable-web
55
+ - git clone https://github.com/flutter/web_installers.git
56
+ - cd web_installers/packages/web_drivers/
57
+ - pub get
58
+ - dart lib/web_driver_installer.dart chromedriver --install-only
59
+ - ./chromedriver/chromedriver --port=4444 &
60
+ test_script :
61
+ - cd $E2E_PATH/example/
62
+ - flutter drive -v --target=test_driver/example_e2e.dart -d web-server --release --browser-name=chrome
48
63
- name : build-apks+java-test+firebase-test-lab
49
64
env :
50
65
matrix :
Original file line number Diff line number Diff line change
1
+ ## 0.2.4+4
2
+
3
+ * Fixed a hang that occurred on platforms that don't have a ` MethodChannel ` listener registered..
4
+
1
5
## 0.2.4+3
2
6
3
7
* Fixed code snippet in the readme under the "Using Flutter driver to run tests" section.
Original file line number Diff line number Diff line change @@ -69,6 +69,15 @@ cd example
69
69
flutter drive --driver=test_driver/<package_name>_test.dart test/<package_name>_e2e.dart
70
70
```
71
71
72
+ You can run tests on web on release mode.
73
+
74
+ First you need to make sure you have downloaded the driver for the browser.
75
+
76
+ ```
77
+ cd example
78
+ flutter drive -v --target=test_driver/<package_name>dart -d web-server --release --browser-name=chrome
79
+ ```
80
+
72
81
## Android device testing
73
82
74
83
Create an instrumentation test file in your application's
Original file line number Diff line number Diff line change 1
- import 'dart:io' show Platform;
2
- import 'package:flutter/material.dart' ;
1
+ import 'my_app.dart' if (dart.library.html) 'my_web_app.dart' ;
3
2
4
3
// ignore_for_file: public_member_api_docs
5
4
6
- void main () => runApp (MyApp ());
7
-
8
- class MyApp extends StatefulWidget {
9
- @override
10
- _MyAppState createState () => _MyAppState ();
11
- }
12
-
13
- class _MyAppState extends State <MyApp > {
14
- @override
15
- Widget build (BuildContext context) {
16
- return MaterialApp (
17
- home: Scaffold (
18
- appBar: AppBar (
19
- title: const Text ('Plugin example app' ),
20
- ),
21
- body: Center (
22
- child: Text ('Platform: ${Platform .operatingSystem }\n ' ),
23
- ),
24
- ),
25
- );
26
- }
27
- }
5
+ void main () => startApp ();
Original file line number Diff line number Diff line change
1
+ import 'dart:io' show Platform;
2
+ import 'package:flutter/material.dart' ;
3
+
4
+ // ignore_for_file: public_member_api_docs
5
+
6
+ void startApp () => runApp (MyApp ());
7
+
8
+ class MyApp extends StatefulWidget {
9
+ @override
10
+ _MyAppState createState () => _MyAppState ();
11
+ }
12
+
13
+ class _MyAppState extends State <MyApp > {
14
+ @override
15
+ Widget build (BuildContext context) {
16
+ return MaterialApp (
17
+ home: Scaffold (
18
+ appBar: AppBar (
19
+ title: const Text ('Plugin example app' ),
20
+ ),
21
+ body: Center (
22
+ child: Text ('Platform: ${Platform .operatingSystem }\n ' ),
23
+ ),
24
+ ),
25
+ );
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ import 'dart:html' as html;
2
+ import 'package:flutter/material.dart' ;
3
+
4
+ // ignore_for_file: public_member_api_docs
5
+
6
+ void startApp () => runApp (MyWebApp ());
7
+
8
+ class MyWebApp extends StatefulWidget {
9
+ @override
10
+ _MyWebAppState createState () => _MyWebAppState ();
11
+ }
12
+
13
+ class _MyWebAppState extends State <MyWebApp > {
14
+ @override
15
+ Widget build (BuildContext context) {
16
+ return MaterialApp (
17
+ home: Scaffold (
18
+ appBar: AppBar (
19
+ title: const Text ('Plugin example app' ),
20
+ ),
21
+ body: Center (
22
+ key: Key ('mainapp' ),
23
+ child: Text ('Platform: ${html .window .navigator .platform }\n ' ),
24
+ ),
25
+ ),
26
+ );
27
+ }
28
+ }
Original file line number Diff line number Diff line change 5
5
// gestures. You can also use WidgetTester to find child widgets in the widget
6
6
// tree, read text, and verify that the values of widget properties are correct.
7
7
8
- import 'dart:io' show Platform;
9
- import 'package:flutter/material.dart' ;
10
- import 'package:flutter_test/flutter_test.dart' ;
11
8
import 'package:e2e/e2e.dart' ;
12
9
13
- import 'package:e2e_example/main.dart' ;
10
+ import 'example_e2e_io.dart' if (dart.library.html) 'example_e2e_web.dart'
11
+ as tests;
14
12
15
13
void main () {
16
14
E2EWidgetsFlutterBinding .ensureInitialized ();
17
- testWidgets ('verify text' , (WidgetTester tester) async {
18
- // Build our app and trigger a frame.
19
- await tester.pumpWidget (MyApp ());
20
-
21
- // Verify that platform version is retrieved.
22
- expect (
23
- find.byWidgetPredicate (
24
- (Widget widget) =>
25
- widget is Text &&
26
- widget.data.startsWith ('Platform: ${Platform .operatingSystem }' ),
27
- ),
28
- findsOneWidget,
29
- );
30
- });
15
+ tests.main ();
31
16
}
Original file line number Diff line number Diff line change
1
+ // This is a basic Flutter widget test.
2
+ //
3
+ // To perform an interaction with a widget in your test, use the WidgetTester
4
+ // utility that Flutter provides. For example, you can send tap and scroll
5
+ // gestures. You can also use WidgetTester to find child widgets in the widget
6
+ // tree, read text, and verify that the values of widget properties are correct.
7
+
8
+ import 'dart:io' show Platform;
9
+ import 'package:flutter/material.dart' ;
10
+ import 'package:flutter_test/flutter_test.dart' ;
11
+ import 'package:e2e/e2e.dart' ;
12
+
13
+ import 'package:e2e_example/main.dart' as app;
14
+
15
+ void main () {
16
+ E2EWidgetsFlutterBinding .ensureInitialized ();
17
+ testWidgets ('verify text' , (WidgetTester tester) async {
18
+ // Build our app and trigger a frame.
19
+ app.main ();
20
+
21
+ // Trigger a frame.
22
+ await tester.pumpAndSettle ();
23
+
24
+ // Verify that platform version is retrieved.
25
+ expect (
26
+ find.byWidgetPredicate (
27
+ (Widget widget) =>
28
+ widget is Text &&
29
+ widget.data.startsWith ('Platform: ${Platform .operatingSystem }' ),
30
+ ),
31
+ findsOneWidget,
32
+ );
33
+ });
34
+ }
Original file line number Diff line number Diff line change
1
+ // This is a basic Flutter widget test.
2
+ //
3
+ // To perform an interaction with a widget in your test, use the WidgetTester
4
+ // utility that Flutter provides. For example, you can send tap and scroll
5
+ // gestures. You can also use WidgetTester to find child widgets in the widget
6
+ // tree, read text, and verify that the values of widget properties are correct.
7
+
8
+ import 'dart:html' as html;
9
+ import 'package:flutter/material.dart' ;
10
+ import 'package:flutter_test/flutter_test.dart' ;
11
+ import 'package:e2e/e2e.dart' ;
12
+
13
+ import 'package:e2e_example/main.dart' as app;
14
+
15
+ void main () {
16
+ E2EWidgetsFlutterBinding .ensureInitialized ();
17
+ testWidgets ('verify text' , (WidgetTester tester) async {
18
+ // Build our app and trigger a frame.
19
+ app.main ();
20
+
21
+ // Trigger a frame.
22
+ await tester.pumpAndSettle ();
23
+
24
+ // Verify that platform is retrieved.
25
+ expect (
26
+ find.byWidgetPredicate (
27
+ (Widget widget) =>
28
+ widget is Text &&
29
+ widget.data
30
+ .startsWith ('Platform: ${html .window .navigator .platform }\n ' ),
31
+ ),
32
+ findsOneWidget,
33
+ );
34
+ });
35
+ }
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
6
6
import 'package:flutter_test/flutter_test.dart' ;
7
7
import 'package:e2e/e2e.dart' ;
8
8
9
- import 'package:e2e_example/main.dart' ;
9
+ import 'package:e2e_example/main.dart' as app ;
10
10
11
11
// Tests the failure behavior of the E2EWidgetsFlutterBinding
12
12
//
@@ -21,10 +21,10 @@ void main() {
21
21
22
22
testWidgets ('failure 1' , (WidgetTester tester) async {
23
23
// Build our app and trigger a frame.
24
- await tester. pumpWidget ( MyApp () );
24
+ app. main ( );
25
25
26
26
// Verify that platform version is retrieved.
27
- expect (
27
+ await expectLater (
28
28
find.byWidgetPredicate (
29
29
(Widget widget) =>
30
30
widget is Text && widget.data.startsWith ('This should fail' ),
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta content ="IE=Edge " http-equiv ="X-UA-Compatible ">
6
+ < meta name ="description " content ="A new Flutter project. ">
7
+
8
+ <!-- iOS meta tags & icons -->
9
+ < meta name ="apple-mobile-web-app-capable " content ="yes ">
10
+ < meta name ="apple-mobile-web-app-status-bar-style " content ="black ">
11
+ < meta name ="apple-mobile-web-app-title " content ="example ">
12
+ < link rel ="apple-touch-icon " href ="/icons/Icon-192.png ">
13
+
14
+ <!-- Favicon -->
15
+ < link rel ="shortcut icon " type ="image/png " href ="/favicon.png "/>
16
+
17
+ < title > example</ title >
18
+ < link rel ="manifest " href ="/manifest.json ">
19
+ </ head >
20
+ < body >
21
+ <!-- This script installs service_worker.js to provide PWA functionality to
22
+ application. For more information, see:
23
+ https://developers.google.com/web/fundamentals/primers/service-workers -->
24
+ < script >
25
+ if ( 'serviceWorker' in navigator ) {
26
+ window . addEventListener ( 'load' , function ( ) {
27
+ navigator . serviceWorker . register ( '/flutter_service_worker.js' ) ;
28
+ } ) ;
29
+ }
30
+ </ script >
31
+ < script src ="main.dart.js " type ="application/javascript "> </ script >
32
+ </ body >
33
+ </ html >
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " example" ,
3
+ "short_name" : " example" ,
4
+ "start_url" : " ." ,
5
+ "display" : " minimal-ui" ,
6
+ "background_color" : " #0175C2" ,
7
+ "theme_color" : " #0175C2" ,
8
+ "description" : " A new Flutter project." ,
9
+ "orientation" : " portrait-primary" ,
10
+ "prefer_related_applications" : false ,
11
+ "icons" : [
12
+ {
13
+ "src" : " icons/Icon-192.png" ,
14
+ "sizes" : " 192x192" ,
15
+ "type" : " image/png"
16
+ },
17
+ {
18
+ "src" : " icons/Icon-512.png" ,
19
+ "sizes" : " 512x512" ,
20
+ "type" : " image/png"
21
+ }
22
+ ]
23
+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding {
19
19
// TODO(jackson): Report test results as they arrive
20
20
tearDownAll (() async {
21
21
try {
22
+ // For web integration tests we are not using the
23
+ // `plugins.flutter.io/e2e`. Mark the tests as complete before invoking
24
+ // the channel.
25
+ if (kIsWeb) {
26
+ if (! _allTestsPassed.isCompleted) _allTestsPassed.complete (true );
27
+ }
22
28
await _channel.invokeMethod <void >(
23
29
'allTestsFinished' , < String , dynamic > {'results' : _results});
24
30
} on MissingPluginException {
Original file line number Diff line number Diff line change 1
1
name : e2e
2
2
description : Runs tests that use the flutter_test API as integration tests.
3
- version : 0.2.4+3
3
+ version : 0.2.4+4
4
4
homepage : https://github.com/flutter/plugins/tree/master/packages/e2e
5
5
6
6
environment :
You can’t perform that action at this time.
0 commit comments