FIRMessagingReceiverTest.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright 2018 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 <XCTest/XCTest.h>
  17. #import <OCMock/OCMock.h>
  18. #import <FirebaseInstanceID/FirebaseInstanceID.h>
  19. #import "FIRMessaging.h"
  20. #import "FIRMessaging_Private.h"
  21. @interface FIRMessagingReceiverTest : XCTestCase
  22. @property(nonatomic, readonly, strong) FIRMessaging *messaging;
  23. @end
  24. @implementation FIRMessagingReceiverTest
  25. - (void)setUp {
  26. [super setUp];
  27. _messaging = [FIRMessaging messaging];
  28. [[NSUserDefaults standardUserDefaults]
  29. removePersistentDomainForName:[NSBundle mainBundle].bundleIdentifier];
  30. }
  31. - (void)testUseMessagingDelegate {
  32. XCTAssertFalse(_messaging.useMessagingDelegateForDirectChannel);
  33. _messaging.useMessagingDelegateForDirectChannel = YES;
  34. XCTAssertTrue(_messaging.useMessagingDelegateForDirectChannel);
  35. }
  36. - (void)testUseMessagingDelegateFlagOverridedByPlistWithFalseValue {
  37. id bundleMock = OCMPartialMock([NSBundle mainBundle]);
  38. OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistUseMessagingDelegate])
  39. .andReturn(nil);
  40. XCTAssertFalse(_messaging.useMessagingDelegateForDirectChannel);
  41. [bundleMock stopMocking];
  42. }
  43. - (void)testUseMessagingDelegateFlagOverridedByPlistWithTrueValue {
  44. id bundleMock = OCMPartialMock([NSBundle mainBundle]);
  45. OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistUseMessagingDelegate])
  46. .andReturn(@YES);
  47. XCTAssertTrue(_messaging.useMessagingDelegateForDirectChannel);
  48. [bundleMock stopMocking];
  49. }
  50. @end