// Path: example/src/main/java/net/cattaka/android/adaptertoolbox/example/data/ActivityEntry.java
// public class ActivityEntry implements ITreeItem<ActivityEntry> {
//     @StringRes
//     private int labelResId;
//     private Class<? extends Activity> clazz;
//     private List<ActivityEntry> children;
// 
//     public ActivityEntry(@StringRes int labelResId, Class<? extends Activity> clazz, ActivityEntry... children) {
//         this.labelResId = labelResId;
//         this.clazz = clazz;
//         this.children = Arrays.asList(children);
//     }
// 
//     public String getLabel(Resources res) {
//         return res.getString(labelResId);
//     }
// 
//     public Class<? extends Activity> getClazz() {
//         return clazz;
//     }
// 
//     @Override
//     public List<ActivityEntry> getChildren() {
//         return children;
//     }
// }
// 
// Path: example/src/androidTest/java/net/cattaka/android/adaptertoolbox/example/test/TestUtils.java
// @SuppressWarnings("unchecked")
// public static <T extends Activity> T monitorActivity(@NonNull Class<T> activityClass, int timeOut, @NonNull Runnable runnable) {
//     Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor(activityClass.getCanonicalName(), null, false);
//     try {
//         InstrumentationRegistry.getInstrumentation().addMonitor(monitor);
//         runnable.run();
//         return (T) monitor.waitForActivityWithTimeout(timeOut);
//     } finally {
//         InstrumentationRegistry.getInstrumentation().removeMonitor(monitor);
//     }
// }


import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import net.cattaka.android.adaptertoolbox.example.data.ActivityEntry;
import org.junit.Rule;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
import static android.support.test.espresso.contrib.RecyclerViewActions.scrollToPosition;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static net.cattaka.android.adaptertoolbox.example.test.TestUtils.monitorActivity;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
package net.cattaka.android.adaptertoolbox.example;






/**
 * Created by cattaka on 16/06/05.
 */
public class MainActivityTest {
    @Rule
    public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class, false, false);

    @Test
    public void clickAll() {
        mActivityTestRule.launchActivity(null);
        List<ActivityEntry> dataPoinsts = pullDataPoints(new ArrayList<ActivityEntry>(), MainActivity.ACTIVITY_ENTRIES);
        for (int i = 0; i < dataPoinsts.size(); i++) {
            ActivityEntry item = dataPoinsts.get(i);
            if (item.getClazz() == null) {
                continue;
            }
            mActivityTestRule.getActivity();
            final int position = i;
// Path: example/src/main/java/net/cattaka/android/adaptertoolbox/example/data/ActivityEntry.java
// public class ActivityEntry implements ITreeItem<ActivityEntry> {
//     @StringRes
//     private int labelResId;
//     private Class<? extends Activity> clazz;
//     private List<ActivityEntry> children;
// 
//     public ActivityEntry(@StringRes int labelResId, Class<? extends Activity> clazz, ActivityEntry... children) {
//         this.labelResId = labelResId;
//         this.clazz = clazz;
//         this.children = Arrays.asList(children);
//     }
// 
//     public String getLabel(Resources res) {
//         return res.getString(labelResId);
//     }
// 
//     public Class<? extends Activity> getClazz() {
//         return clazz;
//     }
// 
//     @Override
//     public List<ActivityEntry> getChildren() {
//         return children;
//     }
// }
// 
// Path: example/src/androidTest/java/net/cattaka/android/adaptertoolbox/example/test/TestUtils.java
// @SuppressWarnings("unchecked")
// public static <T extends Activity> T monitorActivity(@NonNull Class<T> activityClass, int timeOut, @NonNull Runnable runnable) {
//     Instrumentation.ActivityMonitor monitor = new Instrumentation.ActivityMonitor(activityClass.getCanonicalName(), null, false);
//     try {
//         InstrumentationRegistry.getInstrumentation().addMonitor(monitor);
//         runnable.run();
//         return (T) monitor.waitForActivityWithTimeout(timeOut);
//     } finally {
//         InstrumentationRegistry.getInstrumentation().removeMonitor(monitor);
//     }
// }


// Path: example/src/androidTest/java/net/cattaka/android/adaptertoolbox/example/MainActivityTest.java
import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import net.cattaka.android.adaptertoolbox.example.data.ActivityEntry;
import org.junit.Rule;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
import static android.support.test.espresso.contrib.RecyclerViewActions.scrollToPosition;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static net.cattaka.android.adaptertoolbox.example.test.TestUtils.monitorActivity;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;

package net.cattaka.android.adaptertoolbox.example;






/**
 * Created by cattaka on 16/06/05.
 */
public class MainActivityTest {
    @Rule
    public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class, false, false);

    @Test
    public void clickAll() {
        mActivityTestRule.launchActivity(null);
        List<ActivityEntry> dataPoinsts = pullDataPoints(new ArrayList<ActivityEntry>(), MainActivity.ACTIVITY_ENTRIES);
        for (int i = 0; i < dataPoinsts.size(); i++) {
            ActivityEntry item = dataPoinsts.get(i);
            if (item.getClazz() == null) {
                continue;
            }
            mActivityTestRule.getActivity();
            final int position = i;
            Activity nextActivity = monitorActivity(item.getClazz(), 5000, new Runnable() {