FIRMessagingTestUtilities.h 2.4 KB

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