diff options
author | Juha Alanen <juha.alanen@mapbox.com> | 2020-01-23 14:24:09 +0200 |
---|---|---|
committer | Juha Alanen <juha.alanen@mapbox.com> | 2020-02-06 17:52:12 +0200 |
commit | d4d96fd88c83a5640fdef408f1ff3f69db0a584c (patch) | |
tree | d5cddd1ceea4eb1642c081848b499bc7ff2144dd | |
parent | aed25c04383bfccfb8860a4745691538a16e093a (diff) | |
download | qtlocation-mapboxgl-d4d96fd88c83a5640fdef408f1ff3f69db0a584c.tar.gz |
[test] Enable HTTP server on Android
-rw-r--r-- | next/platform/android/android.cmake | 24 | ||||
-rw-r--r-- | next/test/CMakeLists.txt | 2 | ||||
-rw-r--r-- | platform/android/src/test/test_runner.cpp | 9 | ||||
-rw-r--r-- | test/android/app/build.gradle | 2 | ||||
-rw-r--r-- | test/android/app/src/main/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | test/include/mbgl/test/util.hpp | 2 |
6 files changed, 33 insertions, 8 deletions
diff --git a/next/platform/android/android.cmake b/next/platform/android/android.cmake index 454e11bcd2..1f77d0a29a 100644 --- a/next/platform/android/android.cmake +++ b/next/platform/android/android.cmake @@ -329,7 +329,6 @@ add_library( ${MBGL_ROOT}/platform/default/src/mbgl/text/local_glyph_rasterizer.cpp ${MBGL_ROOT}/platform/android/src/test/collator_test_stub.cpp ${MBGL_ROOT}/platform/android/src/test/number_format_test_stub.cpp - ${MBGL_ROOT}/platform/android/src/test/http_file_source_test_stub.cpp ) target_include_directories( @@ -347,6 +346,29 @@ target_link_libraries( -Wl,--no-whole-archive ) +if(ANDROID_NATIVE_API_LEVEL VERSION_LESS 24) + target_sources( + mbgl-test-runner + PRIVATE ${MBGL_ROOT}/platform/android/src/test/http_file_source_test_stub.cpp + ) +else() + set(CURL_DIR ${MBGL_ROOT}/vendor/curl-android-ios/prebuilt-with-ssl/android) + set(CURL_LIBRARY ${CURL_DIR}/${ANDROID_ABI}/libcurl.a) + + target_sources( + mbgl-test-runner + PRIVATE ${MBGL_ROOT}/platform/default/src/mbgl/storage/http_file_source.cpp + ) + target_include_directories( + mbgl-test-runner + PRIVATE ${CURL_DIR}/include + ) + target_link_libraries( + mbgl-test-runner + PRIVATE ${CURL_LIBRARY} + ) +endif() + add_custom_command( TARGET mbgl-test-runner PRE_BUILD COMMAND diff --git a/next/test/CMakeLists.txt b/next/test/CMakeLists.txt index ce980f78d1..a9814aa033 100644 --- a/next/test/CMakeLists.txt +++ b/next/test/CMakeLists.txt @@ -117,7 +117,7 @@ if(MBGL_WITH_OPENGL) ) endif() -if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL Android) +if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL Android AND ANDROID_NATIVE_API_LEVEL VERSION_LESS 24) message("Target platform does not support HTTP tests or dependencies not found.") set(MBGL_TEST_HAS_TEST_SERVER 0) diff --git a/platform/android/src/test/test_runner.cpp b/platform/android/src/test/test_runner.cpp index ec315fe27c..4f8b2165f8 100644 --- a/platform/android/src/test/test_runner.cpp +++ b/platform/android/src/test/test_runner.cpp @@ -2,12 +2,14 @@ #include "test_runner_common.hpp" #include <unistd.h> +#include <mutex> #include <thread> using namespace mbgl; using namespace mbgl::android; std::atomic<bool> running{true}; +std::atomic<bool> success{false}; std::once_flag done; ALooper* looper = NULL; @@ -23,6 +25,7 @@ void runner() { int status = mbgl::runTests(argv.size(), argv.data()); mbgl::Log::Info(mbgl::Event::General, "TestRunner finished with status: '%d'", status); running = false; + success = (status == 0); ALooper_wake(looper); } @@ -39,14 +42,14 @@ void android_main(struct android_app* app) { if (copyFile(env, app->activity->assetManager, zipFile, storagePath, "data.zip")) { if (chdir("/sdcard")) { mbgl::Log::Error(mbgl::Event::General, "Failed to change the directory to /sdcard"); - changeState(env, app, false); + changeState(env, app, success); } else { unZipFile(env, zipFile, "/sdcard/"); runnerThread = std::thread(runner); } } else { mbgl::Log::Error(mbgl::Event::General, "Failed to copy zip file '%s' to external storage", zipFile.c_str()); - changeState(env, app, false); + changeState(env, app, success); } int outFd, outEvents; @@ -62,7 +65,7 @@ void android_main(struct android_app* app) { std::call_once(done, [&] { mbgl::Log::Info(mbgl::Event::General, "TestRunner done"); runnerThread.join(); - changeState(env, app, true); + changeState(env, app, success); }); } diff --git a/test/android/app/build.gradle b/test/android/app/build.gradle index 9f915bbbd0..cadbdf6fd9 100644 --- a/test/android/app/build.gradle +++ b/test/android/app/build.gradle @@ -5,7 +5,7 @@ android { defaultConfig { applicationId = 'com.mapbox.mapboxsdk.maps.test_runner' - minSdkVersion 14 + minSdkVersion 24 targetSdkVersion 28 def abi = 'all' if (project.hasProperty('mapbox.abis')) { diff --git a/test/android/app/src/main/AndroidManifest.xml b/test/android/app/src/main/AndroidManifest.xml index 40767881d1..5311bf0507 100644 --- a/test/android/app/src/main/AndroidManifest.xml +++ b/test/android/app/src/main/AndroidManifest.xml @@ -5,6 +5,8 @@ android:versionName="1.0"> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="false" android:fullBackupContent="false" diff --git a/test/include/mbgl/test/util.hpp b/test/include/mbgl/test/util.hpp index 42be19e9ae..959b3e646f 100644 --- a/test/include/mbgl/test/util.hpp +++ b/test/include/mbgl/test/util.hpp @@ -6,8 +6,6 @@ #if ANDROID #define TEST_READ_ONLY 0 - #undef TEST_HAS_SERVER - #define TEST_HAS_SERVER 0 #elif TARGET_OS_IOS #define TEST_READ_ONLY 1 #undef TEST_HAS_SERVER |