Add clang-format (#1086)

Co-authored-by: mwilsnd <mwilsnd@gmail.com>
This commit is contained in:
Bart Louwers
2023-05-01 16:57:37 +02:00
committed by GitHub
parent 403a12bd1b
commit 71f6da2722
1018 changed files with 27876 additions and 25862 deletions

View File

@@ -10,16 +10,17 @@
#include <algorithm>
#include <list>
namespace mbgl {
/*
FakeFileSource is similar to StubFileSource, but it follows a post hoc, "push" model rather than
a pre hoc, "pull" model. You pass it to code that makes requests, it records what requests are
made, then you can examine them, make assertions about them, and respond as desired.
FakeFileSource is similar to StubFileSource, but it follows a post hoc,
"push" model rather than a pre hoc, "pull" model. You pass it to code that
makes requests, it records what requests are made, then you can examine them,
make assertions about them, and respond as desired.
This is particularly useful if you want to simulate multiple responses, e.g. as part of a resource
revalidation flow. StubFileSource allows only a single response.
This is particularly useful if you want to simulate multiple responses, e.g.
as part of a resource revalidation flow. StubFileSource allows only a single
response.
*/
class FakeFileSource : public FileSource {
public:
@@ -35,17 +36,16 @@ public:
: resource(std::move(resource_)),
callback(std::move(callback_)),
list(list_),
link((list.push_back(this), std::prev(list.end()))) {
}
link((list.push_back(this), std::prev(list.end()))) {}
~FakeFileRequest() override {
list.erase(link);
}
~FakeFileRequest() override { list.erase(link); }
};
FakeFileSource(const ResourceOptions& resourceOptions_, const ClientOptions& clientOptions_)
: resourceOptions(resourceOptions_.clone()), clientOptions(clientOptions_.clone()) {}
FakeFileSource() : FakeFileSource(ResourceOptions::Default(), ClientOptions()) {}
: resourceOptions(resourceOptions_.clone()),
clientOptions(clientOptions_.clone()) {}
FakeFileSource()
: FakeFileSource(ResourceOptions::Default(), ClientOptions()) {}
std::unique_ptr<AsyncRequest> request(const Resource& resource, Callback callback) override {
return std::make_unique<FakeFileRequest>(resource, callback, requests);
@@ -54,7 +54,7 @@ public:
bool canRequest(const Resource&) const override { return true; }
bool respond(Resource::Kind kind, const Response& response) {
auto it = std::find_if(requests.begin(), requests.end(), [&] (FakeFileRequest* fakeRequest) {
auto it = std::find_if(requests.begin(), requests.end(), [&](FakeFileRequest* fakeRequest) {
return fakeRequest->resource.kind == kind;
});
@@ -71,19 +71,11 @@ public:
std::list<FakeFileRequest*> requests;
void setResourceOptions(ResourceOptions options) override {
resourceOptions = options;
}
ResourceOptions getResourceOptions() override {
return resourceOptions.clone();
}
void setResourceOptions(ResourceOptions options) override { resourceOptions = options; }
ResourceOptions getResourceOptions() override { return resourceOptions.clone(); }
void setClientOptions(ClientOptions options) override {
clientOptions = options;
}
ClientOptions getClientOptions() override {
return clientOptions.clone();
}
void setClientOptions(ClientOptions options) override { clientOptions = options; }
ClientOptions getClientOptions() override { return clientOptions.clone(); }
private:
ResourceOptions resourceOptions;
@@ -92,7 +84,8 @@ private:
class FakeOnlineFileSource : public FakeFileSource {
public:
FakeOnlineFileSource() : FakeOnlineFileSource(ResourceOptions::Default(), ClientOptions()) {}
FakeOnlineFileSource()
: FakeOnlineFileSource(ResourceOptions::Default(), ClientOptions()) {}
FakeOnlineFileSource(const ResourceOptions& resourceOptions_, const ClientOptions& clientOptions_)
: FakeFileSource(resourceOptions_, clientOptions_) {}
@@ -100,15 +93,14 @@ public:
return FakeFileSource::request(resource, callback);
}
bool respond(Resource::Kind kind, const Response& response) {
return FakeFileSource::respond(kind, response);
}
bool respond(Resource::Kind kind, const Response& response) { return FakeFileSource::respond(kind, response); }
mapbox::base::Value getProperty(const std::string& property) const override {
return onlineFs->getProperty(property);
}
std::unique_ptr<FileSource> onlineFs = std::make_unique<OnlineFileSource>(ResourceOptions::Default(), ClientOptions());
std::unique_ptr<FileSource> onlineFs = std::make_unique<OnlineFileSource>(ResourceOptions::Default(),
ClientOptions());
};
} // namespace mbgl

View File

@@ -4,20 +4,19 @@
namespace mbgl {
FixtureLog::Message::Message(EventSeverity severity_,
Event event_,
int64_t code_,
std::string msg_)
: severity(severity_), event(event_), code(code_), msg(std::move(msg_)) {
}
FixtureLog::Message::Message(EventSeverity severity_, Event event_, int64_t code_, std::string msg_)
: severity(severity_),
event(event_),
code(code_),
msg(std::move(msg_)) {}
bool FixtureLog::Message::matches(const Message& rhs, bool substring) const {
return severity == rhs.severity && event == rhs.event && code == rhs.code &&
(substring ? msg.find(rhs.msg) != std::string::npos : msg == rhs.msg);
}
FixtureLog::Observer::Observer(FixtureLog* log_) : log(log_) {
}
FixtureLog::Observer::Observer(FixtureLog* log_)
: log(log_) {}
FixtureLog::Observer::~Observer() {
if (log) {
@@ -26,10 +25,7 @@ FixtureLog::Observer::~Observer() {
std::cerr << unchecked();
}
bool FixtureLog::Observer::onRecord(EventSeverity severity,
Event event,
int64_t code,
const std::string& msg) {
bool FixtureLog::Observer::onRecord(EventSeverity severity, Event event, int64_t code, const std::string& msg) {
std::lock_guard<std::mutex> lock(messagesMutex);
if (severity != EventSeverity::Debug) {
@@ -58,7 +54,8 @@ size_t FixtureLog::Observer::count(const Message& message, bool substring) const
return message_count;
}
FixtureLog::FixtureLog() : observer(new FixtureLogObserver(this)) {
FixtureLog::FixtureLog()
: observer(new FixtureLogObserver(this)) {
Log::setObserver(std::unique_ptr<Log::Observer>(observer));
Log::useLogThread(false);
}

View File

@@ -17,10 +17,10 @@ public:
bool matches(const Message& rhs, bool substring = false) const;
const EventSeverity severity {};
const Event event {};
const int64_t code {};
const std::string msg {};
const EventSeverity severity{};
const Event event{};
const int64_t code{};
const std::string msg{};
mutable bool checked = false;
};
@@ -33,10 +33,7 @@ public:
~Observer() override;
// Log::Observer implementation
bool onRecord(EventSeverity severity,
Event event,
int64_t code,
const std::string& msg) override;
bool onRecord(EventSeverity severity, Event event, int64_t code, const std::string& msg) override;
bool empty() const;
size_t uncheckedCount() const;
@@ -61,9 +58,8 @@ private:
Observer* observer;
};
::std::ostream &operator<<(::std::ostream &os,
const std::vector<FixtureLog::Observer::LogMessage> &messages);
::std::ostream &operator<<(::std::ostream &os, const FixtureLog::Observer::LogMessage &message);
::std::ostream& operator<<(::std::ostream& os, const std::vector<FixtureLog::Observer::LogMessage>& messages);
::std::ostream& operator<<(::std::ostream& os, const FixtureLog::Observer::LogMessage& message);
using FixtureLogObserver = FixtureLog::Observer;

View File

@@ -18,41 +18,39 @@ namespace test {
* memory use) measured in bytes, or zero if the value cannot be
* determined on this OS.
*/
size_t getPeakRSS( )
{
size_t getPeakRSS() {
#if defined(_WIN32)
/* Windows -------------------------------------------------- */
PROCESS_MEMORY_COUNTERS info;
GetProcessMemoryInfo( GetCurrentProcess( ), &info, sizeof(info) );
return (size_t)info.PeakWorkingSetSize;
/* Windows -------------------------------------------------- */
PROCESS_MEMORY_COUNTERS info;
GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
return (size_t)info.PeakWorkingSetSize;
#elif (defined(_AIX) || defined(__TOS__AIX__)) || (defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__)))
/* AIX and Solaris ------------------------------------------ */
struct psinfo psinfo;
int fd = -1;
if ( (fd = open( "/proc/self/psinfo", O_RDONLY )) == -1 )
return (size_t)0L; /* Can't open? */
if ( read( fd, &psinfo, sizeof(psinfo) ) != sizeof(psinfo) )
{
close( fd );
return (size_t)0L; /* Can't read? */
}
close( fd );
return (size_t)(psinfo.pr_rssize * 1024L);
#elif (defined(_AIX) || defined(__TOS__AIX__)) || \
(defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__)))
/* AIX and Solaris ------------------------------------------ */
struct psinfo psinfo;
int fd = -1;
if ((fd = open("/proc/self/psinfo", O_RDONLY)) == -1) return (size_t)0L; /* Can't open? */
if (read(fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo)) {
close(fd);
return (size_t)0L; /* Can't read? */
}
close(fd);
return (size_t)(psinfo.pr_rssize * 1024L);
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
/* BSD, Linux, and OSX -------------------------------------- */
struct rusage rusage;
getrusage( RUSAGE_SELF, &rusage );
/* BSD, Linux, and OSX -------------------------------------- */
struct rusage rusage;
getrusage(RUSAGE_SELF, &rusage);
#if defined(__APPLE__) && defined(__MACH__)
return (size_t)rusage.ru_maxrss;
return (size_t)rusage.ru_maxrss;
#else
return (size_t)(rusage.ru_maxrss * 1024L);
return (size_t)(rusage.ru_maxrss * 1024L);
#endif
#else
/* Unknown OS ----------------------------------------------- */
return (size_t)0L; /* Unsupported. */
/* Unknown OS ----------------------------------------------- */
return (size_t)0L; /* Unsupported. */
#endif
}
@@ -60,43 +58,38 @@ size_t getPeakRSS( )
* Returns the current resident set size (physical memory use) measured
* in bytes, or zero if the value cannot be determined on this OS.
*/
size_t getCurrentRSS( )
{
size_t getCurrentRSS() {
#if defined(_WIN32)
/* Windows -------------------------------------------------- */
PROCESS_MEMORY_COUNTERS info;
GetProcessMemoryInfo( GetCurrentProcess( ), &info, sizeof(info) );
return (size_t)info.WorkingSetSize;
/* Windows -------------------------------------------------- */
PROCESS_MEMORY_COUNTERS info;
GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
return (size_t)info.WorkingSetSize;
#elif defined(__APPLE__) && defined(__MACH__)
/* OSX ------------------------------------------------------ */
struct mach_task_basic_info info;
mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
if ( task_info( mach_task_self( ), MACH_TASK_BASIC_INFO,
(task_info_t)&info, &infoCount ) != KERN_SUCCESS )
return (size_t)0L; /* Can't access? */
return (size_t)info.resident_size;
/* OSX ------------------------------------------------------ */
struct mach_task_basic_info info;
mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&info, &infoCount) != KERN_SUCCESS)
return (size_t)0L; /* Can't access? */
return (size_t)info.resident_size;
#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
/* Linux ---------------------------------------------------- */
long rss = 0L;
FILE* fp = nullptr;
if ( (fp = fopen( "/proc/self/statm", "r" )) == nullptr )
return (size_t)0L; /* Can't open? */
if ( fscanf( fp, "%*s%ld", &rss ) != 1 )
{
fclose( fp );
return (size_t)0L; /* Can't read? */
}
fclose( fp );
return (size_t)rss * (size_t)sysconf( _SC_PAGESIZE);
/* Linux ---------------------------------------------------- */
long rss = 0L;
FILE* fp = nullptr;
if ((fp = fopen("/proc/self/statm", "r")) == nullptr) return (size_t)0L; /* Can't open? */
if (fscanf(fp, "%*s%ld", &rss) != 1) {
fclose(fp);
return (size_t)0L; /* Can't read? */
}
fclose(fp);
return (size_t)rss * (size_t)sysconf(_SC_PAGESIZE);
#else
/* AIX, BSD, Solaris, and Unknown OS ------------------------ */
return (size_t)0L; /* Unsupported. */
/* AIX, BSD, Solaris, and Unknown OS ------------------------ */
return (size_t)0L; /* Unsupported. */
#endif
}
} // namespace test
} // namespace mbgl

View File

@@ -8,10 +8,11 @@
#if defined(__APPLE__) && defined(__MACH__)
#include <mach/mach.h>
#include <mach/message.h> // for mach_port_t
#include <mach/message.h> // for mach_port_t
#include <mach/task_info.h>
#elif (defined(_AIX) || defined(__TOS__AIX__)) || (defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__)))
#elif (defined(_AIX) || defined(__TOS__AIX__)) || \
(defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__)))
#include <fcntl.h>
#include <procfs.h>
@@ -26,7 +27,6 @@
namespace mbgl {
namespace test {
/**
* Returns the peak (maximum so far) resident set size (physical

View File

@@ -42,7 +42,8 @@ void runServer(std::unique_ptr<httplib::Server>& server) {
std::atomic_int cacheCounter(0);
server->Get("/cache", [&](const Request&, Response& res) {
res.set_header("Cache-Control", "max-age=30"); // Allow caching for 30 seconds
res.set_header("Cache-Control",
"max-age=30"); // Allow caching for 30 seconds
res.set_content("Response " + std::to_string(++cacheCounter), "text/plain");
});
@@ -205,6 +206,5 @@ HttpServer::~HttpServer() {
serverThread.join();
}
} // namespace test
} // namespace mbgl

View File

@@ -12,7 +12,7 @@
struct MockTileData;
struct MockSource {
mbgl::Range<uint8_t> zoomRange { 0, 16 };
mbgl::Range<uint8_t> zoomRange{0, 16};
std::map<mbgl::OverscaledTileID, std::unique_ptr<MockTileData>> dataTiles;
std::set<mbgl::OverscaledTileID> idealTiles;
@@ -22,21 +22,15 @@ struct MockSource {
struct MockBucket {};
struct MockTileData {
MockTileData(const mbgl::OverscaledTileID& tileID_) : tileID(tileID_) {}
MockTileData(const mbgl::OverscaledTileID& tileID_)
: tileID(tileID_) {}
bool hasTriedCache() const {
return triedOptional;
}
bool hasTriedCache() const { return triedOptional; }
bool isRenderable() const {
return renderable;
}
bool isRenderable() const { return renderable; }
bool isLoaded() const {
return loaded;
}
bool isLoaded() const { return loaded; }
bool renderable = false;
bool triedOptional = false;

View File

@@ -216,7 +216,7 @@ static int sqlite3_test_fs_open(sqlite3_vfs* vfs, const char* zName, sqlite3_fil
return status;
}
static int sqlite3_test_fs_delete(sqlite3_vfs* vfs, const char *zPath, int dirSync) {
static int sqlite3_test_fs_delete(sqlite3_vfs* vfs, const char* zPath, int dirSync) {
if (sqlite3_test_fs_debug) {
fprintf(stderr, "SQLite3: delete(name=%s, sync=%d)\n", zPath, dirSync);
}
@@ -227,7 +227,7 @@ static int sqlite3_test_fs_delete(sqlite3_vfs* vfs, const char *zPath, int dirSy
return unix_fs->xDelete(unix_fs, zPath, dirSync);
}
static int sqlite3_test_fs_access(sqlite3_vfs* vfs, const char *zPath, int flags, int *pResOut) {
static int sqlite3_test_fs_access(sqlite3_vfs* vfs, const char* zPath, int flags, int* pResOut) {
if (sqlite3_test_fs_debug) {
fprintf(stderr, "SQLite3: access(name=%s, flags=%d)\n", zPath, flags);
}

View File

@@ -13,24 +13,25 @@ public:
// When enabled, the VFS will log all I/O operations to stdout.
void setDebug(bool);
// Allow any type of I/O. Will fail with SQLITE_AUTH if set to false. This is useful to simulate
// scenarios where the OS blocks an entire app's I/O, e.g. when it's in the background.
// Allow any type of I/O. Will fail with SQLITE_AUTH if set to false. This
// is useful to simulate scenarios where the OS blocks an entire app's I/O,
// e.g. when it's in the background.
void allowIO(bool);
// Allow files to be opened. Will fail with SQLITE_CANTOPEN if set to false.
void allowFileOpen(bool);
// Allow files to be created. Will fail with SQLITE_CANTOPEN if set to false.
void allowFileCreate(bool);
// Allow N bytes to be read, then fail reads with SQLITE_IOERR. -1 == unlimited
// This limit is global, not per file.
// Allow N bytes to be read, then fail reads with SQLITE_IOERR. -1 ==
// unlimited This limit is global, not per file.
void setReadLimit(int64_t);
// Allow N bytes to be written, then fail writes with SQLITE_FULL. -1 == unlimited
// This limit is global, not per file.
// Allow N bytes to be written, then fail writes with SQLITE_FULL. -1 ==
// unlimited This limit is global, not per file.
void setWriteLimit(int64_t);
// Reset all restrictions.
void reset();
};

View File

@@ -10,21 +10,24 @@ using namespace std::chrono_literals;
class StubFileRequest : public AsyncRequest {
public:
StubFileRequest(StubFileSource& fileSource_)
: fileSource(fileSource_) {
}
: fileSource(fileSource_) {}
~StubFileRequest() override {
fileSource.remove(this);
}
~StubFileRequest() override { fileSource.remove(this); }
StubFileSource& fileSource;
};
StubFileSource::StubFileSource(ResponseType type_):
StubFileSource::StubFileSource(ResourceOptions().withTileServerOptions(TileServerOptions::MapTilerConfiguration()), ClientOptions(), type_) {}
StubFileSource::StubFileSource(ResponseType type_)
: StubFileSource::StubFileSource(
ResourceOptions().withTileServerOptions(TileServerOptions::MapTilerConfiguration()), ClientOptions(), type_) {
}
StubFileSource::StubFileSource(const ResourceOptions& resourceOptions_, const ClientOptions& clientOptions_, ResponseType type_)
: type(type_), resourceOptions(resourceOptions_.clone()), clientOptions(clientOptions_.clone()) {
StubFileSource::StubFileSource(const ResourceOptions& resourceOptions_,
const ClientOptions& clientOptions_,
ResponseType type_)
: type(type_),
resourceOptions(resourceOptions_.clone()),
clientOptions(clientOptions_.clone()) {
if (type == ResponseType::Synchronous) {
return;
}
@@ -35,14 +38,16 @@ StubFileSource::StubFileSource(const ResourceOptions& resourceOptions_, const Cl
for (auto& pair : pending_) {
std::optional<Response> res = std::get<1>(pair.second)(std::get<0>(pair.second));
if (res) {
// This must be before calling the callback, because it's possible that the callback
// could:
// This must be before calling the callback, because it's
// possible that the callback could:
//
// 1. Deallocate the AsyncRequest itself, thus removing it from pending
// 1. Deallocate the AsyncRequest itself, thus removing it
// from pending
// 2. Allocate a new AsyncRequest at the same memory location
//
// If remove(pair.first) was called after both those things happened, it would
// remove the newly allocated request rather than the intended request.
// If remove(pair.first) was called after both those things
// happened, it would remove the newly allocated request rather
// than the intended request.
if (!res->error) {
remove(pair.first);
}
@@ -86,29 +91,29 @@ mapbox::base::Value StubFileSource::getProperty(const std::string& key) const {
std::optional<Response> StubFileSource::defaultResponse(const Resource& resource) {
switch (resource.kind) {
case Resource::Kind::Style:
if (!styleResponse) throw std::runtime_error("unexpected style request");
return styleResponse(resource);
case Resource::Kind::Source:
if (!sourceResponse) throw std::runtime_error("unexpected source request");
return sourceResponse(resource);
case Resource::Kind::Tile:
if (!tileResponse) throw std::runtime_error("unexpected tile request");
return tileResponse(resource);
case Resource::Kind::Glyphs:
if (!glyphsResponse) throw std::runtime_error("unexpected glyphs request");
return glyphsResponse(resource);
case Resource::Kind::SpriteJSON:
if (!spriteJSONResponse) throw std::runtime_error("unexpected sprite JSON request");
return spriteJSONResponse(resource);
case Resource::Kind::SpriteImage:
if (!spriteImageResponse) throw std::runtime_error("unexpected sprite image request");
return spriteImageResponse(resource);
case Resource::Kind::Image:
if (!imageResponse) throw std::runtime_error("unexpected image request");
return imageResponse(resource);
case Resource::Kind::Unknown:
throw std::runtime_error("unknown resource type");
case Resource::Kind::Style:
if (!styleResponse) throw std::runtime_error("unexpected style request");
return styleResponse(resource);
case Resource::Kind::Source:
if (!sourceResponse) throw std::runtime_error("unexpected source request");
return sourceResponse(resource);
case Resource::Kind::Tile:
if (!tileResponse) throw std::runtime_error("unexpected tile request");
return tileResponse(resource);
case Resource::Kind::Glyphs:
if (!glyphsResponse) throw std::runtime_error("unexpected glyphs request");
return glyphsResponse(resource);
case Resource::Kind::SpriteJSON:
if (!spriteJSONResponse) throw std::runtime_error("unexpected sprite JSON request");
return spriteJSONResponse(resource);
case Resource::Kind::SpriteImage:
if (!spriteImageResponse) throw std::runtime_error("unexpected sprite image request");
return spriteImageResponse(resource);
case Resource::Kind::Image:
if (!imageResponse) throw std::runtime_error("unexpected image request");
return imageResponse(resource);
case Resource::Kind::Unknown:
throw std::runtime_error("unknown resource type");
}
// The above switch is exhaustive, but placate GCC nonetheless:

View File

@@ -29,10 +29,10 @@ public:
void setProperty(const std::string&, const mapbox::base::Value&) override;
mapbox::base::Value getProperty(const std::string&) const override;
using ResponseFunction = std::function<std::optional<Response> (const Resource&)>;
using ResponseFunction = std::function<std::optional<Response>(const Resource&)>;
// You can set the response callback on a global level by assigning this callback:
ResponseFunction response = [this] (const Resource& resource) {
ResponseFunction response = [this](const Resource& resource) {
return defaultResponse(resource);
};

View File

@@ -6,39 +6,35 @@ namespace mbgl {
class StubGeometryTileFeature : public GeometryTileFeature {
public:
StubGeometryTileFeature(PropertyMap properties_)
: properties(std::move(properties_)) {
}
: properties(std::move(properties_)) {}
StubGeometryTileFeature(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_)
StubGeometryTileFeature(FeatureIdentifier id_,
FeatureType type_,
GeometryCollection geometry_,
PropertyMap properties_)
: properties(std::move(properties_)),
id(std::move(id_)),
type(type_),
geometry(std::move(geometry_)) {
}
geometry(std::move(geometry_)) {}
StubGeometryTileFeature(FeatureType type_, GeometryCollection geometry_)
: type(type_), geometry(std::move(geometry_)) {}
: type(type_),
geometry(std::move(geometry_)) {}
PropertyMap properties;
FeatureIdentifier id;
FeatureType type = FeatureType::Point;
GeometryCollection geometry;
FeatureType getType() const override {
return type;
}
FeatureType getType() const override { return type; }
FeatureIdentifier getID() const override {
return id;
}
FeatureIdentifier getID() const override { return id; }
std::optional<Value> getValue(const std::string& key) const override {
return properties.count(key) ? properties.at(key) : std::optional<Value>();
}
const GeometryCollection& getGeometries() const override {
return geometry;
}
const GeometryCollection& getGeometries() const override { return geometry; }
};
} // namespace mbgl

View File

@@ -6,7 +6,8 @@ using namespace mbgl;
using namespace mbgl::style;
/**
* An implementation of style::LayerObserver that forwards all methods to dynamically-settable lambas.
* An implementation of style::LayerObserver that forwards all methods to
* dynamically-settable lambas.
*/
class StubLayerObserver : public style::LayerObserver {
public:
@@ -14,5 +15,5 @@ public:
if (layerChanged) layerChanged(layer);
}
std::function<void (Layer&)> layerChanged;
std::function<void(Layer&)> layerChanged;
};

View File

@@ -59,5 +59,4 @@ public:
std::function<void(gfx::ShaderRegistry&)> onRegisterShadersCallback;
};
} // namespace mbgl

View File

@@ -5,7 +5,8 @@
using namespace mbgl;
/**
* An implementation of style::Observer that forwards all methods to dynamically-settable lambdas.
* An implementation of style::Observer that forwards all methods to
* dynamically-settable lambdas.
*/
class StubRenderSourceObserver : public RenderSourceObserver {
public:
@@ -13,11 +14,10 @@ public:
if (tileChanged) tileChanged(source, tileID);
};
void
onTileError(RenderSource& source, const OverscaledTileID& tileID, std::exception_ptr error) override {
void onTileError(RenderSource& source, const OverscaledTileID& tileID, std::exception_ptr error) override {
if (tileError) tileError(source, tileID, error);
}
std::function<void (RenderSource&, const OverscaledTileID&)> tileChanged;
std::function<void (RenderSource&, const OverscaledTileID&, std::exception_ptr)> tileError;
std::function<void(RenderSource&, const OverscaledTileID&)> tileChanged;
std::function<void(RenderSource&, const OverscaledTileID&, std::exception_ptr)> tileError;
};

View File

@@ -6,7 +6,8 @@ using namespace mbgl;
using namespace mbgl::style;
/**
* An implementation of style::Observer that forwards all methods to dynamically-settable lambdas.
* An implementation of style::Observer that forwards all methods to
* dynamically-settable lambdas.
*/
class StubStyleObserver : public style::Observer {
public:
@@ -30,9 +31,9 @@ public:
if (resourceError) resourceError(error);
};
std::function<void (Source&)> sourceLoaded;
std::function<void (Source&)> sourceChanged;
std::function<void (Source&, std::exception_ptr)> sourceError;
std::function<void (Source&)> sourceDescriptionChanged;
std::function<void (std::exception_ptr)> resourceError;
std::function<void(Source&)> sourceLoaded;
std::function<void(Source&)> sourceChanged;
std::function<void(Source&, std::exception_ptr)> sourceError;
std::function<void(Source&)> sourceDescriptionChanged;
std::function<void(std::exception_ptr)> resourceError;
};

View File

@@ -5,7 +5,8 @@
using namespace mbgl;
/**
* An implementation of TileObserver that forwards all methods to dynamically-settable lambas.
* An implementation of TileObserver that forwards all methods to
* dynamically-settable lambas.
*/
class StubTileObserver : public TileObserver {
public:
@@ -17,6 +18,6 @@ public:
if (tileError) tileError(tile, error);
}
std::function<void (Tile&)> tileChanged;
std::function<void (Tile&, std::exception_ptr)> tileError;
std::function<void(Tile&)> tileChanged;
std::function<void(Tile&, std::exception_ptr)> tileError;
};

View File

@@ -8,7 +8,7 @@ namespace mbgl {
int runTests(int argc, char *argv[]) {
testing::InitGoogleTest(&argc, argv);
// In order to run specific tests
// testing::GTEST_FLAG(filter) = "TileServerOptions*";
// testing::GTEST_FLAG(filter) = "MainResourceLoader.ResourceOptions";

View File

@@ -15,7 +15,6 @@
#pragma warning(pop)
#endif
namespace mbgl {
namespace test {
@@ -39,8 +38,7 @@ void checkImage(const std::string& base,
}
PremultipliedImage expected = decodeImage(expected_image);
PremultipliedImage diff { expected.size };
PremultipliedImage diff{expected.size};
#if !TEST_READ_ONLY
util::write_file(base + "/actual.png", encodePNG(actual));