diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-08-27 14:28:56 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-08-27 14:28:56 +0200 |
commit | 953e5524a99325ffb049f466b85ce13a62dc327a (patch) | |
tree | 36e1db7f68c94f1ad0135eed0dd1b3292c4a4ca3 /test | |
parent | a55be0217bdc2b4e15500f9a5cd4aba207d33fc7 (diff) | |
download | qtlocation-mapboxgl-953e5524a99325ffb049f466b85ce13a62dc327a.tar.gz |
fix basepath for headless stylesheets
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/fixture_request.cpp | 14 | ||||
-rw-r--r-- | test/headless.cpp | 17 |
2 files changed, 10 insertions, 21 deletions
diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index 1a7ed2ccc3..7e351ecfac 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -1,12 +1,15 @@ #include <mbgl/platform/platform.hpp> #include <mbgl/platform/request.hpp> #include <mbgl/util/uv_detail.hpp> +#include <mbgl/util/url.hpp> #include <mbgl/platform/log.hpp> const std::string base_directory = []{ std::string fn = __FILE__; fn.erase(fn.find_last_of("/")); - return fn; + fn.erase(fn.find_last_of("/")); + fn.erase(fn.find_last_of("/")); + return fn + "/node_modules/mapbox-gl-test-suite/"; }(); @@ -23,14 +26,11 @@ platform::request_http(const std::string &url, l = uv_default_loop(); } - std::string clean_url = base_directory + "/" + url; - auto pos = clean_url.find("://"); - if (pos != std::string::npos) { - clean_url.replace(pos, 3, "/"); + std::string clean_url = util::percentDecode(url); + if (clean_url.find("local://") == 0) { + clean_url = base_directory + clean_url.substr(8); } - std::replace(clean_url.begin(), clean_url.end(), '+', ' '); - std::shared_ptr<Request> req = std::make_shared<Request>(url, callback, loop); int err; diff --git a/test/headless.cpp b/test/headless.cpp index a2f58e98d9..2453f1bb37 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -18,17 +18,12 @@ const std::string base_directory = []{ std::string fn = __FILE__; fn.erase(fn.find_last_of("/")); - return fn + "/../node_modules/mapbox-gl-test-suite/"; + fn.erase(fn.find_last_of("/")); + return fn + "/node_modules/mapbox-gl-test-suite/"; }(); class HeadlessTest : public ::testing::TestWithParam<std::string> {}; -void ResolveLocalURL(rapidjson::Value& value, rapidjson::Document& doc) { - std::string str { value.GetString(), value.GetStringLength() }; - str.replace(0, 8, base_directory); // local:// - value.SetString(str.c_str(), str.length(), doc.GetAllocator()); -} - TEST_P(HeadlessTest, render) { using namespace mbgl; @@ -43,12 +38,6 @@ TEST_P(HeadlessTest, render) { ASSERT_EQ(false, styleDoc.HasParseError()); ASSERT_EQ(true, styleDoc.IsObject()); - if (styleDoc.HasMember("sprite")) { - ResolveLocalURL(styleDoc["sprite"], styleDoc); - } - - ResolveLocalURL(styleDoc["sources"]["mapbox"]["tiles"][rapidjson::SizeType(0)], styleDoc); - rapidjson::StringBuffer buffer; rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); styleDoc.Accept(writer); @@ -91,7 +80,7 @@ TEST_P(HeadlessTest, render) { } } - map.setStyleJSON(style); + map.setStyleJSON(style, base_directory); map.setAppliedClasses(classes); view.resize(width, height); |