// Path: example/src/androidTest/java/net/cattaka/android/adaptertoolbox/example/test/RecyclerViewAnimatingIdlingResource.java
// public class RecyclerViewAnimatingIdlingResource implements IdlingResource {
//     RecyclerView mRecyclerView;
//     ResourceCallback mCallback;
// 
//     public RecyclerViewAnimatingIdlingResource(RecyclerView recyclerView) {
//         mRecyclerView = recyclerView;
//     }
// 
//     @Override
//     public void registerIdleTransitionCallback(ResourceCallback callback) {
//         mCallback = callback;
//     }
// 
//     @Override
//     public boolean isIdleNow() {
//         if (!mRecyclerView.isAnimating()) {
//             if (mCallback != null) {
//                 mCallback.onTransitionToIdle();
//             }
//             return true;
//         } else {
//             return false;
//         }
//     }
// 
//     @Override
//     public String getName() {
//         return "RecyclerViewAnimatingIdlingResource";
//     }
// }
// 
// Path: example/src/androidTest/java/net/cattaka/android/adaptertoolbox/example/test/TestUtils.java
// public static void waitForIdlingResource(IdlingResource idlingResource, int timeout) {
//     long l = SystemClock.elapsedRealtime();
//     do {
//         if (idlingResource.isIdleNow()) {
//             break;
//         }
//         SystemClock.sleep(100);
//     } while (SystemClock.elapsedRealtime() - l > timeout);
// }


import android.support.test.rule.ActivityTestRule;
import net.cattaka.android.adaptertoolbox.example.test.RecyclerViewAnimatingIdlingResource;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.swipeDown;
import static android.support.test.espresso.action.ViewActions.swipeUp;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static net.cattaka.android.adaptertoolbox.example.test.TestUtils.waitForIdlingResource;
package net.cattaka.android.adaptertoolbox.example;





/**
 * Created by cattaka on 17/01/02.
 */
public class VerticalListDividerExampleActivityTest {
    @Rule
    public ActivityTestRule<VerticalListDividerExampleActivity> mActivityTestRule = new ActivityTestRule<>(VerticalListDividerExampleActivity.class, false, false);

    RecyclerViewAnimatingIdlingResource mRecyclerViewAnimatingIdlingResource;
    VerticalListDividerExampleActivity mActivity;

    @Before
    public void before() {
        mActivity = mActivityTestRule.launchActivity(null);
        mRecyclerViewAnimatingIdlingResource = new RecyclerViewAnimatingIdlingResource(mActivity.mRecyclerView);
    }

    @Test
    public void testRun() {
        onView(withId(R.id.recycler)).perform(swipeUp());
        waitForIdlingResource(mRecyclerViewAnimatingIdlingResource, 5000);
        onView(withId(R.id.recycler)).perform(swipeDown());
// Path: example/src/androidTest/java/net/cattaka/android/adaptertoolbox/example/test/RecyclerViewAnimatingIdlingResource.java
// public class RecyclerViewAnimatingIdlingResource implements IdlingResource {
//     RecyclerView mRecyclerView;
//     ResourceCallback mCallback;
// 
//     public RecyclerViewAnimatingIdlingResource(RecyclerView recyclerView) {
//         mRecyclerView = recyclerView;
//     }
// 
//     @Override
//     public void registerIdleTransitionCallback(ResourceCallback callback) {
//         mCallback = callback;
//     }
// 
//     @Override
//     public boolean isIdleNow() {
//         if (!mRecyclerView.isAnimating()) {
//             if (mCallback != null) {
//                 mCallback.onTransitionToIdle();
//             }
//             return true;
//         } else {
//             return false;
//         }
//     }
// 
//     @Override
//     public String getName() {
//         return "RecyclerViewAnimatingIdlingResource";
//     }
// }
// 
// Path: example/src/androidTest/java/net/cattaka/android/adaptertoolbox/example/test/TestUtils.java
// public static void waitForIdlingResource(IdlingResource idlingResource, int timeout) {
//     long l = SystemClock.elapsedRealtime();
//     do {
//         if (idlingResource.isIdleNow()) {
//             break;
//         }
//         SystemClock.sleep(100);
//     } while (SystemClock.elapsedRealtime() - l > timeout);
// }


// Path: example/src/androidTest/java/net/cattaka/android/adaptertoolbox/example/VerticalListDividerExampleActivityTest.java
import android.support.test.rule.ActivityTestRule;
import net.cattaka.android.adaptertoolbox.example.test.RecyclerViewAnimatingIdlingResource;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.swipeDown;
import static android.support.test.espresso.action.ViewActions.swipeUp;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static net.cattaka.android.adaptertoolbox.example.test.TestUtils.waitForIdlingResource;

package net.cattaka.android.adaptertoolbox.example;





/**
 * Created by cattaka on 17/01/02.
 */
public class VerticalListDividerExampleActivityTest {
    @Rule
    public ActivityTestRule<VerticalListDividerExampleActivity> mActivityTestRule = new ActivityTestRule<>(VerticalListDividerExampleActivity.class, false, false);

    RecyclerViewAnimatingIdlingResource mRecyclerViewAnimatingIdlingResource;
    VerticalListDividerExampleActivity mActivity;

    @Before
    public void before() {
        mActivity = mActivityTestRule.launchActivity(null);
        mRecyclerViewAnimatingIdlingResource = new RecyclerViewAnimatingIdlingResource(mActivity.mRecyclerView);
    }

    @Test
    public void testRun() {
        onView(withId(R.id.recycler)).perform(swipeUp());
        waitForIdlingResource(mRecyclerViewAnimatingIdlingResource, 5000);
        onView(withId(R.id.recycler)).perform(swipeDown());
        waitForIdlingResource(mRecyclerViewAnimatingIdlingResource, 5000);