// Path: app/src/androidTest/java/de/czyrux/store/toolbox/idlingresource/RxIdlingResource.java
// public class RxIdlingResource implements IdlingResource, Function<Runnable, Runnable> {
// 
//     private static final String RESOURCE_NAME = RxIdlingResource.class.getSimpleName();
// 
//     private static final ReentrantLock IDLING_STATE_LOCK = new ReentrantLock();
// 
//     // Guarded by IDLING_STATE_LOCK
//     private int taskCount = 0;
// 
//     // Guarded by IDLING_STATE_LOCK
//     private IdlingResource.ResourceCallback transitionCallback;
// 
//     @Override
//     public String getName() {
//         return RESOURCE_NAME;
//     }
// 
//     @Override
//     public boolean isIdleNow() {
//         boolean result;
// 
//         IDLING_STATE_LOCK.lock();
//         result = taskCount == 0;
//         IDLING_STATE_LOCK.unlock();
// 
//         return result;
//     }
// 
//     @Override
//     public void registerIdleTransitionCallback(final ResourceCallback callback) {
//         IDLING_STATE_LOCK.lock();
//         this.transitionCallback = callback;
//         IDLING_STATE_LOCK.unlock();
//     }
// 
//     @Override
//     public Runnable apply(final Runnable runnable)  {
//         return () -> {
//             IDLING_STATE_LOCK.lock();
//             taskCount++;
//             IDLING_STATE_LOCK.unlock();
// 
//             try {
//                 runnable.run();
//             } finally {
//                 IDLING_STATE_LOCK.lock();
// 
//                 try {
//                     taskCount--;
// 
//                     if (taskCount == 0 && transitionCallback != null) {
//                         transitionCallback.onTransitionToIdle();
//                     }
//                 } finally {
//                     IDLING_STATE_LOCK.unlock();
//                 }
//             }
//         };
//     }
// }


import android.support.test.espresso.Espresso;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import de.czyrux.store.toolbox.idlingresource.RxIdlingResource;
import io.reactivex.plugins.RxJavaPlugins;
package de.czyrux.store.toolbox.rules;




public class RxIdlingRule implements TestRule {

    @Override
    public Statement apply(final Statement base, Description description) {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
// Path: app/src/androidTest/java/de/czyrux/store/toolbox/idlingresource/RxIdlingResource.java
// public class RxIdlingResource implements IdlingResource, Function<Runnable, Runnable> {
// 
//     private static final String RESOURCE_NAME = RxIdlingResource.class.getSimpleName();
// 
//     private static final ReentrantLock IDLING_STATE_LOCK = new ReentrantLock();
// 
//     // Guarded by IDLING_STATE_LOCK
//     private int taskCount = 0;
// 
//     // Guarded by IDLING_STATE_LOCK
//     private IdlingResource.ResourceCallback transitionCallback;
// 
//     @Override
//     public String getName() {
//         return RESOURCE_NAME;
//     }
// 
//     @Override
//     public boolean isIdleNow() {
//         boolean result;
// 
//         IDLING_STATE_LOCK.lock();
//         result = taskCount == 0;
//         IDLING_STATE_LOCK.unlock();
// 
//         return result;
//     }
// 
//     @Override
//     public void registerIdleTransitionCallback(final ResourceCallback callback) {
//         IDLING_STATE_LOCK.lock();
//         this.transitionCallback = callback;
//         IDLING_STATE_LOCK.unlock();
//     }
// 
//     @Override
//     public Runnable apply(final Runnable runnable)  {
//         return () -> {
//             IDLING_STATE_LOCK.lock();
//             taskCount++;
//             IDLING_STATE_LOCK.unlock();
// 
//             try {
//                 runnable.run();
//             } finally {
//                 IDLING_STATE_LOCK.lock();
// 
//                 try {
//                     taskCount--;
// 
//                     if (taskCount == 0 && transitionCallback != null) {
//                         transitionCallback.onTransitionToIdle();
//                     }
//                 } finally {
//                     IDLING_STATE_LOCK.unlock();
//                 }
//             }
//         };
//     }
// }


// Path: app/src/androidTest/java/de/czyrux/store/toolbox/rules/RxIdlingRule.java
import android.support.test.espresso.Espresso;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import de.czyrux.store.toolbox.idlingresource.RxIdlingResource;
import io.reactivex.plugins.RxJavaPlugins;

package de.czyrux.store.toolbox.rules;




public class RxIdlingRule implements TestRule {

    @Override
    public Statement apply(final Statement base, Description description) {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
                RxIdlingResource rxIdlingResource = new RxIdlingResource();