Last active
April 6, 2018 03:54
-
-
Save rpgobjects/ed023abb8e00d000fa3e to your computer and use it in GitHub Desktop.
Revisions
-
rpgobjects renamed this gist
May 24, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
rpgobjects renamed this gist
May 24, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
rpgobjects created this gist
May 24, 2014 .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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ /** * Espresso IdlingResource for Ion * https://github.com/koush/ion * https://code.google.com/p/android-test-kit/ * Because you can't deregister an IdlingResource, you have to create a new one per test. * You need to use a unique resourceName each test. */ public final class IonIdlingResource implements IdlingResource { private static final String TAG = "IonIdlingResource"; private final String resourceName; private Context context; private volatile ResourceCallback resourceCallback; public IonIdlingResource(String resourceName, Context context) { this.resourceName = resourceName; this.context = context; } @Override public String getName() { return resourceName; } @Override public boolean isIdleNow() { int count = Ion.getDefault(context).getPendingRequestCount(context); if(count == 0) { resourceCallback.onTransitionToIdle(); } Log.d(TAG,resourceName + " count=" + count); return count == 0; } @Override public void registerIdleTransitionCallback(ResourceCallback resourceCallback) { this.resourceCallback = resourceCallback; } }