FSTLevelDBSpecTests.mm 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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/leveldb_persistence.h"
  19. #include "Firestore/core/src/util/path.h"
  20. #include "Firestore/core/test/unit/local/persistence_testing.h"
  21. using firebase::firestore::local::LevelDbDir;
  22. using firebase::firestore::local::LevelDbPersistenceForTesting;
  23. using firebase::firestore::local::Persistence;
  24. using firebase::firestore::util::Path;
  25. NS_ASSUME_NONNULL_BEGIN
  26. /**
  27. * An implementation of FSTSpecTests that uses the LevelDB implementation of local storage.
  28. *
  29. * See the FSTSpecTests class comments for more information about how this works.
  30. */
  31. @interface FSTLevelDBSpecTests : FSTSpecTests
  32. @end
  33. @implementation FSTLevelDBSpecTests {
  34. Path _levelDbDir;
  35. }
  36. - (void)setUpForSpecWithConfig:(NSDictionary *)config {
  37. // Getting a new directory will ensure that it is empty.
  38. _levelDbDir = LevelDbDir();
  39. [super setUpForSpecWithConfig:config];
  40. }
  41. /** Overrides -[FSTSpecTests persistence] */
  42. - (std::unique_ptr<Persistence>)persistenceWithGCEnabled:(__unused BOOL)GCEnabled {
  43. return LevelDbPersistenceForTesting(_levelDbDir);
  44. }
  45. - (BOOL)shouldRunWithTags:(NSArray<NSString *> *)tags {
  46. if ([tags containsObject:kEagerGC]) {
  47. return NO;
  48. }
  49. return [super shouldRunWithTags:tags];
  50. }
  51. @end
  52. NS_ASSUME_NONNULL_END