diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-11 12:39:43 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-16 14:52:29 -0800 |
commit | 13d5b18ebaeb330f05c4abfc04e0247222e038ba (patch) | |
tree | 90e24f1fb745581767b6979d1c562e60859cbcf6 /android/MapboxGLAndroidSDKTestApp/src/androidTest | |
parent | 0db9f229f2bb14e2c6ccd3a8c0d0a30eb25ea5c5 (diff) | |
download | qtlocation-mapboxgl-13d5b18ebaeb330f05c4abfc04e0247222e038ba.tar.gz |
[android] Move into platform subdirectory
Diffstat (limited to 'android/MapboxGLAndroidSDKTestApp/src/androidTest')
13 files changed, 0 insertions, 830 deletions
diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/BaseTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/BaseTest.java deleted file mode 100644 index e432d5f576..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/BaseTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.mapbox.mapboxsdk.testapp; - -import android.app.Activity; - -import com.mapbox.mapboxsdk.testapp.utils.ScreenshotUtil; - -import static android.support.test.espresso.Espresso.onView; -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.withId; - -/** - * Base Espresso class for all tests, helps working with ActivityInstrumentationTestCase2 - */ -public class BaseTest { - - protected final static String HOME_BUTTON_STRING = "Navigate up"; - - /* - * Shortcuts for common UI tests - */ - - protected void checkViewIsDisplayed(int id) { - onView(withId(id)) - .check(matches(isDisplayed())); - } - - /* - * Screenshots logic - */ - - protected void takeNamedScreenshot(final Activity activity, final String name) { - - // Screenshots need to be taken on the UI thread - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - ScreenshotUtil.take(activity, name); - } - }); - - } - -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/BulkMarkerActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/BulkMarkerActivityTest.java deleted file mode 100644 index d66ae8f514..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/BulkMarkerActivityTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.mapbox.mapboxsdk.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; - -/** - * Tests on BulkMarkerActivity - */ -@RunWith(AndroidJUnit4.class) -@LargeTest -public class BulkMarkerActivityTest extends BaseTest { - - @Rule - public ActivityTestRule<BulkMarkerActivity> mActivityRule = new ActivityTestRule<>( - BulkMarkerActivity.class); - - private BulkMarkerActivity mActivity = null; - - @Before - public void setActivity() { - mActivity = mActivityRule.getActivity(); - } - - @Test - public void testSanity() { - checkViewIsDisplayed(R.id.mapView); - } -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivityTest.java deleted file mode 100644 index 9fb99fe262..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivityTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.mapbox.mapboxsdk.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; - -/** - * Tests on InfoWindowActivity - */ -@RunWith(AndroidJUnit4.class) -@LargeTest -public class InfoWindowActivityTest extends BaseTest { - - @Rule - public ActivityTestRule<InfoWindowActivity> mActivityRule = new ActivityTestRule<>( - InfoWindowActivity.class); - - private InfoWindowActivity mActivity = null; - - @Before - public void setActivity() { - mActivity = mActivityRule.getActivity(); - } - - @Test - public void testSanity() { - checkViewIsDisplayed(R.id.mapView); - } -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/InfoWindowAdapterActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/InfoWindowAdapterActivityTest.java deleted file mode 100644 index 51bd163fc1..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/InfoWindowAdapterActivityTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.mapbox.mapboxsdk.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; - -/** - * Tests on InfoWindowAdapterActivity. - */ -@RunWith(AndroidJUnit4.class) -@LargeTest -public class InfoWindowAdapterActivityTest extends BaseTest { - - @Rule - public ActivityTestRule<InfoWindowAdapterActivity> mActivityRule = new ActivityTestRule<>( - InfoWindowAdapterActivity.class); - - private InfoWindowAdapterActivity mActivity = null; - - @Before - public void setActivity() { - mActivity = mActivityRule.getActivity(); - } - - @Test - public void testSanity() { - checkViewIsDisplayed(R.id.mapView); - } -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MainActivityScreenTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MainActivityScreenTest.java deleted file mode 100644 index bbfa4ec73a..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MainActivityScreenTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.mapbox.mapboxsdk.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.action.ViewActions.doubleClick; -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()); - - // Zoom in - onView(withId(R.id.mainMapView)) - .perform(doubleClick()); - onView(withId(R.id.mainMapView)) - .perform(doubleClick()); - - // Standard screenshot - takeNamedScreenshot(mActivity, "testMapboxStreetsBlackAndWhite"); - } - -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MainActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MainActivityTest.java deleted file mode 100644 index c545bc118b..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MainActivityTest.java +++ /dev/null @@ -1,289 +0,0 @@ -package com.mapbox.mapboxsdk.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.action.ViewActions.doubleClick; -import static android.support.test.espresso.action.ViewActions.longClick; -import static android.support.test.espresso.action.ViewActions.swipeDown; -import static android.support.test.espresso.action.ViewActions.swipeLeft; -import static android.support.test.espresso.action.ViewActions.swipeRight; -import static android.support.test.espresso.action.ViewActions.swipeUp; -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 MainActivity - */ -@RunWith(AndroidJUnit4.class) -@LargeTest -public class MainActivityTest extends BaseTest { - - @Rule - public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>( - MainActivity.class); - - private MainActivity 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 - public void testSwipeLeftMap() { - onView(withId(R.id.mainMapView)) - .perform(swipeLeft()) - .check(matches(isDisplayed())); - } - - @Test - public void testSwipeRightMap() { - onView(withId(R.id.mainMapView)) - .perform(swipeRight()) - .check(matches(isDisplayed())); - } - - @Test - public void testSwipeDownMap() { - onView(withId(R.id.mainMapView)) - .perform(swipeDown()) - .check(matches(isDisplayed())); - } - - @Test - public void testSwipeUpMap() { - onView(withId(R.id.mainMapView)) - .perform(swipeUp()) - .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())); - } - -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MapFragmentActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MapFragmentActivityTest.java deleted file mode 100644 index e65860f4b2..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MapFragmentActivityTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.mapbox.mapboxsdk.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; - -/** - * Tests on MapFragmentActivity - */ -@RunWith(AndroidJUnit4.class) -@LargeTest -public class MapFragmentActivityTest extends BaseTest { - - @Rule - public ActivityTestRule<MapFragmentActivity> mActivityRule = new ActivityTestRule<>( - MapFragmentActivity.class); - - private MapFragmentActivity mActivity = null; - - @Before - public void setActivity() { - mActivity = mActivityRule.getActivity(); - } - - @Test - public void testSanity() { - checkViewIsDisplayed(R.id.fragment_container); - } - - // FIXME need a way to check if fragment was correctly added to Activity -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MyLocationTrackingModeActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MyLocationTrackingModeActivityTest.java deleted file mode 100644 index b21cd070a6..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/MyLocationTrackingModeActivityTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.mapbox.mapboxsdk.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; - -/** - * Tests on User LocationTrackingModeActivity - */ -@RunWith(AndroidJUnit4.class) -@LargeTest -public class MyLocationTrackingModeActivityTest extends BaseTest { - - @Rule - public ActivityTestRule<MyLocationTrackingModeActivity> mActivityRule = new ActivityTestRule<>(MyLocationTrackingModeActivity.class); - - private MyLocationTrackingModeActivity mActivity = null; - - @Before - public void setActivity() { - mActivity = mActivityRule.getActivity(); - } - - @Test - public void testSanity() { - checkViewIsDisplayed(R.id.mapView); - } -}
\ No newline at end of file diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/PolylineActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/PolylineActivityTest.java deleted file mode 100644 index 653921497e..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/PolylineActivityTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.mapbox.mapboxsdk.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; - -/** - * Tests on PolyLineActivity - */ -@RunWith(AndroidJUnit4.class) -@LargeTest -public class PolylineActivityTest extends BaseTest { - - @Rule - public ActivityTestRule<PolylineActivity> mActivityRule = new ActivityTestRule<>( - PolylineActivity.class); - - private PolylineActivity mActivity = null; - - @Before - public void setActivity() { - mActivity = mActivityRule.getActivity(); - } - - @Test - public void testSanity() { - checkViewIsDisplayed(R.id.mapView); - } -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/PressForMarkerActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/PressForMarkerActivityTest.java deleted file mode 100644 index ccb8354fc5..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/PressForMarkerActivityTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.mapbox.mapboxsdk.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; - -/** - * 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); - } -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/TiltActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/TiltActivityTest.java deleted file mode 100644 index a38af03a61..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/TiltActivityTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mapbox.mapboxsdk.testapp; - -import android.support.test.rule.ActivityTestRule; - -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); - } - -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/VisibleCoordinateBoundsActivityTest.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/VisibleCoordinateBoundsActivityTest.java deleted file mode 100644 index 29ed3fa53a..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/VisibleCoordinateBoundsActivityTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.mapbox.mapboxsdk.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; - -/** - * Tests on VisibleCoordinateBoundsActivity - */ -@RunWith(AndroidJUnit4.class) -@LargeTest -public class VisibleCoordinateBoundsActivityTest extends BaseTest { - - @Rule - public ActivityTestRule<VisibleCoordinateBoundsActivity> mActivityRule = new ActivityTestRule<>( - VisibleCoordinateBoundsActivity.class); - - private VisibleCoordinateBoundsActivity mActivity = null; - - @Before - public void setActivity() { - mActivity = mActivityRule.getActivity(); - } - - @Test - public void testSanity() { - checkViewIsDisplayed(R.id.mapView); - } -} diff --git a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java b/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java deleted file mode 100644 index d25afec815..0000000000 --- a/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/ScreenshotUtil.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.utils; - -import android.app.Activity; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.os.Environment; -import android.util.Log; -import android.view.TextureView; -import android.view.View; -import android.view.ViewGroup; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -/** - * The built-in Fuzz Suite on AWS Device Farm takes screenshots after every test. However, - * this doesn't happen with Espresso unless we manually do it. This class fixes it. - */ -public class ScreenshotUtil { - - private static final String LOG_TAG = ScreenshotUtil.class.getName(); - - // Where to store the files. This path is required by AWS Device Farm: - // http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-instrumentation.html#test-types-android-instrumentation-screenshots - private static final String SCREENSHOT_FOLDER = "test-screenshots"; - - // Image type and quality - private static final String DEFAULT_IMAGE_EXTENSION = ".png"; - private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG; - private static final int DEFAULT_IMAGE_QUALITY = 100; - - public static void take(Activity activity, String testName) { - - // Check if storage is available - if (!isExternalStorageWritable()) { - Log.d(LOG_TAG, "External storage is not available."); - return; - } - - // Get a bitmap from the activity root view. When the drawing cache is enabled, - // the next call to getDrawingCache() will draw the view in a bitmap. - View rootView = activity.getWindow().getDecorView().getRootView(); - rootView.setDrawingCacheEnabled(true); - Bitmap bitmap = Bitmap.createBitmap(rootView.getDrawingCache()); - rootView.setDrawingCacheEnabled(false); - - // Add the SurfaceView bit (see getAllTextureViews() below) - List<TextureView> tilingViews = getAllTextureViews(rootView); - if (tilingViews.size() > 0) { - Canvas canvas = new Canvas(bitmap); - for (TextureView TextureView : tilingViews) { - Bitmap b = TextureView.getBitmap(TextureView.getWidth(), TextureView.getHeight()); - int[] location = new int[2]; - TextureView.getLocationInWindow(location); - int[] location2 = new int[2]; - TextureView.getLocationOnScreen(location2); - canvas.drawBitmap(b, location[0], location[1], null); - } - } - - // Save the bitmap in external storage - String uniqueAbsolutePath = getUniqueAbsolutePath(testName); - File outputFile = new File(uniqueAbsolutePath); - OutputStream outputStream = null; - try { - outputStream = new FileOutputStream(outputFile); - bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream); - outputStream.flush(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (outputStream != null) { - try { - outputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - /* - * The classic way of taking a screenshot (above) doesn't work with TextureView, this fixes it: - * http://stackoverflow.com/questions/19704060/screen-capture-textureview-is-black-using-drawingcache - */ - - public static List<TextureView> getAllTextureViews(View view) - { - List<TextureView> tilingViews = new ArrayList<TextureView>(); - if (view instanceof TextureView) { - tilingViews.add((TextureView)view); - } else if(view instanceof ViewGroup) { - ViewGroup viewGroup = (ViewGroup)view; - for (int i = 0; i < viewGroup.getChildCount(); i++) { - tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i))); - } - } - - return tilingViews; - } - - /* - * Utils - */ - - public static boolean isExternalStorageWritable() { - // Checks if external storage is available for read and write - String state = Environment.getExternalStorageState(); - return Environment.MEDIA_MOUNTED.equals(state); - } - - private static String getUniqueAbsolutePath(String testName) { - // A screenshot after every test vs. manual tests - String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION; - if (testName != null && !testName.isEmpty()) { - filename = testName + DEFAULT_IMAGE_EXTENSION; - } - - String externalPath = Environment.getExternalStorageDirectory().toString(); - String path = externalPath + File.separator + SCREENSHOT_FOLDER + File.separator + filename; - Log.d(LOG_TAG, "Screenshot path: " + path); - return path; - } - -} |