Skip to content

Instantly share code, notes, and snippets.

@azzumw
Last active February 2, 2019 18:29
Show Gist options
  • Save azzumw/556fa82fc96ab6e34e70f178da5f77b5 to your computer and use it in GitHub Desktop.
Save azzumw/556fa82fc96ab6e34e70f178da5f77b5 to your computer and use it in GitHub Desktop.
package com.example.macintosh.thebakingappproject;
import com.example.macintosh.thebakingappproject.IdlingResource.EspressoIdlingResource;
import com.example.macintosh.thebakingappproject.IdlingResource.OkHttpIdlingResource;
import com.example.macintosh.thebakingappproject.IdlingResource.SimpleIdlingResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.Random;
import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.IdlingRegistry;
import androidx.test.espresso.IdlingResource;
import androidx.test.espresso.contrib.RecyclerViewActions;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import okhttp3.OkHttpClient;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.core.AllOf.allOf;
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> mainActivityTestRule = new ActivityTestRule<>(MainActivity.class);
@Before
public void prepare() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Test
public void scrollToPosition_mainRecipeList() {
// First, scroll to the position that needs to be matched and click on it.
onView(withId(R.id.mainRecipeRV)).perform(RecyclerViewActions.scrollToPosition(1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment