FIRCLSMockReportUploader.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2019 Google
  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/FIRCLSMockReportUploader.h"
  15. #import "Crashlytics/Crashlytics/Models/FIRCLSFileManager.h"
  16. #import "Crashlytics/Crashlytics/Models/FIRCLSInternalReport.h"
  17. @interface FIRCLSMockReportUploader () {
  18. NSMutableArray *_prepareAndSubmitReportArray;
  19. NSMutableArray *_uploadReportArray;
  20. }
  21. @end
  22. @implementation FIRCLSMockReportUploader
  23. - (instancetype)initWithManagerData:(FIRCLSManagerData *)managerData {
  24. self = [super initWithManagerData:managerData];
  25. if (!self) {
  26. return nil;
  27. }
  28. _prepareAndSubmitReportArray = [[NSMutableArray alloc] init];
  29. _uploadReportArray = [[NSMutableArray alloc] init];
  30. return self;
  31. }
  32. - (void)prepareAndSubmitReport:(FIRCLSInternalReport *)report
  33. dataCollectionToken:(FIRCLSDataCollectionToken *)dataCollectionToken
  34. asUrgent:(BOOL)urgent
  35. withProcessing:(BOOL)shouldProcess {
  36. [_prepareAndSubmitReportArray
  37. addObject:@{@"report" : report, @"urgent" : @(urgent), @"process" : @(shouldProcess)}];
  38. // report should be from active/processing here. We just need to "move" it.
  39. [self.fileManager removeItemAtPath:report.path];
  40. return;
  41. }
  42. - (void)uploadPackagedReportAtPath:(NSString *)path
  43. dataCollectionToken:(FIRCLSDataCollectionToken *)dataCollectionToken
  44. asUrgent:(BOOL)urgent {
  45. [_uploadReportArray addObject:@{@"path" : path, @"urgent" : @(urgent)}];
  46. // After upload, the file should be removed.
  47. [self.fileManager removeItemAtPath:path];
  48. return;
  49. }
  50. @end