summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapReadyIdlingResource.java63
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java20
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_espresso_test.xml1
3 files changed, 6 insertions, 78 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapReadyIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapReadyIdlingResource.java
deleted file mode 100644
index 9adb30ee32..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/OnMapReadyIdlingResource.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.mapbox.mapboxsdk.location.utils;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.os.Looper;
-import android.support.test.espresso.IdlingResource;
-
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
-
-import java.lang.reflect.Field;
-
-public class OnMapReadyIdlingResource implements IdlingResource, OnMapReadyCallback {
-
- private MapboxMap mapboxMap;
- private MapView mapView;
- private IdlingResource.ResourceCallback resourceCallback;
-
- public OnMapReadyIdlingResource(Activity activity) {
- new Handler(Looper.getMainLooper()).post(() -> {
- try {
- Field field = activity.getClass().getDeclaredField("mapView");
- field.setAccessible(true);
- mapView = ((MapView) field.get(activity));
- mapView.getMapAsync(this);
- } catch (Exception err) {
- throw new RuntimeException(err);
- }
- });
- }
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public boolean isIdleNow() {
- return mapboxMap != null;
- }
-
- @Override
- public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
- this.resourceCallback = resourceCallback;
- }
-
- public MapView getMapView() {
- return mapView;
- }
-
- public MapboxMap getMapboxMap() {
- return mapboxMap;
- }
-
- @Override
- public void onMapReady(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- if (resourceCallback != null) {
- resourceCallback.onTransitionToIdle();
- }
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java
index d40b678279..b1bcead8b9 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/BaseActivityTest.java
@@ -1,28 +1,22 @@
package com.mapbox.mapboxsdk.testapp.activity;
import android.app.Activity;
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.IdlingRegistry;
import android.support.test.espresso.IdlingResourceTimeoutException;
import android.support.test.espresso.ViewInteraction;
import android.support.test.rule.ActivityTestRule;
-
+import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
import com.mapbox.mapboxsdk.testapp.action.WaitAction;
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
-
import junit.framework.Assert;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
-
import timber.log.Timber;
import static android.support.test.espresso.Espresso.onView;
@@ -59,7 +53,10 @@ public abstract class BaseActivityTest {
}
protected void validateTestSetup() {
- Assert.assertTrue("Device is not connected to the Internet.", isConnected(rule.getActivity()));
+ if (!Mapbox.isConnected()) {
+ Timber.e("Not connected to the internet while running test");
+ }
+
checkViewIsDisplayed(R.id.mapView);
Assert.assertNotNull(mapboxMap);
}
@@ -82,13 +79,6 @@ public abstract class BaseActivityTest {
onView(withId(R.id.mapView)).perform(new WaitAction(waitTime));
}
- static boolean isConnected(Context context) {
- ConnectivityManager connectivityManager
- = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
- return activeNetworkInfo != null && activeNetworkInfo.isConnected();
- }
-
protected ViewInteraction onMapView() {
return onView(withId(R.id.mapView));
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_espresso_test.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_espresso_test.xml
index e4b66c2981..be84b7b61b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_espresso_test.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_espresso_test.xml
@@ -10,6 +10,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
+ app:mapbox_styleUrl="asset://streets.json"
app:mapbox_cameraZoom="1"/>
</RelativeLayout>