mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-10 22:45:59 +05:45
Basically a port of https://github.com/firebase/firebase-js-sdk/commit/a1e346ff93c6cbcc0a1b3b33f0fbc3a7b66e7e12 and https://github.com/firebase/firebase-js-sdk/commit/fce4168309f42aa038125f39818fbf654b65b05f * Introduces a DelayedCallback helper class in FSTDispatchQueue to encapsulate delayed callback logic. * Adds cancellation support. * Updates the idle timer in FSTStream to use new cancellation support. * Adds a FSTTimerId enum for identifying delayed operations on the queue and uses it to identify our existing backoff and idle timers. * Added containsDelayedCallback: and runDelayedCallbacksUntil: methods to FSTDispatchQueue which can be used from tests to check for the presence of a callback or to schedule them to run early. * Removes FSTTestDispatchQueue and changes idle tests to use new test methods.
114 lines
3.7 KiB
Objective-C
114 lines
3.7 KiB
Objective-C
/*
|
|
* Copyright 2017 Google
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <XCTest/XCTest.h>
|
|
|
|
#import "Firestore/Example/Tests/Util/XCTestCase+Await.h"
|
|
#import "Firestore/Source/Core/FSTTypes.h"
|
|
|
|
@class FIRCollectionReference;
|
|
@class FIRDocumentSnapshot;
|
|
@class FIRDocumentReference;
|
|
@class FIRQuerySnapshot;
|
|
@class FIRFirestore;
|
|
@class FIRFirestoreSettings;
|
|
@class FIRQuery;
|
|
@class FSTEventAccumulator;
|
|
@class FSTDispatchQueue;
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
#if __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
@interface FSTIntegrationTestCase : XCTestCase
|
|
|
|
/** Returns the default Firestore project ID for testing. */
|
|
+ (NSString *)projectID;
|
|
|
|
/** Returns a FirestoreSettings configured to use either hexa or the emulator. */
|
|
+ (FIRFirestoreSettings *)settings;
|
|
|
|
/** Returns a new Firestore connected to the "test-db" project. */
|
|
- (FIRFirestore *)firestore;
|
|
|
|
/** Returns a new Firestore connected to the project with the given projectID. */
|
|
- (FIRFirestore *)firestoreWithProjectID:(NSString *)projectID;
|
|
|
|
/** Synchronously shuts down the given firestore. */
|
|
- (void)shutdownFirestore:(FIRFirestore *)firestore;
|
|
|
|
- (NSString *)documentPath;
|
|
|
|
- (FIRDocumentReference *)documentRef;
|
|
|
|
- (FIRCollectionReference *)collectionRef;
|
|
|
|
- (FIRCollectionReference *)collectionRefWithDocuments:
|
|
(NSDictionary<NSString *, NSDictionary<NSString *, id> *> *)documents;
|
|
|
|
- (void)writeAllDocuments:(NSDictionary<NSString *, NSDictionary<NSString *, id> *> *)documents
|
|
toCollection:(FIRCollectionReference *)collection;
|
|
|
|
- (void)readerAndWriterOnDocumentRef:(void (^)(NSString *path,
|
|
FIRDocumentReference *readerRef,
|
|
FIRDocumentReference *writerRef))action;
|
|
|
|
- (FIRDocumentSnapshot *)readDocumentForRef:(FIRDocumentReference *)ref;
|
|
|
|
- (FIRQuerySnapshot *)readDocumentSetForRef:(FIRQuery *)query;
|
|
|
|
- (FIRDocumentSnapshot *)readSnapshotForRef:(FIRDocumentReference *)query
|
|
requireOnline:(BOOL)online;
|
|
|
|
- (void)writeDocumentRef:(FIRDocumentReference *)ref data:(NSDictionary<NSString *, id> *)data;
|
|
|
|
- (void)updateDocumentRef:(FIRDocumentReference *)ref data:(NSDictionary<NSString *, id> *)data;
|
|
|
|
- (void)deleteDocumentRef:(FIRDocumentReference *)ref;
|
|
|
|
- (void)disableNetwork;
|
|
|
|
- (void)enableNetwork;
|
|
|
|
- (FSTDispatchQueue *)queueForFirestore:(FIRFirestore *)firestore;
|
|
|
|
/**
|
|
* "Blocks" the current thread/run loop until the block returns YES.
|
|
* Should only be called on the main thread.
|
|
* The block is invoked frequently and in a loop (every couple of milliseconds) to ensure fast
|
|
* test progress and make sure actions to be run on main thread are not blocked by this method.
|
|
*/
|
|
- (void)waitUntil:(BOOL (^)())predicate;
|
|
|
|
@property(nonatomic, strong) FIRFirestore *db;
|
|
@property(nonatomic, strong) FSTEventAccumulator *eventAccumulator;
|
|
@end
|
|
|
|
/** Converts the FIRQuerySnapshot to an NSArray containing the data of the documents in order. */
|
|
NSArray<NSDictionary<NSString *, id> *> *FIRQuerySnapshotGetData(FIRQuerySnapshot *docs);
|
|
|
|
/** Converts the FIRQuerySnapshot to an NSArray containing the document IDs in order. */
|
|
NSArray<NSString *> *FIRQuerySnapshotGetIDs(FIRQuerySnapshot *docs);
|
|
|
|
#if __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
NS_ASSUME_NONNULL_END
|