@react-native-firebase/app 26.4.0 → 27.0.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.
Files changed (242) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +10 -27
  3. package/RNFBApp.podspec +13 -5
  4. package/android/build.gradle +3 -0
  5. package/android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.kt +29 -0
  6. package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.kt +146 -0
  7. package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.kt +156 -0
  8. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.kt +44 -0
  9. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.kt +100 -0
  10. package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.kt +250 -0
  11. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.kt +64 -0
  12. package/android/src/reactnative/java/io/invertase/firebase/app/{ReactNativeFirebaseAppInitProvider.java → ReactNativeFirebaseAppInitProvider.kt} +3 -4
  13. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.kt +47 -0
  14. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.kt +33 -0
  15. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +1 -1
  16. package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.kt +185 -0
  17. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.kt +35 -0
  18. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.kt +662 -0
  19. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.kt +103 -0
  20. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.kt +96 -0
  21. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.kt +140 -0
  22. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.kt +109 -0
  23. package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.kt +451 -0
  24. package/android/src/reactnative/java/io/invertase/firebase/interfaces/{ContextProvider.java → ContextProvider.kt} +8 -8
  25. package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeError.java → NativeError.kt} +8 -8
  26. package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeEvent.java → NativeEvent.kt} +6 -6
  27. package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.kt +219 -0
  28. package/android/src/test/java/expo/core/ModuleRegistry.java +9 -0
  29. package/android/src/test/java/io/invertase/firebase/app/NativeRNFBTurboAppTest.java +182 -59
  30. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppComponentsJavaCompatibilityTest.java +70 -0
  31. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppJavaCompatibilityTest.java +60 -0
  32. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackageTest.java +165 -0
  33. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppTest.kt +167 -0
  34. package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseJavaCompatibilityTest.java +112 -0
  35. package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseTest.kt +317 -0
  36. package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.kt +309 -0
  37. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterJavaCompatibilityTest.java +176 -0
  38. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterTest.java +143 -12
  39. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventTest.kt +61 -0
  40. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONJavaCompatibilityTest.java +85 -0
  41. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.kt +296 -0
  42. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaJavaCompatibilityTest.java +67 -0
  43. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaTest.kt +246 -0
  44. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseModuleTest.kt +254 -0
  45. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesJavaCompatibilityTest.java +87 -0
  46. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesTest.kt +260 -0
  47. package/android/src/test/java/io/invertase/firebase/common/SharedUtilsJavaCompatibilityTest.java +255 -0
  48. package/android/src/test/java/io/invertase/firebase/common/SharedUtilsTest.kt +674 -0
  49. package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.kt +290 -0
  50. package/android/src/test/java/io/invertase/firebase/common/UniversalFirebaseModuleJavaCompatibilityTest.java +178 -0
  51. package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesJavaCompatibilityTest.java +99 -0
  52. package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesTest.kt +217 -0
  53. package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleJavaCompatibilityTest.java +176 -0
  54. package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleKotlinCompatibilityTest.kt +52 -0
  55. package/android/src/test/java/io/invertase/firebase/interfaces/InterfacesJavaCompatibilityTest.java +144 -0
  56. package/android/src/test/java/io/invertase/firebase/interfaces/NativeEventTest.kt +56 -0
  57. package/android/src/test/java/io/invertase/firebase/utils/NativeRNFBTurboUtilsTest.java +517 -21
  58. package/dist/module/FirebaseApp.js +10 -0
  59. package/dist/module/FirebaseApp.js.map +1 -1
  60. package/dist/module/common/deeps.js +3 -0
  61. package/dist/module/common/deeps.js.map +1 -1
  62. package/dist/module/internal/FirebaseModule.js.map +1 -1
  63. package/dist/module/internal/RNFBNativeEventEmitter.js +12 -1
  64. package/dist/module/internal/RNFBNativeEventEmitter.js.map +1 -1
  65. package/dist/module/internal/SharedEventEmitter.js +3 -1
  66. package/dist/module/internal/SharedEventEmitter.js.map +1 -1
  67. package/dist/module/internal/index.js +1 -0
  68. package/dist/module/internal/index.js.map +1 -1
  69. package/dist/module/internal/registry/app.js +7 -1
  70. package/dist/module/internal/registry/app.js.map +1 -1
  71. package/dist/module/types/app.js.map +1 -1
  72. package/dist/module/types/internal.js +2 -0
  73. package/dist/module/version.js +1 -1
  74. package/dist/typescript/lib/FirebaseApp.d.ts +7 -0
  75. package/dist/typescript/lib/FirebaseApp.d.ts.map +1 -1
  76. package/dist/typescript/lib/common/deeps.d.ts.map +1 -1
  77. package/dist/typescript/lib/internal/FirebaseModule.d.ts +2 -3
  78. package/dist/typescript/lib/internal/FirebaseModule.d.ts.map +1 -1
  79. package/dist/typescript/lib/internal/NativeModules.d.ts +4 -1
  80. package/dist/typescript/lib/internal/NativeModules.d.ts.map +1 -1
  81. package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts +2 -2
  82. package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts.map +1 -1
  83. package/dist/typescript/lib/internal/SharedEventEmitter.d.ts +3 -3
  84. package/dist/typescript/lib/internal/SharedEventEmitter.d.ts.map +1 -1
  85. package/dist/typescript/lib/internal/index.d.ts +1 -0
  86. package/dist/typescript/lib/internal/index.d.ts.map +1 -1
  87. package/dist/typescript/lib/internal/registry/app.d.ts.map +1 -1
  88. package/dist/typescript/lib/types/app.d.ts +10 -3
  89. package/dist/typescript/lib/types/app.d.ts.map +1 -1
  90. package/dist/typescript/lib/types/internal.d.ts +12 -0
  91. package/dist/typescript/lib/types/internal.d.ts.map +1 -1
  92. package/dist/typescript/lib/version.d.ts +1 -1
  93. package/firebase-schema.json +4 -0
  94. package/firebase_spm.rb +552 -96
  95. package/ios/RNFBApp/RCTConvert+FIRApp.h +2 -5
  96. package/ios/RNFBApp/RCTConvert+FIRApp.m +11 -6
  97. package/ios/RNFBApp/RCTConvert+FIROptions.h +2 -5
  98. package/ios/RNFBApp/RCTConvert+FIROptions.m +11 -10
  99. package/ios/RNFBApp/RCTConvertFIRApp.swift +86 -0
  100. package/ios/RNFBApp/RCTConvertFIROptions.swift +259 -0
  101. package/ios/RNFBApp/RNFBAppCustomAuthDomains.swift +63 -0
  102. package/ios/RNFBApp/RNFBAppInitializeOptionsMapper.swift +113 -0
  103. package/ios/RNFBApp/RNFBAppLogLevelMapper.swift +53 -0
  104. package/ios/RNFBApp/RNFBAppModule+CustomAuthDomain.m +35 -0
  105. package/ios/RNFBApp/RNFBAppModule.h +6 -2
  106. package/ios/RNFBApp/RNFBAppModule.mm +65 -228
  107. package/ios/RNFBApp/RNFBAppModuleFirebase.swift +439 -0
  108. package/ios/RNFBApp/RNFBAppModuleImplementation.h +68 -0
  109. package/ios/RNFBApp/RNFBAppModuleImplementation.m +195 -0
  110. package/ios/RNFBApp/RNFBHandleMap.m +27 -56
  111. package/ios/RNFBApp/RNFBHandleMapStorage.swift +90 -0
  112. package/ios/RNFBApp/RNFBInitializeAppArguments.swift +82 -0
  113. package/ios/RNFBApp/RNFBJSON.m +22 -38
  114. package/ios/RNFBApp/RNFBJSONImplementation.swift +71 -0
  115. package/ios/RNFBApp/RNFBMeta.m +24 -26
  116. package/ios/RNFBApp/RNFBMetaStorage.swift +76 -0
  117. package/ios/RNFBApp/RNFBNullSentinelDecoding.swift +135 -0
  118. package/ios/RNFBApp/RNFBNullSentinelInterceptor.h +30 -3
  119. package/ios/RNFBApp/RNFBNullSentinelInterceptor.m +28 -5
  120. package/ios/RNFBApp/RNFBPreferences.m +22 -20
  121. package/ios/RNFBApp/RNFBPreferencesStorage.swift +101 -0
  122. package/ios/RNFBApp/RNFBRCTEventEmitter.m +36 -93
  123. package/ios/RNFBApp/RNFBRCTEventEmitterCore.swift +161 -0
  124. package/ios/RNFBApp/RNFBSharedUtils.h +2 -5
  125. package/ios/RNFBApp/RNFBSharedUtils.m +109 -198
  126. package/ios/RNFBApp/RNFBSharedUtilsConfig.swift +72 -0
  127. package/ios/RNFBApp/RNFBSharedUtilsFIRApp.swift +271 -0
  128. package/ios/RNFBApp/RNFBSharedUtilsFormatting.swift +59 -0
  129. package/ios/RNFBApp/RNFBSharedUtilsPromiseRejection.swift +88 -0
  130. package/ios/RNFBApp/RNFBUtilsHelpers.swift +116 -0
  131. package/ios/RNFBApp/RNFBUtilsModule+Foundation.m +44 -0
  132. package/ios/RNFBApp/RNFBUtilsModule+PhotoAssets.m +47 -0
  133. package/ios/RNFBApp/RNFBUtilsModule.h +11 -1
  134. package/ios/RNFBApp/RNFBUtilsModule.mm +10 -85
  135. package/ios/RNFBApp/RNFBUtilsModuleImplementation.h +32 -0
  136. package/ios/RNFBApp/RNFBUtilsModuleImplementation.m +56 -0
  137. package/ios/RNFBApp/RNFBVersion.m +1 -1
  138. package/ios/RNFBApp.xcodeproj/project.pbxproj +100 -0
  139. package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FIRApp.m +171 -0
  140. package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FirebaseCore.h +78 -0
  141. package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FIRInstallations.m +7 -0
  142. package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FirebaseInstallations.h +8 -0
  143. package/ios/RNFBAppUnitTests/HostStubs/RNFBAppModuleHostStub.m +55 -0
  144. package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.h +89 -0
  145. package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.mm +30 -0
  146. package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.h +19 -0
  147. package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.m +32 -0
  148. package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridgeModule.h +19 -0
  149. package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.h +28 -0
  150. package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.m +23 -0
  151. package/ios/RNFBAppUnitTests/HostStubs/React/RCTEventEmitter.h +9 -0
  152. package/ios/RNFBAppUnitTests/HostStubs/React/RCTInvalidating.h +24 -0
  153. package/ios/RNFBAppUnitTests/HostStubs/React/RCTUtils.h +9 -0
  154. package/ios/RNFBAppUnitTests/HostStubs/module.modulemap +13 -0
  155. package/ios/RNFBAppUnitTests/RCTConvertFIRAppFacadeTests.m +61 -0
  156. package/ios/RNFBAppUnitTests/RCTConvertFIRAppTests.swift +73 -0
  157. package/ios/RNFBAppUnitTests/RCTConvertFIROptionsFacadeTests.m +57 -0
  158. package/ios/RNFBAppUnitTests/RCTConvertFIROptionsTests.swift +243 -0
  159. package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsFacadeTests.m +73 -0
  160. package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsTests.swift +70 -0
  161. package/ios/RNFBAppUnitTests/RNFBAppInitializeOptionsMapperTests.swift +190 -0
  162. package/ios/RNFBAppUnitTests/RNFBAppLogLevelFacadeTests.m +76 -0
  163. package/ios/RNFBAppUnitTests/RNFBAppLogLevelMapperTests.swift +59 -0
  164. package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseFacadeTests.m +215 -0
  165. package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseTests.swift +430 -0
  166. package/ios/RNFBAppUnitTests/RNFBAppModuleLifecycleTests.m +206 -0
  167. package/ios/RNFBAppUnitTests/RNFBAppModuleShellTests.mm +367 -0
  168. package/ios/RNFBAppUnitTests/RNFBAppUnitTests.xcodeproj/project.pbxproj +355 -2
  169. package/ios/RNFBAppUnitTests/RNFBFirebaseAppClientTests.swift +165 -0
  170. package/ios/RNFBAppUnitTests/RNFBHandleMapStorageTests.swift +121 -0
  171. package/ios/RNFBAppUnitTests/RNFBInitializeAppArgumentsTests.swift +256 -0
  172. package/ios/RNFBAppUnitTests/RNFBJSONImplementationTests.swift +126 -0
  173. package/ios/RNFBAppUnitTests/RNFBJSONTests.m +172 -0
  174. package/ios/RNFBAppUnitTests/RNFBMetaStorageTests.swift +106 -0
  175. package/ios/RNFBAppUnitTests/RNFBMetaTests.m +65 -0
  176. package/ios/RNFBAppUnitTests/RNFBNullSentinelDecodingTests.swift +286 -0
  177. package/ios/RNFBAppUnitTests/RNFBNullSentinelInterceptorTests.m +312 -0
  178. package/ios/RNFBAppUnitTests/RNFBPreferencesStorageTests.swift +105 -0
  179. package/ios/RNFBAppUnitTests/RNFBPreferencesTests.m +110 -0
  180. package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterCoreTests.swift +163 -0
  181. package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterFacadeTests.m +141 -0
  182. package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigFacadeTests.m +100 -0
  183. package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigTests.swift +234 -0
  184. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppFacadeTests.m +145 -0
  185. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppTests.swift +173 -0
  186. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingFacadeTests.m +38 -0
  187. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingTests.swift +82 -0
  188. package/ios/RNFBAppUnitTests/RNFBSharedUtilsNullSentinelTests.m +35 -0
  189. package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionFacadeTests.m +107 -0
  190. package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionTests.swift +133 -0
  191. package/ios/RNFBAppUnitTests/RNFBUtilsHelpersTests.swift +144 -0
  192. package/ios/RNFBAppUnitTests/RNFBUtilsModuleFacadeTests.m +72 -0
  193. package/ios/RNFBAppUnitTests/RNFBUtilsModuleShellTests.mm +282 -0
  194. package/ios/RNFBFirebase/Package.swift +53 -0
  195. package/ios/RNFBFirebase/Sources/RNFBFirebase/RNFBFirebase.swift +285 -0
  196. package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/Public/.gitkeep +0 -0
  197. package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/RNFBFirebaseBridge.m +169 -0
  198. package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/include/RNFBFirebaseBridge.h +52 -0
  199. package/ios/RNFBFirebaseUnitTests/RNFBAppDynamicFacadeTests.swift +240 -0
  200. package/{android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.java → ios/RNFBFirebaseUnitTests/RNFBFirebaseClientImport.swift} +23 -14
  201. package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/project.pbxproj +588 -0
  202. package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/xcshareddata/xcschemes/RNFBFirebaseUnitTests.xcscheme +83 -0
  203. package/ios_config.sh +50 -22
  204. package/lib/FirebaseApp.ts +10 -0
  205. package/lib/common/deeps.ts +3 -0
  206. package/lib/internal/FirebaseModule.ts +6 -3
  207. package/lib/internal/NativeModules.ts +4 -1
  208. package/lib/internal/RNFBNativeEventEmitter.ts +14 -5
  209. package/lib/internal/SharedEventEmitter.ts +5 -1
  210. package/lib/internal/index.ts +1 -0
  211. package/lib/internal/react-native-vendor-emitter.d.ts +11 -0
  212. package/lib/internal/registry/app.ts +7 -1
  213. package/lib/types/app.ts +10 -3
  214. package/lib/types/internal.ts +19 -0
  215. package/lib/version.ts +1 -1
  216. package/package.json +8 -8
  217. package/plugin/build/ios/appDelegate.js +2 -2
  218. package/plugin/build/ios/podfile.js +16 -16
  219. package/plugin/build/pluginConfig.d.ts +4 -2
  220. package/plugin/src/ios/appDelegate.ts +2 -2
  221. package/plugin/src/ios/podfile.ts +20 -23
  222. package/plugin/src/pluginConfig.ts +4 -2
  223. package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.java +0 -150
  224. package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java +0 -148
  225. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.java +0 -62
  226. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.java +0 -91
  227. package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.java +0 -224
  228. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.java +0 -46
  229. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java +0 -49
  230. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.java +0 -35
  231. package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.java +0 -192
  232. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.java +0 -53
  233. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.java +0 -606
  234. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.java +0 -109
  235. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.java +0 -101
  236. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.java +0 -146
  237. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.java +0 -96
  238. package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java +0 -441
  239. package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.java +0 -223
  240. package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.java +0 -275
  241. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.java +0 -108
  242. package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.java +0 -97
@@ -1,275 +0,0 @@
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
-
20
- import static org.junit.Assert.assertEquals;
21
- import static org.junit.Assert.assertFalse;
22
- import static org.junit.Assert.assertNull;
23
- import static org.junit.Assert.assertSame;
24
- import static org.junit.Assert.assertTrue;
25
- import static org.junit.Assert.fail;
26
-
27
- import java.util.List;
28
- import java.util.concurrent.CountDownLatch;
29
- import java.util.concurrent.TimeUnit;
30
- import java.util.concurrent.atomic.AtomicReference;
31
- import org.junit.Before;
32
- import org.junit.Test;
33
-
34
- /**
35
- * JVM coverage for {@link RNFBHandleMap}. Tests must not invoke methods on stored values — the map
36
- * only moves pointers.
37
- */
38
- public class RNFBHandleMapTest {
39
-
40
- private RNFBHandleMap<Integer, Object> map;
41
-
42
- @Before
43
- public void setUp() {
44
- map = new RNFBHandleMap<>();
45
- }
46
-
47
- @Test
48
- public void putGetTake_happyPath() throws Exception {
49
- Object handle = new Object();
50
- map.put(1, handle);
51
-
52
- assertSame(handle, map.get(1));
53
- assertSame(handle, map.take(1));
54
- assertNull(map.get(1));
55
- }
56
-
57
- @Test
58
- public void take_missingKey_returnsNull() {
59
- assertNull(map.take(99));
60
- assertNull(map.get(99));
61
- }
62
-
63
- @Test
64
- public void takeAll_returnsSnapshotAndLeavesMapEmpty() throws Exception {
65
- Object a = new Object();
66
- Object b = new Object();
67
- map.put(1, a);
68
- map.put(2, b);
69
-
70
- List<Object> snapshot = map.takeAll();
71
-
72
- assertEquals(2, snapshot.size());
73
- assertTrue(snapshot.contains(a));
74
- assertTrue(snapshot.contains(b));
75
- assertNull(map.get(1));
76
- assertNull(map.get(2));
77
- assertTrue(map.takeAll().isEmpty());
78
- }
79
-
80
- @Test
81
- public void put_occupiedId_throwsCollision() throws Exception {
82
- Object first = new Object();
83
- map.put(1, first);
84
- try {
85
- map.put(1, new Object());
86
- fail("expected RNFBHandleCollisionException");
87
- } catch (RNFBHandleCollisionException e) {
88
- assertTrue(e.getMessage().contains("1"));
89
- assertSame(first, map.get(1));
90
- }
91
- }
92
-
93
- @Test
94
- public void putIfAbsent_whenFree_storesAndReturnsTrue() throws Exception {
95
- Object handle = new Object();
96
- assertTrue(map.putIfAbsent(1, handle));
97
- assertSame(handle, map.get(1));
98
- }
99
-
100
- @Test
101
- public void putIfAbsent_whenOccupied_keepsExistingAndReturnsFalse() throws Exception {
102
- Object first = new Object();
103
- Object second = new Object();
104
- map.put(1, first);
105
- assertFalse(map.putIfAbsent(1, second));
106
- assertSame(first, map.get(1));
107
- }
108
-
109
- @Test
110
- public void putIfAbsentOrSame_whenAbsent_storesAndReturnsTrue() {
111
- Object handle = new Object();
112
- assertTrue(map.putIfAbsentOrSame(1, handle));
113
- assertSame(handle, map.get(1));
114
- }
115
-
116
- @Test
117
- public void putIfAbsentOrSame_whenSameInstance_returnsTrue() throws Exception {
118
- Object handle = new Object();
119
- map.put(1, handle);
120
- assertTrue(map.putIfAbsentOrSame(1, handle));
121
- assertSame(handle, map.get(1));
122
- }
123
-
124
- @Test
125
- public void putIfAbsentOrSame_whenDifferent_returnsFalse() throws Exception {
126
- Object first = new Object();
127
- Object second = new Object();
128
- map.put(1, first);
129
- assertFalse(map.putIfAbsentOrSame(1, second));
130
- assertSame(first, map.get(1));
131
- }
132
-
133
- @Test
134
- public void putReplacing_whenFree_storesAndReturnsNull() throws Exception {
135
- Object handle = new Object();
136
- assertNull(map.putReplacing(1, handle));
137
- assertSame(handle, map.get(1));
138
- }
139
-
140
- @Test
141
- public void putReplacing_whenOccupied_replacesLastWins() throws Exception {
142
- Object first = new Object();
143
- Object second = new Object();
144
- map.put(1, first);
145
- assertSame(first, map.putReplacing(1, second));
146
- assertSame(second, map.get(1));
147
- }
148
-
149
- @Test
150
- public void put_afterTake_allowsReuse() throws Exception {
151
- Object first = new Object();
152
- Object second = new Object();
153
- map.put(1, first);
154
- assertSame(first, map.take(1));
155
- map.put(1, second);
156
- assertSame(second, map.get(1));
157
- }
158
-
159
- @Test
160
- public void takeIf_whenPredicateTrue_removesAndReturns() throws Exception {
161
- Object handle = new Object();
162
- map.put(1, handle);
163
- assertSame(handle, map.takeIf(1, v -> v == handle));
164
- assertNull(map.get(1));
165
- }
166
-
167
- @Test
168
- public void takeIf_whenPredicateFalse_leavesMapping() throws Exception {
169
- Object handle = new Object();
170
- map.put(1, handle);
171
- assertNull(map.takeIf(1, v -> false));
172
- assertSame(handle, map.get(1));
173
- }
174
-
175
- @Test
176
- public void takeIf_whenMissing_returnsNull() {
177
- assertNull(map.takeIf(99, v -> true));
178
- }
179
-
180
- @Test
181
- public void take_sameIdFromTwoThreads_onlyOneReturnsNonNull() throws Exception {
182
- Object handle = new Object();
183
- map.put(1, handle);
184
-
185
- CountDownLatch start = new CountDownLatch(1);
186
- CountDownLatch done = new CountDownLatch(2);
187
- AtomicReference<Object> first = new AtomicReference<>();
188
- AtomicReference<Object> second = new AtomicReference<>();
189
-
190
- Thread t1 =
191
- new Thread(
192
- () -> {
193
- try {
194
- start.await();
195
- first.set(map.take(1));
196
- } catch (InterruptedException e) {
197
- Thread.currentThread().interrupt();
198
- } finally {
199
- done.countDown();
200
- }
201
- });
202
- Thread t2 =
203
- new Thread(
204
- () -> {
205
- try {
206
- start.await();
207
- second.set(map.take(1));
208
- } catch (InterruptedException e) {
209
- Thread.currentThread().interrupt();
210
- } finally {
211
- done.countDown();
212
- }
213
- });
214
-
215
- t1.start();
216
- t2.start();
217
- start.countDown();
218
- assertTrue(done.await(5, TimeUnit.SECONDS));
219
-
220
- Object a = first.get();
221
- Object b = second.get();
222
- boolean onlyFirst = a == handle && b == null;
223
- boolean onlySecond = b == handle && a == null;
224
- assertTrue(onlyFirst || onlySecond);
225
- assertNull(map.get(1));
226
- }
227
-
228
- @Test
229
- public void putReplacing_sameIdFromTwoThreads_lastWins() throws Exception {
230
- Object first = new Object();
231
- Object second = new Object();
232
- Object third = new Object();
233
- map.put(1, first);
234
-
235
- CountDownLatch start = new CountDownLatch(1);
236
- CountDownLatch done = new CountDownLatch(2);
237
- AtomicReference<Object> prevA = new AtomicReference<>();
238
- AtomicReference<Object> prevB = new AtomicReference<>();
239
-
240
- Thread t1 =
241
- new Thread(
242
- () -> {
243
- try {
244
- start.await();
245
- prevA.set(map.putReplacing(1, second));
246
- } catch (InterruptedException e) {
247
- Thread.currentThread().interrupt();
248
- } finally {
249
- done.countDown();
250
- }
251
- });
252
- Thread t2 =
253
- new Thread(
254
- () -> {
255
- try {
256
- start.await();
257
- prevB.set(map.putReplacing(1, third));
258
- } catch (InterruptedException e) {
259
- Thread.currentThread().interrupt();
260
- } finally {
261
- done.countDown();
262
- }
263
- });
264
-
265
- t1.start();
266
- t2.start();
267
- start.countDown();
268
- assertTrue(done.await(5, TimeUnit.SECONDS));
269
-
270
- Object winner = map.get(1);
271
- assertTrue(winner == second || winner == third);
272
- Object returnedFirst = prevA.get() == first ? prevA.get() : prevB.get();
273
- assertSame(first, returnedFirst);
274
- }
275
- }
@@ -1,108 +0,0 @@
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.assertSame;
20
- import static org.mockito.ArgumentMatchers.eq;
21
- import static org.mockito.Mockito.mock;
22
- import static org.mockito.Mockito.mockStatic;
23
- import static org.mockito.Mockito.verifyNoInteractions;
24
- import static org.mockito.Mockito.when;
25
-
26
- import com.facebook.react.bridge.Arguments;
27
- import com.facebook.react.bridge.WritableMap;
28
- import java.lang.reflect.Field;
29
- import java.util.Collections;
30
- import java.util.List;
31
- import org.json.JSONObject;
32
- import org.junit.After;
33
- import org.junit.Before;
34
- import org.junit.Test;
35
- import org.mockito.MockedStatic;
36
-
37
- /**
38
- * Plain JUnit4 + Mockito (AndroidTest-AD-1). Covers {@link ReactNativeFirebaseJSON#getAll()}.
39
- * JSONObject is mocked because Android's org.json stubs are not available on the JVM.
40
- */
41
- public class ReactNativeFirebaseJSONTest {
42
-
43
- private ReactNativeFirebaseJSON json;
44
- private Field jsonObjectField;
45
- private Object originalJsonObject;
46
-
47
- @Before
48
- public void setUp() throws Exception {
49
- json = ReactNativeFirebaseJSON.getSharedInstance();
50
- jsonObjectField = ReactNativeFirebaseJSON.class.getDeclaredField("jsonObject");
51
- jsonObjectField.setAccessible(true);
52
- originalJsonObject = jsonObjectField.get(json);
53
- }
54
-
55
- @After
56
- public void tearDown() throws Exception {
57
- jsonObjectField.set(json, originalJsonObject);
58
- }
59
-
60
- @Test
61
- public void getAllReturnsEmptyMapWhenJsonObjectIsNull() throws Exception {
62
- WritableMap emptyMap = mock(WritableMap.class);
63
- jsonObjectField.set(json, null);
64
-
65
- try (MockedStatic<Arguments> arguments = mockStatic(Arguments.class)) {
66
- arguments.when(Arguments::createMap).thenReturn(emptyMap);
67
-
68
- assertSame(emptyMap, json.getAll());
69
- verifyNoInteractions(emptyMap);
70
- }
71
- }
72
-
73
- @Test
74
- public void getAllReturnsEmptyMapForEmptyJsonObject() throws Exception {
75
- WritableMap emptyMap = mock(WritableMap.class);
76
- JSONObject jsonObject = mock(JSONObject.class);
77
- when(jsonObject.keys()).thenReturn(Collections.emptyIterator());
78
- jsonObjectField.set(json, jsonObject);
79
-
80
- try (MockedStatic<Arguments> arguments = mockStatic(Arguments.class)) {
81
- arguments.when(Arguments::createMap).thenReturn(emptyMap);
82
-
83
- assertSame(emptyMap, json.getAll());
84
- verifyNoInteractions(emptyMap);
85
- }
86
- }
87
-
88
- @Test
89
- public void getAllMapsNonEmptyJsonObjectEntries() throws Exception {
90
- WritableMap writableMap = mock(WritableMap.class);
91
- JSONObject jsonObject = mock(JSONObject.class);
92
- when(jsonObject.keys()).thenReturn(List.of("analytics_auto_collection_enabled").iterator());
93
- when(jsonObject.get("analytics_auto_collection_enabled")).thenReturn(false);
94
- jsonObjectField.set(json, jsonObject);
95
-
96
- try (MockedStatic<Arguments> arguments = mockStatic(Arguments.class);
97
- MockedStatic<SharedUtils> sharedUtils = mockStatic(SharedUtils.class)) {
98
- arguments.when(Arguments::createMap).thenReturn(writableMap);
99
-
100
- assertSame(writableMap, json.getAll());
101
-
102
- sharedUtils.verify(
103
- () ->
104
- SharedUtils.mapPutValue(
105
- eq("analytics_auto_collection_enabled"), eq(false), eq(writableMap)));
106
- }
107
- }
108
- }
@@ -1,97 +0,0 @@
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
-
20
- import static org.junit.Assert.assertFalse;
21
- import static org.junit.Assert.assertTrue;
22
- import static org.mockito.ArgumentMatchers.anyInt;
23
- import static org.mockito.ArgumentMatchers.anyString;
24
- import static org.mockito.Mockito.mock;
25
- import static org.mockito.Mockito.mockStatic;
26
- import static org.mockito.Mockito.when;
27
-
28
- import java.util.concurrent.CountDownLatch;
29
- import java.util.concurrent.ExecutorService;
30
- import java.util.concurrent.TimeUnit;
31
- import java.util.concurrent.atomic.AtomicBoolean;
32
- import org.junit.After;
33
- import org.junit.Before;
34
- import org.junit.Test;
35
- import org.mockito.MockedStatic;
36
-
37
- /**
38
- * Plain JUnit4 + Mockito (AndroidTest-AD-1). Constructor reads pool sizing from {@link
39
- * ReactNativeFirebaseJSON}; stub that away so we never touch Android's unmocked {@code
40
- * org.json.JSONObject}.
41
- */
42
- public class TaskExecutorServiceTest {
43
-
44
- private MockedStatic<ReactNativeFirebaseJSON> jsonStatic;
45
-
46
- @Before
47
- public void setUp() {
48
- ReactNativeFirebaseJSON json = mock(ReactNativeFirebaseJSON.class);
49
- when(json.getIntValue(anyString(), anyInt())).thenAnswer(inv -> inv.getArgument(1));
50
- jsonStatic = mockStatic(ReactNativeFirebaseJSON.class);
51
- jsonStatic.when(ReactNativeFirebaseJSON::getSharedInstance).thenReturn(json);
52
- }
53
-
54
- @After
55
- public void tearDown() {
56
- jsonStatic.close();
57
- }
58
-
59
- @Test
60
- public void transactionalExecutorRunsSubmittedWork() throws Exception {
61
- TaskExecutorService service = new TaskExecutorService("TestTransactionalRuns");
62
- ExecutorService executor = service.getTransactionalExecutor();
63
- CountDownLatch latch = new CountDownLatch(1);
64
-
65
- executor.execute(latch::countDown);
66
-
67
- assertTrue("work submitted before shutdown runs", latch.await(5, TimeUnit.SECONDS));
68
- service.shutdown();
69
- }
70
-
71
- @Test
72
- public void transactionalExecutorDiscardsWorkSubmittedAfterShutdown() {
73
- TaskExecutorService service = new TaskExecutorService("TestTransactionalShutdown");
74
- ExecutorService executor = service.getTransactionalExecutor();
75
- service.shutdown();
76
- AtomicBoolean ran = new AtomicBoolean(false);
77
-
78
- // Must not throw RejectedExecutionException - this is the crash path hit when a
79
- // play-services Task completes after module invalidation has shut the executor down.
80
- executor.execute(() -> ran.set(true));
81
-
82
- assertFalse("work submitted after shutdown is discarded", ran.get());
83
- }
84
-
85
- @Test
86
- public void pooledExecutorDiscardsWorkSubmittedAfterShutdown() {
87
- TaskExecutorService service = new TaskExecutorService("TestPooledShutdown");
88
- ExecutorService executor = service.getExecutor(false, "");
89
- service.shutdown();
90
- AtomicBoolean ran = new AtomicBoolean(false);
91
-
92
- // Exercises the executeInFallback handler's shutdown guard.
93
- executor.execute(() -> ran.set(true));
94
-
95
- assertFalse("work submitted after shutdown is discarded", ran.get());
96
- }
97
- }