[android] #4365 - reworked some samples, resources and tests
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.activity.CameraAnimationTypeActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Tests on CameraAnimationTypeActivity
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class CameraActivityTest extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<CameraAnimationTypeActivity> mActivityRule = new ActivityTestRule<>(CameraAnimationTypeActivity.class);
|
||||
|
||||
private Activity mActivity = null;
|
||||
|
||||
@Before
|
||||
public void setActivity() {
|
||||
mActivity = mActivityRule.getActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
checkViewIsDisplayed(R.id.cameraMapView);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.activity.CoordinateChangeActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Tests on CameraAnimationTypeActivity
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class CoordinateChangeActivityTest extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<CoordinateChangeActivity> mActivityRule = new ActivityTestRule<>(CoordinateChangeActivity.class);
|
||||
|
||||
private Activity mActivity = null;
|
||||
|
||||
@Before
|
||||
public void setActivity() {
|
||||
mActivity = mActivityRule.getActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.activity.DoubleMapActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Tests on DoubleMapActivity
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class DoubleMapActivityTest extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<DoubleMapActivity> mActivityRule = new ActivityTestRule<>(DoubleMapActivity.class);
|
||||
|
||||
private Activity mActivity = null;
|
||||
|
||||
@Before
|
||||
public void setActivity() {
|
||||
mActivity = mActivityRule.getActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
checkViewIsDisplayed(R.id.mini_map);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.FeatureOverviewActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.DrawerUtils;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.GestureUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
/**
|
||||
* Tests on FeatureOverviewActivity with screenshots
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class MainActivityScreenTest extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<FeatureOverviewActivity> mActivityRule = new ActivityTestRule<>(
|
||||
FeatureOverviewActivity.class);
|
||||
|
||||
private FeatureOverviewActivity mActivity = null;
|
||||
|
||||
@Before
|
||||
public void setActivity() {
|
||||
mActivity = mActivityRule.getActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
checkViewIsDisplayed(R.id.mainMapView);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStyleEmerald() {
|
||||
DrawerUtils.openDrawer();
|
||||
DrawerUtils.clickItem(R.string.styleEmerald);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
takeNamedScreenshot(mActivity, "testEmeraldStyle");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStyleStreets() {
|
||||
DrawerUtils.openDrawer();
|
||||
DrawerUtils.clickItem(R.string.styleMapboxStreets);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
takeNamedScreenshot(mActivity, "testStreetsStyle");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStyleDark() {
|
||||
DrawerUtils.openDrawer();
|
||||
DrawerUtils.clickItem(R.string.styleDark);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
takeNamedScreenshot(mActivity, "testDarkStyle");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStyleLight() {
|
||||
DrawerUtils.openDrawer();
|
||||
DrawerUtils.clickItem(R.string.styleLight);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
takeNamedScreenshot(mActivity, "testLightStyle");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStyleSatellite() {
|
||||
DrawerUtils.openDrawer();
|
||||
DrawerUtils.clickItem(R.string.styleSatellite);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
GestureUtils.doubleClickGesture(R.id.mainMapView);
|
||||
takeNamedScreenshot(mActivity, "testSatelliteStyle");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,260 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.FeatureOverviewActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
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.action.ViewActions.doubleClick;
|
||||
import static android.support.test.espresso.action.ViewActions.longClick;
|
||||
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;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
/**
|
||||
* Tests on FeatureOverviewActivity
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class MainActivityTest extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<FeatureOverviewActivity> mActivityRule = new ActivityTestRule<>(
|
||||
FeatureOverviewActivity.class);
|
||||
|
||||
private FeatureOverviewActivity mActivity = null;
|
||||
|
||||
@Before
|
||||
public void setActivity() {
|
||||
mActivity = mActivityRule.getActivity();
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that we need to keep the `test` prefix if we want to be able to run these
|
||||
* tests on AWS Device Farm, annotations are not enough:
|
||||
* https://github.com/awslabs/aws-device-farm-sample-app-for-android/issues/5#issuecomment-138258444
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
checkViewIsDisplayed(R.id.mainMapView);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check UI ids are visible
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testDrawerLayoutIsDisplayed() {
|
||||
onView(withId(R.id.drawer_layout))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToolbarIsDisplayed() {
|
||||
onView(withId(R.id.toolbar))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContentFrameIsDisplayed() {
|
||||
onView(withId(R.id.content_frame))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testViewFpsIsDisplayed() {
|
||||
// By default, R.id.view_fps is not displayed
|
||||
onView(withId(R.id.view_fps))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocationFABIsDisplayed() {
|
||||
onView(withId(R.id.locationFAB))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavViewIsNotDisplayed() {
|
||||
// By default, nav_view not displayed
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavViewIsDisplayed() {
|
||||
// However, it's displayed when we click the home icon
|
||||
onView(withContentDescription(HOME_BUTTON_STRING))
|
||||
.perform(click());
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Some more tests on the map view (clicks, gestures)
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testClickMap() {
|
||||
onView(withId(R.id.mainMapView))
|
||||
.perform(click())
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoubleClickMap() {
|
||||
onView(withId(R.id.mainMapView))
|
||||
.perform(doubleClick())
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongClickMap() {
|
||||
onView(withId(R.id.mainMapView))
|
||||
.perform(longClick())
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test the main drawer options
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testNavViewActionDebug() {
|
||||
onView(withContentDescription(HOME_BUTTON_STRING))
|
||||
.perform(click());
|
||||
onView(withText(R.string.action_debug))
|
||||
.perform(click());
|
||||
|
||||
// Clicking the item closes the drawer
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavViewActionPointAnnotations() {
|
||||
onView(withContentDescription(HOME_BUTTON_STRING))
|
||||
.perform(click());
|
||||
onView(withText(R.string.action_point_annotations))
|
||||
.perform(click());
|
||||
|
||||
// Clicking the item closes the drawer
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavViewActionCompass() {
|
||||
onView(withContentDescription(HOME_BUTTON_STRING))
|
||||
.perform(click());
|
||||
onView(withText(R.string.action_compass))
|
||||
.perform(click());
|
||||
|
||||
// Clicking the item closes the drawer
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavViewStyleMapboxStreets() {
|
||||
onView(withContentDescription(HOME_BUTTON_STRING))
|
||||
.perform(click());
|
||||
onView(withText(R.string.styleMapboxStreets))
|
||||
.perform(click());
|
||||
|
||||
// Clicking the item closes the drawer
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavViewStyleEmerald() {
|
||||
onView(withContentDescription(HOME_BUTTON_STRING))
|
||||
.perform(click());
|
||||
onView(withText(R.string.styleEmerald))
|
||||
.perform(click());
|
||||
|
||||
// Clicking the item closes the drawer
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavViewStyleLight() {
|
||||
onView(withContentDescription(HOME_BUTTON_STRING))
|
||||
.perform(click());
|
||||
onView(withText(R.string.styleLight))
|
||||
.perform(click());
|
||||
|
||||
// Clicking the item closes the drawer
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavViewStyleDark() {
|
||||
onView(withContentDescription(HOME_BUTTON_STRING))
|
||||
.perform(click());
|
||||
onView(withText(R.string.styleDark))
|
||||
.perform(click());
|
||||
|
||||
// Clicking the item closes the drawer
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavViewStyleSatellite() {
|
||||
onView(withContentDescription(HOME_BUTTON_STRING))
|
||||
.perform(click());
|
||||
onView(withText(R.string.styleSatellite))
|
||||
.perform(click());
|
||||
|
||||
// Clicking the item closes the drawer
|
||||
onView(withId(R.id.nav_view))
|
||||
.check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
/*
|
||||
* We can also check the map inner elements are visible
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testMapIconContentDescription() {
|
||||
// Mapbox logo
|
||||
onView(withContentDescription(mActivity.getResources()
|
||||
.getString(R.string.mapboxIconContentDescription)))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testMapCompassContentDescription() {
|
||||
// //FIXME this is currently broken hence compass view is only being showed when rotating the map
|
||||
// // Map compass
|
||||
//// onView(withContentDescription(mActivity.getResources()
|
||||
//// .getString(R.string.compassContentDescription)))
|
||||
//// .check(matches(isDisplayed()));
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testMapAttributionsIconContentDescription() {
|
||||
// Attribution icon
|
||||
onView(withContentDescription(mActivity.getResources()
|
||||
.getString(R.string.attributionsIconContentDescription)))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Tests on MapboxMapActivity
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class MapboxMapActivityTest extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<MapboxMapActivity> mActivityRule = new ActivityTestRule<>(MapboxMapActivity.class);
|
||||
|
||||
private Activity mActivity = null;
|
||||
|
||||
@Before
|
||||
public void setActivity() {
|
||||
mActivity = mActivityRule.getActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,6 @@ public class MaxMinZoomActivityTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
checkViewIsDisplayed(R.id.manualZoomMapView);
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.activity.PressForMarkerActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Tests on PressForMarkerActivity
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class PressForMarkerActivityTest extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<PressForMarkerActivity> mActivityRule = new ActivityTestRule<>(
|
||||
PressForMarkerActivity.class);
|
||||
|
||||
private PressForMarkerActivity mActivity = null;
|
||||
|
||||
@Before
|
||||
public void setActivity() {
|
||||
mActivity = mActivityRule.getActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
// we are adding mapview on the fly.. just validating if we have a toolbar
|
||||
checkViewIsDisplayed(R.id.secondToolBar);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.TiltActivity;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TiltActivityTest extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<TiltActivity> mActivityRule = new ActivityTestRule<>(
|
||||
TiltActivity.class);
|
||||
|
||||
private TiltActivity mActivity = null;
|
||||
|
||||
@Before
|
||||
public void setActivity() {
|
||||
mActivity = mActivityRule.getActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
checkViewIsDisplayed(R.id.tiltMapView);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,24 +7,25 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapUtils;
|
||||
import com.mapbox.mapboxsdk.testapp.FeatureOverviewActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.PolylineActivity;
|
||||
import com.robotium.solo.Solo;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public abstract class BaseMainActivityTest extends ActivityInstrumentationTestCase2<FeatureOverviewActivity> {
|
||||
public abstract class BaseMainActivityTest extends ActivityInstrumentationTestCase2<PolylineActivity> {
|
||||
|
||||
protected Solo solo;
|
||||
protected MapView mapView;
|
||||
protected MapboxMap mapboxMap;
|
||||
|
||||
public BaseMainActivityTest() {
|
||||
super(FeatureOverviewActivity.class);
|
||||
super(PolylineActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
solo = new Solo(getInstrumentation(), getActivity());
|
||||
mapView = (MapView) solo.getView(R.id.mainMapView);
|
||||
mapView = (MapView) solo.getView(R.id.mapView);
|
||||
mapboxMap = MapboxMapUtils.getMapboxMap(mapView);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user