Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #5859 - generate espresso tests
Browse files Browse the repository at this point in the history
[android] #5859 - cleanup xml files, use all the same resource id for map view

[android] #5859 - update scripts

[android] #5859 - update Activity to match mapboxMap naming

[android] #5859 - make SurfaceViewMediaControlActivity compatible

[android] #5859 - make MarkerViewScaleActivity test generation compatible

[android] #5859 - make PolygonActivity test generation compatible

[android] #5859 - integration within make file

[android] #5859 - made CameraPostion generation safe

[android] #5859 - generate sanity test

[android] #5859 - add generated test cases

[android] #5859 - add documentation
  • Loading branch information
tobrun committed Aug 15, 2016
1 parent c5c713a commit 8221b35
Show file tree
Hide file tree
Showing 124 changed files with 2,039 additions and 1,243 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ apackage:
style-code-android:
node platform/android/scripts/generate-style-code.js

.PHONY: android-generate-test
android-generate-test:
node platform/android/scripts/generate-test-code.js

#### Miscellaneous targets #####################################################

.PHONY: style-code
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,44 +1,62 @@
package com.mapbox.mapboxsdk.activity;

import android.app.Activity;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.util.Log;

import com.mapbox.mapboxsdk.activity.utils.ScreenshotUtil;
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 org.junit.After;
import org.junit.Before;
import org.junit.Rule;

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 {
public abstract class BaseTest {

@Rule
public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass());
protected MapboxMap mapboxMap;
protected OnMapReadyIdlingResource idlingResource;

protected final static String HOME_BUTTON_STRING = "Navigate up";
@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();
}

/*
* Shortcuts for common UI tests
*/
protected abstract Class getActivityClass();

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
protected void takeScreenshot(final String name) {
final Activity activity = rule.getActivity();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
ScreenshotUtil.take(activity, name);
}
});

}

@After
public void afterTest() {
Log.e(MapboxConstants.TAG, "@After test: unregister idle resource");
Espresso.unregisterIdlingResources(idlingResource);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8221b35

Please sign in to comment.