[android] #4301 - added robotium testing framework to perform integration testing
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
/**
|
||||
* Utility class to fetch a MapboxMap instance by bypassing package visibility
|
||||
*/
|
||||
public class MapboxMapUtils {
|
||||
|
||||
/**
|
||||
* Get the MapboxMap instance linked to passed MapView
|
||||
*
|
||||
* @param mapView
|
||||
* @return
|
||||
*/
|
||||
public static MapboxMap getMapboxMap(MapView mapView){
|
||||
return mapView.getMapboxMap();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ScreenshotUtil;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.ScreenshotUtil;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.BulkMarkerActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.CameraActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.CoordinateChangeActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.DirectionsActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.DoubleMapActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.utils.ViewUtils;
|
||||
import com.mapbox.mapboxsdk.testapp.DynamicMarkerChangeActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.ViewUtils;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.GeocoderActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.InfoWindowActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.InfoWindowAdapterActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.InfoWindowConcurrentActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.LatLngBoundsActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,20 +1,19 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.utils.DrawerUtils;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.GestureUtils;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ScreenshotUtil;
|
||||
import com.mapbox.mapboxsdk.testapp.MainActivity;
|
||||
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.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.doubleClick;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
/**
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.MainActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.ManualZoomActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.MapFragmentActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.MapPaddingActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.MapboxMapActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.MaxMinZoomActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.MyLocationTrackingModeActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.PolylineActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.PressForMarkerActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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.R;
|
||||
import com.mapbox.mapboxsdk.testapp.ScrollByActivity;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
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 com.mapbox.mapboxsdk.testapp.SupportMapFragmentActivity;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
package com.mapbox.mapboxsdk.testapp.espresso;
|
||||
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.TiltActivity;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.testapp.utils;
|
||||
package com.mapbox.mapboxsdk.testapp.espresso.utils;
|
||||
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.test.espresso.Espresso;
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.testapp.utils;
|
||||
package com.mapbox.mapboxsdk.testapp.espresso.utils;
|
||||
|
||||
import android.support.annotation.IdRes;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.doubleClick;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.testapp.utils;
|
||||
package com.mapbox.mapboxsdk.testapp.espresso.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.testapp.utils;
|
||||
package com.mapbox.mapboxsdk.testapp.espresso.utils;
|
||||
|
||||
import android.support.annotation.IdRes;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mapbox.mapboxsdk.testapp.robotium;
|
||||
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapUtils;
|
||||
import com.mapbox.mapboxsdk.testapp.MainActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.robotium.solo.Solo;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public abstract class BaseMainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
|
||||
|
||||
protected Solo solo;
|
||||
protected MapView mapView;
|
||||
protected MapboxMap mapboxMap;
|
||||
|
||||
public BaseMainActivityTest() {
|
||||
super(MainActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
solo = new Solo(getInstrumentation(), getActivity());
|
||||
mapView = (MapView) solo.getView(R.id.mainMapView);
|
||||
mapboxMap = MapboxMapUtils.getMapboxMap(mapView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
solo.finishOpenedActivities();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanity() throws Exception {
|
||||
assertNotNull("Should be non null", solo);
|
||||
assertNotNull("Should be non null", mapView);
|
||||
assertNotNull("Should be non null", mapboxMap);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mapbox.mapboxsdk.testapp.robotium;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.widgets.CompassView;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.robotium.utils.ViewAssertion;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class CompassViewTest extends BaseMainActivityTest {
|
||||
|
||||
private CompassView compassView;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
compassView = (CompassView) solo.getView(R.id.compassView);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompass() {
|
||||
setCameraDirection(0);
|
||||
solo.sleep(200);
|
||||
ViewAssertion.isInvisible(compassView);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompassClick() throws Exception {
|
||||
setCameraDirection(20);
|
||||
solo.sleep(200);
|
||||
ViewAssertion.isVisible(compassView);
|
||||
solo.clickOnView(compassView);
|
||||
solo.sleep(200);
|
||||
ViewAssertion.isVisible(compassView);
|
||||
}
|
||||
|
||||
private void setCameraDirection(float bearing) {
|
||||
mapboxMap.setCameraPosition(new CameraPosition.Builder()
|
||||
.target(new LatLng(0, 0))
|
||||
.tilt(0)
|
||||
.zoom(15)
|
||||
.bearing(bearing)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mapbox.mapboxsdk.testapp.robotium.utils;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
public class ViewAssertion {
|
||||
|
||||
public static void isVisible(View view) {
|
||||
assertEquals(view.getClass().getSimpleName() + " should be visible", view.getVisibility(), View.VISIBLE);
|
||||
}
|
||||
|
||||
public static void isInvisible(View view) {
|
||||
assertEquals(view.getClass().getSimpleName() + " should be visible", view.getVisibility(), View.INVISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user