Files
MapLibreParticleLab/platform/android/MapboxGLAndroidSDKTestApp
Antonio Zugaldia 01e55f183e # This is a combination of 8 commits.
# The first commit's message is:
# This is a combination of 2 commits.
# The first commit's message is:

# This is a combination of 3 commits.
# The first commit's message is:
# This is a combination of 2 commits.
# The first commit's message is:

# This is a combination of 21 commits.
# The first commit's message is:
[android] - Implements Android bindings for offline API
Fixes #3891

# The 2nd commit message will be skipped:

#	[android] #3891 - rename OFFLINE_MAX_CACHE_SIZE to DEFAULT_MAX_CACHE_SIZE and adjust value

# The 3rd commit message will be skipped:

#	[android] #3891 - makes de documentation more relevant to the current android implementation

# The 4th commit message will be skipped:

#	[android] #3891 - rename isRequiredResourceCountIsIndeterminate() to isRequiredResourceCountPrecise()

# The 5th commit message will be skipped:

#	[android] #3891 - rename complete() to isComplete()

# The 6th commit message will be skipped:

#	[android] #3891 - rename OfflineRegionDefinition to OfflineTilePyramidRegionDefinition and make OfflineRegionDefinition an interface. Docs for corresponding classes updated.

# The 7th commit message will be skipped:

#	[android] #3891 - make reason a more idiomatic ErrorReason Android IntDef and remove unnecessary constructor

# The 8th commit message will be skipped:

#	[android] #3891 - reuse the calling object instead of creating a new manager

# The 9th commit message will be skipped:

#	[android] #3891 - location, location, location

# The 10th commit message will be skipped:

#	[android] #3891 - simpler list regions iteration

# The 11th commit message will be skipped:

#	[android] #3891 - proper indeterminate -> precise transition

# The 12th commit message will be skipped:

#	[android] #3891 - improve description for DEFAULT_MAX_CACHE_SIZE

# The 13th commit message will be skipped:

#	[android] #3891 - delete global refs for obj and listCallback

# The 14th commit message will be skipped:

#	[android] #3891 - simplify metadata conversion and fix metadata object

# The 15th commit message will be skipped:

#	[android] - Implements Android bindings for offline API
#	Fixes #3891

# The 16th commit message will be skipped:

#	[android] #3891 - avoid exposing the int reason value in the public API

# The 17th commit message will be skipped:

#	[android] #3891 - delete global refs for remaining callbacks and observer

# The 18th commit message will be skipped:

#	[android] #3891 - remove unused offlineManagerClassConstructorId together with unnecessary private java constructor

# The 19th commit message will be skipped:

#	[android] #3891 - remove non-relevant line

# The 20th commit message will be skipped:

#	[android] #3891 - handle requiredResourceCountIsIndeterminate -> requiredResourceCountIsPrecise rename

# The 21st commit message will be skipped:

#	[android] #3891 - revert map changes to allow rebase

# The 2nd commit message will be skipped:

#	[android] #3891 - avoid exposing the int reason value in the public API

# The 2nd commit message will be skipped:

#	[android] #3891 - rename complete() to isComplete()

# The 3rd commit message will be skipped:

#	[android] #3891 - rename OfflineRegionDefinition to OfflineTilePyramidRegionDefinition and make OfflineRegionDefinition an interface. Docs for corresponding classes updated.

# The 2nd commit message will be skipped:

#	[android] #3891 - location, location, location

# The 2nd commit message will be skipped:

#	[android] #3891 - improve description for DEFAULT_MAX_CACHE_SIZE

# The 3rd commit message will be skipped:

#	[android] #3891 - delete global refs for obj and listCallback

# The 4th commit message will be skipped:

#	[android] #3891 - simplify metadata conversion and fix metadata object

# The 5th commit message will be skipped:

#	[android] #3891 - delete global refs for remaining callbacks and observer

# The 6th commit message will be skipped:

#	[android] #3891 - remove unused offlineManagerClassConstructorId together with unnecessary private java constructor

# The 7th commit message will be skipped:

#	[android] #3891 - remove non-relevant line

# The 8th commit message will be skipped:

#	[android] #3891 - handle requiredResourceCountIsIndeterminate -> requiredResourceCountIsPrecise rename
2016-02-26 09:13:17 -05:00
..
2016-02-26 09:13:17 -05:00

Mapbox GL Test App

Testing

Running Espresso tests on a device

This test project comes with all the required Android Testing Support Library dependencies in the Gradle file. Tests are under the app/src/androidTest folder.

Note that before running your tests, you might want to turn off animations on your test device. It's a known issue that leaving system animations turned on in a test device (window animation scale, transition animation scale, animator duration scale) might cause unexpected results, or may lead tests to fail.

To create a new run configuration:

  • Click on Run -> Edit Configurations...
  • Click on the plus sign and then on "Android Tests"
  • Give a name to the configuration, e.g. TestAppTests
  • Choose the MapboxGLAndroidSDKTestApp module
  • Choose android.support.test.runner.AndroidJUnitRunner as the instrumentation runner
  • Click OK to save the new configuration

You can now run this configuration from the main toolbar dropdown menu.

Running Espresso tests on AWS Device Farm

On a terminal, within mapbox-gl-native/android/java, run the tests (cC stands for connectedCheck):

$ ./gradlew cC -p MapboxGLAndroidSDKTestApp

Then:

  • Go to your AWS Console and choose Device Farm.
  • Create a new project, e.g. MapboxGLAndroidSDKTestApp
  • On step 1, upload the APK in mapbox-gl-native/android/java/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug-unaligned.apk
  • On step 2, choose Instrumentation, test filter is com.mapbox.mapboxgl.testapp.MainActivityTest and upload the APK in mapbox-gl-native/android/java/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug-androidTest-unaligned.apk
  • On step 3, choose a device pool. E.g. Top Devices
  • On step 4, customize your device state (if needed)
  • Finally, confirm the configuration and run the tests.

On Step 2, you can also separate by commas different classes: com.mapbox.mapboxgl.testapp.MainActivityTest,com.mapbox.mapboxgl.testapp.MainActivityScreenTest

If you have no tests for your app, or want to test some random user behaviour, you can just choose "Built-in: Fuzz" in step 2.

Running pure JUnit tests

These tests run on a local JVM on your development machine and they are extremely fast to run (as compared to Espresso). These tests are located under src/test/java. To run them you switch to the Unit Tests build variant, then right click the corresponding test class or method and select "Run ...".

You can also have a run configuration:

  • Click on Run -> Edit Configurations...
  • Click on "Junit Tests"
  • Give a name to the configuration, e.g. JUnit tests
  • As "Test Kind", choose "All in directory"
  • As folder, choose the following folder: mapbox-gl-native/android/java/MapboxGLAndroidSDKTestApp/src/test/java
  • Click OK to save the new configuration

You can also run the tests from the command line with:

$ ./gradlew test --continue -p MapboxGLAndroidSDKTestApp

Running the UI/Application Exerciser Monkey

Similar to the "Built-in: Fuzz" test mentioned above, Android provides Monkey, "a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events."

To exercise Monkey on the test app, install the package on the device (e.g. via Android Studio) and then:

$ adb shell monkey -p com.mapbox.mapboxgl.testapp -v 500