add first test driver
This commit is contained in:
@@ -16,6 +16,9 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_driver:
|
||||
sdk: flutter
|
||||
test: any
|
||||
|
||||
flutter:
|
||||
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) {
|
||||
return Expanded(
|
||||
child: TextField(
|
||||
key: Key('messageInputText'),
|
||||
minLines: null,
|
||||
maxLines: null,
|
||||
onSubmitted: (_) {
|
||||
@@ -524,6 +525,7 @@ class _MessageInputState extends State<MessageInput> {
|
||||
),
|
||||
color: Colors.transparent,
|
||||
child: IconButton(
|
||||
key: Key('sendButton'),
|
||||
onPressed: () {
|
||||
_sendMessage(context);
|
||||
},
|
||||
|
||||
@@ -108,6 +108,7 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
return true;
|
||||
},
|
||||
child: ListView.custom(
|
||||
key: Key('messageListView'),
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
controller: _scrollController,
|
||||
reverse: true,
|
||||
|
||||
Reference in New Issue
Block a user