Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
647c213
- Created cloud_firestore_platform interface package
amrfarid140 Dec 14, 2019
9ed7d8c
- Created cloud_firestore_web package
amrfarid140 Dec 14, 2019
7fdd1c8
Created query interface
amrfarid140 Dec 15, 2019
14bad9c
created base QuerySnapshot
amrfarid140 Dec 16, 2019
552305d
organised platform_interface module
amrfarid140 Dec 16, 2019
63f3488
- created query_web
amrfarid140 Dec 16, 2019
9c7ea4a
- fixed method_channel_query_snapshot
amrfarid140 Dec 16, 2019
250f017
- implemented query_web
amrfarid140 Dec 16, 2019
dfaa02a
- delegated collection_reference_web to use query_web
amrfarid140 Dec 16, 2019
46349f6
- added firestore web to firestore package
amrfarid140 Dec 16, 2019
d731ecd
- create delegate for collection reference
amrfarid140 Dec 16, 2019
9ad5779
- create delegate for document related items
amrfarid140 Dec 16, 2019
8557df2
- create delegate for transaction and query
amrfarid140 Dec 16, 2019
fa06657
delegate cloud_firestore to abstract types
amrfarid140 Dec 17, 2019
993b86a
- added method_channel_firestore_test
amrfarid140 Dec 17, 2019
2a160d5
Use support multiple apps in FirestoreWeb
amrfarid140 Dec 17, 2019
3e24ca2
added transaction implementation
amrfarid140 Dec 17, 2019
76037e7
updated readmes
amrfarid140 Dec 17, 2019
e1f1591
Merge pull request #1 from amrfarid140/feature/firestore_web_support
amrfarid140 Dec 17, 2019
ffb12cd
fixed copy typo on readme
amrfarid140 Dec 17, 2019
c30f1f7
- Added change log
amrfarid140 Dec 17, 2019
65984ff
Added support for field value
amrfarid140 Dec 18, 2019
ec595fe
Build example for web and mobile
amrfarid140 Dec 18, 2019
aa7d422
Support new FieldValueInterface on mobile
amrfarid140 Dec 18, 2019
082baa3
Fix query delegation on web
amrfarid140 Dec 18, 2019
61cc5b1
Use PlaformUtils for conversions in DocumentChange
amrfarid140 Dec 18, 2019
aa3089e
Fixed typo in variable name
amrfarid140 Dec 18, 2019
2d3e712
Pass timeout value for transaction
amrfarid140 Dec 18, 2019
abed99e
Delete unused cloud_firestore/firestore_message_codec
amrfarid140 Dec 18, 2019
269d71e
removed unused imports
amrfarid140 Dec 18, 2019
d820fbc
removed empty constructor
amrfarid140 Dec 18, 2019
685d168
Fixed argument name
amrfarid140 Dec 18, 2019
c618131
Addressed comments for cloud_firestore_platform_interface setup
amrfarid140 Dec 18, 2019
874fdfb
Use cast
amrfarid140 Dec 18, 2019
124501e
Add timeout to web transaction
amrfarid140 Dec 18, 2019
3f182de
Fixed cloud_firestore_web version
amrfarid140 Dec 18, 2019
8b93dfa
Improved Query code and added documentation for main interface classes
amrfarid140 Dec 18, 2019
b2e46f1
Minor PR fixes
amrfarid140 Dec 18, 2019
98bfeb2
Fixed current analyze and fmt issues
amrfarid140 Dec 18, 2019
dc3e4cc
Fix message codec to run transaction on mobile
amrfarid140 Dec 19, 2019
b7cb9a3
Fix transaction writes on mobile and web
amrfarid140 Dec 19, 2019
05584ed
Updated example to showcase transactions
amrfarid140 Dec 19, 2019
b74bd77
PR feedback fixes
amrfarid140 Dec 19, 2019
0e261aa
Added write batch support
amrfarid140 Dec 19, 2019
d73dcce
Formatting
amrfarid140 Dec 19, 2019
0bfd691
Fix write batch examples
amrfarid140 Dec 19, 2019
3c7faa0
Added comments to match existing API level documentation
amrfarid140 Dec 19, 2019
dab85d2
Avoid setting host and ssl if either is null
amrfarid140 Dec 19, 2019
b23805c
Bug fixes for QueryWeb and CollectionWeb
amrfarid140 Dec 19, 2019
6632ae7
Added support for handling Blob and GeoPoint
amrfarid140 Dec 19, 2019
e74a230
Started code utility stuff
amrfarid140 Dec 19, 2019
3932bdf
Handle maps and arrays for codec conversions
amrfarid140 Dec 19, 2019
67574b1
Removed cupertino import
amrfarid140 Dec 19, 2019
7cd3c13
Lazily load Firestore instances
amrfarid140 Dec 19, 2019
64392c4
PR Feedback fixes
amrfarid140 Dec 19, 2019
9967067
Use PlatformInterface to check for verify implementation
amrfarid140 Dec 20, 2019
164b8b5
removed comments on analysis file
amrfarid140 Dec 20, 2019
b6050f9
removed todo as its not a client side logic
amrfarid140 Dec 20, 2019
762daae
Removed ensureInitialized() call
amrfarid140 Dec 20, 2019
2082303
Added null checks for codec_utility
amrfarid140 Dec 20, 2019
d3c65ad
Use setUpAll for test
amrfarid140 Dec 20, 2019
a2623e1
Use toList()
amrfarid140 Dec 20, 2019
73627b6
Added platform_interface/document_reference_test.dart
amrfarid140 Dec 20, 2019
f77739d
Added platform_interface field value test
amrfarid140 Dec 20, 2019
ef5d223
Fixed method_channel_document_reference
amrfarid140 Dec 20, 2019
3e70296
Add comments on public functions for field_value_factory
amrfarid140 Dec 20, 2019
103f534
added platform_interface_query_test
amrfarid140 Dec 20, 2019
8513162
Added unit tests for method channel document and collection reference
amrfarid140 Dec 20, 2019
efa315d
added snapshot() unit test for document reference
amrfarid140 Dec 20, 2019
b4fa2db
Added method_channel_field_value_factory_test
amrfarid140 Dec 20, 2019
afd6b0e
added transaction unit test
amrfarid140 Dec 20, 2019
8860659
Separated common testing logic
amrfarid140 Dec 20, 2019
cc2af37
use serve delegates in transaction
amrfarid140 Dec 20, 2019
ade9dbf
use serve delegates in write batch
amrfarid140 Dec 20, 2019
98d021e
Formatting changes
amrfarid140 Dec 20, 2019
6491ade
Started firestore_web tests
amrfarid140 Dec 20, 2019
77f4318
Completed collection_reference_web_test
amrfarid140 Dec 20, 2019
118780d
Avoid storing non-default Firestore app as static instance
amrfarid140 Dec 21, 2019
e4519d4
Fixed method_channel_transaction
amrfarid140 Dec 21, 2019
e26a812
Check for null data in codec_utility
amrfarid140 Dec 21, 2019
f8bc035
Unit test firestore_web
amrfarid140 Dec 21, 2019
4b79e26
Fix typo
amrfarid140 Dec 21, 2019
5391128
Fix analyze issues
amrfarid140 Dec 21, 2019
d3e60d5
Added firestore_web codec_utility_test
amrfarid140 Dec 21, 2019
cac92e2
Added test for field factory web
amrfarid140 Dec 22, 2019
207cc23
unit tested get document for QueryWeb
amrfarid140 Dec 22, 2019
5accb7a
Added more unit tests for QueryWeb
amrfarid140 Dec 22, 2019
ac1907d
Formatted code
amrfarid140 Dec 22, 2019
7c2ff05
Added public methods documentation
amrfarid140 Dec 22, 2019
37f7bd0
added TransactionWeb unit test
amrfarid140 Dec 22, 2019
a771d88
Added WriteBatchTest
amrfarid140 Dec 22, 2019
49edada
Added visiblefortesting annotation
amrfarid140 Dec 23, 2019
50ef0f1
Fix analyzer
amrfarid140 Dec 23, 2019
566e011
Delete unnecessary timestamp.dart
amrfarid140 Jan 3, 2020
b2b445c
Handle DateTime to Timestamp conversion for web
amrfarid140 Jan 3, 2020
9b786db
Use codec_utility across web
amrfarid140 Jan 3, 2020
24adc0c
Avoid building unnecessary instances of FirebaseApp
amrfarid140 Jan 3, 2020
19b094c
Added platform interface updates
amrfarid140 Jan 8, 2020
abacb4c
Add latest update for platform_interface
amrfarid140 Jan 8, 2020
e7204f2
Use platform interface types in cloud_firestore
amrfarid140 Jan 17, 2020
5bcaa82
removed material import from firestore_web
amrfarid140 Jan 17, 2020
09aa7ff
Fixed documentation comments
amrfarid140 Jan 17, 2020
b09cd24
Added comment on the purpose of lazy init of Firestore delegate
amrfarid140 Jan 17, 2020
7428da2
Separate Platform Interface source from Method Channel.
ditman Jan 27, 2020
06242c8
Start fixing imports
ditman Jan 27, 2020
52008c6
Moved some more
ditman Jan 27, 2020
5be6db8
Some more moving
ditman Jan 27, 2020
91ed554
Fix imports after moving files around. Interface should be identical …
ditman Jan 27, 2020
3c207c1
Make all platform_interface classes names consistent.
collinjackson Jan 29, 2020
182d2ae
Ensure platform interfaces can only be extended, not implemented.
collinjackson Jan 29, 2020
082ae1d
MethodChannelFieldValueFactory now extends FieldValueFactoryPlatform
ditman Jan 29, 2020
e7be32a
.appName() -> .app.name
collinjackson Jan 29, 2020
b036a96
Ensure PlatformInterface _delegate classes extend the Platform class,
collinjackson Jan 29, 2020
c2c75d0
Get web going again...
ditman Jan 30, 2020
3214bb1
Remove unneeded mocking on app.name so web tests pass again.
ditman Jan 30, 2020
8a1e1c8
Add token verification to instances of FieldValueFactoryPlatform.
ditman Jan 30, 2020
f68b5ea
Use FieldValuePlatform instead of FieldValueInterface. Ensure it's "e…
ditman Jan 31, 2020
6f4d042
Docs update
collinjackson Feb 1, 2020
5b80b50
Merge pull request #60 from collinjackson/amr-master-pr-2
ditman Feb 1, 2020
9dcc1c9
Hide most of the API surface from cloud_firestore_web.
ditman Feb 1, 2020
8b95bc9
Hide _webFirestore
collinjackson Feb 1, 2020
b7b5fc9
Moving some more stuff around
ditman Feb 1, 2020
bd96dde
Hide the MethodChannel implementation from the world.
ditman Feb 1, 2020
15dd903
analyze + dartfmt
ditman Feb 3, 2020
e8fe1a6
Hide FieldPathType from the world, since it's only used by MethodChan…
ditman Feb 3, 2020
2b4cde2
Use import/export instead of part in cloud_firestore_platform_interfa…
ditman Feb 3, 2020
e40a1c3
Add copyright notices everywhere.
ditman Feb 4, 2020
6f74929
Ensure FieldValue extends Platform, not implements.
ditman Feb 4, 2020
192ad66
Remove implements web.FieldValue from FieldValueWeb, since the
ditman Feb 4, 2020
ff5561e
Remove `serverDelegates` from `FieldValuePlatform`, and convert to a
ditman Feb 4, 2020
b4de785
dartfmt
ditman Feb 4, 2020
d69f67e
Remove appName() from FirestorePlatform.
ditman Feb 4, 2020
7009ef6
Use Source and DocumentChangeType enums from PlatformInterface.
ditman Feb 4, 2020
3b30165
Transaction constructor is properly public, not visibleForTesting. da…
ditman Feb 4, 2020
926ba55
Do not export auto_id_generator from PlatformInterface.
ditman Feb 4, 2020
4cb361c
Remove as much logic as possible from FieldValue instances.
ditman Feb 4, 2020
7c92e7c
FieldValue now internally stores the platform-dependent value.
ditman Feb 5, 2020
542a8e3
Merge pull request #2 from amrfarid140/amr-master-pr
amrfarid140 Feb 5, 2020
12277b0
Merge branch 'master' of github.com:FirebaseExtended/flutterfire and …
amrfarid140 Feb 5, 2020
00e04ed
Merge branch 'master' of github.com:FirebaseExtended/flutterfire
amrfarid140 Feb 6, 2020
48e5ba3
Use published version of `cloud_firestore_platform_interface`
amrfarid140 Feb 6, 2020
e192292
Merge branch 'master' of github.com:FirebaseExtended/flutterfire
amrfarid140 Feb 11, 2020
c7a4647
updated readme to indicate cloud_firestore web implementation status
amrfarid140 Feb 11, 2020
684ad09
removed already deleted file
amrfarid140 Feb 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
FieldValue now internally stores the platform-dependent value.
Refactor tests and code around the new API.
  • Loading branch information
