[test] Enable HTTP server on Android

This commit is contained in:
Juha Alanen
2020-01-23 14:24:09 +02:00
parent aed25c0438
commit d4d96fd88c
6 changed files with 33 additions and 8 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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);
});
}

View File

@@ -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')) {

View File

@@ -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"

View File

@@ -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