| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /*
- * Copyright 2019 Google
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #import "FIRMessagingTestUtilities.h"
- #import <FirebaseAnalyticsInterop/FIRAnalyticsInterop.h>
- #import <FirebaseInstanceID/FirebaseInstanceID.h>
- NS_ASSUME_NONNULL_BEGIN
- @interface FIRInstanceID (ExposedForTest)
- /// Private initializer to avoid singleton usage.
- - (FIRInstanceID *)initPrivately;
- /// Starts fetching and configuration of InstanceID. This is necessary after the `initPrivately`
- /// call.
- - (void)start;
- @end
- @interface FIRMessaging (ExposedForTest)
- /// Surface internal initializer to avoid singleton usage during tests.
- - (instancetype)initWithAnalytics:(nullable id<FIRAnalyticsInterop>)analytics
- withInstanceID:(FIRInstanceID *)instanceID
- withUserDefaults:(NSUserDefaults *)defaults;
- /// Kicks off required calls for some messaging tests.
- - (void)start;
- @end
- @implementation FIRMessagingTestUtilities
- + (FIRMessaging *)messagingForTestsWithUserDefaults:(NSUserDefaults *)userDefaults {
- // Create the messaging instance with all the necessary dependencies.
- FIRInstanceID *instanceID = [[FIRInstanceID alloc] initPrivately];
- [instanceID start];
- // Create the messaging instance and call `start`.
- FIRMessaging *messaging = [[FIRMessaging alloc] initWithAnalytics:nil
- withInstanceID:instanceID
- withUserDefaults:userDefaults];
- [messaging start];
- return messaging;
- }
- @end
- NS_ASSUME_NONNULL_END
|