-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
It looks like it would be relatively straightforward to extend this approach to the query tests and the expression tests? Being able to run expression tests on Android would be useful for the |
Great idea @ChrisLoer, quickly glanced at tests in These tests require some kind of integration of QueryRenderFeatures functionality (see queryGeometry in json below). This kind of feature isn't implemented on MapSnapshotter but we can definitely add this. {
"version": 8,
"metadata": {
"test": {
"height": 256,
"queryGeometry": [
10,
100
]
}
},
"center": [
13.418056,
52.499167
],
"zoom": 14,
"sources": {
"mapbox": {
"type": "vector",
"maxzoom": 14,
"tiles": [
"local://tiles/{z}-{x}-{y}.mvt"
]
}
},
"layers": [
{
"id": "road",
"type": "circle",
"source": "mapbox",
"source-layer": "road",
"paint": {
"circle-radius": 10
},
"interactive": true
}
]
} That said, this fits inline with some other render tests that I had to ignore for a similar reason (I'm ignoring all tests with I will be ticketing these improvements out with the rest of the todo items, thank you for 👀 'ing this! |
61b6115
to
97b56de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This look amazing! 🚀
A couple of comments below.
int size = input.available(); | ||
byte[] buffer = new byte[size]; | ||
input.read(buffer); | ||
input.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using try-with-resources
?
setupIdlingResource(); | ||
} | ||
|
||
private void grantWriteRuntimePermission() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be achieved with handy JUnit Rules.
|
||
@Before | ||
public void beforeTest() { | ||
IdlingPolicies.setMasterPolicyTimeout(30, TimeUnit.MINUTES); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract the timeout to a variable?
private void setupIdlingResource() { | ||
try { | ||
Timber.e("@Before test: register idle resource"); | ||
IdlingPolicies.setIdlingResourceTimeout(30, TimeUnit.MINUTES); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
} | ||
|
||
private static String loadStyleJson(AssetManager assets, String category, String test) throws IOException { | ||
InputStream input = assets.open(String.format("%s/%s/%s/style.json", RENDER_TEST_BASE_PATH, category, test)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try-with-resources
would be nice, also extracting whole path format or at least the file name to a variable.
FileOutputStream out = new FileOutputStream(filePath); | ||
testResult.compress(Bitmap.CompressFormat.PNG, 100, out); | ||
out.flush(); | ||
out.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting try-with-resources
again.
} | ||
|
||
private static File createTestResultRootFolder() { | ||
File testResultDir = new File(Environment.getExternalStorageDirectory() + File.separator + "mapbox"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding "/render" to the root path?
// | ||
// Callback configuration to notify test executor of test finishing | ||
// | ||
public interface OnSnapshotReadyListener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface's name and method's name are a bit ambiguous. Could we rename it to something along the lines of OnTestSnapshotsReadyListener
?
try { | ||
Timber.e("@Before test: register idle resource"); | ||
IdlingPolicies.setIdlingResourceTimeout(30, TimeUnit.MINUTES); | ||
Espresso.registerIdlingResources(idlingResource = new SnapshotterIdlingResource(rule.getActivity())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is deprecated, could you use IdlingRegistry.register(IdlingResource...)
instead?
@After | ||
public void afterTest() { | ||
Timber.e("@After test: unregister idle resource"); | ||
Espresso.unregisterIdlingResources(idlingResource); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
dcfa87d
to
9810d8c
Compare
int size = input.available(); | ||
buffer = new byte[size]; | ||
input.read(buffer); | ||
input.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to explicitly close the resource here.
@@ -791,6 +791,18 @@ | |||
<activity | |||
android:name=".activity.style.FillExtrusionStyleTestActivity" | |||
android:screenOrientation="portrait" /> | |||
<activity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was only the debug setup. Can we remove it?
bdf6b5d
to
3f04f13
Compare
Continuation of #10045, Closes #10047.
This PR enables running the node render test suite on Android:
Example run can be seen here, executing these tests can be done with:
When running the render tests the following happens
mapbox-gl-js/test/integration/*
to app assets folderRenderTest.java
instrumentation testThe following items are open, thinking about tackling them in separate PRs: