From cb020c00fe899599bbb002d4cbf66a113dc9c0cd Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Tue, 5 Feb 2019 14:35:36 +0100 Subject: [PATCH] Add the first integration test using the flutter driver We need to test the git operations on all the devices. --- lib/gitapp.dart | 4 ++-- pubspec.lock | 31 +++++++++++++++++++++++++++++++ pubspec.yaml | 2 ++ test_driver/git.dart | 11 +++++++++++ test_driver/git_test.dart | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 test_driver/git.dart create mode 100644 test_driver/git_test.dart diff --git a/lib/gitapp.dart b/lib/gitapp.dart index 7a6e0c14..0a899b29 100644 --- a/lib/gitapp.dart +++ b/lib/gitapp.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:journal/apis/git.dart'; - import 'package:journal/apis/git_migration.dart'; const basePath = "journal"; @@ -32,7 +31,8 @@ buildGitButtons() { RaisedButton( child: Text("Git Clone"), onPressed: () async { - gitClone("root@bcn.vhanda.in:git/test", basePath); + gitClone( + "git@github.com:GitJournal/GitJournal.github.io.git", basePath); }, ), RaisedButton( diff --git a/pubspec.lock b/pubspec.lock index 87687d70..c9214b1e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -94,6 +94,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.4" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.7" firebase_analytics: dependency: "direct main" description: @@ -113,6 +120,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.0" + flutter_driver: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" flutter_launcher_icons: dependency: "direct dev" description: @@ -132,6 +144,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.9+1" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" glob: dependency: transitive description: @@ -286,6 +303,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" plugin: dependency: transitive description: @@ -300,6 +324,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.4.0" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.9" pub_semver: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index cefadae3..507ef027 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,8 @@ dev_dependencies: test: ^1.5.1 flutter_test: sdk: flutter + flutter_driver: + sdk: flutter flutter: uses-material-design: true diff --git a/test_driver/git.dart b/test_driver/git.dart new file mode 100644 index 00000000..236dde7d --- /dev/null +++ b/test_driver/git.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_driver/driver_extension.dart'; +import 'package:journal/gitapp.dart'; +//import 'package:journal/apis/git.dart'; + +void main() { + // This line enables the extension + enableFlutterDriverExtension(); + + runApp(GitApp()); +} diff --git a/test_driver/git_test.dart b/test_driver/git_test.dart new file mode 100644 index 00000000..aa95d9a3 --- /dev/null +++ b/test_driver/git_test.dart @@ -0,0 +1,32 @@ +import 'package:flutter_driver/flutter_driver.dart'; +import 'package:test/test.dart'; + +void main() { + group('Git Test', () { + // First, define the Finders. We can use these to locate Widgets from the + // test suite. Note: the Strings provided to the `byValueKey` method must + // be the same as the Strings we used for the Keys in step 1. + // final counterTextFinder = find.byValueKey('counter'); + final buttonFinder = find.text('Git Clone'); + + FlutterDriver driver; + + // Connect to the Flutter driver before running any tests + setUpAll(() async { + driver = await FlutterDriver.connect(); + }); + + // Close the connection to the driver after the tests have completed + tearDownAll(() async { + if (driver != null) { + driver.close(); + } + }); + + test('Anonymous GitClone works', () async { + print(buttonFinder.finderType); + print(buttonFinder.serialize()); + await driver.tap(buttonFinder); + }); + }); +}