From 6aef3754109d91a758c3b56c1a6290554478304d Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Fri, 15 Mar 2019 11:38:15 -0700 Subject: [PATCH] [cloud_firestore] fix NoSuchMethodError regression and add test (#1345) Fix cloud_firestore regression and add test --- packages/cloud_firestore/CHANGELOG.md | 5 +++ packages/cloud_firestore/example/pubspec.yaml | 5 +++ .../example/test_driver/cloud_firestore.dart | 34 +++++++++++++++++++ .../test_driver/cloud_firestore_test.dart | 10 ++++++ .../ios/Classes/CloudFirestorePlugin.m | 2 +- packages/cloud_firestore/pubspec.yaml | 5 ++- 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 packages/cloud_firestore/example/test_driver/cloud_firestore.dart create mode 100644 packages/cloud_firestore/example/test_driver/cloud_firestore_test.dart diff --git a/packages/cloud_firestore/CHANGELOG.md b/packages/cloud_firestore/CHANGELOG.md index a0033d45bd89..39a58e8e2225 100644 --- a/packages/cloud_firestore/CHANGELOG.md +++ b/packages/cloud_firestore/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.9.7 + +* Fixes a NoSuchMethodError when using getDocuments on iOS (introduced in 0.9.6). +* Adds a driver test for getDocuments. + ## 0.9.6 * On iOS, update null checking to match the recommended pattern usage in the Firebase documentation. diff --git a/packages/cloud_firestore/example/pubspec.yaml b/packages/cloud_firestore/example/pubspec.yaml index 09f65bbeb5db..7180f0d9b9dc 100755 --- a/packages/cloud_firestore/example/pubspec.yaml +++ b/packages/cloud_firestore/example/pubspec.yaml @@ -8,5 +8,10 @@ dependencies: path: ../ firebase_core: "^0.3.0" +dev_dependencies: + flutter_driver: + sdk: flutter + test: any + flutter: uses-material-design: true diff --git a/packages/cloud_firestore/example/test_driver/cloud_firestore.dart b/packages/cloud_firestore/example/test_driver/cloud_firestore.dart new file mode 100644 index 000000000000..c56444543d81 --- /dev/null +++ b/packages/cloud_firestore/example/test_driver/cloud_firestore.dart @@ -0,0 +1,34 @@ +import 'dart:async'; +import 'package:flutter_driver/driver_extension.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_core/firebase_core.dart'; + +void main() { + final Completer completer = Completer(); + enableFlutterDriverExtension(handler: (_) => completer.future); + tearDownAll(() => completer.complete(null)); + + group('$Firestore', () { + Firestore firestore; + + setUp(() async { + final FirebaseApp app = await FirebaseApp.configure( + name: 'test', + options: const FirebaseOptions( + googleAppID: '1:79601577497:ios:5f2bcc6ba8cecddd', + gcmSenderID: '79601577497', + apiKey: 'AIzaSyArgmRGfB5kiQT6CunAOmKRVKEsxKmy6YI-G72PVU', + projectID: 'flutter-firestore', + ), + ); + firestore = Firestore(app: app); + }); + + test('getDocuments', () async { + final CollectionReference reference = firestore.collection('messages'); + final QuerySnapshot snapshot = await reference.getDocuments(); + expect(snapshot.documents.length, isNonZero); + }); + }); +} diff --git a/packages/cloud_firestore/example/test_driver/cloud_firestore_test.dart b/packages/cloud_firestore/example/test_driver/cloud_firestore_test.dart new file mode 100644 index 000000000000..314b54af921d --- /dev/null +++ b/packages/cloud_firestore/example/test_driver/cloud_firestore_test.dart @@ -0,0 +1,10 @@ +import 'package:flutter_driver/flutter_driver.dart'; +import 'package:test/test.dart'; + +void main() { + test('CloudFirestore driver test', () async { + final FlutterDriver driver = await FlutterDriver.connect(); + await driver.requestData(null, timeout: const Duration(minutes: 1)); + driver.close(); + }); +} diff --git a/packages/cloud_firestore/ios/Classes/CloudFirestorePlugin.m b/packages/cloud_firestore/ios/Classes/CloudFirestorePlugin.m index 9f100a70aa01..22cd18a08d13 100644 --- a/packages/cloud_firestore/ios/Classes/CloudFirestorePlugin.m +++ b/packages/cloud_firestore/ios/Classes/CloudFirestorePlugin.m @@ -450,7 +450,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result } [query getDocumentsWithCompletion:^(FIRQuerySnapshot *_Nullable snapshot, NSError *_Nullable error) { - if (snapshot != nil) { + if (snapshot == nil) { result(getFlutterError(error)); return; } diff --git a/packages/cloud_firestore/pubspec.yaml b/packages/cloud_firestore/pubspec.yaml index 4e23ccadf1e7..f4b9318a6529 100755 --- a/packages/cloud_firestore/pubspec.yaml +++ b/packages/cloud_firestore/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Cloud Firestore, a cloud-hosted, noSQL database live synchronization and offline support on Android and iOS. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_firestore -version: 0.9.6 +version: 0.9.7 flutter: plugin: @@ -21,6 +21,9 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_driver: + sdk: flutter + test: any environment: sdk: ">=2.0.0-dev.28.0 <3.0.0"