FIRMessagingTestUtilities.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2019 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 <Foundation/Foundation.h>
  17. #import <FirebaseInstanceID/FIRInstanceID.h>
  18. #import <FirebaseMessaging/FIRMessaging.h>
  19. #import "Firebase/Messaging/FIRMessagingPendingTopicsList.h"
  20. #import "Firebase/Messaging/FIRMessagingTopicsCommon.h"
  21. @class GULUserDefaults;
  22. NS_ASSUME_NONNULL_BEGIN
  23. typedef void (^MockDelegateSubscriptionHandler)(NSString *topic,
  24. FIRMessagingTopicAction action,
  25. FIRMessagingTopicOperationCompletion completion);
  26. /**
  27. * This object lets us provide a stub delegate where we can customize the behavior by providing
  28. * blocks. We need to use this instead of stubbing a OCMockProtocol because our delegate methods
  29. * take primitive values (e.g. action), which is not easy to use from OCMock
  30. * @see http://stackoverflow.com/a/6332023
  31. */
  32. @interface MockPendingTopicsListDelegate : NSObject <FIRMessagingPendingTopicsListDelegate>
  33. @property(nonatomic, assign) BOOL isReady;
  34. @property(nonatomic, copy) MockDelegateSubscriptionHandler subscriptionHandler;
  35. @property(nonatomic, copy) void (^updateHandler)(void);
  36. @end
  37. @interface FIRMessaging (TestUtilities)
  38. // Surface the user defaults instance to clean up after tests.
  39. @property(nonatomic, strong) NSUserDefaults *messagingUserDefaults;
  40. @end
  41. @interface FIRMessagingTestUtilities : NSObject
  42. @property(nonatomic, strong) id mockInstanceID;
  43. @property(nonatomic, strong) id mockPubsub;
  44. @property(nonatomic, strong) id mockMessaging;
  45. @property(nonatomic, strong) id mockInstallations;
  46. @property(nonatomic, readonly, strong) FIRMessaging *messaging;
  47. @property(nonatomic, readonly, strong) FIRInstanceID *instanceID;
  48. - (instancetype)initWithUserDefaults:(NSUserDefaults *)userDefaults
  49. withRMQManager:(BOOL)withRMQManager;
  50. - (void)cleanupAfterTest:(XCTestCase *)testCase;
  51. @end
  52. NS_ASSUME_NONNULL_END