FIRCLSMockOnDemandModel.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "Crashlytics/UnitTests/Mocks/FIRCLSMockOnDemandModel.h"
  15. @interface FIRCLSMockOnDemandModel ()
  16. @property(nonatomic, readonly) FIRCLSSettings *settings;
  17. @end
  18. @implementation FIRCLSMockOnDemandModel
  19. - (instancetype)initWithFIRCLSSettings:(FIRCLSSettings *)settings
  20. sleepBlock:(void (^)(int))sleepBlock {
  21. self = [super initWithFIRCLSSettings:settings];
  22. if (!self) {
  23. return nil;
  24. }
  25. _settings = settings;
  26. _sleepBlock = sleepBlock;
  27. return self;
  28. }
  29. - (void)setQueueToFull {
  30. [self setQueuedOperationsCount:self.settings.onDemandUploadRate];
  31. }
  32. - (void)setQueueToEmpty {
  33. [self setQueuedOperationsCount:0];
  34. }
  35. - (int)getQueueMax {
  36. return self.settings.onDemandUploadRate;
  37. }
  38. - (void)implementOnDemandUploadDelay:(int)delay {
  39. _sleepBlock(delay);
  40. }
  41. @end