add first test driver
This commit is contained in:
@@ -16,6 +16,9 @@ dependencies:
|
|||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_driver:
|
||||||
|
sdk: flutter
|
||||||
|
test: any
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import 'package:flutter_driver/driver_extension.dart';
|
||||||
|
|
||||||
|
import '../lib/single_conversation.dart' as app;
|
||||||
|
|
||||||
|
void main() async {
|
||||||
|
enableFlutterDriverExtension();
|
||||||
|
|
||||||
|
await app.main();
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter_driver/flutter_driver.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('Single conversation', () async {
|
||||||
|
final inputFinder = find.byValueKey('messageInputText');
|
||||||
|
final sendButtonFinder = find.byValueKey('sendButton');
|
||||||
|
final messageListViewFinder = find.byValueKey('messageListView');
|
||||||
|
|
||||||
|
FlutterDriver driver = await FlutterDriver.connect();
|
||||||
|
// Connect to the Flutter driver before running any tests.
|
||||||
|
|
||||||
|
await sleep(Duration(seconds: 5));
|
||||||
|
|
||||||
|
await driver.waitFor(inputFinder);
|
||||||
|
|
||||||
|
await driver.tap(inputFinder);
|
||||||
|
|
||||||
|
await sleep(Duration(seconds: 1));
|
||||||
|
|
||||||
|
await driver.enterText('hey');
|
||||||
|
|
||||||
|
await sleep(Duration(seconds: 1));
|
||||||
|
|
||||||
|
await driver.tap(sendButtonFinder);
|
||||||
|
|
||||||
|
await sleep(Duration(seconds: 1));
|
||||||
|
|
||||||
|
await driver.scroll(
|
||||||
|
messageListViewFinder,
|
||||||
|
0,
|
||||||
|
2000,
|
||||||
|
Duration(seconds: 1),
|
||||||
|
);
|
||||||
|
|
||||||
|
await sleep(Duration(seconds: 1));
|
||||||
|
|
||||||
|
// Close the connection to the driver after the tests have completed.
|
||||||
|
await sleep(Duration(seconds: 5));
|
||||||
|
if (driver != null) {
|
||||||
|
await driver.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -132,6 +132,7 @@ class _MessageInputState extends State<MessageInput> {
|
|||||||
Expanded _buildTextInput(BuildContext context) {
|
Expanded _buildTextInput(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
key: Key('messageInputText'),
|
||||||
minLines: null,
|
minLines: null,
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
onSubmitted: (_) {
|
onSubmitted: (_) {
|
||||||
@@ -524,6 +525,7 @@ class _MessageInputState extends State<MessageInput> {
|
|||||||
),
|
),
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
|
key: Key('sendButton'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_sendMessage(context);
|
_sendMessage(context);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
child: ListView.custom(
|
child: ListView.custom(
|
||||||
|
key: Key('messageListView'),
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
physics: AlwaysScrollableScrollPhysics(),
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
reverse: true,
|
reverse: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user