Comments (4)
I'm having a crash in DelegatingIdlingResourceScheduler.stopWork
as well due to callback being null.
from rxidler.
Related to this, we get a similar crash by trying to do the init "(RxJavaPlugins.setInitIoSchedulerHandler(Rx2Idler.create(RXJAVA_IO_SCHEDULER_NAME))" in TestRunner's onCreate (otherwise, the app init creates schedulers before onStart so it will never get overridden w/ the idling one). If we do the init in onStart, the IOScheduler is already started so InitIoSchedulerHandler never gets called (verified w/ breakpoints)
from rxidler.
DelegatingIdlingResourceScheduler.stopWork() probably needs a null check for callback but it also looks like it's not initialized properly...
from rxidler.
I've written a workaround for this error while the issue is not merged, it's far from perfect but it does the trick for me.
class TestRunner : AndroidJUnitRunner() {
override fun onStart() {
RxJavaPlugins.setInitComputationSchedulerHandler {
Rx2Idler.create("RxJava Computation Scheduler").apply(it).also {
forceIdlingResourceRegistrySync()
}
}
RxJavaPlugins.setInitIoSchedulerHandler {
Rx2Idler.create("RxJava IO Scheduler").apply(it).also {
forceIdlingResourceRegistrySync()
}
}
super.onStart()
}
@Suppress("DEPRECATION")
private fun forceIdlingResourceRegistrySync() {
// Workaround for https://github.com/square/RxIdler/issues/20
// This forces espresso to sync idling resources, cause the callback to be set for all available
// resources and preventing RxIdler from crashing
// By registering and unregistering a new resource we will force the registry to be updated,
// we don't really care for the resource we are registering itself
// TODO PLEASE REMOVE THIS ONCE THE BUG ON RXIDLER HAS BEEN FIXED
val mockIdlingResource = object : IdlingResource {
override fun getName(): String = "Mock Idling Resource Name"
override fun isIdleNow(): Boolean = false
override fun registerIdleTransitionCallback(callback: IdlingResource.ResourceCallback?) {
}
}
Espresso.registerIdlingResources(mockIdlingResource)
Espresso.unregisterIdlingResources(mockIdlingResource)
}
}
I'm not sure if a simple call to Espresso.onIdle would suffice, and since I can't seem to reproduce it consistently I went with a flow that I could easily track. If there's a cleaner way to do this please let me know
from rxidler.
Related Issues (14)
- RxIdler throws IllegalStateException when buffer is used HOT 15
- Scheduler handlers do not take effect in rxjava-2.1.3 HOT 8
- DelegatingIdlingResourceScheduler does not work with .delay() HOT 2
- Debounce doesn't taken into account. HOT 3
- Support for AndroidX ? HOT 4
- Does library unregisters IdlingResource? HOT 4
- Latest code changes not released yet HOT 1
- stopWork() crashes when attempting to call onTransitionToIdle() HOT 4
- Not idling? HOT 1
- Is there any idler library used for rxjava3? HOT 1
- Question: How could I test case with an infinite Observable?
- RxJava 3 and RxJava 3 Retrofit adapter HOT 1
- RxIdler does not wait until network request get finished HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxidler.