Replace platform-specific code with std::filesystem in MBTiles test (#2634)

This commit is contained in:
Bart Louwers
2024-07-29 02:17:04 +02:00
committed by GitHub
parent 2e3538c2fe
commit 1fa3bb4cd8
2 changed files with 13 additions and 19 deletions

View File

@@ -45,9 +45,17 @@ To run the instrumentation tests, choose the "Instrumentation Tests" run configu
Your device needs remain unlocked for the duration of the tests.
## C++ Unit Tests
There is a separate Gradle project that contains a test app which runs the C++ Unit Tests. It does not depend on the Android platform implementations.
You can find the project in `test/android.` You can open this project in Android Studio and run the C++ Tests on an Android device or Simulator.
To run a particular set of tests you can modify the `--gtest_filter` flag in `platform/android/src/test/test_runner.cpp`. See the [GoogleTest documentation](https://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests) for details how to use this flag.
### AWS Device Farm
The instrumentation tests are running on AWS Device Farm. To see the results and the logs, go to:
The instrumentation tests and C++ unit tests are running on AWS Device Farm. To see the results and the logs, go to:
https://us-west-2.console.aws.amazon.com/devicefarm/home?region=us-east-1#/mobile/projects/20687d72-0e46-403e-8f03-0941850665bc/runs

View File

@@ -4,30 +4,16 @@
#include <mbgl/util/platform.hpp>
#include <mbgl/util/run_loop.hpp>
#include <filesystem>
#include <climits>
#include <gtest/gtest.h>
#if defined(WIN32)
#include <Windows.h>
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
#endif /* PATH_MAX */
#else
#include <unistd.h>
#endif
namespace {
std::string toAbsoluteURL(const std::string &fileName) {
char buff[PATH_MAX + 1];
#ifdef _MSC_VER
char *cwd = _getcwd(buff, PATH_MAX + 1);
#else
char *cwd = getcwd(buff, PATH_MAX + 1);
#endif
std::string url = {"mbtiles://" + std::string(cwd) + "/test/fixtures/storage/mbtiles/" + fileName};
assert(url.size() <= PATH_MAX);
return url;
auto path = std::filesystem::current_path() / "test/fixtures/storage/mbtiles" / fileName;
return "mbtiles://" + std::string(path);
}
} // namespace