本文整理汇总了C++中OfflineRegion类的典型用法代码示例。如果您正苦于以下问题:C++ OfflineRegion类的具体用法?C++ OfflineRegion怎么用?C++ OfflineRegion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OfflineRegion类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(OfflineDownload, Deactivate) {
OfflineTest test;
OfflineRegion region = test.createRegion();
OfflineDownload download(
region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
test.fileSource.styleResponse = [&] (const Resource& resource) {
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
return test.response("mapbox_source.style.json");
};
auto observer = std::make_unique<MockObserver>();
observer->statusChangedFn = [&] (OfflineRegionStatus status) {
if (status.downloadState == OfflineRegionDownloadState::Inactive) {
test.loop.stop();
} else {
download.setState(OfflineRegionDownloadState::Inactive);
}
};
download.setObserver(std::move(observer));
download.setState(OfflineRegionDownloadState::Active);
test.loop.run();
}
示例2: TEST
TEST(OfflineDatabase, CreateRegionInfiniteMaxZoom) {
using namespace mbgl;
OfflineDatabase db(":memory:");
OfflineRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0 };
OfflineRegionMetadata metadata;
OfflineRegion region = db.createRegion(definition, metadata);
EXPECT_EQ(0, region.getDefinition().minZoom);
EXPECT_EQ(INFINITY, region.getDefinition().maxZoom);
}
示例3: TEST
TEST(OfflineDownload, ReactivatePreviouslyCompletedDownload) {
OfflineTest test;
OfflineRegion region = test.createRegion();
OfflineDownload download(
region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
test.fileSource.styleResponse = [&] (const Resource& resource) {
EXPECT_EQ("http://127.0.0.1:3000/style.json", resource.url);
return test.response("inline_source.style.json");
};
test.db.put(
Resource::tile("http://127.0.0.1:3000/{z}-{x}-{y}.vector.pbf", 1, 0, 0, 0),
test.response("0-0-0.vector.pbf"));
auto observer = std::make_unique<MockObserver>();
observer->statusChangedFn = [&] (OfflineRegionStatus status) {
if (status.complete()) {
test.loop.stop();
}
};
download.setObserver(std::move(observer));
download.setState(OfflineRegionDownloadState::Active);
test.loop.run();
OfflineDownload redownload(
region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
std::vector<OfflineRegionStatus> statusesAfterReactivate;
observer = std::make_unique<MockObserver>();
observer->statusChangedFn = [&] (OfflineRegionStatus status) {
statusesAfterReactivate.push_back(status);
if (status.complete()) {
test.loop.stop();
}
};
redownload.setObserver(std::move(observer));
redownload.setState(OfflineRegionDownloadState::Active);
test.loop.run();
ASSERT_EQ(4u, statusesAfterReactivate.size());
EXPECT_EQ(OfflineRegionDownloadState::Active, statusesAfterReactivate[0].downloadState);
EXPECT_FALSE(statusesAfterReactivate[0].requiredResourceCountIsPrecise);
EXPECT_EQ(1u, statusesAfterReactivate[0].requiredResourceCount);
EXPECT_EQ(0u, statusesAfterReactivate[0].completedResourceCount);
EXPECT_EQ(OfflineRegionDownloadState::Active, statusesAfterReactivate[1].downloadState);
EXPECT_TRUE(statusesAfterReactivate[1].requiredResourceCountIsPrecise);
EXPECT_EQ(2u, statusesAfterReactivate[1].requiredResourceCount);
EXPECT_EQ(1u, statusesAfterReactivate[1].completedResourceCount);
EXPECT_EQ(OfflineRegionDownloadState::Active, statusesAfterReactivate[2].downloadState);
EXPECT_TRUE(statusesAfterReactivate[2].requiredResourceCountIsPrecise);
EXPECT_EQ(2u, statusesAfterReactivate[2].requiredResourceCount);
EXPECT_EQ(2u, statusesAfterReactivate[2].completedResourceCount);
}
示例4: setOfflineRegionDownloadState
void DefaultFileSource::setOfflineRegionDownloadState(OfflineRegion& region, OfflineRegionDownloadState state) {
thread->invoke(&Impl::setRegionDownloadState, region.getID(), state);
}
示例5: setOfflineRegionObserver
void DefaultFileSource::setOfflineRegionObserver(OfflineRegion& region, std::unique_ptr<OfflineRegionObserver> observer) {
thread->invoke(&Impl::setRegionObserver, region.getID(), std::move(observer));
}
示例6: getOfflineRegionStatus
void DefaultFileSource::getOfflineRegionStatus(OfflineRegion& region, std::function<void (std::exception_ptr, optional<OfflineRegionStatus>)> callback) const {
thread->invoke(&Impl::getRegionStatus, region.getID(), callback);
}