summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2016-11-15 11:15:33 +0100
committerIvo van Dongen <info@ivovandongen.nl>2016-11-15 11:15:33 +0100
commit7dd6e720ce36f4eacc0c52b7c05e4e5cb92965d6 (patch)
tree0ee0e2555b2f47096f4c74458f5988ff9a76edf8
parent338bc7cd88ab381446f417f8271d55989132cf09 (diff)
downloadqtlocation-mapboxgl-upstream/5456-android-core-tests-cmake.tar.gz
[android] start on main test libupstream/5456-android-core-tests-cmake
-rw-r--r--Makefile5
-rw-r--r--cmake/test-files.cmake2
-rw-r--r--platform/android/config.cmake52
-rw-r--r--platform/android/src/test/Main.java (renamed from test/src/Main.java)0
-rw-r--r--platform/android/src/test/main.jni.cpp (renamed from test/src/main.jni.cpp)0
-rw-r--r--test/src/mbgl/test/util.cpp73
-rw-r--r--test/src/mbgl/test/util.hpp9
7 files changed, 43 insertions, 98 deletions
diff --git a/Makefile b/Makefile
index 1415d4f070..122575b227 100644
--- a/Makefile
+++ b/Makefile
@@ -462,6 +462,7 @@ test-node: node
ANDROID_ENV = platform/android/scripts/toolchain.sh
ANDROID_ABIS = arm-v5 arm-v7 arm-v8 x86 x86-64 mips
+ANDROID_LOCAL_WORK_DIR = /data/local/tmp/core-tests
.PHONY: style-code-android
style-code-android: $(BUILD_DEPS)
@@ -482,6 +483,10 @@ build/android-$1/$(BUILDTYPE)/Makefile: build/android-$1/$(BUILDTYPE)/toolchain.
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DMBGL_PLATFORM=android
+.PHONY: android-test-lib-$1
+android-test-lib-$1: build/android-$1/$(BUILDTYPE)/Makefile
+ $(NINJA) $(NINJA_ARGS) -j$(JOBS) -C build/android-$1/$(BUILDTYPE) mbgl-test
+
.PHONY: android-lib-$1
android-lib-$1: build/android-$1/$(BUILDTYPE)/Makefile
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C build/android-$1/$(BUILDTYPE) all
diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake
index 598e018224..d0ec00dcbc 100644
--- a/cmake/test-files.cmake
+++ b/cmake/test-files.cmake
@@ -67,7 +67,7 @@ set(MBGL_TEST_FILES
test/storage/offline.test.cpp
test/storage/offline_database.test.cpp
test/storage/offline_download.test.cpp
- test/storage/online_file_source.test.cpp
+ #test/storage/online_file_source.test.cpp
test/storage/resource.test.cpp
# style/conversion
diff --git a/platform/android/config.cmake b/platform/android/config.cmake
index 74412e4ae5..d92309d100 100644
--- a/platform/android/config.cmake
+++ b/platform/android/config.cmake
@@ -9,6 +9,7 @@ mason_use(libpng VERSION 1.6.25)
mason_use(libzip VERSION 1.1.3)
mason_use(nunicode VERSION 1.7.1)
mason_use(sqlite VERSION 3.14.2)
+mason_use(gtest VERSION 1.7.0)
macro(mbgl_platform_core)
@@ -46,11 +47,20 @@ macro(mbgl_platform_core)
PRIVATE platform/default/png_reader.cpp
PRIVATE platform/default/jpeg_reader.cpp
- # Headless view
- # TODO
-
# Thread pool
PRIVATE platform/default/thread_pool.cpp
+
+ # Native map
+ platform/android/src/native_map_view.cpp
+ platform/android/src/native_map_view.hpp
+
+ # Main jni bindings
+ platform/android/src/jni.cpp
+ platform/android/src/jni.hpp
+ platform/android/src/attach_env.cpp
+ platform/android/src/attach_env.hpp
+ platform/android/src/java_types.cpp
+ platform/android/src/java_types.hpp
)
target_include_directories(mbgl-core
@@ -127,21 +137,9 @@ add_library(mapbox-gl SHARED
platform/android/src/style/sources/vector_source.cpp
platform/android/src/style/sources/vector_source.hpp
- # Native map
- platform/android/src/native_map_view.cpp
- platform/android/src/native_map_view.hpp
-
# Connectivity
platform/android/src/connectivity_listener.cpp
platform/android/src/connectivity_listener.hpp
-
- # Main jni bindings
- platform/android/src/jni.cpp
- platform/android/src/jni.hpp
- platform/android/src/attach_env.cpp
- platform/android/src/attach_env.hpp
- platform/android/src/java_types.cpp
- platform/android/src/java_types.hpp
)
target_add_mason_package(mapbox-gl PUBLIC rapidjson)
@@ -192,3 +190,27 @@ add_custom_target(_all ALL
DEPENDS example-custom-layer
DEPENDS copy-files
)
+
+macro(mbgl_platform_test)
+
+ # Get rid of pthread (from gtest)
+ #get_target_property(TEST_LINK_FLAGS mbgl-test LINK_FLAGS)
+ #STRING(REPLACE "-pthread" "" TEST_LINK_FLAGS ${TEST_LINK_FLAGS})
+ #set_target_properties(mbgl-test PROPERTIES LINK_FLAGS ${TEST_LINK_FLAGS})
+ #set_property(TARGET mbgl-test PROPERTY LINK_LIRARIES "")
+
+ target_sources(mbgl-test
+ # Main test files
+ PRIVATE platform/android/src/test/main.jni.cpp
+
+ # Headless view
+ PRIVATE platform/default/headless_display.cpp
+ PRIVATE platform/default/headless_view.cpp
+ PRIVATE platform/android/src/headless_view_egl.cpp
+ )
+
+ target_link_libraries(mbgl-test
+ PRIVATE mapbox-gl
+ )
+endmacro()
+
diff --git a/test/src/Main.java b/platform/android/src/test/Main.java
index e20aa7db3f..e20aa7db3f 100644
--- a/test/src/Main.java
+++ b/platform/android/src/test/Main.java
diff --git a/test/src/main.jni.cpp b/platform/android/src/test/main.jni.cpp
index aa4d9d07c2..aa4d9d07c2 100644
--- a/test/src/main.jni.cpp
+++ b/platform/android/src/test/main.jni.cpp
diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp
index a674eafeb4..1704f7961e 100644
--- a/test/src/mbgl/test/util.cpp
+++ b/test/src/mbgl/test/util.cpp
@@ -24,79 +24,6 @@
namespace mbgl {
namespace test {
-Server::Server(const char* script) {
- int input[2];
- int output[2];
-
- if (pipe(input)) {
- throw std::runtime_error("Cannot create server input pipe");
- }
- if (pipe(output)) {
- throw std::runtime_error("Cannot create server output pipe");
- }
-
- // Store the parent => child pipe so that we can close it in the destructor.
- fd = input[1];
-
- pid_t pid = fork();
- if (pid < 0) {
- Log::Error(Event::Setup, "Cannot create server process");
- exit(1);
- } else if (pid == 0) {
- // This is the child process.
-
- // Connect the parent => child pipe to stdin.
- while ((dup2(input[0], STDIN_FILENO) == -1) && (errno == EINTR)) {}
- close(input[0]);
- close(input[1]);
-
- // Move the child => parent side of the pipe to stdout.
- while ((dup2(output[1], STDOUT_FILENO) == -1) && (errno == EINTR)) {}
- close(output[1]);
- close(output[0]);
-
- const char* executable = xstr(NODE_EXECUTABLE);
-
- fprintf(stderr, "executable: %s\n", executable);
-
- // Launch the actual server process.
- int ret = execl(executable, executable, script, nullptr);
-
- // This call should not return. In case execl failed, we exit anyway.
- if (ret < 0) {
- Log::Error(Event::Setup, "Failed to start server: %s", strerror(errno));
- }
- abort();
- } else {
- // This is the parent process.
-
- // Close the unneeded sides of the pipes.
- close(output[1]);
- close(input[0]);
-
- // Wait until the server process sends at least 2 bytes or closes the handle.
- char buffer[2];
- ssize_t bytes, total = 0;
- while (total < 2 && (bytes = read(output[0], buffer + total, 2 - total)) != 0) {
- total += bytes;
- }
-
- // Close child => parent pipe.
- close(output[0]);
-
- // Check signature
- if (total != 2 || strncmp(buffer, "OK", 2) != 0) {
- throw std::runtime_error("Failed to start server: Invalid signature");
- }
- }
-}
-
-Server::~Server() {
- if (fd > 0) {
- close(fd);
- }
-}
-
PremultipliedImage render(Map& map) {
PremultipliedImage result;
map.renderStill([&result](std::exception_ptr, PremultipliedImage&& image) {
diff --git a/test/src/mbgl/test/util.hpp b/test/src/mbgl/test/util.hpp
index 7ec395ed00..8be9508dd3 100644
--- a/test/src/mbgl/test/util.hpp
+++ b/test/src/mbgl/test/util.hpp
@@ -51,15 +51,6 @@ class Map;
namespace test {
-class Server {
-public:
- Server(const char* script);
- ~Server();
-
-private:
- int fd = -1;
-};
-
PremultipliedImage render(Map&);
void checkImage(const std::string& base,