FIRCLSMockReportManager.m 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 "FIRCLSMockReportManager.h"
  15. #import "FIRCLSApplicationIdentifierModel.h"
  16. #import "FIRCLSContext.h"
  17. #import "FIRCLSMockNetworkClient.h"
  18. #import "FIRCLSMockReportUploader.h"
  19. @interface FIRCLSMockReportManager () {
  20. FIRCLSMockReportUploader *_uploader;
  21. }
  22. // Made this a property so we can override this with mocked values
  23. @property(nonatomic, strong) FIRCLSApplicationIdentifierModel *appIDModel;
  24. @end
  25. @implementation FIRCLSMockReportManager
  26. // these have to be synthesized, to override the pre-existing method
  27. @synthesize bundleIdentifier;
  28. - (instancetype)initWithFileManager:(FIRCLSFileManager *)fileManager
  29. instanceID:(FIRInstanceID *)instanceID
  30. analytics:(id<FIRAnalyticsInterop>)analytics
  31. googleAppID:(nonnull NSString *)googleAppID
  32. dataArbiter:(FIRCLSDataCollectionArbiter *)dataArbiter
  33. appIDModel:(FIRCLSApplicationIdentifierModel *)appIDModel {
  34. self = [super initWithFileManager:fileManager
  35. instanceID:instanceID
  36. analytics:analytics
  37. googleAppID:googleAppID
  38. dataArbiter:dataArbiter];
  39. if (!self) {
  40. return nil;
  41. }
  42. _appIDModel = appIDModel;
  43. _uploader = [[FIRCLSMockReportUploader alloc] initWithQueue:self.operationQueue
  44. delegate:self
  45. dataSource:self
  46. client:self.networkClient
  47. fileManager:fileManager
  48. analytics:analytics];
  49. return self;
  50. }
  51. - (FIRCLSNetworkClient *)clientWithOperationQueue:(NSOperationQueue *)queue {
  52. return [[FIRCLSMockNetworkClient alloc] initWithQueue:queue
  53. fileManager:self.fileManager
  54. delegate:(id<FIRCLSNetworkClientDelegate>)self];
  55. }
  56. - (FIRCLSReportUploader *)uploader {
  57. return _uploader;
  58. }
  59. - (BOOL)startCrashReporterWithProfilingMark:(FIRCLSProfileMark)mark
  60. report:(FIRCLSInternalReport *)report {
  61. NSLog(@"Crash Reporting system disabled for testing");
  62. return YES;
  63. }
  64. - (BOOL)installCrashReportingHandlers:(FIRCLSContextInitData *)initData {
  65. return YES;
  66. // This actually installs crash handlers, there is no need to do that during testing.
  67. }
  68. - (void)crashReportingSetupCompleted {
  69. // This stuff does operations on the main thread, which we don't want during tests.
  70. }
  71. @end