summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-09-08 10:10:33 -0700
committerGitHub <noreply@github.com>2016-09-08 10:10:33 -0700
commit36a744c96a529c82de5c9cad9e944a9380712bd8 (patch)
tree49773bf62848350a42608e74e06352b0ca62c716 /platform
parent4ef8f815c9bb8793f2ab3ec522a57117d0435700 (diff)
downloadqtlocation-mapboxgl-36a744c96a529c82de5c9cad9e944a9380712bd8.tar.gz
[android] - throw concrete exception when generated test cases fail to read the Activity members (#6281)
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java
index c5543222f1..144073ae27 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java
@@ -2,14 +2,15 @@ package com.mapbox.mapboxsdk.activity;
import android.app.Activity;
import android.support.test.espresso.Espresso;
+import android.support.test.espresso.IdlingResourceTimeoutException;
import android.support.test.rule.ActivityTestRule;
import android.util.Log;
-import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
-import com.mapbox.mapboxsdk.utils.ScreenshotUtil;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.ScreenshotUtil;
import org.junit.After;
import org.junit.Before;
@@ -29,11 +30,19 @@ public abstract class BaseTest {
@Before
public void beforeTest() {
- Log.e(MapboxConstants.TAG, "@Before test: register idle resource");
- idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
- Espresso.registerIdlingResources(idlingResource);
- checkViewIsDisplayed(R.id.mapView);
- mapboxMap = idlingResource.getMapboxMap();
+ try {
+ Log.e(MapboxConstants.TAG, "@Before test: register idle resource");
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ checkViewIsDisplayed(R.id.mapView);
+ mapboxMap = idlingResource.getMapboxMap();
+ } catch (IdlingResourceTimeoutException e) {
+ Log.e(MapboxConstants.TAG, "Idling resource timed out. Couldn't not validate if map is ready.");
+ throw new RuntimeException("Could not start test for " + getActivityClass().getSimpleName() + ".\n" +
+ "The ViewHierarchy doesn't contain a view with resource id = R.id.mapView or \n" +
+ "the Activity doesn't contain an instance variable with a name equal to mapboxMap.\n" +
+ "You can resolve this issue be implementing the requirements above or\n add " + getActivityClass().getSimpleName() + " to the excludeActivities array in `generate-test-code.js`.\n");
+ }
}
protected abstract Class getActivityClass();