moved screenshot tests to its own class

This commit is contained in:
Antonio Zugaldia
2015-09-16 11:02:11 -04:00
parent e4d1e67d71
commit c3dffb6e46

View File

@@ -0,0 +1,61 @@
package com.mapbox.mapboxgl.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
/**
* Tests on MainActivity with screenshots
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityScreenTest extends BaseTest {
private final static String HOME_BUTTON_STRING = "Navigate up";
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
MainActivity.class);
private MainActivity mActivity = null;
@Before
public void setActivity() {
mActivity = mActivityRule.getActivity();
}
@Test
public void testSanity() {
checkViewIsDisplayed(R.id.mainMapView);
}
/*
* Take a screenshot of Mapbox Streets to monitor #1649
*/
@Test
public void testMapboxStreetsBlackAndWhite() {
// Click home and switch to Mapbox streets
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.styleMapboxStreets))
.perform(click());
// Standard screenshot
takeNamedScreenshot(mActivity, "testMapboxStreetsBlackAndWhite");
}
}