diff options
author | Tobrun <tobrun@mapbox.com> | 2017-06-12 11:02:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-12 11:02:36 +0200 |
commit | e59766f4e805a2cd081fbf30ab2365d05ddda8a3 (patch) | |
tree | 51d237a1a7b853bb1049ede7438faa67f3047759 /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs | |
parent | 294f4f8df9541f735d3928c605f123c444c60a28 (diff) | |
download | qtlocation-mapboxgl-e59766f4e805a2cd081fbf30ab2365d05ddda8a3.tar.gz |
[android] - run MapboxMap invocations to ui thread for instrumentation tests (#9198)
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs index cb3ba58100..2f22a8f3f0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs @@ -9,6 +9,7 @@ import android.support.test.espresso.ViewAction; import android.support.test.runner.AndroidJUnit4; import android.view.View; +import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.light.Light; import com.mapbox.mapboxsdk.style.functions.Function; import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops; @@ -16,6 +17,7 @@ import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; import com.mapbox.mapboxsdk.style.light.Position; import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction; import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity; @@ -35,6 +37,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionCol import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity; +import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; @@ -48,14 +51,18 @@ public class LightTest extends BaseActivityTest { @Test public void test<%- camelize(property.name) %>Transition() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("<%- property.name %>TransitionOptions"); - assertNotNull(light); - - // Set and Get - TransitionOptions options = new TransitionOptions(300, 100); - light.set<%- camelize(property.name) %>Transition(options); - assertEquals("Transition options should match", options, light.get<%- camelize(property.name) %>Transition()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + TransitionOptions options = new TransitionOptions(300, 100); + light.set<%- camelize(property.name) %>Transition(options); + assertEquals("Transition options should match", options, light.get<%- camelize(property.name) %>Transition()); + } + }); } <% } -%> <% if (property.name == "position") { -%> @@ -63,35 +70,44 @@ public class LightTest extends BaseActivityTest { @Test public void test<%- camelize(property.name) %>() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("<%- property.name %>"); - assertNotNull(light); - - // Set and Get - Position position = new Position(1,2,3); - light.set<%- camelize(property.name) %>(position); - assertEquals("Position should match", position, light.get<%- camelize(property.name) %>()); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + Position position = new Position(1, 2, 3); + light.set<%- camelize(property.name) %>(position); + assertEquals("Position should match", position, light.get<%- camelize(property.name) %>()); + } + }); } <% } else { -%> @Test public void test<%- camelize(property.name) %>() { validateTestSetup(); - setupLayer(); + setupLight(); Timber.i("<%- property.name %>"); - assertNotNull(light); - // Set and Get - light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>); + invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() { + @Override + public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) { + assertNotNull(light); + // Set and Get + light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>); <% if (property.name == 'color') { -%> - assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>.replaceAll("\\s+",""), light.get<%- camelize(property.name) %>()); + assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>.replaceAll("\\s+", ""), light.get<%- camelize(property.name) %>()); <% } else { -%> - assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>()); + assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>()); <% } -%> + } + }); } <% } -%> <% } -%> - private void setupLayer() { + private void setupLight() { onView(withId(R.id.mapView)).perform(new ViewAction() { @Override public Matcher<View> getConstraints() { |