-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Run the tests on latest android emulators #4868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gosha212
merged 8 commits into
master
from
feature/4867-android-migrate-the-tests-to-android-16
Dec 24, 2025
+41
−12
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e0a3d46
Run the tests on latest android emulators
gosha212 9c8eb51
Merge branch 'master' into feature/4867-android-migrate-the-tests-to-…
gosha212 c8efd9b
Merge branch 'master' into feature/4867-android-migrate-the-tests-to-…
gosha212 6d1561f
Fixed espresso loopers caching
gosha212 52206cc
Merge branch 'master' into feature/4867-android-migrate-the-tests-to-…
gosha212 5d623f5
Merge branch 'master' into feature/4867-android-migrate-the-tests-to-…
d4vidi a5ced7e
Merge branch 'master' into feature/4867-android-migrate-the-tests-to-…
gosha212 23ce04c
Fixes after pr
gosha212 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ class ReactNativeIdlingResources( | |
| fun unregisterAll() { | ||
| unregisterMQThreadsInterrogators() | ||
| unregisterIdlingResources() | ||
| syncIdlingResources() | ||
| } | ||
|
|
||
| fun pauseNetworkSynchronization() = pauseIdlingResource(IdlingResourcesName.Network) | ||
|
|
@@ -77,8 +78,8 @@ class ReactNativeIdlingResources( | |
| } | ||
|
|
||
| private fun setupMQThreadsInterrogator(looperName: LooperName) { | ||
| reactApplication.getCurrentReactContext()?.let { | ||
| val mqThreadsReflector = MQThreadsReflector(it) | ||
| reactApplication.getCurrentReactContext()?.let { reactContext -> | ||
| val mqThreadsReflector = MQThreadsReflector(reactContext) | ||
| val looper = when (looperName) { | ||
| LooperName.JS -> mqThreadsReflector.getJSMQueue()?.getLooper() | ||
| LooperName.NativeModules -> mqThreadsReflector.getNativeModulesQueue()?.getLooper() | ||
|
|
@@ -108,12 +109,44 @@ class ReactNativeIdlingResources( | |
| } | ||
|
|
||
| private fun unregisterMQThreadsInterrogators() { | ||
| loopers.values.forEach { | ||
| IdlingRegistry.getInstance().unregisterLooperAsIdlingResource(it) | ||
| loopers.values.forEach { looper -> | ||
| IdlingRegistry.getInstance().unregisterLooperAsIdlingResource(looper) | ||
| clearLooperHandlerCache(looper) | ||
| } | ||
| loopers.clear() | ||
| } | ||
|
|
||
| /** | ||
| * Workaround for Espresso 3.7.0+ where LooperIdlingResourceInterrogationHandler | ||
| * caches handlers in a static map but doesn't clear them on release(). | ||
| * This causes re-registered loopers to get stale handlers with releasing=true. | ||
| * | ||
| * For older Espresso versions without this static cache, this is a no-op. | ||
| */ | ||
| private fun clearLooperHandlerCache(looper: Looper) { | ||
| try { | ||
| val handlerClass = Class.forName("androidx.test.espresso.base.LooperIdlingResourceInterrogationHandler") | ||
| val instsField = handlerClass.getDeclaredField("insts") | ||
| instsField.isAccessible = true | ||
| @Suppress("UNCHECKED_CAST") | ||
| val insts = instsField.get(null) as java.util.concurrent.ConcurrentHashMap<String, Any> | ||
|
|
||
| val name = String.format( | ||
|
||
| java.util.Locale.ROOT, | ||
| "LooperIdlingResource-%s-%s", | ||
| looper.thread.id, | ||
| looper.thread.name | ||
| ) | ||
| insts.remove(name) | ||
| } catch (_: ClassNotFoundException) { | ||
| // Expected for older Espresso versions - silently ignore | ||
| } catch (_: NoSuchFieldException) { | ||
| // Expected for Espresso versions with different implementation - silently ignore | ||
| } catch (e: Exception) { | ||
| Log.w(LOG_TAG, "Failed to clear looper handler cache", e) | ||
| } | ||
| } | ||
|
|
||
| @OptIn(ExperimentalStdlibApi::class) | ||
| private fun unregisterIdlingResources() { | ||
| IdlingResourcesName.entries.forEach { | ||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.