FSTMemorySpecTests.mm 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "Firestore/Example/Tests/SpecTests/FSTSpecTests.h"
  17. #import "Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h"
  18. #include "Firestore/core/src/local/memory_persistence.h"
  19. #include "Firestore/core/src/local/reference_delegate.h"
  20. #include "Firestore/core/test/unit/local/persistence_testing.h"
  21. NS_ASSUME_NONNULL_BEGIN
  22. using firebase::firestore::local::MemoryPersistenceWithEagerGcForTesting;
  23. using firebase::firestore::local::MemoryPersistenceWithLruGcForTesting;
  24. using firebase::firestore::local::Persistence;
  25. /**
  26. * An implementation of FSTSpecTests that uses the memory-only implementation of local storage.
  27. *
  28. * @see the FSTSpecTests class comments for more information about how this works.
  29. */
  30. @interface FSTMemorySpecTests : FSTSpecTests
  31. @end
  32. @implementation FSTMemorySpecTests
  33. /** Overrides -[FSTSpecTests persistence] */
  34. - (std::unique_ptr<Persistence>)persistenceWithEagerGCForMemory:(BOOL)eagerGC {
  35. if (eagerGC) {
  36. return MemoryPersistenceWithEagerGcForTesting();
  37. } else {
  38. return MemoryPersistenceWithLruGcForTesting();
  39. }
  40. }
  41. - (BOOL)shouldRunWithTags:(NSArray<NSString *> *)tags {
  42. if ([tags containsObject:kDurablePersistence]) {
  43. return NO;
  44. }
  45. return [super shouldRunWithTags:tags];
  46. }
  47. @end
  48. /**
  49. * An implementation of FSTMemorySpecTests that runs tests in pipeline mode.
  50. */
  51. @interface FSTMemoryPipelineSpecTests : FSTMemorySpecTests
  52. @end
  53. @implementation FSTMemoryPipelineSpecTests
  54. - (BOOL)usePipelineMode {
  55. return YES;
  56. }
  57. @end
  58. NS_ASSUME_NONNULL_END