package com.beaker.reciperoulette; 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.withId; import static androidx.test.espresso.matcher.ViewMatchers.withTagValue; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import android.content.Context; import android.content.SharedPreferences; import androidx.test.ext.junit.rules.ActivityScenarioRule; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; import androidx.test.platform.app.InstrumentationRegistry; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @LargeTest @RunWith(AndroidJUnit4.class) public class NNRecipeGenerationTest { @Rule public ActivityScenarioRule<MainMenu> mActivityScenarioRule = new ActivityScenarioRule<>(MainMenu.class); @Rule public TInternetOffRule ior = new TInternetOffRule(); @Before public void waitForMenu() throws InterruptedException { Context c = InstrumentationRegistry.getInstrumentation().getTargetContext(); SharedPreferences sharedPref = c.getSharedPreferences(c.getString(R.string.shared_pref_filename), Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(c.getString(R.string.prf_token), "TESTTOKEN"); editor.putString(c.getString(R.string.prf_eml), "18chanp1@gmail.com"); editor.apply(); } @Test public void checkGenerateRecipesButtonVisible() { gotoGenerateRecipe(); String tagval = "valentinosfavoritebutton"; onView(withId(R.id.recipeButtonLayout)).check(matches(not(withTagValue(is(tagval))))); } private void gotoGenerateRecipe() { onView(withText("Recipe Engine")).perform(click()); } }