forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] Engine integration test (flutter#16930)
* squashing the commits together * directory rename, project rename. addressing reviewer comments * update cirrus file * change tool signature
- Loading branch information
Nurhan Turgut
authored
Mar 6, 2020
1 parent
e1ba7a1
commit fc5963d
Showing
10 changed files
with
292 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Signature: a0775818831a05f46ce1628c95d834c1 | ||
Signature: 9ad4afaa43bd81d0e6a011688ca40377 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
60
e2etests/web/regular_integration_tests/lib/text_editing_main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:', | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
43 changes: 43 additions & 0 deletions
43
e2etests/web/regular_integration_tests/test_driver/text_editing_e2e.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
} |
19 changes: 19 additions & 0 deletions
19
e2etests/web/regular_integration_tests/test_driver/text_editing_e2e_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters