forked from microsoft/react-native-macos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose an API to enable Concurrent Root on Android (facebook#33645)
Summary: Pull Request resolved: facebook#33645 With React 18, we now need to allow users on Fabric to opt-in for Concurrent Root. This commit adds a new method that can be called on the ReactActivityDelegate that can be used to set the `concurrentRoot` flag on the `initialProps` on the Render. Changelog: [Android] [Added] - Expose an API to enable Concurrent Root on Android Reviewed By: mdvacca Differential Revision: D35614879 fbshipit-source-id: 2de83e8115d3748c0346cdec6f31b2ab1f899478
- Loading branch information
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
ReactAndroid/src/test/java/com/facebook/react/ReactActivityDelegateTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react | ||
|
||
import android.os.Bundle | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class ReactActivityDelegateTest { | ||
|
||
@Test | ||
fun delegateWithConcurrentRoot_populatesInitialPropsCorrectly() { | ||
val delegate = | ||
object : ReactActivityDelegate(null, "test-delegate") { | ||
override fun isConcurrentRootEnabled() = true | ||
public val inspectLaunchOptions: Bundle? | ||
get() = getLaunchOptions() | ||
} | ||
|
||
assertNotNull(delegate.inspectLaunchOptions) | ||
assertTrue(delegate.inspectLaunchOptions!!.containsKey("concurrentRoot")) | ||
assertTrue(delegate.inspectLaunchOptions!!.getBoolean("concurrentRoot")) | ||
} | ||
|
||
@Test | ||
fun delegateWithoutConcurrentRoot_hasNullInitialProperties() { | ||
val delegate = | ||
object : ReactActivityDelegate(null, "test-delegate") { | ||
override fun isConcurrentRootEnabled() = false | ||
public val inspectLaunchOptions: Bundle? | ||
get() = getLaunchOptions() | ||
} | ||
|
||
assertNull(delegate.inspectLaunchOptions) | ||
} | ||
|
||
@Test | ||
fun delegateWithConcurrentRoot_composesInitialPropertiesCorrectly() { | ||
val delegate = | ||
object : ReactActivityDelegate(null, "test-delegate") { | ||
override fun isConcurrentRootEnabled() = true | ||
override fun getLaunchOptions(): Bundle = | ||
Bundle().apply { putString("test-property", "test-value") } | ||
public val inspectLaunchOptions: Bundle? | ||
get() = getLaunchOptions() | ||
} | ||
|
||
assertNotNull(delegate.inspectLaunchOptions) | ||
assertTrue(delegate.inspectLaunchOptions!!.containsKey("concurrentRoot")) | ||
assertTrue(delegate.inspectLaunchOptions!!.getBoolean("concurrentRoot")) | ||
assertTrue(delegate.inspectLaunchOptions!!.containsKey("test-property")) | ||
assertEquals("test-value", delegate.inspectLaunchOptions!!.getString("test-property")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters