FIRCLSMockReportManager.m 3.3 KB

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