@react-native-firebase/app 26.4.0 → 27.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +10 -27
- package/RNFBApp.podspec +13 -5
- package/android/build.gradle +3 -0
- package/android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.kt +29 -0
- package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.kt +146 -0
- package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.kt +156 -0
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.kt +44 -0
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.kt +100 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.kt +250 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.kt +64 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/{ReactNativeFirebaseAppInitProvider.java → ReactNativeFirebaseAppInitProvider.kt} +3 -4
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.kt +47 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.kt +33 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +1 -1
- package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.kt +185 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.kt +35 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.kt +662 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.kt +103 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.kt +96 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.kt +140 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.kt +109 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.kt +451 -0
- package/android/src/reactnative/java/io/invertase/firebase/interfaces/{ContextProvider.java → ContextProvider.kt} +8 -8
- package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeError.java → NativeError.kt} +8 -8
- package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeEvent.java → NativeEvent.kt} +6 -6
- package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.kt +219 -0
- package/android/src/test/java/expo/core/ModuleRegistry.java +9 -0
- package/android/src/test/java/io/invertase/firebase/app/NativeRNFBTurboAppTest.java +182 -59
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppComponentsJavaCompatibilityTest.java +70 -0
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppJavaCompatibilityTest.java +60 -0
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackageTest.java +165 -0
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppTest.kt +167 -0
- package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseJavaCompatibilityTest.java +112 -0
- package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseTest.kt +317 -0
- package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.kt +309 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterJavaCompatibilityTest.java +176 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterTest.java +143 -12
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventTest.kt +61 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONJavaCompatibilityTest.java +85 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.kt +296 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaJavaCompatibilityTest.java +67 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaTest.kt +246 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseModuleTest.kt +254 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesJavaCompatibilityTest.java +87 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesTest.kt +260 -0
- package/android/src/test/java/io/invertase/firebase/common/SharedUtilsJavaCompatibilityTest.java +255 -0
- package/android/src/test/java/io/invertase/firebase/common/SharedUtilsTest.kt +674 -0
- package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.kt +290 -0
- package/android/src/test/java/io/invertase/firebase/common/UniversalFirebaseModuleJavaCompatibilityTest.java +178 -0
- package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesJavaCompatibilityTest.java +99 -0
- package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesTest.kt +217 -0
- package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleJavaCompatibilityTest.java +176 -0
- package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleKotlinCompatibilityTest.kt +52 -0
- package/android/src/test/java/io/invertase/firebase/interfaces/InterfacesJavaCompatibilityTest.java +144 -0
- package/android/src/test/java/io/invertase/firebase/interfaces/NativeEventTest.kt +56 -0
- package/android/src/test/java/io/invertase/firebase/utils/NativeRNFBTurboUtilsTest.java +517 -21
- package/dist/module/FirebaseApp.js +10 -0
- package/dist/module/FirebaseApp.js.map +1 -1
- package/dist/module/common/deeps.js +3 -0
- package/dist/module/common/deeps.js.map +1 -1
- package/dist/module/internal/FirebaseModule.js.map +1 -1
- package/dist/module/internal/RNFBNativeEventEmitter.js +12 -1
- package/dist/module/internal/RNFBNativeEventEmitter.js.map +1 -1
- package/dist/module/internal/SharedEventEmitter.js +3 -1
- package/dist/module/internal/SharedEventEmitter.js.map +1 -1
- package/dist/module/internal/index.js +1 -0
- package/dist/module/internal/index.js.map +1 -1
- package/dist/module/internal/registry/app.js +7 -1
- package/dist/module/internal/registry/app.js.map +1 -1
- package/dist/module/types/app.js.map +1 -1
- package/dist/module/types/internal.js +2 -0
- package/dist/module/version.js +1 -1
- package/dist/typescript/lib/FirebaseApp.d.ts +7 -0
- package/dist/typescript/lib/FirebaseApp.d.ts.map +1 -1
- package/dist/typescript/lib/common/deeps.d.ts.map +1 -1
- package/dist/typescript/lib/internal/FirebaseModule.d.ts +2 -3
- package/dist/typescript/lib/internal/FirebaseModule.d.ts.map +1 -1
- package/dist/typescript/lib/internal/NativeModules.d.ts +4 -1
- package/dist/typescript/lib/internal/NativeModules.d.ts.map +1 -1
- package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts +2 -2
- package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts.map +1 -1
- package/dist/typescript/lib/internal/SharedEventEmitter.d.ts +3 -3
- package/dist/typescript/lib/internal/SharedEventEmitter.d.ts.map +1 -1
- package/dist/typescript/lib/internal/index.d.ts +1 -0
- package/dist/typescript/lib/internal/index.d.ts.map +1 -1
- package/dist/typescript/lib/internal/registry/app.d.ts.map +1 -1
- package/dist/typescript/lib/types/app.d.ts +10 -3
- package/dist/typescript/lib/types/app.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +12 -0
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/firebase-schema.json +4 -0
- package/firebase_spm.rb +552 -96
- package/ios/RNFBApp/RCTConvert+FIRApp.h +2 -5
- package/ios/RNFBApp/RCTConvert+FIRApp.m +11 -6
- package/ios/RNFBApp/RCTConvert+FIROptions.h +2 -5
- package/ios/RNFBApp/RCTConvert+FIROptions.m +11 -10
- package/ios/RNFBApp/RCTConvertFIRApp.swift +86 -0
- package/ios/RNFBApp/RCTConvertFIROptions.swift +259 -0
- package/ios/RNFBApp/RNFBAppCustomAuthDomains.swift +63 -0
- package/ios/RNFBApp/RNFBAppInitializeOptionsMapper.swift +113 -0
- package/ios/RNFBApp/RNFBAppLogLevelMapper.swift +53 -0
- package/ios/RNFBApp/RNFBAppModule+CustomAuthDomain.m +35 -0
- package/ios/RNFBApp/RNFBAppModule.h +6 -2
- package/ios/RNFBApp/RNFBAppModule.mm +65 -228
- package/ios/RNFBApp/RNFBAppModuleFirebase.swift +439 -0
- package/ios/RNFBApp/RNFBAppModuleImplementation.h +68 -0
- package/ios/RNFBApp/RNFBAppModuleImplementation.m +195 -0
- package/ios/RNFBApp/RNFBHandleMap.m +27 -56
- package/ios/RNFBApp/RNFBHandleMapStorage.swift +90 -0
- package/ios/RNFBApp/RNFBInitializeAppArguments.swift +82 -0
- package/ios/RNFBApp/RNFBJSON.m +22 -38
- package/ios/RNFBApp/RNFBJSONImplementation.swift +71 -0
- package/ios/RNFBApp/RNFBMeta.m +24 -26
- package/ios/RNFBApp/RNFBMetaStorage.swift +76 -0
- package/ios/RNFBApp/RNFBNullSentinelDecoding.swift +135 -0
- package/ios/RNFBApp/RNFBNullSentinelInterceptor.h +30 -3
- package/ios/RNFBApp/RNFBNullSentinelInterceptor.m +28 -5
- package/ios/RNFBApp/RNFBPreferences.m +22 -20
- package/ios/RNFBApp/RNFBPreferencesStorage.swift +101 -0
- package/ios/RNFBApp/RNFBRCTEventEmitter.m +36 -93
- package/ios/RNFBApp/RNFBRCTEventEmitterCore.swift +161 -0
- package/ios/RNFBApp/RNFBSharedUtils.h +2 -5
- package/ios/RNFBApp/RNFBSharedUtils.m +109 -198
- package/ios/RNFBApp/RNFBSharedUtilsConfig.swift +72 -0
- package/ios/RNFBApp/RNFBSharedUtilsFIRApp.swift +271 -0
- package/ios/RNFBApp/RNFBSharedUtilsFormatting.swift +59 -0
- package/ios/RNFBApp/RNFBSharedUtilsPromiseRejection.swift +88 -0
- package/ios/RNFBApp/RNFBUtilsHelpers.swift +116 -0
- package/ios/RNFBApp/RNFBUtilsModule+Foundation.m +44 -0
- package/ios/RNFBApp/RNFBUtilsModule+PhotoAssets.m +47 -0
- package/ios/RNFBApp/RNFBUtilsModule.h +11 -1
- package/ios/RNFBApp/RNFBUtilsModule.mm +10 -85
- package/ios/RNFBApp/RNFBUtilsModuleImplementation.h +32 -0
- package/ios/RNFBApp/RNFBUtilsModuleImplementation.m +56 -0
- package/ios/RNFBApp/RNFBVersion.m +1 -1
- package/ios/RNFBApp.xcodeproj/project.pbxproj +100 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FIRApp.m +171 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FirebaseCore.h +78 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FIRInstallations.m +7 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FirebaseInstallations.h +8 -0
- package/ios/RNFBAppUnitTests/HostStubs/RNFBAppModuleHostStub.m +55 -0
- package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.h +89 -0
- package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.mm +30 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.h +19 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.m +32 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridgeModule.h +19 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.h +28 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.m +23 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTEventEmitter.h +9 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTInvalidating.h +24 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTUtils.h +9 -0
- package/ios/RNFBAppUnitTests/HostStubs/module.modulemap +13 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIRAppFacadeTests.m +61 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIRAppTests.swift +73 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIROptionsFacadeTests.m +57 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIROptionsTests.swift +243 -0
- package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsFacadeTests.m +73 -0
- package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsTests.swift +70 -0
- package/ios/RNFBAppUnitTests/RNFBAppInitializeOptionsMapperTests.swift +190 -0
- package/ios/RNFBAppUnitTests/RNFBAppLogLevelFacadeTests.m +76 -0
- package/ios/RNFBAppUnitTests/RNFBAppLogLevelMapperTests.swift +59 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseFacadeTests.m +215 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseTests.swift +430 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleLifecycleTests.m +206 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleShellTests.mm +367 -0
- package/ios/RNFBAppUnitTests/RNFBAppUnitTests.xcodeproj/project.pbxproj +355 -2
- package/ios/RNFBAppUnitTests/RNFBFirebaseAppClientTests.swift +165 -0
- package/ios/RNFBAppUnitTests/RNFBHandleMapStorageTests.swift +121 -0
- package/ios/RNFBAppUnitTests/RNFBInitializeAppArgumentsTests.swift +256 -0
- package/ios/RNFBAppUnitTests/RNFBJSONImplementationTests.swift +126 -0
- package/ios/RNFBAppUnitTests/RNFBJSONTests.m +172 -0
- package/ios/RNFBAppUnitTests/RNFBMetaStorageTests.swift +106 -0
- package/ios/RNFBAppUnitTests/RNFBMetaTests.m +65 -0
- package/ios/RNFBAppUnitTests/RNFBNullSentinelDecodingTests.swift +286 -0
- package/ios/RNFBAppUnitTests/RNFBNullSentinelInterceptorTests.m +312 -0
- package/ios/RNFBAppUnitTests/RNFBPreferencesStorageTests.swift +105 -0
- package/ios/RNFBAppUnitTests/RNFBPreferencesTests.m +110 -0
- package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterCoreTests.swift +163 -0
- package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterFacadeTests.m +141 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigFacadeTests.m +100 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigTests.swift +234 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppFacadeTests.m +145 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppTests.swift +173 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingFacadeTests.m +38 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingTests.swift +82 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsNullSentinelTests.m +35 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionFacadeTests.m +107 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionTests.swift +133 -0
- package/ios/RNFBAppUnitTests/RNFBUtilsHelpersTests.swift +144 -0
- package/ios/RNFBAppUnitTests/RNFBUtilsModuleFacadeTests.m +72 -0
- package/ios/RNFBAppUnitTests/RNFBUtilsModuleShellTests.mm +282 -0
- package/ios/RNFBFirebase/Package.swift +53 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebase/RNFBFirebase.swift +285 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/Public/.gitkeep +0 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/RNFBFirebaseBridge.m +169 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/include/RNFBFirebaseBridge.h +52 -0
- package/ios/RNFBFirebaseUnitTests/RNFBAppDynamicFacadeTests.swift +240 -0
- package/{android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.java → ios/RNFBFirebaseUnitTests/RNFBFirebaseClientImport.swift} +23 -14
- package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/project.pbxproj +588 -0
- package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/xcshareddata/xcschemes/RNFBFirebaseUnitTests.xcscheme +83 -0
- package/ios_config.sh +50 -22
- package/lib/FirebaseApp.ts +10 -0
- package/lib/common/deeps.ts +3 -0
- package/lib/internal/FirebaseModule.ts +6 -3
- package/lib/internal/NativeModules.ts +4 -1
- package/lib/internal/RNFBNativeEventEmitter.ts +14 -5
- package/lib/internal/SharedEventEmitter.ts +5 -1
- package/lib/internal/index.ts +1 -0
- package/lib/internal/react-native-vendor-emitter.d.ts +11 -0
- package/lib/internal/registry/app.ts +7 -1
- package/lib/types/app.ts +10 -3
- package/lib/types/internal.ts +19 -0
- package/lib/version.ts +1 -1
- package/package.json +8 -8
- package/plugin/build/ios/appDelegate.js +2 -2
- package/plugin/build/ios/podfile.js +16 -16
- package/plugin/build/pluginConfig.d.ts +4 -2
- package/plugin/src/ios/appDelegate.ts +2 -2
- package/plugin/src/ios/podfile.ts +20 -23
- package/plugin/src/pluginConfig.ts +4 -2
- package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.java +0 -150
- package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java +0 -148
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.java +0 -62
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.java +0 -91
- package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.java +0 -224
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.java +0 -46
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java +0 -49
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.java +0 -35
- package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.java +0 -192
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.java +0 -53
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.java +0 -606
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.java +0 -109
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.java +0 -101
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.java +0 -146
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.java +0 -96
- package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java +0 -441
- package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.java +0 -223
- package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.java +0 -275
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.java +0 -108
- package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.java +0 -97
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package io.invertase.firebase.app;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import static org.junit.Assert.assertNull;
|
|
20
|
+
import static org.mockito.Mockito.mock;
|
|
21
|
+
import static org.mockito.Mockito.mockStatic;
|
|
22
|
+
import static org.mockito.Mockito.times;
|
|
23
|
+
|
|
24
|
+
import android.util.Log;
|
|
25
|
+
import com.google.firebase.FirebaseApp;
|
|
26
|
+
import com.google.firebase.FirebaseOptions;
|
|
27
|
+
import org.junit.After;
|
|
28
|
+
import org.junit.Test;
|
|
29
|
+
import org.mockito.MockedStatic;
|
|
30
|
+
|
|
31
|
+
/** Proves Java callers retain nullable calls and the public no-argument constructor. */
|
|
32
|
+
public class ReactNativeFirebaseAppJavaCompatibilityTest {
|
|
33
|
+
@After
|
|
34
|
+
public void resetApplicationContext() {
|
|
35
|
+
try (MockedStatic<Log> ignored = mockStatic(Log.class)) {
|
|
36
|
+
ReactNativeFirebaseApp.setApplicationContext(null);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Test
|
|
41
|
+
public void javaCanConstructAndCallEveryStaticMethodWithNull() {
|
|
42
|
+
new ReactNativeFirebaseApp();
|
|
43
|
+
FirebaseOptions options = mock(FirebaseOptions.class);
|
|
44
|
+
|
|
45
|
+
try (MockedStatic<Log> log = mockStatic(Log.class);
|
|
46
|
+
MockedStatic<FirebaseOptions> firebaseOptions = mockStatic(FirebaseOptions.class);
|
|
47
|
+
MockedStatic<FirebaseApp> firebaseApps = mockStatic(FirebaseApp.class)) {
|
|
48
|
+
firebaseOptions.when(() -> FirebaseOptions.fromResource(null)).thenReturn(options);
|
|
49
|
+
|
|
50
|
+
ReactNativeFirebaseApp.setApplicationContext(null);
|
|
51
|
+
assertNull(ReactNativeFirebaseApp.getApplicationContext());
|
|
52
|
+
ReactNativeFirebaseApp.initializeSecondaryApp(null);
|
|
53
|
+
ReactNativeFirebaseApp.initializeSecondaryApp(null, null);
|
|
54
|
+
|
|
55
|
+
log.verify(() -> Log.d("ReactNativeFirebaseApp", "received application context."), times(1));
|
|
56
|
+
firebaseOptions.verify(() -> FirebaseOptions.fromResource(null), times(2));
|
|
57
|
+
firebaseApps.verify(() -> FirebaseApp.initializeApp(null, options, null), times(2));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackageTest.java
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
package io.invertase.firebase.app;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import static org.junit.Assert.assertEquals;
|
|
20
|
+
import static org.junit.Assert.assertFalse;
|
|
21
|
+
import static org.junit.Assert.assertNull;
|
|
22
|
+
import static org.junit.Assert.assertSame;
|
|
23
|
+
import static org.junit.Assert.assertTrue;
|
|
24
|
+
import static org.mockito.Mockito.mock;
|
|
25
|
+
import static org.mockito.Mockito.never;
|
|
26
|
+
import static org.mockito.Mockito.verify;
|
|
27
|
+
import static org.mockito.Mockito.when;
|
|
28
|
+
|
|
29
|
+
import android.content.Context;
|
|
30
|
+
import android.util.Log;
|
|
31
|
+
import com.facebook.react.bridge.NativeModule;
|
|
32
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
33
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
34
|
+
import io.invertase.firebase.utils.NativeRNFBTurboUtils;
|
|
35
|
+
import java.lang.reflect.Constructor;
|
|
36
|
+
import java.lang.reflect.Field;
|
|
37
|
+
import java.lang.reflect.Method;
|
|
38
|
+
import java.lang.reflect.Modifier;
|
|
39
|
+
import java.lang.reflect.ParameterizedType;
|
|
40
|
+
import java.lang.reflect.Type;
|
|
41
|
+
import java.util.ArrayList;
|
|
42
|
+
import java.util.List;
|
|
43
|
+
import javax.annotation.Nonnull;
|
|
44
|
+
import org.junit.After;
|
|
45
|
+
import org.junit.Before;
|
|
46
|
+
import org.junit.Test;
|
|
47
|
+
import org.mockito.MockedStatic;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Verifies behavior and Java ABI remain stable while the package implementation moves to Kotlin.
|
|
51
|
+
*/
|
|
52
|
+
public class ReactNativeFirebaseAppPackageTest {
|
|
53
|
+
private Field applicationContextField;
|
|
54
|
+
private Context originalApplicationContext;
|
|
55
|
+
private MockedStatic<Log> log;
|
|
56
|
+
|
|
57
|
+
@Before
|
|
58
|
+
public void setUp() throws Exception {
|
|
59
|
+
applicationContextField = ReactNativeFirebaseApp.class.getDeclaredField("applicationContext");
|
|
60
|
+
applicationContextField.setAccessible(true);
|
|
61
|
+
originalApplicationContext = (Context) applicationContextField.get(null);
|
|
62
|
+
applicationContextField.set(null, null);
|
|
63
|
+
log = org.mockito.Mockito.mockStatic(Log.class);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@After
|
|
67
|
+
public void tearDown() throws Exception {
|
|
68
|
+
applicationContextField.set(null, originalApplicationContext);
|
|
69
|
+
log.close();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Test
|
|
73
|
+
public void createNativeModules_setsMissingApplicationContextAndReturnsMutableOrderedArrayList() {
|
|
74
|
+
ReactApplicationContext reactContext = mock(ReactApplicationContext.class);
|
|
75
|
+
Context applicationContext = mock(Context.class);
|
|
76
|
+
when(reactContext.getApplicationContext()).thenReturn(applicationContext);
|
|
77
|
+
|
|
78
|
+
List<NativeModule> modules =
|
|
79
|
+
new ReactNativeFirebaseAppPackage().createNativeModules(reactContext);
|
|
80
|
+
|
|
81
|
+
assertSame(applicationContext, ReactNativeFirebaseApp.getApplicationContext());
|
|
82
|
+
assertTrue(modules instanceof ArrayList);
|
|
83
|
+
assertEquals(2, modules.size());
|
|
84
|
+
assertEquals(NativeRNFBTurboApp.class, modules.get(0).getClass());
|
|
85
|
+
assertEquals(NativeRNFBTurboUtils.class, modules.get(1).getClass());
|
|
86
|
+
modules.clear();
|
|
87
|
+
assertTrue(modules.isEmpty());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Test
|
|
91
|
+
public void createNativeModules_preservesExistingApplicationContext() throws Exception {
|
|
92
|
+
Context existingApplicationContext = mock(Context.class);
|
|
93
|
+
applicationContextField.set(null, existingApplicationContext);
|
|
94
|
+
ReactApplicationContext reactContext = mock(ReactApplicationContext.class);
|
|
95
|
+
|
|
96
|
+
List<NativeModule> modules =
|
|
97
|
+
new ReactNativeFirebaseAppPackage().createNativeModules(reactContext);
|
|
98
|
+
|
|
99
|
+
assertSame(existingApplicationContext, ReactNativeFirebaseApp.getApplicationContext());
|
|
100
|
+
verify(reactContext, never()).getApplicationContext();
|
|
101
|
+
assertEquals(NativeRNFBTurboApp.class, modules.get(0).getClass());
|
|
102
|
+
assertEquals(NativeRNFBTurboUtils.class, modules.get(1).getClass());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Test
|
|
106
|
+
public void createViewManagers_returnsEmptyList() {
|
|
107
|
+
ReactNativeFirebaseAppPackage subject = new ReactNativeFirebaseAppPackage();
|
|
108
|
+
ReactApplicationContext reactContext = mock(ReactApplicationContext.class);
|
|
109
|
+
|
|
110
|
+
List<ViewManager> viewManagers = subject.createViewManagers(reactContext);
|
|
111
|
+
|
|
112
|
+
assertTrue(viewManagers.isEmpty());
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@Test
|
|
116
|
+
public void preservesPublicOpenNoArgJavaAbiAndNonnullGenericContracts() throws Exception {
|
|
117
|
+
Class<ReactNativeFirebaseAppPackage> type = ReactNativeFirebaseAppPackage.class;
|
|
118
|
+
Constructor<ReactNativeFirebaseAppPackage> constructor = type.getConstructor();
|
|
119
|
+
|
|
120
|
+
assertTrue(Modifier.isPublic(type.getModifiers()));
|
|
121
|
+
assertFalse(Modifier.isFinal(type.getModifiers()));
|
|
122
|
+
assertTrue(Modifier.isPublic(constructor.getModifiers()));
|
|
123
|
+
|
|
124
|
+
assertPackageMethodAbi(
|
|
125
|
+
type.getDeclaredMethod("createNativeModules", ReactApplicationContext.class),
|
|
126
|
+
NativeModule.class);
|
|
127
|
+
assertPackageMethodAbi(
|
|
128
|
+
type.getDeclaredMethod("createViewManagers", ReactApplicationContext.class),
|
|
129
|
+
ViewManager.class);
|
|
130
|
+
|
|
131
|
+
ReactNativeFirebaseAppPackage subclass =
|
|
132
|
+
new ReactNativeFirebaseAppPackage() {
|
|
133
|
+
@Override
|
|
134
|
+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
135
|
+
return new ArrayList<>();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@Override
|
|
139
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
140
|
+
return new ArrayList<>();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
assertTrue(subclass.createNativeModules(mock(ReactApplicationContext.class)).isEmpty());
|
|
144
|
+
assertTrue(subclass.createViewManagers(mock(ReactApplicationContext.class)).isEmpty());
|
|
145
|
+
assertNull(subclass.getModule("missing", mock(ReactApplicationContext.class)));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private static void assertPackageMethodAbi(Method method, Class<?> genericElementType) {
|
|
149
|
+
assertTrue(Modifier.isPublic(method.getModifiers()));
|
|
150
|
+
assertFalse(Modifier.isFinal(method.getModifiers()));
|
|
151
|
+
assertEquals(List.class, method.getReturnType());
|
|
152
|
+
assertTrue(method.isAnnotationPresent(Nonnull.class));
|
|
153
|
+
assertTrue(method.getParameters()[0].isAnnotationPresent(Nonnull.class));
|
|
154
|
+
|
|
155
|
+
ParameterizedType genericReturnType = (ParameterizedType) method.getGenericReturnType();
|
|
156
|
+
assertEquals(List.class, genericReturnType.getRawType());
|
|
157
|
+
Type[] arguments = genericReturnType.getActualTypeArguments();
|
|
158
|
+
assertEquals(1, arguments.length);
|
|
159
|
+
Type elementType = arguments[0];
|
|
160
|
+
if (elementType instanceof ParameterizedType) {
|
|
161
|
+
elementType = ((ParameterizedType) elementType).getRawType();
|
|
162
|
+
}
|
|
163
|
+
assertEquals(genericElementType, elementType);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
package io.invertase.firebase.app
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import android.content.Context
|
|
20
|
+
import android.util.Log
|
|
21
|
+
import com.google.firebase.FirebaseApp
|
|
22
|
+
import com.google.firebase.FirebaseOptions
|
|
23
|
+
import org.junit.After
|
|
24
|
+
import org.junit.Assert.assertEquals
|
|
25
|
+
import org.junit.Assert.assertFalse
|
|
26
|
+
import org.junit.Assert.assertNull
|
|
27
|
+
import org.junit.Assert.assertSame
|
|
28
|
+
import org.junit.Assert.assertTrue
|
|
29
|
+
import org.junit.Test
|
|
30
|
+
import org.mockito.Mockito.mock
|
|
31
|
+
import org.mockito.Mockito.mockStatic
|
|
32
|
+
import org.mockito.Mockito.times
|
|
33
|
+
import java.lang.reflect.Modifier
|
|
34
|
+
|
|
35
|
+
class ReactNativeFirebaseAppTest {
|
|
36
|
+
@After
|
|
37
|
+
fun resetApplicationContext() {
|
|
38
|
+
mockStatic(Log::class.java).use {
|
|
39
|
+
ReactNativeFirebaseApp.setApplicationContext(null)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Test
|
|
44
|
+
fun javaVisibleApiPreservesClassConstructorAndStaticDescriptors() {
|
|
45
|
+
val appClass = ReactNativeFirebaseApp::class.java
|
|
46
|
+
val constructor = appClass.getConstructor()
|
|
47
|
+
|
|
48
|
+
assertTrue(Modifier.isPublic(constructor.modifiers))
|
|
49
|
+
assertFalse(Modifier.isFinal(appClass.modifiers))
|
|
50
|
+
assertEquals(
|
|
51
|
+
4,
|
|
52
|
+
appClass.declaredMethods.count {
|
|
53
|
+
Modifier.isPublic(it.modifiers) &&
|
|
54
|
+
Modifier.isStatic(it.modifiers) &&
|
|
55
|
+
!it.isSynthetic
|
|
56
|
+
},
|
|
57
|
+
)
|
|
58
|
+
assertStaticMethod(appClass, "getApplicationContext", Context::class.java)
|
|
59
|
+
assertStaticMethod(
|
|
60
|
+
appClass,
|
|
61
|
+
"setApplicationContext",
|
|
62
|
+
Void.TYPE,
|
|
63
|
+
Context::class.java,
|
|
64
|
+
)
|
|
65
|
+
assertStaticMethod(
|
|
66
|
+
appClass,
|
|
67
|
+
"initializeSecondaryApp",
|
|
68
|
+
Void.TYPE,
|
|
69
|
+
String::class.java,
|
|
70
|
+
)
|
|
71
|
+
assertStaticMethod(
|
|
72
|
+
appClass,
|
|
73
|
+
"initializeSecondaryApp",
|
|
74
|
+
Void.TYPE,
|
|
75
|
+
String::class.java,
|
|
76
|
+
Context::class.java,
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Test
|
|
81
|
+
fun applicationContextStoresExactValueIncludingNullAndLogsExactly() {
|
|
82
|
+
val context = mock(Context::class.java)
|
|
83
|
+
|
|
84
|
+
mockStatic(Log::class.java).use { log ->
|
|
85
|
+
ReactNativeFirebaseApp.setApplicationContext(context)
|
|
86
|
+
assertSame(context, ReactNativeFirebaseApp.getApplicationContext())
|
|
87
|
+
|
|
88
|
+
ReactNativeFirebaseApp.setApplicationContext(null)
|
|
89
|
+
assertNull(ReactNativeFirebaseApp.getApplicationContext())
|
|
90
|
+
|
|
91
|
+
log.verify(
|
|
92
|
+
{ Log.d("ReactNativeFirebaseApp", "received application context.") },
|
|
93
|
+
times(2),
|
|
94
|
+
)
|
|
95
|
+
log.verifyNoMoreInteractions()
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Test
|
|
100
|
+
fun initializeSecondaryAppUsesStoredNullableContextAndName() {
|
|
101
|
+
val context = mock(Context::class.java)
|
|
102
|
+
val options = mock(FirebaseOptions::class.java)
|
|
103
|
+
val initializedApp = mock(FirebaseApp::class.java)
|
|
104
|
+
|
|
105
|
+
mockStatic(Log::class.java).use {
|
|
106
|
+
ReactNativeFirebaseApp.setApplicationContext(context)
|
|
107
|
+
}
|
|
108
|
+
mockStatic(FirebaseOptions::class.java).use { firebaseOptions ->
|
|
109
|
+
mockStatic(FirebaseApp::class.java).use { firebaseApps ->
|
|
110
|
+
firebaseOptions
|
|
111
|
+
.`when`<FirebaseOptions> { FirebaseOptions.fromResource(context) }
|
|
112
|
+
.thenReturn(options)
|
|
113
|
+
firebaseApps
|
|
114
|
+
.`when`<FirebaseApp> {
|
|
115
|
+
FirebaseApp.initializeApp(context, options, nullAsPlatformType())
|
|
116
|
+
}.thenReturn(initializedApp)
|
|
117
|
+
|
|
118
|
+
ReactNativeFirebaseApp.initializeSecondaryApp(null)
|
|
119
|
+
|
|
120
|
+
firebaseOptions.verify { FirebaseOptions.fromResource(context) }
|
|
121
|
+
firebaseApps.verify {
|
|
122
|
+
FirebaseApp.initializeApp(context, options, nullAsPlatformType())
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@Test
|
|
129
|
+
fun explicitContextOverloadIgnoresStoredContextAndAcceptsNull() {
|
|
130
|
+
val storedContext = mock(Context::class.java)
|
|
131
|
+
val options = mock(FirebaseOptions::class.java)
|
|
132
|
+
|
|
133
|
+
mockStatic(Log::class.java).use {
|
|
134
|
+
ReactNativeFirebaseApp.setApplicationContext(storedContext)
|
|
135
|
+
}
|
|
136
|
+
mockStatic(FirebaseOptions::class.java).use { firebaseOptions ->
|
|
137
|
+
mockStatic(FirebaseApp::class.java).use { firebaseApps ->
|
|
138
|
+
firebaseOptions
|
|
139
|
+
.`when`<FirebaseOptions> { FirebaseOptions.fromResource(nullAsPlatformType()) }
|
|
140
|
+
.thenReturn(options)
|
|
141
|
+
|
|
142
|
+
ReactNativeFirebaseApp.initializeSecondaryApp("secondary", null)
|
|
143
|
+
|
|
144
|
+
firebaseOptions.verify { FirebaseOptions.fromResource(nullAsPlatformType()) }
|
|
145
|
+
firebaseApps.verify {
|
|
146
|
+
FirebaseApp.initializeApp(nullAsPlatformType(), options, "secondary")
|
|
147
|
+
}
|
|
148
|
+
assertSame(storedContext, ReactNativeFirebaseApp.getApplicationContext())
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@Suppress("UNCHECKED_CAST")
|
|
154
|
+
private fun <T> nullAsPlatformType(): T = null as T
|
|
155
|
+
|
|
156
|
+
private fun assertStaticMethod(
|
|
157
|
+
owner: Class<*>,
|
|
158
|
+
name: String,
|
|
159
|
+
returnType: Class<*>,
|
|
160
|
+
vararg parameterTypes: Class<*>,
|
|
161
|
+
) {
|
|
162
|
+
val method = owner.getMethod(name, *parameterTypes)
|
|
163
|
+
assertTrue("$name must remain static", Modifier.isStatic(method.modifiers))
|
|
164
|
+
assertTrue("$name must remain public", Modifier.isPublic(method.modifiers))
|
|
165
|
+
assertEquals(returnType, method.returnType)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
package io.invertase.firebase.common;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import static org.junit.Assert.assertEquals;
|
|
20
|
+
import static org.junit.Assert.assertFalse;
|
|
21
|
+
import static org.junit.Assert.assertSame;
|
|
22
|
+
import static org.junit.Assert.assertTrue;
|
|
23
|
+
import static org.mockito.Mockito.mock;
|
|
24
|
+
import static org.mockito.Mockito.verify;
|
|
25
|
+
import static org.mockito.Mockito.when;
|
|
26
|
+
|
|
27
|
+
import android.content.Context;
|
|
28
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
29
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
30
|
+
import com.facebook.react.bridge.WritableMap;
|
|
31
|
+
import com.google.firebase.FirebaseApp;
|
|
32
|
+
import java.lang.reflect.Method;
|
|
33
|
+
import java.lang.reflect.Modifier;
|
|
34
|
+
import java.lang.reflect.ParameterizedType;
|
|
35
|
+
import java.lang.reflect.Type;
|
|
36
|
+
import java.util.ArrayList;
|
|
37
|
+
import java.util.HashMap;
|
|
38
|
+
import java.util.List;
|
|
39
|
+
import java.util.Map;
|
|
40
|
+
import org.junit.Test;
|
|
41
|
+
|
|
42
|
+
/** Compile-time and reflection checks for callers that consume the Kotlin port from Java. */
|
|
43
|
+
public class RCTConvertFirebaseJavaCompatibilityTest {
|
|
44
|
+
@Test
|
|
45
|
+
public void preservesPublicOpenNoArgClassAndExactStaticMethodTypes() throws Exception {
|
|
46
|
+
Class<RCTConvertFirebase> type = RCTConvertFirebase.class;
|
|
47
|
+
|
|
48
|
+
assertTrue(Modifier.isPublic(type.getModifiers()));
|
|
49
|
+
assertFalse(Modifier.isFinal(type.getModifiers()));
|
|
50
|
+
assertTrue(Modifier.isPublic(type.getConstructor().getModifiers()));
|
|
51
|
+
assertEquals(type, new RCTConvertFirebase().getClass());
|
|
52
|
+
|
|
53
|
+
assertStaticMethod(
|
|
54
|
+
type.getMethod("firebaseAppToMap", FirebaseApp.class),
|
|
55
|
+
Map.class,
|
|
56
|
+
String.class,
|
|
57
|
+
Object.class);
|
|
58
|
+
assertStaticMethod(
|
|
59
|
+
type.getMethod("firebaseAppToWritableMap", FirebaseApp.class), WritableMap.class);
|
|
60
|
+
assertStaticMethod(
|
|
61
|
+
type.getMethod(
|
|
62
|
+
"readableMapToFirebaseApp", ReadableMap.class, ReadableMap.class, Context.class),
|
|
63
|
+
FirebaseApp.class);
|
|
64
|
+
assertStaticMethod(
|
|
65
|
+
type.getMethod("mapPutValue", String.class, Object.class, WritableMap.class),
|
|
66
|
+
WritableMap.class);
|
|
67
|
+
assertStaticMethod(
|
|
68
|
+
type.getMethod("readableMapToWritableMap", ReadableMap.class), WritableMap.class);
|
|
69
|
+
assertStaticMethod(
|
|
70
|
+
type.getMethod("toHashMap", ReadableMap.class), Map.class, String.class, Object.class);
|
|
71
|
+
assertStaticMethod(
|
|
72
|
+
type.getMethod("toArrayList", ReadableArray.class), List.class, Object.class);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Test
|
|
76
|
+
public void staticCallAcceptsNullableValueWithoutKotlinEntryChecks() {
|
|
77
|
+
WritableMap map = mock(WritableMap.class);
|
|
78
|
+
|
|
79
|
+
assertSame(map, RCTConvertFirebase.mapPutValue("null", null, map));
|
|
80
|
+
|
|
81
|
+
verify(map).putNull("null");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Test
|
|
85
|
+
public void javaStaticCollectionDelegatesPreserveMutableReturnIdentity() {
|
|
86
|
+
ReadableMap readableMap = mock(ReadableMap.class);
|
|
87
|
+
HashMap<String, Object> hashMap = new HashMap<>();
|
|
88
|
+
when(readableMap.toHashMap()).thenReturn(hashMap);
|
|
89
|
+
ReadableArray readableArray = mock(ReadableArray.class);
|
|
90
|
+
ArrayList<Object> arrayList = new ArrayList<>();
|
|
91
|
+
when(readableArray.toArrayList()).thenReturn(arrayList);
|
|
92
|
+
|
|
93
|
+
assertSame(hashMap, RCTConvertFirebase.toHashMap(readableMap));
|
|
94
|
+
assertSame(arrayList, RCTConvertFirebase.toArrayList(readableArray));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private static void assertStaticMethod(
|
|
98
|
+
Method method, Class<?> returnType, Type... genericArguments) {
|
|
99
|
+
assertTrue(Modifier.isPublic(method.getModifiers()));
|
|
100
|
+
assertTrue(Modifier.isStatic(method.getModifiers()));
|
|
101
|
+
assertEquals(returnType, method.getReturnType());
|
|
102
|
+
|
|
103
|
+
if (genericArguments.length == 0) {
|
|
104
|
+
assertEquals(returnType, method.getGenericReturnType());
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
ParameterizedType genericReturnType = (ParameterizedType) method.getGenericReturnType();
|
|
109
|
+
assertEquals(returnType, genericReturnType.getRawType());
|
|
110
|
+
assertEquals(List.of(genericArguments), List.of(genericReturnType.getActualTypeArguments()));
|
|
111
|
+
}
|
|
112
|
+
}
|