ditman committed Feb 5, 2020
commit 7c92e7c808f6d56b77d0bf824187950dff0a8d29
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_inte
import 'package:firebase_core/firebase_core.dart';

export 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart'
show
FieldPath,
FieldValuePlatform,
Blob,
GeoPoint,
Timestamp,
Source,
DocumentChangeType;
show FieldPath, Blob, GeoPoint, Timestamp, Source, DocumentChangeType;

part 'src/collection_reference.dart';
part 'src/document_change.dart';
Expand Down
26 changes: 15 additions & 11 deletions packages/cloud_firestore/cloud_firestore/lib/src/field_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,43 @@ part of cloud_firestore;
/// This class serves as a static factory for FieldValuePlatform instances, but also
/// as a Facade for the Fieldvalue type, so plugin users don't need to worry about
/// the actual internal implementation of their Fieldvalues, after they're created.
class FieldValue {
static final platform.FieldValueFactoryPlatform _delegate =
class FieldValue extends platform.FieldValuePlatform {
static final platform.FieldValueFactoryPlatform _factory =
platform.FieldValueFactoryPlatform.instance;

FieldValue._(platform.FieldValuePlatform delegate) : super(delegate) {
platform.FieldValuePlatform.verifyExtends(delegate);
}

/// Returns a special value that tells the server to union the given elements
/// with any array value that already exists on the server.
///
/// Each specified element that doesn't already exist in the array will be
/// added to the end. If the field being modified is not already an array it
/// will be overwritten with an array containing exactly the specified
/// elements.
static platform.FieldValuePlatform arrayUnion(List<dynamic> elements) =>
_delegate.arrayUnion(elements);
static FieldValue arrayUnion(List<dynamic> elements) =>
FieldValue._(_factory.arrayUnion(elements));

/// Returns a special value that tells the server to remove the given
/// elements from any array value that already exists on the server.
///
/// All instances of each element specified will be removed from the array.
/// If the field being modified is not already an array it will be overwritten
/// with an empty array.
static platform.FieldValuePlatform arrayRemove(List<dynamic> elements) =>
_delegate.arrayRemove(elements);
static FieldValue arrayRemove(List<dynamic> elements) =>
FieldValue._(_factory.arrayRemove(elements));

/// Returns a sentinel for use with update() to mark a field for deletion.
static platform.FieldValuePlatform delete() => _delegate.delete();
static FieldValue delete() => FieldValue._(_factory.delete());

/// Returns a sentinel for use with set() or update() to include a
/// server-generated timestamp in the written data.
static platform.FieldValuePlatform serverTimestamp() =>
_delegate.serverTimestamp();
static FieldValue serverTimestamp() =>
FieldValue._(_factory.serverTimestamp());

/// Returns a special value for use with set() or update() that tells the
/// server to increment the field’s current value by the given value.
static platform.FieldValuePlatform increment(num value) =>
_delegate.increment(value);
static FieldValue increment(num value) =>
FieldValue._(_factory.increment(value));
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MethodChannelFirestore extends FirestorePlatform {
static bool _initialized = false;

/// The [MethodChannel] used to communicate with the native plugin
static const MethodChannel channel = MethodChannel(
static MethodChannel channel = MethodChannel(
'plugins.flutter.io/cloud_firestore',
StandardMethodCodec(FirestoreMessageCodec()),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ class FirestoreMessageCodec extends StandardMessageCodec {
buffer.putUint8(_kBlob);
writeSize(buffer, value.bytes.length);
buffer.putUint8List(value.bytes);
} else if (value is MethodChannelFieldValue) {
final int code = _kFieldValueCodes[value.type];
} else if (value is FieldValuePlatform) {
MethodChannelFieldValue delegate = FieldValuePlatform.getDelegate(value);
final int code = _kFieldValueCodes[delegate.type];
assert(code != null);
buffer.putUint8(code);
if (value.value != null) writeValue(buffer, value.value);
if (delegate.value != null) writeValue(buffer, delegate.value);
} else if (value is FieldPath) {
final int code = _kFieldPathCodes[value.type];
assert(code != null);
Expand Down Expand Up @@ -107,24 +108,16 @@ class FirestoreMessageCodec extends StandardMessageCodec {
final int length = readSize(buffer);
final List<int> bytes = buffer.getUint8List(length);
return Blob(bytes);
case _kDocumentId:
return FieldPath.documentId;
case _kArrayUnion:
final List<dynamic> value = readValue(buffer);
return FieldValueFactoryPlatform.instance.arrayUnion(value);
case _kArrayRemove:
final List<dynamic> value = readValue(buffer);
return FieldValueFactoryPlatform.instance.arrayRemove(value);
case _kDelete:
return FieldValueFactoryPlatform.instance.delete();
case _kServerTimestamp:
return FieldValueFactoryPlatform.instance.serverTimestamp();
case _kIncrementDouble:
final double value = readValue(buffer);
return FieldValueFactoryPlatform.instance.increment(value);
case _kIncrementInteger:
final int value = readValue(buffer);
return FieldValueFactoryPlatform.instance.increment(value);
case _kDocumentId:
return FieldPath.documentId;
// These cases are only needed on tests, and therefore handled
// by [TestFirestoreMessageCodec], a subclass of this codec.
default:
return super.readValueOfType(type, buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,26 @@ abstract class FieldValueFactoryPlatform extends PlatformInterface {
/// never "peek" inside subclasses of this.
///
/// Just treat it as a "black box".
abstract class FieldValuePlatform extends PlatformInterface {
class FieldValuePlatform extends PlatformInterface {
static final Object _token = Object();

/// Constructor
FieldValuePlatform() : super(token: _token);
FieldValuePlatform([this._delegate]) : super(token: _token);

final FieldValuePlatform _delegate;

/// Throws an [AssertionError] if [instance] does not extend
/// [FieldValuePlatform].
///
/// This is used by the app-facing [FieldValue] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static verifyExtends(FieldValuePlatform instance) {
PlatformInterface.verifyToken(instance, _token);
}

/// Used by platform implementers to obtain a value suitable for being passed
/// through to the underlying implementation.
static dynamic getDelegate(FieldValuePlatform fieldValue) =>
fieldValue._delegate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart';
import 'package:flutter_test/flutter_test.dart';

import 'test_common.dart';

const _kCollectionId = "test";
const _kDocumentId = "document";

Expand All @@ -14,7 +16,8 @@ class TestDocumentReference extends DocumentReferencePlatform {
}

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
initializeMethodChannel();

group("$DocumentReferencePlatform()", () {
test("Parent", () {
final document = TestDocumentReference._();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ import 'package:cloud_firestore_platform_interface/src/method_channel/method_cha
import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_field_value.dart';
import 'package:cloud_firestore_platform_interface/src/method_channel/utils/firestore_message_codec.dart';

import 'test_common.dart';
import 'test_firestore_message_codec.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
initializeMethodChannel();

group('$MethodChannelFirestore()', () {
group('MethodChannelFirestore()', () {
int mockHandleId = 0;
FirebaseApp app;
MethodChannelFirestore firestore;
Expand Down Expand Up @@ -1159,18 +1162,50 @@ void main() {
});

test('encode and decode FieldValue', () {
const MessageCodec<dynamic> decoder = TestFirestoreMessageCodec();

_checkEncodeDecode<dynamic>(
codec, FieldValueFactoryPlatform.instance.arrayUnion(<int>[123]));
codec,
FieldValuePlatform(
FieldValueFactoryPlatform.instance.arrayUnion(<int>[123]),
),
decodingCodec: decoder,
);
_checkEncodeDecode<dynamic>(
codec, FieldValueFactoryPlatform.instance.arrayRemove(<int>[123]));
codec,
FieldValuePlatform(
FieldValueFactoryPlatform.instance.arrayRemove(<int>[123]),
),
decodingCodec: decoder,
);
_checkEncodeDecode<dynamic>(
codec, FieldValueFactoryPlatform.instance.delete());
codec,
FieldValuePlatform(
FieldValueFactoryPlatform.instance.delete(),
),
decodingCodec: decoder,
);
_checkEncodeDecode<dynamic>(
codec, FieldValueFactoryPlatform.instance.serverTimestamp());
codec,
FieldValuePlatform(
FieldValueFactoryPlatform.instance.serverTimestamp(),
),
decodingCodec: decoder,
);
_checkEncodeDecode<dynamic>(
codec, FieldValueFactoryPlatform.instance.increment(1.0));
codec,
FieldValuePlatform(
FieldValueFactoryPlatform.instance.increment(1.0),
),
decodingCodec: decoder,
);
_checkEncodeDecode<dynamic>(
codec, FieldValueFactoryPlatform.instance.increment(1));
codec,
FieldValuePlatform(
FieldValueFactoryPlatform.instance.increment(1),
),
decodingCodec: decoder,
);
});

test('encode and decode FieldPath', () {
Expand Down Expand Up @@ -1381,9 +1416,15 @@ void main() {
});
}

void _checkEncodeDecode<T>(MessageCodec<T> codec, T message) {
void _checkEncodeDecode<T>(
MessageCodec<T> codec,
T message, {
MessageCodec<T> decodingCodec,
}) {
MessageCodec<T> decoder = decodingCodec ?? codec;

final ByteData encoded = codec.encodeMessage(message);
final T decoded = codec.decodeMessage(encoded);
final T decoded = decoder.decodeMessage(encoded);
if (message == null) {
expect(encoded, isNull);
expect(decoded, isNull);
Expand All @@ -1404,8 +1445,8 @@ bool _deepEquals(dynamic valueA, dynamic valueB) {
if (valueA is List) return valueB is List && _deepEqualsList(valueA, valueB);
if (valueA is Map) return valueB is Map && _deepEqualsMap(valueA, valueB);
if (valueA is double && valueA.isNaN) return valueB is double && valueB.isNaN;
if (valueA is MethodChannelFieldValue) {
return valueB is MethodChannelFieldValue &&
if (valueA is FieldValuePlatform) {
return valueB is FieldValuePlatform &&
_deepEqualsFieldValue(valueA, valueB);
}
if (valueA is FieldPath) {
Expand Down Expand Up @@ -1456,10 +1497,10 @@ bool _deepEqualsMap(
return true;
}

bool _deepEqualsFieldValue(
MethodChannelFieldValue valueA,
MethodChannelFieldValue valueB,
) {
bool _deepEqualsFieldValue(FieldValuePlatform a, FieldValuePlatform b) {
MethodChannelFieldValue valueA = FieldValuePlatform.getDelegate(a);
MethodChannelFieldValue valueB = FieldValuePlatform.getDelegate(b);

if (valueA.type != valueB.type) return false;
if (valueA.value == null) return valueB.value == null;
if (valueA.value is List) return _deepEqualsList(valueA.value, valueB.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart';
import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_collection_reference.dart';

import 'test_common.dart';

const _kCollectionId = "test";
const _kDocumentId = "document";

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
initializeMethodChannel();

group("$MethodChannelCollectionReference", () {
MethodChannelCollectionReference _testCollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:cloud_firestore_platform_interface/src/method_channel/method_cha
import 'test_common.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
initializeMethodChannel();

group("$MethodChannelDocumentReference()", () {
MethodChannelDocumentReference _documentReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:flutter_test/flutter_test.dart';

import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_query.dart';

import 'test_common.dart';

const _kQueryPath = "test/collection";

class TestQuery extends MethodChannelQuery {
Expand All @@ -17,7 +19,8 @@ class TestQuery extends MethodChannelQuery {
}

void main() {
TestWidgetsFlutterBinding.ensureInitialized();
initializeMethodChannel();

group("$QueryPlatform()", () {
test("parameters", () {
_hasDefaultParameters(TestQuery._().parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,23 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart';
import 'test_firestore_message_codec.dart';

typedef MethodCallCallback = dynamic Function(MethodCall methodCall);

const kCollectionId = "test";
const kDocumentId = "document";

void initializeMethodChannel() {
// Install the Codec that is able to decode FieldValues.
MethodChannelFirestore.channel = MethodChannel(
'plugins.flutter.io/cloud_firestore',
StandardMethodCodec(TestFirestoreMessageCodec()),
);

TestWidgetsFlutterBinding.ensureInitialized();
}

void handleMethodCall(MethodCallCallback methodCallCallback) =>
MethodChannelFirestore.channel.setMockMethodCallHandler((call) async {
expect(
Expand Down
Loading