mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-06 20:44:25 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -26,8 +26,7 @@ void TestAddress(ReverseGeocoder & coder, ms::LatLon const & ll, std::string_vie
|
||||
ReverseGeocoder::Address addr;
|
||||
coder.GetNearbyAddress(mercator::FromLatLon(ll), addr);
|
||||
|
||||
std::string const expectedKey =
|
||||
strings::ToUtf8(GetStreetNameAsKey(street, false /* ignoreStreetSynonyms */));
|
||||
std::string const expectedKey = strings::ToUtf8(GetStreetNameAsKey(street, false /* ignoreStreetSynonyms */));
|
||||
std::string const resultKey =
|
||||
strings::ToUtf8(GetStreetNameAsKey(addr.m_street.m_name, false /* ignoreStreetSynonyms */));
|
||||
|
||||
@@ -39,8 +38,8 @@ void TestAddress(ReverseGeocoder & coder, std::shared_ptr<MwmInfo> mwmInfo, ms::
|
||||
StringUtf8Multilang const & streetNames, std::string const & houseNumber)
|
||||
{
|
||||
feature::NameParamsOut out;
|
||||
feature::GetReadableName({ streetNames, mwmInfo->GetRegionData(), languages::GetCurrentMapLanguage(),
|
||||
false /* allowTranslit */ }, out);
|
||||
feature::GetReadableName(
|
||||
{streetNames, mwmInfo->GetRegionData(), languages::GetCurrentMapLanguage(), false /* allowTranslit */}, out);
|
||||
|
||||
TestAddress(coder, ll, out.primary, houseNumber);
|
||||
}
|
||||
@@ -104,4 +103,4 @@ UNIT_TEST(ReverseGeocoder_Smoke)
|
||||
TestAddress(coder, mwmInfo, {53.89745, 27.55835}, streetNames, "18А");
|
||||
}
|
||||
}
|
||||
} // namespace address_tests
|
||||
} // namespace address_tests
|
||||
|
||||
@@ -38,115 +38,114 @@ char const * kmlString =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
"<kml xmlns=\"http://earth.google.com/kml/2.2\">"
|
||||
"<Document>"
|
||||
"<name>MapName</name>"
|
||||
"<description><![CDATA[MapDescription]]></description>"
|
||||
"<visibility>0</visibility>"
|
||||
"<Style id=\"placemark-blue\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-blue.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-brown\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-brown.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-green\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-green.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-orange\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-orange.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-pink\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-pink.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-purple\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-purple.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-red\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-red.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Placemark>"
|
||||
"<name>Nebraska</name>"
|
||||
"<description><![CDATA[]]></description>"
|
||||
"<styleUrl>#placemark-red</styleUrl>"
|
||||
"<Point>"
|
||||
"<coordinates>-99.901810,41.492538,0.000000</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"<Placemark>"
|
||||
"<name>Monongahela National Forest</name>"
|
||||
"<description><![CDATA[Huttonsville, WV 26273<br>]]></description>"
|
||||
"<styleUrl>#placemark-pink</styleUrl>"
|
||||
"<TimeStamp>"
|
||||
"<when>1986-08-12T07:10:43Z</when>"
|
||||
"</TimeStamp>"
|
||||
"<Point>"
|
||||
"<coordinates>-79.829674,38.627785,0.000000</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"<Placemark>"
|
||||
"<name>From: Минск, Минская область, Беларусь</name>"
|
||||
"<description><![CDATA[]]></description>"
|
||||
"<styleUrl>#placemark-blue</styleUrl>"
|
||||
"<TimeStamp>"
|
||||
"<when>1998-03-03T03:04:48+01:30</when>"
|
||||
"</TimeStamp>"
|
||||
"<Point>"
|
||||
"<coordinates>27.566765,53.900047,0</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"<Placemark>"
|
||||
"<name><![CDATA[<MWM & Sons>]]></name>"
|
||||
"<description><![CDATA[Amps & <brackets>]]></description>"
|
||||
"<styleUrl>#placemark-green</styleUrl>"
|
||||
"<TimeStamp>"
|
||||
"<when>2048 bytes in two kilobytes - some invalid timestamp</when>"
|
||||
"</TimeStamp>"
|
||||
"<Point>"
|
||||
"<coordinates>27.551532,53.89306</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"<name>MapName</name>"
|
||||
"<description><![CDATA[MapDescription]]></description>"
|
||||
"<visibility>0</visibility>"
|
||||
"<Style id=\"placemark-blue\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-blue.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-brown\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-brown.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-green\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-green.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-orange\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-orange.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-pink\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-pink.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-purple\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-purple.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Style id=\"placemark-red\">"
|
||||
"<IconStyle>"
|
||||
"<Icon>"
|
||||
"<href>https://comaps.at/placemarks/placemark-red.png</href>"
|
||||
"</Icon>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Placemark>"
|
||||
"<name>Nebraska</name>"
|
||||
"<description><![CDATA[]]></description>"
|
||||
"<styleUrl>#placemark-red</styleUrl>"
|
||||
"<Point>"
|
||||
"<coordinates>-99.901810,41.492538,0.000000</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"<Placemark>"
|
||||
"<name>Monongahela National Forest</name>"
|
||||
"<description><![CDATA[Huttonsville, WV 26273<br>]]></description>"
|
||||
"<styleUrl>#placemark-pink</styleUrl>"
|
||||
"<TimeStamp>"
|
||||
"<when>1986-08-12T07:10:43Z</when>"
|
||||
"</TimeStamp>"
|
||||
"<Point>"
|
||||
"<coordinates>-79.829674,38.627785,0.000000</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"<Placemark>"
|
||||
"<name>From: Минск, Минская область, Беларусь</name>"
|
||||
"<description><![CDATA[]]></description>"
|
||||
"<styleUrl>#placemark-blue</styleUrl>"
|
||||
"<TimeStamp>"
|
||||
"<when>1998-03-03T03:04:48+01:30</when>"
|
||||
"</TimeStamp>"
|
||||
"<Point>"
|
||||
"<coordinates>27.566765,53.900047,0</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"<Placemark>"
|
||||
"<name><![CDATA[<MWM & Sons>]]></name>"
|
||||
"<description><![CDATA[Amps & <brackets>]]></description>"
|
||||
"<styleUrl>#placemark-green</styleUrl>"
|
||||
"<TimeStamp>"
|
||||
"<when>2048 bytes in two kilobytes - some invalid timestamp</when>"
|
||||
"</TimeStamp>"
|
||||
"<Point>"
|
||||
"<coordinates>27.551532,53.89306</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"</Document>"
|
||||
"</kml>";
|
||||
|
||||
#define BM_CALLBACKS { \
|
||||
[]() -> StringsBundle const & \
|
||||
{ \
|
||||
static StringsBundle const dummyBundle; \
|
||||
return dummyBundle; \
|
||||
}, \
|
||||
static_cast<BookmarkManager::Callbacks::GetSeacrhAPIFn>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::CreatedBookmarksCallback>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::UpdatedBookmarksCallback>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::DeletedBookmarksCallback>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::AttachedBookmarksCallback>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::DetachedBookmarksCallback>(nullptr) \
|
||||
}
|
||||
#define BM_CALLBACKS \
|
||||
{[]() -> StringsBundle const & \
|
||||
{ \
|
||||
static StringsBundle const dummyBundle; \
|
||||
return dummyBundle; \
|
||||
}, \
|
||||
static_cast<BookmarkManager::Callbacks::GetSeacrhAPIFn>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::CreatedBookmarksCallback>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::UpdatedBookmarksCallback>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::DeletedBookmarksCallback>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::AttachedBookmarksCallback>(nullptr), \
|
||||
static_cast<BookmarkManager::Callbacks::DetachedBookmarksCallback>(nullptr)}
|
||||
|
||||
void CheckBookmarks(BookmarkManager const & bmManager, kml::MarkGroupId groupId)
|
||||
{
|
||||
@@ -198,7 +197,7 @@ UNIT_CLASS_TEST(Runner, Bookmarks_ImportKML)
|
||||
|
||||
BookmarkManager::KMLDataCollection kmlDataCollection;
|
||||
|
||||
kmlDataCollection.emplace_back(""/* filePath */,
|
||||
kmlDataCollection.emplace_back("" /* filePath */,
|
||||
LoadKmlData(MemReader(kmlString, strlen(kmlString)), KmlFileType::Text));
|
||||
TEST(kmlDataCollection.back().second, ());
|
||||
bmManager.CreateCategories(std::move(kmlDataCollection));
|
||||
@@ -216,17 +215,20 @@ UNIT_CLASS_TEST(Runner, Bookmarks_ExportKML)
|
||||
{
|
||||
string const dir = GetBookmarksDirectory();
|
||||
bool const delDirOnExit = Platform::MkDir(dir) == Platform::ERR_OK;
|
||||
SCOPE_GUARD(dirDeleter, [&](){ if (delDirOnExit) (void)Platform::RmDir(dir); });
|
||||
SCOPE_GUARD(dirDeleter, [&]()
|
||||
{
|
||||
if (delDirOnExit)
|
||||
(void)Platform::RmDir(dir);
|
||||
});
|
||||
string const ext = ".kmb";
|
||||
string const fileName = base::JoinPath(dir, "UnitTestBookmarks" + ext);
|
||||
SCOPE_GUARD(fileDeleter, [&](){ (void)base::DeleteFileX(fileName); });
|
||||
SCOPE_GUARD(fileDeleter, [&]() { (void)base::DeleteFileX(fileName); });
|
||||
|
||||
BookmarkManager bmManager(BM_CALLBACKS);
|
||||
bmManager.EnableTestMode(true);
|
||||
|
||||
BookmarkManager::KMLDataCollection kmlDataCollection1;
|
||||
kmlDataCollection1.emplace_back("",
|
||||
LoadKmlData(MemReader(kmlString, strlen(kmlString)), KmlFileType::Text));
|
||||
kmlDataCollection1.emplace_back("", LoadKmlData(MemReader(kmlString, strlen(kmlString)), KmlFileType::Text));
|
||||
bmManager.CreateCategories(std::move(kmlDataCollection1));
|
||||
TEST_EQUAL(bmManager.GetBmGroupsCount(), 1, ());
|
||||
|
||||
@@ -283,40 +285,40 @@ UNIT_CLASS_TEST(Runner, Bookmarks_ExportKML)
|
||||
|
||||
namespace
|
||||
{
|
||||
void DeleteCategoryFiles(vector<string> const & arrFiles)
|
||||
{
|
||||
string const path = GetBookmarksDirectory();
|
||||
string const extension = ".kmb";
|
||||
for (auto const & fileName : arrFiles)
|
||||
FileWriter::DeleteFileX(base::JoinPath(path, fileName + extension));
|
||||
}
|
||||
void DeleteCategoryFiles(vector<string> const & arrFiles)
|
||||
{
|
||||
string const path = GetBookmarksDirectory();
|
||||
string const extension = ".kmb";
|
||||
for (auto const & fileName : arrFiles)
|
||||
FileWriter::DeleteFileX(base::JoinPath(path, fileName + extension));
|
||||
}
|
||||
|
||||
UserMark const * GetMark(Framework & fm, m2::PointD const & pt)
|
||||
{
|
||||
m2::AnyRectD rect;
|
||||
fm.GetTouchRect(fm.GtoP(pt), 20, rect);
|
||||
UserMark const * GetMark(Framework & fm, m2::PointD const & pt)
|
||||
{
|
||||
m2::AnyRectD rect;
|
||||
fm.GetTouchRect(fm.GtoP(pt), 20, rect);
|
||||
|
||||
return fm.GetBookmarkManager().FindNearestUserMark(rect);
|
||||
}
|
||||
return fm.GetBookmarkManager().FindNearestUserMark(rect);
|
||||
}
|
||||
|
||||
Bookmark const * GetBookmark(Framework & fm, m2::PointD const & pt)
|
||||
{
|
||||
auto const * mark = GetMark(fm, pt);
|
||||
ASSERT(mark, ());
|
||||
ASSERT(mark->GetMarkType() == UserMark::BOOKMARK, ());
|
||||
return dynamic_cast<Bookmark const *>(mark);
|
||||
}
|
||||
Bookmark const * GetBookmark(Framework & fm, m2::PointD const & pt)
|
||||
{
|
||||
auto const * mark = GetMark(fm, pt);
|
||||
ASSERT(mark, ());
|
||||
ASSERT(mark->GetMarkType() == UserMark::BOOKMARK, ());
|
||||
return dynamic_cast<Bookmark const *>(mark);
|
||||
}
|
||||
|
||||
Bookmark const * GetBookmarkPxPoint(Framework & fm, m2::PointD const & pt)
|
||||
{
|
||||
return GetBookmark(fm, fm.PtoG(pt));
|
||||
}
|
||||
Bookmark const * GetBookmarkPxPoint(Framework & fm, m2::PointD const & pt)
|
||||
{
|
||||
return GetBookmark(fm, fm.PtoG(pt));
|
||||
}
|
||||
|
||||
bool IsValidBookmark(Framework & fm, m2::PointD const & pt)
|
||||
{
|
||||
auto const * mark = GetMark(fm, pt);
|
||||
return (mark != nullptr) && (mark->GetMarkType() == UserMark::BOOKMARK);
|
||||
}
|
||||
bool IsValidBookmark(Framework & fm, m2::PointD const & pt)
|
||||
{
|
||||
auto const * mark = GetMark(fm, pt);
|
||||
return (mark != nullptr) && (mark->GetMarkType() == UserMark::BOOKMARK);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(Bookmarks_Timestamp)
|
||||
@@ -348,7 +350,7 @@ UNIT_TEST(Bookmarks_Timestamp)
|
||||
Bookmark const * pBm3 = bmManager.GetEditSession().CreateBookmark(std::move(b22), cat2);
|
||||
|
||||
// Check bookmarks order here. First added should be in the bottom of the list.
|
||||
auto const firstId = * bmManager.GetUserMarkIds(cat1).rbegin();
|
||||
auto const firstId = *bmManager.GetUserMarkIds(cat1).rbegin();
|
||||
TEST_EQUAL(firstId, pBm1->GetId(), ());
|
||||
|
||||
Bookmark const * pBm01 = bmManager.GetBookmark(pBm1->GetId());
|
||||
@@ -377,7 +379,7 @@ UNIT_TEST(Bookmarks_Getting)
|
||||
fm.ShowRect(m2::RectD(0, 0, 80, 40));
|
||||
|
||||
// This is not correct because Framework::OnSize doesn't work until SetRenderPolicy is called.
|
||||
//TEST(AlmostEqualULPs(m2::PointD(400, 200), pixC), (pixC));
|
||||
// TEST(AlmostEqualULPs(m2::PointD(400, 200), pixC), (pixC));
|
||||
|
||||
BookmarkManager & bmManager = fm.GetBookmarkManager();
|
||||
bmManager.EnableTestMode(true);
|
||||
@@ -450,8 +452,8 @@ void CheckPlace(Framework const & fm, std::shared_ptr<MwmInfo> const & mwmInfo,
|
||||
auto const info = fm.GetAddressAtPoint(mercator::FromLatLon(lat, lon));
|
||||
|
||||
feature::NameParamsOut out;
|
||||
feature::GetReadableName({ streetNames, mwmInfo->GetRegionData(), languages::GetCurrentMapLanguage(),
|
||||
false /* allowTranslit */ }, out);
|
||||
feature::GetReadableName(
|
||||
{streetNames, mwmInfo->GetRegionData(), languages::GetCurrentMapLanguage(), false /* allowTranslit */}, out);
|
||||
|
||||
TEST_EQUAL(info.GetStreetName(), out.primary, ());
|
||||
TEST_EQUAL(info.GetHouseNumber(), houseNumber, ());
|
||||
@@ -485,7 +487,7 @@ UNIT_TEST(Bookmarks_AddressInfo)
|
||||
UNIT_TEST(Bookmarks_IllegalFileName)
|
||||
{
|
||||
vector<string> const arrIllegal = {"?", "?|", "ч\"x", "|x:", "x<>y", "xy*地圖"};
|
||||
vector<string> const arrLegal = {"", "", "чx", "x", "xy", "xy地圖"};
|
||||
vector<string> const arrLegal = {"", "", "чx", "x", "xy", "xy地圖"};
|
||||
|
||||
for (size_t i = 0; i < arrIllegal.size(); ++i)
|
||||
TEST_EQUAL(arrLegal[i], RemoveInvalidSymbols(arrIllegal[i]), ());
|
||||
@@ -567,8 +569,7 @@ UNIT_TEST(Bookmarks_AddingMoving)
|
||||
TEST_EQUAL(bmManager.GetBmGroupsCount(), 2, ());
|
||||
mark = GetBookmarkPxPoint(fm, pixelPoint);
|
||||
TEST_EQUAL(bmManager.GetCategoryName(mark->GetGroupId()), "cat1", ());
|
||||
TEST_EQUAL(bmManager.GetUserMarkIds(cat1).size(), 2,
|
||||
("Bookmark wasn't moved from one category to another"));
|
||||
TEST_EQUAL(bmManager.GetUserMarkIds(cat1).size(), 2, ("Bookmark wasn't moved from one category to another"));
|
||||
TEST_EQUAL(kml::GetDefaultStr(mark->GetName()), "name2", ());
|
||||
TEST_EQUAL(mark->GetColor(), kml::PredefinedColor::Blue, ());
|
||||
|
||||
@@ -628,61 +629,50 @@ UNIT_TEST(Bookmarks_Sorting)
|
||||
double constexpr kNearR = 20 * 1000;
|
||||
m2::PointD const myPos = mercator::GetSmPoint(kMoscowCenter, -kNearR, 0.0);
|
||||
|
||||
std::vector<TestMarkData> const testMarksData =
|
||||
{
|
||||
{0, mercator::GetSmPoint(myPos, kNearR * 0.07, 0.0), kDay + std::chrono::hours(1), {"historic-ruins"}},
|
||||
{1, mercator::GetSmPoint(myPos, kNearR * 0.06, 0.0), kUnknownTime, {"amenity-restaurant", "cuisine-sushi"}},
|
||||
{2, mercator::GetSmPoint(myPos, kNearR * 0.05, 0.0), kUnknownTime, {"shop-music", "shop-gift"}},
|
||||
{3, mercator::GetSmPoint(myPos, kNearR * 1.01, 0.0), kWeek + std::chrono::hours(2), {"historic-castle"}},
|
||||
{4, mercator::GetSmPoint(myPos, kNearR * 0.04, 0.0), kWeek + std::chrono::hours(3), {"amenity-fast_food"}},
|
||||
{5, mercator::GetSmPoint(myPos, kNearR * 1.02, 0.0), kMonth + std::chrono::hours(1), {"historic-memorial"}},
|
||||
{6, mercator::GetSmPoint(myPos, kNearR * 0.03, 0.0), kMonth + std::chrono::hours(2), {"shop-music"}},
|
||||
{7, mercator::GetSmPoint(myPos, kNearR * 1.05, 0.0), kUnknownTime, {"amenity-cinema"}},
|
||||
{8, mercator::GetSmPoint(myPos, kNearR * 0.02, 0.0), std::chrono::hours(1), {"leisure-stadium"}},
|
||||
{9, mercator::GetSmPoint(myPos, kNearR * 1.06, 0.0), kDay + std::chrono::hours(3), {"amenity-bar"}},
|
||||
{10, mercator::GetSmPoint(myPos, kNearR * 1.03, 0.0), kYear + std::chrono::hours(3), {"historic-castle"}},
|
||||
{11, m2::PointD(0.0, 0.0), kWeek + std::chrono::hours(1), {}},
|
||||
{12, mercator::GetSmPoint(myPos, kNearR * 1.04, 0.0), kDay + std::chrono::hours(2), {"shop-music"}},
|
||||
std::vector<TestMarkData> const testMarksData = {
|
||||
{0, mercator::GetSmPoint(myPos, kNearR * 0.07, 0.0), kDay + std::chrono::hours(1), {"historic-ruins"}},
|
||||
{1, mercator::GetSmPoint(myPos, kNearR * 0.06, 0.0), kUnknownTime, {"amenity-restaurant", "cuisine-sushi"}},
|
||||
{2, mercator::GetSmPoint(myPos, kNearR * 0.05, 0.0), kUnknownTime, {"shop-music", "shop-gift"}},
|
||||
{3, mercator::GetSmPoint(myPos, kNearR * 1.01, 0.0), kWeek + std::chrono::hours(2), {"historic-castle"}},
|
||||
{4, mercator::GetSmPoint(myPos, kNearR * 0.04, 0.0), kWeek + std::chrono::hours(3), {"amenity-fast_food"}},
|
||||
{5, mercator::GetSmPoint(myPos, kNearR * 1.02, 0.0), kMonth + std::chrono::hours(1), {"historic-memorial"}},
|
||||
{6, mercator::GetSmPoint(myPos, kNearR * 0.03, 0.0), kMonth + std::chrono::hours(2), {"shop-music"}},
|
||||
{7, mercator::GetSmPoint(myPos, kNearR * 1.05, 0.0), kUnknownTime, {"amenity-cinema"}},
|
||||
{8, mercator::GetSmPoint(myPos, kNearR * 0.02, 0.0), std::chrono::hours(1), {"leisure-stadium"}},
|
||||
{9, mercator::GetSmPoint(myPos, kNearR * 1.06, 0.0), kDay + std::chrono::hours(3), {"amenity-bar"}},
|
||||
{10, mercator::GetSmPoint(myPos, kNearR * 1.03, 0.0), kYear + std::chrono::hours(3), {"historic-castle"}},
|
||||
{11, m2::PointD(0.0, 0.0), kWeek + std::chrono::hours(1), {}},
|
||||
{12, mercator::GetSmPoint(myPos, kNearR * 1.04, 0.0), kDay + std::chrono::hours(2), {"shop-music"}},
|
||||
};
|
||||
|
||||
std::vector<TestTrackData> const testTracksData =
|
||||
{
|
||||
{0, "Z Last Track", kDay + std::chrono::hours(1)},
|
||||
{1, "Middle Track", kUnknownTime},
|
||||
{2, "First Track", kMonth + std::chrono::hours(1)}
|
||||
};
|
||||
std::vector<TestTrackData> const testTracksData = {{0, "Z Last Track", kDay + std::chrono::hours(1)},
|
||||
{1, "Middle Track", kUnknownTime},
|
||||
{2, "First Track", kMonth + std::chrono::hours(1)}};
|
||||
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByDistance =
|
||||
{
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {0, 1, 2}},
|
||||
{BookmarkManager::GetNearMeSortedBlockName(), {8, 6, 4, 2, 1, 0}, {}},
|
||||
{addrMoscow, {3, 5, 10, 12, 7, 9}, {}},
|
||||
{BookmarkManager::GetOthersSortedBlockName(), {11}, {}}
|
||||
};
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByDistance = {
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {0, 1, 2}},
|
||||
{BookmarkManager::GetNearMeSortedBlockName(), {8, 6, 4, 2, 1, 0}, {}},
|
||||
{addrMoscow, {3, 5, 10, 12, 7, 9}, {}},
|
||||
{BookmarkManager::GetOthersSortedBlockName(), {11}, {}}};
|
||||
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByTime =
|
||||
{
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {0, 2, 1}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::WeekAgo), {8, 0, 12, 9}, {}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::MonthAgo), {11, 3, 4}, {}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::MoreThanMonthAgo), {5, 6}, {}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::MoreThanYearAgo), {10}, {}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::Others), {7, 2, 1}, {}}
|
||||
};
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByTime = {
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {0, 2, 1}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::WeekAgo), {8, 0, 12, 9}, {}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::MonthAgo), {11, 3, 4}, {}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::MoreThanMonthAgo), {5, 6}, {}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::MoreThanYearAgo), {10}, {}},
|
||||
{BookmarkManager::GetSortedByTimeBlockName(BookmarkManager::SortedByTimeBlockType::Others), {7, 2, 1}, {}}};
|
||||
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByType =
|
||||
{
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {0, 1, 2}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Sights), {0, 3, 5, 10}, {}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Food), {9, 4, 1}, {}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Shop), {12, 6, 2}, {}},
|
||||
{BookmarkManager::GetOthersSortedBlockName(), {8, 11, 7}, {}}
|
||||
};
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByType = {
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {0, 1, 2}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Sights), {0, 3, 5, 10}, {}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Food), {9, 4, 1}, {}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Shop), {12, 6, 2}, {}},
|
||||
{BookmarkManager::GetOthersSortedBlockName(), {8, 11, 7}, {}}};
|
||||
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByName =
|
||||
{
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {2, 1, 0}},
|
||||
{BookmarkManager::GetBookmarksSortedBlockName(), {11, 9, 7, 4, 1, 10, 3, 5, 0, 8, 12, 6, 2}, {}},
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByName = {
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {2, 1, 0}},
|
||||
{BookmarkManager::GetBookmarksSortedBlockName(), {11, 9, 7, 4, 1, 10, 3, 5, 0, 8, 12, 6, 2}, {}},
|
||||
};
|
||||
|
||||
auto const kBerlin1 = mercator::FromLatLon(52.5038994, 13.3982282);
|
||||
@@ -699,21 +689,20 @@ UNIT_TEST(Bookmarks_Sorting)
|
||||
auto const kVladimir = mercator::FromLatLon(56.2102137, 40.5195297);
|
||||
auto const kBermuda = mercator::FromLatLon(32.2946391, -64.7820014);
|
||||
|
||||
std::vector<TestMarkData> const testMarksData2 =
|
||||
{
|
||||
{100, kBerlin1, kUnknownTime, {"amenity", "building", "wheelchair-yes", "tourism-museum"}},
|
||||
{101, kGreenland, kUnknownTime, {}},
|
||||
{102, kVladimir, kUnknownTime, {"tourism-artwork"}},
|
||||
{103, kKathmandu, kUnknownTime, {"internet_access-wlan", "wheelchair-no", "amenity-cafe"}},
|
||||
{104, kMinsk1, kUnknownTime, {"amenity-place_of_worship"}},
|
||||
{105, kBerlin2, kUnknownTime, {"building", "amenity-place_of_worship-christian"}},
|
||||
{106, kMoscow2, kUnknownTime, {"tourism-museum"}},
|
||||
{107, kMinsk2, kUnknownTime, {"amenity-restaurant"}},
|
||||
{108, kMinsk3, kUnknownTime, {"amenity-place_of_worship-jewish"}},
|
||||
{109, kWashington, kUnknownTime, {"amenity-restaurant"}},
|
||||
{110, kBerlin3, kUnknownTime, {"tourism-museum"}},
|
||||
{111, kBermuda, kUnknownTime, {"amenity-cafe"}},
|
||||
{112, kMoscow1, kUnknownTime, {"leisure-park"}},
|
||||
std::vector<TestMarkData> const testMarksData2 = {
|
||||
{100, kBerlin1, kUnknownTime, {"amenity", "building", "wheelchair-yes", "tourism-museum"}},
|
||||
{101, kGreenland, kUnknownTime, {}},
|
||||
{102, kVladimir, kUnknownTime, {"tourism-artwork"}},
|
||||
{103, kKathmandu, kUnknownTime, {"internet_access-wlan", "wheelchair-no", "amenity-cafe"}},
|
||||
{104, kMinsk1, kUnknownTime, {"amenity-place_of_worship"}},
|
||||
{105, kBerlin2, kUnknownTime, {"building", "amenity-place_of_worship-christian"}},
|
||||
{106, kMoscow2, kUnknownTime, {"tourism-museum"}},
|
||||
{107, kMinsk2, kUnknownTime, {"amenity-restaurant"}},
|
||||
{108, kMinsk3, kUnknownTime, {"amenity-place_of_worship-jewish"}},
|
||||
{109, kWashington, kUnknownTime, {"amenity-restaurant"}},
|
||||
{110, kBerlin3, kUnknownTime, {"tourism-museum"}},
|
||||
{111, kBermuda, kUnknownTime, {"amenity-cafe"}},
|
||||
{112, kMoscow1, kUnknownTime, {"leisure-park"}},
|
||||
};
|
||||
|
||||
m2::PointD const myPos2 = mercator::GetSmPoint(kVladimir, 2.0 * kNearR, 2.0 * kNearR);
|
||||
@@ -726,81 +715,57 @@ UNIT_TEST(Bookmarks_Sorting)
|
||||
auto const addrVladimir = fm.GetBookmarkManager().GetLocalizedRegionAddress(kVladimir);
|
||||
auto const addrBermuda = fm.GetBookmarkManager().GetLocalizedRegionAddress(kBermuda);
|
||||
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByDistance2 =
|
||||
{
|
||||
{addrVladimir, {102}, {}},
|
||||
{addrMoscow, {106, 112}, {}},
|
||||
{addrMinsk, {107, 104, 108}, {}},
|
||||
{addrBerlin, {100, 105, 110}, {}},
|
||||
{addrGreenland, {101}, {}},
|
||||
{addrKathmandu, {103}, {}},
|
||||
{addrWashington, {109}, {}},
|
||||
{addrBermuda, {111}, {}},
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByDistance2 = {
|
||||
{addrVladimir, {102}, {}}, {addrMoscow, {106, 112}, {}}, {addrMinsk, {107, 104, 108}, {}},
|
||||
{addrBerlin, {100, 105, 110}, {}}, {addrGreenland, {101}, {}}, {addrKathmandu, {103}, {}},
|
||||
{addrWashington, {109}, {}}, {addrBermuda, {111}, {}},
|
||||
};
|
||||
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByType2 =
|
||||
{
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Food), {111, 109, 107, 103}, {}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Museum), {110, 106, 100}, {}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::ReligiousPlace), {108, 105, 104}, {}},
|
||||
{BookmarkManager::GetOthersSortedBlockName(), {112, 102, 101}, {}}
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByType2 = {
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Food), {111, 109, 107, 103}, {}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Museum), {110, 106, 100}, {}},
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::ReligiousPlace), {108, 105, 104}, {}},
|
||||
{BookmarkManager::GetOthersSortedBlockName(), {112, 102, 101}, {}}};
|
||||
|
||||
std::vector<TestMarkData> const testMarksData3 = {
|
||||
{200, {0.0, 0.0}, kUnknownTime, {"tourism-museum"}},
|
||||
{201, {0.0, 0.0}, kUnknownTime, {"leisure-park"}},
|
||||
{202, {0.0, 0.0}, kUnknownTime, {"tourism-artwork"}},
|
||||
{203, {0.0, 0.0}, kUnknownTime, {"amenity-cafe"}},
|
||||
{204, {0.0, 0.0}, kUnknownTime, {"amenity-place_of_worship"}},
|
||||
{205, {0.0, 0.0}, kUnknownTime, {"amenity-place_of_worship-christian"}},
|
||||
};
|
||||
|
||||
std::vector<TestMarkData> const testMarksData3 =
|
||||
{
|
||||
{200, {0.0, 0.0}, kUnknownTime, {"tourism-museum"}},
|
||||
{201, {0.0, 0.0}, kUnknownTime, {"leisure-park"}},
|
||||
{202, {0.0, 0.0}, kUnknownTime, {"tourism-artwork"}},
|
||||
{203, {0.0, 0.0}, kUnknownTime, {"amenity-cafe"}},
|
||||
{204, {0.0, 0.0}, kUnknownTime, {"amenity-place_of_worship"}},
|
||||
{205, {0.0, 0.0}, kUnknownTime, {"amenity-place_of_worship-christian"}},
|
||||
std::vector<TestMarkData> const testMarksData4 = {
|
||||
{300, {0.0, 0.0}, kUnknownTime, {"tourism-museum"}}, {301, {0.0, 0.0}, kUnknownTime, {"leisure-park"}},
|
||||
{302, {0.0, 0.0}, kUnknownTime, {"tourism-artwork"}}, {303, {0.0, 0.0}, kUnknownTime, {"amenity-cafe"}},
|
||||
{304, {0.0, 0.0}, kUnknownTime, {"amenity-place_of_worship"}}, {305, {0.0, 0.0}, kUnknownTime, {"tourism-hotel"}},
|
||||
};
|
||||
|
||||
std::vector<TestMarkData> const testMarksData4 =
|
||||
{
|
||||
{300, {0.0, 0.0}, kUnknownTime, {"tourism-museum"}},
|
||||
{301, {0.0, 0.0}, kUnknownTime, {"leisure-park"}},
|
||||
{302, {0.0, 0.0}, kUnknownTime, {"tourism-artwork"}},
|
||||
{303, {0.0, 0.0}, kUnknownTime, {"amenity-cafe"}},
|
||||
{304, {0.0, 0.0}, kUnknownTime, {"amenity-place_of_worship"}},
|
||||
{305, {0.0, 0.0}, kUnknownTime, {"tourism-hotel"}},
|
||||
};
|
||||
BookmarkManager::SortedBlocksCollection expectedSortedByType4 = {
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Hotel), {305}, {}},
|
||||
{BookmarkManager::GetOthersSortedBlockName(), {304, 303, 302, 301, 300}, {}}};
|
||||
|
||||
BookmarkManager::SortedBlocksCollection expectedSortedByType4 =
|
||||
{
|
||||
{GetLocalizedBookmarkBaseType(BookmarkBaseType::Hotel), {305}, {}},
|
||||
{BookmarkManager::GetOthersSortedBlockName(), {304, 303, 302, 301, 300}, {}}
|
||||
};
|
||||
std::vector<TestTrackData> const testTracksData5 = {
|
||||
{40, "t", kUnknownTime}, {41, "a", kUnknownTime}, {42, "u", std::chrono::hours(1)}, {43, "a", kUnknownTime}};
|
||||
|
||||
std::vector<TestTrackData> const testTracksData5 =
|
||||
{
|
||||
{40, "t", kUnknownTime},
|
||||
{41, "a", kUnknownTime},
|
||||
{42, "u", std::chrono::hours(1)},
|
||||
{43, "a", kUnknownTime}
|
||||
};
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByTime5 = {
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {42, 40, 41, 43}}};
|
||||
|
||||
BookmarkManager::SortedBlocksCollection const expectedSortedByTime5 =
|
||||
{
|
||||
{BookmarkManager::GetTracksSortedBlockName(), {}, {42, 40, 41, 43}}
|
||||
};
|
||||
std::vector<TestTrackData> const testTracksData6 = {
|
||||
{50, "-11", kUnknownTime}, {51, "41", kUnknownTime}, {52, "", kUnknownTime}};
|
||||
|
||||
std::vector<TestTrackData> const testTracksData6 =
|
||||
{
|
||||
{50, "-11", kUnknownTime},
|
||||
{51, "41", kUnknownTime},
|
||||
{52, "", kUnknownTime}
|
||||
};
|
||||
|
||||
auto const fillCategory = [&](kml::MarkGroupId cat, std::vector<TestMarkData> const & marksData, std::vector<TestTrackData> const & tracksData)
|
||||
auto const fillCategory = [&](kml::MarkGroupId cat, std::vector<TestMarkData> const & marksData,
|
||||
std::vector<TestTrackData> const & tracksData)
|
||||
{
|
||||
auto es = bmManager.GetEditSession();
|
||||
for (auto const & [id, position, hours, types] : marksData)
|
||||
{
|
||||
kml::BookmarkData bmData;
|
||||
bmData.m_id = id;
|
||||
bmData.m_name = kml::LocalizableString{{kml::kDefaultLangCode,
|
||||
std::reduce(types.begin(), types.end(), std::string{}, [](auto const & sum, auto const & type) { return sum + type + " "; })}};
|
||||
bmData.m_name = kml::LocalizableString{
|
||||
{kml::kDefaultLangCode, std::reduce(types.begin(), types.end(), std::string{},
|
||||
[](auto const & sum, auto const & type) { return sum + type + " "; })}};
|
||||
bmData.m_point = position;
|
||||
if (hours != kUnknownTime)
|
||||
bmData.m_timestamp = currentTime - hours;
|
||||
@@ -847,11 +812,9 @@ UNIT_TEST(Bookmarks_Sorting)
|
||||
params.m_sortingType = sortingType;
|
||||
params.m_hasMyPosition = hasMyPosition;
|
||||
params.m_myPosition = myPosition;
|
||||
params.m_onResults = [&sortedBlocks](BookmarkManager::SortedBlocksCollection && results,
|
||||
BookmarkManager::SortParams::Status status)
|
||||
{
|
||||
sortedBlocks = std::move(results);
|
||||
};
|
||||
params.m_onResults =
|
||||
[&sortedBlocks](BookmarkManager::SortedBlocksCollection && results, BookmarkManager::SortParams::Status status)
|
||||
{ sortedBlocks = std::move(results); };
|
||||
bmManager.GetSortedCategory(params);
|
||||
return sortedBlocks;
|
||||
};
|
||||
@@ -860,13 +823,9 @@ UNIT_TEST(Bookmarks_Sorting)
|
||||
kml::MarkGroupId catId = bmManager.CreateBookmarkCategory("test", false);
|
||||
fillCategory(catId, testMarksData, testTracksData);
|
||||
|
||||
std::vector<BookmarkManager::SortingType> const expectedSortingTypes =
|
||||
{
|
||||
BookmarkManager::SortingType::ByType,
|
||||
BookmarkManager::SortingType::ByDistance,
|
||||
BookmarkManager::SortingType::ByTime,
|
||||
BookmarkManager::SortingType::ByName
|
||||
};
|
||||
std::vector<BookmarkManager::SortingType> const expectedSortingTypes = {
|
||||
BookmarkManager::SortingType::ByType, BookmarkManager::SortingType::ByDistance,
|
||||
BookmarkManager::SortingType::ByTime, BookmarkManager::SortingType::ByName};
|
||||
|
||||
auto const sortingTypes = bmManager.GetAvailableSortingTypes(catId, true);
|
||||
TEST(sortingTypes == expectedSortingTypes, ());
|
||||
@@ -892,20 +851,18 @@ UNIT_TEST(Bookmarks_Sorting)
|
||||
kml::MarkGroupId const catId2 = bmManager.CreateBookmarkCategory("test2", false);
|
||||
fillCategory(catId2, testMarksData2, {} /* tracksData */);
|
||||
|
||||
std::vector<BookmarkManager::SortingType> const expectedSortingTypes2 =
|
||||
{
|
||||
BookmarkManager::SortingType::ByType,
|
||||
BookmarkManager::SortingType::ByDistance,
|
||||
BookmarkManager::SortingType::ByName,
|
||||
std::vector<BookmarkManager::SortingType> const expectedSortingTypes2 = {
|
||||
BookmarkManager::SortingType::ByType,
|
||||
BookmarkManager::SortingType::ByDistance,
|
||||
BookmarkManager::SortingType::ByName,
|
||||
};
|
||||
|
||||
auto const sortingTypes2 = bmManager.GetAvailableSortingTypes(catId2, true);
|
||||
TEST(sortingTypes2 == expectedSortingTypes2, ());
|
||||
|
||||
std::vector<BookmarkManager::SortingType> expectedSortingTypes2_2 =
|
||||
{
|
||||
BookmarkManager::SortingType::ByType,
|
||||
BookmarkManager::SortingType::ByName,
|
||||
std::vector<BookmarkManager::SortingType> expectedSortingTypes2_2 = {
|
||||
BookmarkManager::SortingType::ByType,
|
||||
BookmarkManager::SortingType::ByName,
|
||||
};
|
||||
|
||||
auto const sortingTypes2_2 = bmManager.GetAvailableSortingTypes(catId2, false);
|
||||
@@ -915,8 +872,7 @@ UNIT_TEST(Bookmarks_Sorting)
|
||||
printBlocks("Sorted by type 2", sortedByType2);
|
||||
TEST(sortedByType2 == expectedSortedByType2, ());
|
||||
|
||||
auto const sortedByDistance2 = getSortedBokmarks(catId2, BookmarkManager::SortingType::ByDistance,
|
||||
true, myPos2);
|
||||
auto const sortedByDistance2 = getSortedBokmarks(catId2, BookmarkManager::SortingType::ByDistance, true, myPos2);
|
||||
printBlocks("Sorted by distance 2", sortedByDistance2);
|
||||
TEST(sortedByDistance2 == expectedSortedByDistance2, ());
|
||||
}
|
||||
@@ -934,7 +890,8 @@ UNIT_TEST(Bookmarks_Sorting)
|
||||
kml::MarkGroupId const catId4 = bmManager.CreateBookmarkCategory("test4", false);
|
||||
fillCategory(catId4, testMarksData4, {} /* tracksData */);
|
||||
|
||||
std::vector<BookmarkManager::SortingType> const expectedSortingTypes4 = { BookmarkManager::SortingType::ByType, BookmarkManager::SortingType::ByName };
|
||||
std::vector<BookmarkManager::SortingType> const expectedSortingTypes4 = {BookmarkManager::SortingType::ByType,
|
||||
BookmarkManager::SortingType::ByName};
|
||||
auto const sortingTypes4 = bmManager.GetAvailableSortingTypes(catId4, false);
|
||||
TEST(sortingTypes4 == expectedSortingTypes4, ());
|
||||
|
||||
@@ -946,7 +903,8 @@ UNIT_TEST(Bookmarks_Sorting)
|
||||
{
|
||||
kml::MarkGroupId const catId5 = bmManager.CreateBookmarkCategory("test5", false);
|
||||
fillCategory(catId5, {} /* marksData */, testTracksData5);
|
||||
std::vector<BookmarkManager::SortingType> const expectedSortingTypes5 = { BookmarkManager::SortingType::ByTime, BookmarkManager::SortingType::ByName };
|
||||
std::vector<BookmarkManager::SortingType> const expectedSortingTypes5 = {BookmarkManager::SortingType::ByTime,
|
||||
BookmarkManager::SortingType::ByName};
|
||||
|
||||
auto const sortingTypes5 = bmManager.GetAvailableSortingTypes(catId5, false);
|
||||
TEST(sortingTypes5 == expectedSortingTypes5, ());
|
||||
@@ -972,27 +930,27 @@ char const * kmlString2 =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
"<kml xmlns=\"http://earth.google.com/kml/2.1\">"
|
||||
"<Document>"
|
||||
"<name>busparkplatz</name>"
|
||||
"<Folder>"
|
||||
"<name>Waypoint</name>"
|
||||
"<Style id=\"poiIcon37\">"
|
||||
"<IconStyle>"
|
||||
"<scale>1</scale>"
|
||||
"<Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href></Icon>"
|
||||
"<hotSpot x=\"0.5\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Placemark>"
|
||||
"<name>[P] Silvrettastrae[Bieler Hhe]</name>"
|
||||
"<description></description>"
|
||||
"<styleUrl>#poiIcon37</styleUrl>"
|
||||
"<Point>"
|
||||
"<coordinates>10.09237,46.91741,0</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"<name>busparkplatz</name>"
|
||||
"<Folder>"
|
||||
"<name>Waypoint</name>"
|
||||
"<Style id=\"poiIcon37\">"
|
||||
"<IconStyle>"
|
||||
"<scale>1</scale>"
|
||||
"<Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href></Icon>"
|
||||
"<hotSpot x=\"0.5\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>"
|
||||
"</IconStyle>"
|
||||
"</Style>"
|
||||
"<Placemark>"
|
||||
"<name>[P] Silvrettastrae[Bieler Hhe]</name>"
|
||||
"<description></description>"
|
||||
"<styleUrl>#poiIcon37</styleUrl>"
|
||||
"<Point>"
|
||||
"<coordinates>10.09237,46.91741,0</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"</Folder>"
|
||||
"</Document>"
|
||||
"</kml>";
|
||||
"</Document>"
|
||||
"</kml>";
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(Runner, Bookmarks_InnerFolder)
|
||||
@@ -1037,34 +995,34 @@ char const * kmlString3 =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
"<kml xmlns=\"http://earth.google.com/kml/2.1\">"
|
||||
"<Document>"
|
||||
"<name>3663 and M <![CDATA[&]]> J Seafood Branches</name>"
|
||||
"<visibility>1</visibility>"
|
||||
"<Placemark>"
|
||||
"<name>![X1]{X2}(X3)</name>"
|
||||
"<Point>"
|
||||
"<coordinates>50, 50</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"</Document>"
|
||||
"</kml>";
|
||||
"<name>3663 and M <![CDATA[&]]> J Seafood Branches</name>"
|
||||
"<visibility>1</visibility>"
|
||||
"<Placemark>"
|
||||
"<name>![X1]{X2}(X3)</name>"
|
||||
"<Point>"
|
||||
"<coordinates>50, 50</coordinates>"
|
||||
"</Point>"
|
||||
"</Placemark>"
|
||||
"</Document>"
|
||||
"</kml>";
|
||||
|
||||
bool EqualBookmarks(Bookmark const & b1, Bookmark const & b2)
|
||||
{
|
||||
if (b1.GetName() != b2.GetName())
|
||||
return false;
|
||||
if (b1.GetDescription() != b2.GetDescription())
|
||||
return false;
|
||||
if (b1.GetColor() != b2.GetColor())
|
||||
return false;
|
||||
if (b1.GetScale() != b2.GetScale())
|
||||
return false;
|
||||
if (!AlmostEqualAbs(b1.GetPivot(), b2.GetPivot(), 1e-6 /* eps*/))
|
||||
return false;
|
||||
bool EqualBookmarks(Bookmark const & b1, Bookmark const & b2)
|
||||
{
|
||||
if (b1.GetName() != b2.GetName())
|
||||
return false;
|
||||
if (b1.GetDescription() != b2.GetDescription())
|
||||
return false;
|
||||
if (b1.GetColor() != b2.GetColor())
|
||||
return false;
|
||||
if (b1.GetScale() != b2.GetScale())
|
||||
return false;
|
||||
if (!AlmostEqualAbs(b1.GetPivot(), b2.GetPivot(), 1e-6 /* eps*/))
|
||||
return false;
|
||||
|
||||
// do not check timestamp
|
||||
return true;
|
||||
}
|
||||
// do not check timestamp
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_CLASS_TEST(Runner, Bookmarks_SpecialXMLNames)
|
||||
{
|
||||
@@ -1074,7 +1032,7 @@ UNIT_CLASS_TEST(Runner, Bookmarks_SpecialXMLNames)
|
||||
auto const file1Name = "file1";
|
||||
BookmarkManager::KMLDataCollection kmlDataCollection1;
|
||||
kmlDataCollection1.emplace_back(file1Name /* filePath */,
|
||||
LoadKmlData(MemReader(kmlString3, strlen(kmlString3)), KmlFileType::Text));
|
||||
LoadKmlData(MemReader(kmlString3, strlen(kmlString3)), KmlFileType::Text));
|
||||
bmManager.CreateCategories(std::move(kmlDataCollection1));
|
||||
|
||||
auto const & groupIds = bmManager.GetSortedBmGroupIdList();
|
||||
@@ -1145,10 +1103,8 @@ UNIT_CLASS_TEST(Runner, TrackParsingTest_1)
|
||||
TEST_EQUAL(bmManager.GetTrackIds(catId).size(), 4, ());
|
||||
|
||||
array<string, 4> const names = {{"Option1", "Pakkred1", "Pakkred2", "Pakkred3"}};
|
||||
array<dp::Color, 4> constexpr col = {{dp::Color(230, 0, 0, 255),
|
||||
dp::Color(171, 230, 0, 255),
|
||||
dp::Color(0, 230, 117, 255),
|
||||
dp::Color(0, 59, 230, 255)}};
|
||||
array<dp::Color, 4> constexpr col = {{dp::Color(230, 0, 0, 255), dp::Color(171, 230, 0, 255),
|
||||
dp::Color(0, 230, 117, 255), dp::Color(0, 59, 230, 255)}};
|
||||
array<double, 4> constexpr length = {{3525.46839061, 27172.44338132, 27046.0456586, 23967.35765800}};
|
||||
array<geometry::Altitude, 4> constexpr altitudes = {{0, 27, -3, -2}};
|
||||
size_t i = 0;
|
||||
@@ -1246,9 +1202,7 @@ UNIT_CLASS_TEST(Runner, Bookmarks_Listeners)
|
||||
resultChanges.m_updatedMarks.insert(mark.m_bookmarkId);
|
||||
};
|
||||
auto const onDelete = [&resultChanges](vector<kml::MarkId> const & marks)
|
||||
{
|
||||
resultChanges.m_deletedMarks.insert(marks.begin(), marks.end());
|
||||
};
|
||||
{ resultChanges.m_deletedMarks.insert(marks.begin(), marks.end()); };
|
||||
auto const onAttach = [&resultChanges](vector<BookmarkGroupInfo> const & groupMarksCollection)
|
||||
{
|
||||
for (auto const & group : groupMarksCollection)
|
||||
@@ -1261,13 +1215,12 @@ UNIT_CLASS_TEST(Runner, Bookmarks_Listeners)
|
||||
};
|
||||
|
||||
BookmarkManager::Callbacks callbacks(
|
||||
[]() -> StringsBundle const &
|
||||
{
|
||||
static StringsBundle const dummyBundle;
|
||||
return dummyBundle;
|
||||
},
|
||||
static_cast<BookmarkManager::Callbacks::GetSeacrhAPIFn>(nullptr),
|
||||
onCreate, onUpdate, onDelete, onAttach, onDetach);
|
||||
[]() -> StringsBundle const &
|
||||
{
|
||||
static StringsBundle const dummyBundle;
|
||||
return dummyBundle;
|
||||
}, static_cast<BookmarkManager::Callbacks::GetSeacrhAPIFn>(nullptr), onCreate, onUpdate, onDelete, onAttach,
|
||||
onDetach);
|
||||
|
||||
BookmarkManager bmManager(std::move(callbacks));
|
||||
bmManager.SetBookmarksChangedCallback([&bookmarksChanged]() { bookmarksChanged = true; });
|
||||
@@ -1434,11 +1387,10 @@ UNIT_CLASS_TEST(Runner, Bookmarks_AutoSave)
|
||||
|
||||
UNIT_CLASS_TEST(Runner, ExportAll)
|
||||
{
|
||||
std::string const gpxFiles[] = {
|
||||
GetPlatform().TestsDataPathForFile("test_data/gpx/route.gpx"),
|
||||
GetPlatform().TestsDataPathForFile("test_data/gpx/points.gpx"),
|
||||
GetPlatform().TestsDataPathForFile("test_data/gpx/Üφήが1.gpx"),
|
||||
GetPlatform().TestsDataPathForFile("test_data/gpx/Üφήが2.gpx")};
|
||||
std::string const gpxFiles[] = {GetPlatform().TestsDataPathForFile("test_data/gpx/route.gpx"),
|
||||
GetPlatform().TestsDataPathForFile("test_data/gpx/points.gpx"),
|
||||
GetPlatform().TestsDataPathForFile("test_data/gpx/Üφήが1.gpx"),
|
||||
GetPlatform().TestsDataPathForFile("test_data/gpx/Üφήが2.gpx")};
|
||||
BookmarkManager bmManager(BM_CALLBACKS);
|
||||
bmManager.EnableTestMode(true);
|
||||
|
||||
@@ -1458,7 +1410,7 @@ UNIT_CLASS_TEST(Runner, ExportAll)
|
||||
TEST_EQUAL(files.size(), 5, ("5 files are expected in kmz"));
|
||||
auto index = "doc.kml";
|
||||
std::vector<std::string> expectedFiles = {"doc.kml", "files/new.kml", "files/Some random route.kml",
|
||||
"files/CoMaps_1.kml", "files/CoMaps_2.kml"};
|
||||
"files/CoMaps_1.kml", "files/CoMaps_2.kml"};
|
||||
for (auto const & file : files)
|
||||
TEST(std::find(expectedFiles.begin(), expectedFiles.end(), file.first) != expectedFiles.end(), ());
|
||||
auto indexPath = base::JoinPath(GetPlatform().TmpDir(), index);
|
||||
@@ -1466,8 +1418,7 @@ UNIT_CLASS_TEST(Runner, ExportAll)
|
||||
std::string indexContent;
|
||||
FileReader(indexPath).ReadAsString(indexContent);
|
||||
std::string expectedIndexContent;
|
||||
FileReader(GetPlatform().TestsDataPathForFile("test_data/kml/kmz_index.kml"))
|
||||
.ReadAsString(expectedIndexContent);
|
||||
FileReader(GetPlatform().TestsDataPathForFile("test_data/kml/kmz_index.kml")).ReadAsString(expectedIndexContent);
|
||||
TEST_EQUAL(expectedIndexContent, indexContent, ("Index content doesnt match expected value"));
|
||||
auto tmpPath = base::JoinPath(GetPlatform().TmpDir(), "tmp.xml");
|
||||
for (auto const & file : files)
|
||||
@@ -1479,7 +1430,8 @@ UNIT_CLASS_TEST(Runner, ExportAll)
|
||||
TEST(base::DeleteFileX(indexPath), ());
|
||||
TEST(base::DeleteFileX(tmpPath), ());
|
||||
};
|
||||
// We use KmlFileType::Text for both single and all tracks export. File structure is determined based on categories size
|
||||
// We use KmlFileType::Text for both single and all tracks export. File structure is determined based on categories
|
||||
// size
|
||||
bmManager.PrepareFileForSharing(std::move(categories), checker, KmlFileType::Text);
|
||||
}
|
||||
|
||||
@@ -1537,9 +1489,7 @@ UNIT_CLASS_TEST(Runner, ExportSingleTrackKmz)
|
||||
{
|
||||
auto track = bmManager.GetTrack(trackId);
|
||||
if (track->GetName().find("Some random route") != std::string::npos)
|
||||
{
|
||||
bmManager.PrepareTrackFileForSharing(track->GetId(), kmzChecker, KmlFileType::Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1567,9 +1517,7 @@ UNIT_CLASS_TEST(Runner, ExportSingleTrackGpx)
|
||||
{
|
||||
auto track = bmManager.GetTrack(trackId);
|
||||
if (track->GetName().find("Some random route") != std::string::npos)
|
||||
{
|
||||
bmManager.PrepareTrackFileForSharing(track->GetId(), gpxChecker, KmlFileType::Gpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1604,11 +1552,16 @@ UNIT_CLASS_TEST(Runner, Bookmarks_RecentlyDeleted)
|
||||
bmManager.EnableTestMode(true);
|
||||
auto const dir = GetBookmarksDirectory();
|
||||
bool const delDirOnExit = Platform::MkDir(dir) == Platform::ERR_OK;
|
||||
SCOPE_GUARD(dirDeleter, [&](){ if (delDirOnExit) (void)Platform::RmDir(dir); });
|
||||
SCOPE_GUARD(dirDeleter, [&]()
|
||||
{
|
||||
if (delDirOnExit)
|
||||
(void)Platform::RmDir(dir);
|
||||
});
|
||||
|
||||
std::string const filePath = base::JoinPath(dir, "file" + std::string{kKmlExtension});
|
||||
BookmarkManager::KMLDataCollection kmlDataCollection;
|
||||
kmlDataCollection.emplace_back(filePath, LoadKmlData(MemReader(kmlString, std::strlen(kmlString)), KmlFileType::Text));
|
||||
kmlDataCollection.emplace_back(filePath,
|
||||
LoadKmlData(MemReader(kmlString, std::strlen(kmlString)), KmlFileType::Text));
|
||||
|
||||
FileWriter w(filePath);
|
||||
w.Write(kmlDataCollection.data(), kmlDataCollection.size());
|
||||
@@ -1631,7 +1584,7 @@ UNIT_CLASS_TEST(Runner, Bookmarks_RecentlyDeleted)
|
||||
auto const deletedFilePath = deletedCategory.first;
|
||||
TEST_EQUAL(base::FileNameFromFullPath(deletedCategory.first), base::FileNameFromFullPath(filePath), ());
|
||||
|
||||
bmManager.DeleteRecentlyDeletedCategoriesAtPaths({ deletedFilePath });
|
||||
bmManager.DeleteRecentlyDeletedCategoriesAtPaths({deletedFilePath});
|
||||
TEST_EQUAL(bmManager.GetBmGroupsCount(), 0, ());
|
||||
TEST_EQUAL(bmManager.GetRecentlyDeletedCategoriesCount(), 0, ());
|
||||
TEST_EQUAL(bmManager.GetRecentlyDeletedCategories()->size(), 0, ());
|
||||
@@ -1649,8 +1602,9 @@ UNIT_CLASS_TEST(Runner, Bookmarks_TestSaveRoute)
|
||||
auto const * track = bmManager.GetTrack(trackId);
|
||||
TEST_EQUAL(track->GetName(), "London - Paris", ());
|
||||
auto const line = track->GetData().m_geometry.m_lines[0];
|
||||
std::vector const expectedLine = {{geometry::PointWithAltitude(m2::PointD(0.0, 0.0), 0.0), geometry::PointWithAltitude(m2::PointD(0.001, 0.001), 0)}};
|
||||
std::vector const expectedLine = {{geometry::PointWithAltitude(m2::PointD(0.0, 0.0), 0.0),
|
||||
geometry::PointWithAltitude(m2::PointD(0.001, 0.001), 0)}};
|
||||
TEST_EQUAL(line, expectedLine, ());
|
||||
}
|
||||
|
||||
} // namespace bookmarks_test
|
||||
} // namespace bookmarks_test
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
#include "map/chart_generator.hpp"
|
||||
|
||||
#include "geometry/point_with_altitude.hpp"
|
||||
#include "base/math.hpp"
|
||||
#include "geometry/point_with_altitude.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace chart_generator_tests
|
||||
{
|
||||
using std::vector;
|
||||
using maps::kAltitudeChartBPP;
|
||||
using std::vector;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -23,15 +23,13 @@ bool AlmostEqualAbs(vector<double> const & v1, vector<double> const & v2)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < v1.size(); ++i)
|
||||
{
|
||||
if (!::AlmostEqualAbs(v1[i], v2[i], kEpsilon))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsColor(vector<uint8_t> const & frameBuffer, size_t startColorIdx, uint8_t expectedR,
|
||||
uint8_t expectedG, uint8_t expectedB, uint8_t expectedA)
|
||||
bool IsColor(vector<uint8_t> const & frameBuffer, size_t startColorIdx, uint8_t expectedR, uint8_t expectedG,
|
||||
uint8_t expectedB, uint8_t expectedA)
|
||||
{
|
||||
CHECK_LESS_OR_EQUAL(startColorIdx + kAltitudeChartBPP, frameBuffer.size(), ());
|
||||
|
||||
@@ -39,17 +37,20 @@ bool IsColor(vector<uint8_t> const & frameBuffer, size_t startColorIdx, uint8_t
|
||||
frameBuffer[startColorIdx + 2] == expectedB && frameBuffer[startColorIdx + 3] == expectedA;
|
||||
}
|
||||
|
||||
void TestAngleColors(size_t width, size_t height, vector<uint8_t> const & frameBuffer,
|
||||
uint8_t expectedR, uint8_t expectedG, uint8_t expectedB, uint8_t expectedA)
|
||||
void TestAngleColors(size_t width, size_t height, vector<uint8_t> const & frameBuffer, uint8_t expectedR,
|
||||
uint8_t expectedG, uint8_t expectedB, uint8_t expectedA)
|
||||
{
|
||||
TEST_EQUAL(frameBuffer.size(), width * height * kAltitudeChartBPP, ());
|
||||
TEST(IsColor(frameBuffer, 0 /* startColorIdx */, expectedR, expectedG, expectedB, expectedA), ());
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * (width - 1) /* startColorIdx */, expectedR,
|
||||
expectedG, expectedB, expectedA), ());
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * height * (width - 1) /* startColorIdx */,
|
||||
expectedR, expectedG, expectedB, expectedA), ());
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * height * width - kAltitudeChartBPP /* startColorIdx */,
|
||||
expectedR, expectedG, expectedB, expectedA), ());
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * (width - 1) /* startColorIdx */, expectedR, expectedG, expectedB,
|
||||
expectedA),
|
||||
());
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * height * (width - 1) /* startColorIdx */, expectedR, expectedG,
|
||||
expectedB, expectedA),
|
||||
());
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * height * width - kAltitudeChartBPP /* startColorIdx */, expectedR,
|
||||
expectedG, expectedB, expectedA),
|
||||
());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -83,8 +84,7 @@ UNIT_TEST(NormalizeChartData_SmokeTest)
|
||||
geometry::Altitudes const altitudeDataM = {0, 0, 0};
|
||||
|
||||
vector<double> uniformAltitudeDataM;
|
||||
TEST(maps::NormalizeChartData(distanceDataM, altitudeDataM, 2 /* resultPointCount */, uniformAltitudeDataM),
|
||||
());
|
||||
TEST(maps::NormalizeChartData(distanceDataM, altitudeDataM, 2 /* resultPointCount */, uniformAltitudeDataM), ());
|
||||
|
||||
vector<double> const expectedUniformAltitudeDataM = {0.0, 0.0};
|
||||
TEST_EQUAL(expectedUniformAltitudeDataM, uniformAltitudeDataM, ());
|
||||
@@ -96,8 +96,7 @@ UNIT_TEST(NormalizeChartData_NoResultPointTest)
|
||||
geometry::Altitudes const altitudeDataM = {0, 0, 0};
|
||||
|
||||
vector<double> uniformAltitudeDataM;
|
||||
TEST(maps::NormalizeChartData(distanceDataM, altitudeDataM, 0 /* resultPointCount */, uniformAltitudeDataM),
|
||||
());
|
||||
TEST(maps::NormalizeChartData(distanceDataM, altitudeDataM, 0 /* resultPointCount */, uniformAltitudeDataM), ());
|
||||
|
||||
TEST(uniformAltitudeDataM.empty(), ());
|
||||
}
|
||||
@@ -108,8 +107,7 @@ UNIT_TEST(NormalizeChartData_NoPointTest)
|
||||
geometry::Altitudes const altitudeDataM = {};
|
||||
|
||||
vector<double> uniformAltitudeDataM;
|
||||
TEST(maps::NormalizeChartData(distanceDataM, altitudeDataM, 2 /* resultPointCount */, uniformAltitudeDataM),
|
||||
());
|
||||
TEST(maps::NormalizeChartData(distanceDataM, altitudeDataM, 2 /* resultPointCount */, uniformAltitudeDataM), ());
|
||||
|
||||
TEST(uniformAltitudeDataM.empty(), ());
|
||||
}
|
||||
@@ -120,11 +118,9 @@ UNIT_TEST(NormalizeChartData_Test)
|
||||
geometry::Altitudes const altitudeDataM = {-9, 0, 9, 18};
|
||||
|
||||
vector<double> uniformAltitudeDataM;
|
||||
TEST(maps::NormalizeChartData(distanceDataM, altitudeDataM, 10 /* resultPointCount */, uniformAltitudeDataM),
|
||||
());
|
||||
TEST(maps::NormalizeChartData(distanceDataM, altitudeDataM, 10 /* resultPointCount */, uniformAltitudeDataM), ());
|
||||
|
||||
vector<double> const expectedUniformAltitudeDataM = {-9.0, -6.0, -3.0, 0.0, 3.0,
|
||||
6.0, 9.0, 12.0, 15.0, 18.0};
|
||||
vector<double> const expectedUniformAltitudeDataM = {-9.0, -6.0, -3.0, 0.0, 3.0, 6.0, 9.0, 12.0, 15.0, 18.0};
|
||||
TEST(AlmostEqualAbs(uniformAltitudeDataM, expectedUniformAltitudeDataM), ());
|
||||
}
|
||||
|
||||
@@ -165,8 +161,8 @@ UNIT_TEST(GenerateChartByPoints_NoGeometryTest)
|
||||
vector<uint8_t> frameBuffer;
|
||||
|
||||
TEST(maps::GenerateChartByPoints(width, height, geometry, MapStyleDefaultLight /* mapStyle */, frameBuffer), ());
|
||||
TestAngleColors(width, height, frameBuffer, 255 /* expectedR */, 255 /* expectedG */,
|
||||
255 /* expectedB */, 0 /* expectedA */);
|
||||
TestAngleColors(width, height, frameBuffer, 255 /* expectedR */, 255 /* expectedG */, 255 /* expectedB */,
|
||||
0 /* expectedA */);
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateChartByPoints_OnePointTest)
|
||||
@@ -177,8 +173,8 @@ UNIT_TEST(GenerateChartByPoints_OnePointTest)
|
||||
vector<uint8_t> frameBuffer;
|
||||
|
||||
TEST(maps::GenerateChartByPoints(width, height, geometry, MapStyleDefaultLight /* mapStyle */, frameBuffer), ());
|
||||
TestAngleColors(width, height, frameBuffer, 255 /* expectedR */, 255 /* expectedG */,
|
||||
255 /* expectedB */, 0 /* expectedA */);
|
||||
TestAngleColors(width, height, frameBuffer, 255 /* expectedR */, 255 /* expectedG */, 255 /* expectedB */,
|
||||
0 /* expectedA */);
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateChartByPoints_Test)
|
||||
@@ -192,8 +188,8 @@ UNIT_TEST(GenerateChartByPoints_Test)
|
||||
TEST(maps::GenerateChartByPoints(width, height, geometry, MapStyleDefaultLight /* mapStyle */, frameBuffer), ());
|
||||
|
||||
TEST_EQUAL(frameBuffer.size(), width * height * kAltitudeChartBPP, ());
|
||||
TEST(IsColor(frameBuffer, 0 /* startColorIdx */, 30 /* expectedR */, 150 /* expectedG */,
|
||||
240 /* expectedB */, 255 /* expectedA */),
|
||||
TEST(IsColor(frameBuffer, 0 /* startColorIdx */, 30 /* expectedR */, 150 /* expectedG */, 240 /* expectedB */,
|
||||
255 /* expectedA */),
|
||||
());
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * (width - 1) /* startColorIdx */, 255 /* expectedR */,
|
||||
255 /* expectedG */, 255 /* expectedB */, 0 /* expectedA */),
|
||||
@@ -210,8 +206,8 @@ UNIT_TEST(GenerateChart_NoPointsTest)
|
||||
TEST(maps::GenerateChart(width, 50 /* height */, distanceDataM, altitudeDataM, MapStyleDefaultDark /* mapStyle */,
|
||||
frameBuffer),
|
||||
());
|
||||
TestAngleColors(width, 50 /* height */, frameBuffer, 255 /* expectedR */, 255 /* expectedG */,
|
||||
255 /* expectedB */, 0 /* expectedA */);
|
||||
TestAngleColors(width, 50 /* height */, frameBuffer, 255 /* expectedR */, 255 /* expectedG */, 255 /* expectedB */,
|
||||
0 /* expectedA */);
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateChart_OnePointTest)
|
||||
@@ -222,14 +218,16 @@ UNIT_TEST(GenerateChart_OnePointTest)
|
||||
geometry::Altitudes const & altitudeDataM = {0};
|
||||
vector<uint8_t> frameBuffer;
|
||||
|
||||
TEST(maps::GenerateChart(width, height, distanceDataM, altitudeDataM, MapStyleDefaultDark /* mapStyle */,
|
||||
frameBuffer),
|
||||
());
|
||||
TEST(
|
||||
maps::GenerateChart(width, height, distanceDataM, altitudeDataM, MapStyleDefaultDark /* mapStyle */, frameBuffer),
|
||||
());
|
||||
TEST_EQUAL(frameBuffer.size(), width * height * kAltitudeChartBPP, ());
|
||||
TEST(IsColor(frameBuffer, 0 /* startColorIdx */, 255 /* expectedR */, 255 /* expectedG */,
|
||||
255 /* expectedB */, 0 /* expectedA */), ());
|
||||
TEST(IsColor(frameBuffer, 0 /* startColorIdx */, 255 /* expectedR */, 255 /* expectedG */, 255 /* expectedB */,
|
||||
0 /* expectedA */),
|
||||
());
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * (width - 1) /* startColorIdx */, 255 /* expectedR */,
|
||||
255 /* expectedG */, 255 /* expectedB */, 0 /* expectedA */), ());
|
||||
255 /* expectedG */, 255 /* expectedB */, 0 /* expectedA */),
|
||||
());
|
||||
}
|
||||
|
||||
UNIT_TEST(GenerateChart_EmptyRectTest)
|
||||
@@ -255,11 +253,10 @@ UNIT_TEST(GenerateChart_Test)
|
||||
TEST(maps::GenerateChart(width, 50 /* height */, distanceDataM, altitudeDataM, MapStyleDefaultDark /* mapStyle */,
|
||||
frameBuffer),
|
||||
());
|
||||
TEST(IsColor(frameBuffer, 0 /* startColorIdx */, 255 /* expectedR */, 255 /* expectedG */,
|
||||
255 /* expectedB */, 0 /* expectedA */),
|
||||
TEST(IsColor(frameBuffer, 0 /* startColorIdx */, 255 /* expectedR */, 255 /* expectedG */, 255 /* expectedB */,
|
||||
0 /* expectedA */),
|
||||
());
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * 3 * width -
|
||||
kAltitudeChartBPP /* startColorIdx */, 255 /* expectedR */,
|
||||
TEST(IsColor(frameBuffer, kAltitudeChartBPP * 3 * width - kAltitudeChartBPP /* startColorIdx */, 255 /* expectedR */,
|
||||
230 /* expectedG */, 140 /* expectedB */, 255 /* expectedA */),
|
||||
());
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ UNIT_TEST(CheckMWM_GeomIndex)
|
||||
vector<unique_ptr<IntervalIndex<ReaderT, uint32_t>>> scale2Index;
|
||||
for (size_t i = 0; i < treesReader.Size(); ++i)
|
||||
{
|
||||
scale2Index.emplace_back(make_unique<IntervalIndex<ReaderT, uint32_t>>(
|
||||
treesReader.SubReader(static_cast<uint32_t>(i))));
|
||||
scale2Index.emplace_back(
|
||||
make_unique<IntervalIndex<ReaderT, uint32_t>>(treesReader.SubReader(static_cast<uint32_t>(i))));
|
||||
}
|
||||
|
||||
// Pass full coverage as input for test.
|
||||
@@ -80,14 +80,9 @@ UNIT_TEST(CheckMWM_GeomIndex)
|
||||
// Count objects for each scale bucket.
|
||||
map<size_t, uint64_t> resCount;
|
||||
for (size_t i = 0; i < scale2Index.size(); ++i)
|
||||
{
|
||||
scale2Index[i]->ForEach([i, &resCount](uint64_t, uint32_t)
|
||||
{
|
||||
++resCount[i];
|
||||
}, beg, end);
|
||||
}
|
||||
scale2Index[i]->ForEach([i, &resCount](uint64_t, uint32_t) { ++resCount[i]; }, beg, end);
|
||||
|
||||
// Print results.
|
||||
LOG(LINFO, (resCount));
|
||||
}
|
||||
} // namespace check_mwms
|
||||
} // namespace check_mwms
|
||||
|
||||
@@ -42,17 +42,17 @@ UNIT_TEST(CountriesNamesTest)
|
||||
base::Cancellable const cancellable;
|
||||
search::CategoriesCache cache(ftypes::IsLocalityChecker::Instance(), cancellable);
|
||||
|
||||
int8_t const langIndices[] = { StringUtf8Multilang::kEnglishCode,
|
||||
StringUtf8Multilang::kDefaultCode,
|
||||
StringUtf8Multilang::kInternationalCode };
|
||||
int8_t const langIndices[] = {StringUtf8Multilang::kEnglishCode, StringUtf8Multilang::kDefaultCode,
|
||||
StringUtf8Multilang::kInternationalCode};
|
||||
|
||||
set<string> const kIgnoreList = {"Northern Cyprus",
|
||||
"Transnistria",
|
||||
"Nagorno-Karabakh Republic",
|
||||
"Republic of Artsakh",
|
||||
"Saint Helena, Ascension and Tristan da Cunha",
|
||||
"Somaliland",
|
||||
};
|
||||
set<string> const kIgnoreList = {
|
||||
"Northern Cyprus",
|
||||
"Transnistria",
|
||||
"Nagorno-Karabakh Republic",
|
||||
"Republic of Artsakh",
|
||||
"Saint Helena, Ascension and Tristan da Cunha",
|
||||
"Somaliland",
|
||||
};
|
||||
|
||||
auto const features = cache.Get(mwmContext);
|
||||
features.ForEach([&](uint64_t fid)
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "map/elevation_info.hpp"
|
||||
|
||||
#include "geometry/point_with_altitude.hpp"
|
||||
#include "geometry/mercator.hpp"
|
||||
#include "geometry/point_with_altitude.hpp"
|
||||
|
||||
#include "kml/types.hpp"
|
||||
|
||||
@@ -33,11 +33,7 @@ UNIT_TEST(ElevationInfo_FromMultiGeometry)
|
||||
auto const point1 = PointWithAltitude({0.0, 0.0}, 100);
|
||||
auto const point2 = PointWithAltitude({1.0, 1.0}, 150);
|
||||
auto const point3 = PointWithAltitude({2.0, 2.0}, 50);
|
||||
geometry.AddLine({
|
||||
point1,
|
||||
point2,
|
||||
point3
|
||||
});
|
||||
geometry.AddLine({point1, point2, point3});
|
||||
ElevationInfo ei(geometry.m_lines);
|
||||
|
||||
TEST_EQUAL(3, ei.GetSize(), ());
|
||||
@@ -53,20 +49,11 @@ UNIT_TEST(ElevationInfo_FromMultiGeometry)
|
||||
UNIT_TEST(ElevationInfo_MultipleLines)
|
||||
{
|
||||
kml::MultiGeometry geometry;
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({0.0, 0.0}, 100),
|
||||
PointWithAltitude({1.0, 1.0}, 150),
|
||||
PointWithAltitude({1.0, 1.0}, 140)
|
||||
});
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({2.0, 2.0}, 50),
|
||||
PointWithAltitude({3.0, 3.0}, 75),
|
||||
PointWithAltitude({3.0, 3.0}, 60)
|
||||
});
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({4.0, 4.0}, 200),
|
||||
PointWithAltitude({5.0, 5.0}, 250)
|
||||
});
|
||||
geometry.AddLine(
|
||||
{PointWithAltitude({0.0, 0.0}, 100), PointWithAltitude({1.0, 1.0}, 150), PointWithAltitude({1.0, 1.0}, 140)});
|
||||
geometry.AddLine(
|
||||
{PointWithAltitude({2.0, 2.0}, 50), PointWithAltitude({3.0, 3.0}, 75), PointWithAltitude({3.0, 3.0}, 60)});
|
||||
geometry.AddLine({PointWithAltitude({4.0, 4.0}, 200), PointWithAltitude({5.0, 5.0}, 250)});
|
||||
ElevationInfo ei(geometry.m_lines);
|
||||
|
||||
TEST_EQUAL(8, ei.GetSize(), ());
|
||||
@@ -75,18 +62,9 @@ UNIT_TEST(ElevationInfo_MultipleLines)
|
||||
UNIT_TEST(ElevationInfo_SegmentDistances)
|
||||
{
|
||||
kml::MultiGeometry geometry;
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({0.0, 0.0}),
|
||||
PointWithAltitude({1.0, 0.0})
|
||||
});
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({2.0, 0.0}),
|
||||
PointWithAltitude({3.0, 0.0})
|
||||
});
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({4.0, 0.0}),
|
||||
PointWithAltitude({5.0, 0.0})
|
||||
});
|
||||
geometry.AddLine({PointWithAltitude({0.0, 0.0}), PointWithAltitude({1.0, 0.0})});
|
||||
geometry.AddLine({PointWithAltitude({2.0, 0.0}), PointWithAltitude({3.0, 0.0})});
|
||||
geometry.AddLine({PointWithAltitude({4.0, 0.0}), PointWithAltitude({5.0, 0.0})});
|
||||
|
||||
ElevationInfo ei(geometry.m_lines);
|
||||
auto const & segmentDistances = ei.GetSegmentsDistances();
|
||||
@@ -101,19 +79,15 @@ UNIT_TEST(ElevationInfo_BuildWithGpsPoints)
|
||||
{
|
||||
auto ei = ElevationInfo();
|
||||
ei.AddGpsPoints({
|
||||
BuildGpsInfo(0.0, 0.0, 0),
|
||||
BuildGpsInfo(1.0, 1.0, 50),
|
||||
BuildGpsInfo(2.0, 2.0, 100),
|
||||
});
|
||||
ei.AddGpsPoints({
|
||||
BuildGpsInfo(3.0, 3.0, -50)
|
||||
});
|
||||
ei.AddGpsPoints({
|
||||
BuildGpsInfo(4.0, 4.0, 0)
|
||||
BuildGpsInfo(0.0, 0.0, 0),
|
||||
BuildGpsInfo(1.0, 1.0, 50),
|
||||
BuildGpsInfo(2.0, 2.0, 100),
|
||||
});
|
||||
ei.AddGpsPoints({BuildGpsInfo(3.0, 3.0, -50)});
|
||||
ei.AddGpsPoints({BuildGpsInfo(4.0, 4.0, 0)});
|
||||
ei.AddGpsPoints({});
|
||||
|
||||
TEST_EQUAL(5, ei.GetSize(), ());
|
||||
TEST_EQUAL(ei.GetSegmentsDistances().size(), 0, ());
|
||||
}
|
||||
} // namespace elevation_info_testa
|
||||
} // namespace elevation_info_tests
|
||||
|
||||
@@ -17,8 +17,7 @@ void TestGpsInfo(GpsInfo const & tested, GpsInfo const & expected)
|
||||
TEST_EQUAL(tested.m_source, expected.m_source, ());
|
||||
TEST(AlmostEqualAbs(tested.m_latitude, expected.m_latitude, kEpsilon), ());
|
||||
TEST(AlmostEqualAbs(tested.m_longitude, expected.m_longitude, kEpsilon), ());
|
||||
TEST(AlmostEqualAbs(tested.m_horizontalAccuracy, expected.m_horizontalAccuracy, kEpsilon),
|
||||
());
|
||||
TEST(AlmostEqualAbs(tested.m_horizontalAccuracy, expected.m_horizontalAccuracy, kEpsilon), ());
|
||||
TEST(AlmostEqualAbs(tested.m_altitude, expected.m_altitude, kEpsilon), ());
|
||||
TEST(AlmostEqualAbs(tested.m_verticalAccuracy, expected.m_verticalAccuracy, kEpsilon), ());
|
||||
TEST(AlmostEqualAbs(tested.m_bearing, expected.m_bearing, kEpsilon), ());
|
||||
@@ -50,22 +49,22 @@ UNIT_TEST(LinearExtrapolation)
|
||||
|
||||
// 100 ms after |point2|.
|
||||
{
|
||||
GpsInfo const expected = GetGpsInfo(1.1 /* timestampS */, 1.011 /* m_latitude */,
|
||||
1.011 /* m_longitude */, 2.1 /* m_altitude */, 12.2 /* m_speed */);
|
||||
GpsInfo const expected = GetGpsInfo(1.1 /* timestampS */, 1.011 /* m_latitude */, 1.011 /* m_longitude */,
|
||||
2.1 /* m_altitude */, 12.2 /* m_speed */);
|
||||
TestGpsInfo(LinearExtrapolation(loc1, loc2, 100 /* timeAfterPoint2Ms */), expected);
|
||||
}
|
||||
|
||||
// 200 ms after |point2|.
|
||||
{
|
||||
GpsInfo const expected = GetGpsInfo(1.2 /* timestampS */, 1.012 /* m_latitude */,
|
||||
1.012 /* m_longitude */, 2.2 /* m_altitude */, 12.4 /* m_speed */);
|
||||
GpsInfo const expected = GetGpsInfo(1.2 /* timestampS */, 1.012 /* m_latitude */, 1.012 /* m_longitude */,
|
||||
2.2 /* m_altitude */, 12.4 /* m_speed */);
|
||||
TestGpsInfo(LinearExtrapolation(loc1, loc2, 200 /* timeAfterPoint2Ms */), expected);
|
||||
}
|
||||
|
||||
// 1000 ms after |point2|.
|
||||
{
|
||||
GpsInfo const expected = GetGpsInfo(2.0 /* timestampS */, 1.02 /* m_latitude */,
|
||||
1.02 /* m_longitude */, 3.0 /* m_altitude */, 14.0 /* m_speed */);
|
||||
GpsInfo const expected = GetGpsInfo(2.0 /* timestampS */, 1.02 /* m_latitude */, 1.02 /* m_longitude */,
|
||||
3.0 /* m_altitude */, 14.0 /* m_speed */);
|
||||
TestGpsInfo(LinearExtrapolation(loc1, loc2, 1000 /* timeAfterPoint2Ms */), expected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
|
||||
UNIT_TEST(Framework_ForEachFeatureAtPoint_And_Others)
|
||||
{
|
||||
using namespace std;
|
||||
@@ -24,18 +23,14 @@ UNIT_TEST(Framework_ForEachFeatureAtPoint_And_Others)
|
||||
frm.RegisterMap(platform::LocalCountryFile::MakeForTesting("minsk-pass"));
|
||||
|
||||
// May vary according to the new minsk-pass data.
|
||||
vector<char const *> types =
|
||||
{
|
||||
"highway|footway|",
|
||||
"hwtag|yesbicycle|",
|
||||
"psurface|paved_good|",
|
||||
vector<char const *> types = {
|
||||
"highway|footway|", "hwtag|yesbicycle|", "psurface|paved_good|",
|
||||
|
||||
"highway|service|",
|
||||
"psurface|paved_good|",
|
||||
"highway|service|", "psurface|paved_good|",
|
||||
|
||||
"amenity|parking|",
|
||||
"amenity|parking|",
|
||||
|
||||
"barrier|lift_gate|",
|
||||
"barrier|lift_gate|",
|
||||
};
|
||||
frm.ForEachFeatureAtPoint([&](FeatureType & ft)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ UNIT_TEST(GpsTrackCollection_Simple)
|
||||
|
||||
TEST_EQUAL(50, collection.GetSize(), ());
|
||||
|
||||
collection.ForEach([&data](location::GpsInfo const & info, size_t id)->bool
|
||||
collection.ForEach([&data](location::GpsInfo const & info, size_t id) -> bool
|
||||
{
|
||||
TEST(data.end() != data.find(id), ());
|
||||
location::GpsInfo const & originInfo = data[id];
|
||||
|
||||
@@ -61,7 +61,7 @@ UNIT_TEST(GpsTrackStorage_WriteRead)
|
||||
stg.Append(points);
|
||||
|
||||
size_t i = 0;
|
||||
stg.ForEach([&](location::GpsInfo const & point)->bool
|
||||
stg.ForEach([&](location::GpsInfo const & point) -> bool
|
||||
{
|
||||
TEST_EQUAL(point.m_latitude, points[i].m_latitude, ());
|
||||
TEST_EQUAL(point.m_longitude, points[i].m_longitude, ());
|
||||
@@ -78,7 +78,7 @@ UNIT_TEST(GpsTrackStorage_WriteRead)
|
||||
GpsTrackStorage stg(filePath);
|
||||
|
||||
size_t i = 0;
|
||||
stg.ForEach([&](location::GpsInfo const & point)->bool
|
||||
stg.ForEach([&](location::GpsInfo const & point) -> bool
|
||||
{
|
||||
TEST_EQUAL(point.m_latitude, points[i].m_latitude, ());
|
||||
TEST_EQUAL(point.m_longitude, points[i].m_longitude, ());
|
||||
@@ -98,8 +98,12 @@ UNIT_TEST(GpsTrackStorage_WriteRead)
|
||||
GpsTrackStorage stg(filePath);
|
||||
|
||||
size_t i = 0;
|
||||
stg.ForEach([&](location::GpsInfo const & point)->bool{ ++i; return true; });
|
||||
stg.ForEach([&](location::GpsInfo const & point) -> bool
|
||||
{
|
||||
++i;
|
||||
return true;
|
||||
});
|
||||
TEST_EQUAL(i, 0, ());
|
||||
}
|
||||
}
|
||||
} // namespace gps_track_storage_test
|
||||
} // namespace gps_track_storage_test
|
||||
|
||||
@@ -42,13 +42,8 @@ inline string GetGpsTrackFilePath()
|
||||
class GpsTrackCallback
|
||||
{
|
||||
public:
|
||||
GpsTrackCallback()
|
||||
: m_toRemove(make_pair(GpsTrack::kInvalidId, GpsTrack::kInvalidId))
|
||||
, m_gotCallback(false)
|
||||
{
|
||||
}
|
||||
void OnUpdate(vector<pair<size_t, location::GpsInfo>> && toAdd,
|
||||
pair<size_t, size_t> const & toRemove)
|
||||
GpsTrackCallback() : m_toRemove(make_pair(GpsTrack::kInvalidId, GpsTrack::kInvalidId)), m_gotCallback(false) {}
|
||||
void OnUpdate(vector<pair<size_t, location::GpsInfo>> && toAdd, pair<size_t, size_t> const & toRemove)
|
||||
{
|
||||
m_toAdd = std::move(toAdd);
|
||||
m_toRemove = toRemove;
|
||||
@@ -68,7 +63,7 @@ public:
|
||||
bool WaitForCallback(seconds t)
|
||||
{
|
||||
unique_lock<mutex> ul(m_mutex);
|
||||
return m_cv.wait_for(ul, t, [this]()->bool{ return m_gotCallback; });
|
||||
return m_cv.wait_for(ul, t, [this]() -> bool { return m_gotCallback; });
|
||||
}
|
||||
|
||||
vector<pair<size_t, location::GpsInfo>> m_toAdd;
|
||||
@@ -107,8 +102,7 @@ UNIT_TEST(GpsTrack_Simple)
|
||||
|
||||
GpsTrackCallback callback;
|
||||
|
||||
track.SetCallback(
|
||||
bind(&GpsTrackCallback::OnUpdate, &callback, placeholders::_1, placeholders::_2));
|
||||
track.SetCallback(bind(&GpsTrackCallback::OnUpdate, &callback, placeholders::_1, placeholders::_2));
|
||||
|
||||
TEST(callback.WaitForCallback(kWaitForCallbackTimeout), ());
|
||||
|
||||
@@ -131,8 +125,7 @@ UNIT_TEST(GpsTrack_Simple)
|
||||
|
||||
GpsTrackCallback callback;
|
||||
|
||||
track.SetCallback(
|
||||
bind(&GpsTrackCallback::OnUpdate, &callback, placeholders::_1, placeholders::_2));
|
||||
track.SetCallback(bind(&GpsTrackCallback::OnUpdate, &callback, placeholders::_1, placeholders::_2));
|
||||
|
||||
TEST(callback.WaitForCallback(kWaitForCallbackTimeout), ());
|
||||
|
||||
@@ -149,4 +142,4 @@ UNIT_TEST(GpsTrack_Simple)
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace gps_track_test
|
||||
} // namespace gps_track_test
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "base/scope_guard.hpp"
|
||||
|
||||
|
||||
UNIT_TEST(KMZ_UnzipTest)
|
||||
{
|
||||
std::string const kmzFile = GetPlatform().TestsDataPathForFile("test_data/kml/test.kmz");
|
||||
@@ -45,8 +44,7 @@ UNIT_TEST(Multi_KML_KMZ_UnzipTest)
|
||||
{
|
||||
std::string const kmzFile = GetPlatform().TestsDataPathForFile("test_data/kml/BACRNKMZ.kmz");
|
||||
auto const filePaths = GetKMLOrGPXFilesPathsToLoad(kmzFile);
|
||||
std::vector<std::string> expectedFileNames =
|
||||
{
|
||||
std::vector<std::string> expectedFileNames = {
|
||||
"BACRNKMZfilesCampgrounds 26may2022 green and tree icon",
|
||||
"BACRNKMZfilesIndoor Accommodations 26may2022 placemark purple and bed icon",
|
||||
"BACRNKMZfilesRoute 1 Canada - West-East Daily Segments",
|
||||
|
||||
@@ -23,7 +23,9 @@ double const kEps = 1e-10;
|
||||
|
||||
UNIT_TEST(MapApiSmoke)
|
||||
{
|
||||
string urlString = "mapswithme://map?ll=38.970559,-9.419289&ignoreThisParam=Yes&z=17&n=Point%20Name&s=black&backurl=https%3A%2F%2Fcomaps.app";
|
||||
string urlString =
|
||||
"mapswithme://"
|
||||
"map?ll=38.970559,-9.419289&ignoreThisParam=Yes&z=17&n=Point%20Name&s=black&backurl=https%3A%2F%2Fcomaps.app";
|
||||
TEST(url::Url(urlString).IsValid(), ());
|
||||
|
||||
ParsedMapApi test(urlString);
|
||||
@@ -41,8 +43,7 @@ UNIT_TEST(MapApiSmoke)
|
||||
|
||||
UNIT_TEST(RouteApiSmoke)
|
||||
{
|
||||
string const urlString =
|
||||
"mapswithme://route?sll=1,1&saddr=name0&dll=2,2&daddr=name1&type=vehicle";
|
||||
string const urlString = "mapswithme://route?sll=1,1&saddr=name0&dll=2,2&daddr=name1&type=vehicle";
|
||||
TEST(url::Url(urlString).IsValid(), ());
|
||||
|
||||
ParsedMapApi test(urlString);
|
||||
@@ -59,7 +60,8 @@ UNIT_TEST(RouteApiSmoke)
|
||||
|
||||
UNIT_TEST(SearchApiSmoke)
|
||||
{
|
||||
string const urlString = "mapsme://search?query=Saint%20Hilarion&cll=35.3166654,33.2833322&locale=ru&map&appname=CoMaps";
|
||||
string const urlString =
|
||||
"mapsme://search?query=Saint%20Hilarion&cll=35.3166654,33.2833322&locale=ru&map&appname=CoMaps";
|
||||
TEST(url::Url(urlString).IsValid(), ());
|
||||
|
||||
ParsedMapApi test(urlString);
|
||||
@@ -121,7 +123,8 @@ UNIT_TEST(SearchApiInvalidUrl)
|
||||
ParsedMapApi test;
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapsme://search?"), UrlType::Incorrect, ("Empty query string"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapsme://search?query"), UrlType::Incorrect, ("Search query can't be empty"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapsme://serch?cll=1,1&locale=ru&query=aaa"), UrlType::Incorrect, ("Incorrect url type"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapsme://serch?cll=1,1&locale=ru&query=aaa"), UrlType::Incorrect,
|
||||
("Incorrect url type"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapsme://search?Query=fff"), UrlType::Incorrect, ("The parser is case sensitive"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("incorrect://search?query=aaa"), UrlType::Incorrect, ("Wrong prefix"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("http://search?query=aaa"), UrlType::Incorrect, ("Wrong prefix"));
|
||||
@@ -131,7 +134,7 @@ UNIT_TEST(LeadApiSmoke)
|
||||
{
|
||||
ParsedMapApi test;
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapsme://lead?utm_source=a&utm_medium=b&utm_campaign=c&utm_content=d&utm_term=e"),
|
||||
UrlType::Incorrect, ("Lead API is not supported"));
|
||||
UrlType::Incorrect, ("Lead API is not supported"));
|
||||
}
|
||||
|
||||
UNIT_TEST(MapApiInvalidUrl)
|
||||
@@ -149,17 +152,24 @@ UNIT_TEST(MapApiInvalidUrl)
|
||||
UNIT_TEST(RouteApiInvalidUrl)
|
||||
{
|
||||
ParsedMapApi test;
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&saddr=name0&dll=2,2&daddr=name2"), UrlType::Incorrect, ("Route type doesn't exist"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&saddr=name0"), UrlType::Incorrect, ("Destination doesn't exist"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&dll=2,2&type=vehicle"), UrlType::Incorrect, ("Source or destination name doesn't exist"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&saddr=name0&dll=2,2&daddr=name2"), UrlType::Incorrect,
|
||||
("Route type doesn't exist"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&saddr=name0"), UrlType::Incorrect,
|
||||
("Destination doesn't exist"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&dll=2,2&type=vehicle"), UrlType::Incorrect,
|
||||
("Source or destination name doesn't exist"));
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?saddr=name0&daddr=name1&type=vehicle"), UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&sll=2.2&type=vehicle"), UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&dll=2.2&type=666"), UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&saddr=name0&sll=2,2&saddr=name1&type=vehicle"), UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&saddr=name0&sll=2,2&saddr=name1&type=vehicle"),
|
||||
UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&type=vehicle"), UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?sll=1,1&saddr=name0&sll=2,2&saddr=name1&sll=1,1&saddr=name0&type=vehicle"), UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse(
|
||||
"mapswithme://route?sll=1,1&saddr=name0&sll=2,2&saddr=name1&sll=1,1&saddr=name0&type=vehicle"),
|
||||
UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://route?type=vehicle"), UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://rout?sll=1,1&saddr=name0&dll=2,2&daddr=name1&type=vehicle"), UrlType::Incorrect, ());
|
||||
TEST_EQUAL(test.SetUrlAndParse("mapswithme://rout?sll=1,1&saddr=name0&dll=2,2&daddr=name1&type=vehicle"),
|
||||
UrlType::Incorrect, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(MapApiLatLonLimits)
|
||||
@@ -385,7 +395,6 @@ UNIT_TEST(CrosshairApi)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UNIT_TEST(GlobalBackUrl)
|
||||
{
|
||||
{
|
||||
@@ -409,19 +418,30 @@ UNIT_TEST(GlobalBackUrl)
|
||||
TEST_EQUAL(api.GetGlobalBackUrl(), "http://mapswithme.com", ());
|
||||
}
|
||||
{
|
||||
ParsedMapApi api("mwm://map?ll=1,2&n=PointName&backurl=someapp://%D0%9C%D0%BE%D0%B1%D0%B8%D0%BB%D1%8C%D0%BD%D1%8B%D0%B5%20%D0%9A%D0%B0%D1%80%D1%82%D1%8B");
|
||||
TEST_EQUAL(api.GetGlobalBackUrl(), "someapp://\xd0\x9c\xd0\xbe\xd0\xb1\xd0\xb8\xd0\xbb\xd1\x8c\xd0\xbd\xd1\x8b\xd0\xb5 \xd0\x9a\xd0\xb0\xd1\x80\xd1\x82\xd1\x8b", ());
|
||||
ParsedMapApi api(
|
||||
"mwm://map?ll=1,2&n=PointName&backurl=someapp://"
|
||||
"%D0%9C%D0%BE%D0%B1%D0%B8%D0%BB%D1%8C%D0%BD%D1%8B%D0%B5%20%D0%9A%D0%B0%D1%80%D1%82%D1%8B");
|
||||
TEST_EQUAL(api.GetGlobalBackUrl(),
|
||||
"someapp://\xd0\x9c\xd0\xbe\xd0\xb1\xd0\xb8\xd0\xbb\xd1\x8c\xd0\xbd\xd1\x8b\xd0\xb5 "
|
||||
"\xd0\x9a\xd0\xb0\xd1\x80\xd1\x82\xd1\x8b",
|
||||
());
|
||||
}
|
||||
{
|
||||
ParsedMapApi api("mwm://map?ll=1,2&n=PointName");
|
||||
TEST_EQUAL(api.GetGlobalBackUrl(), "", ());
|
||||
}
|
||||
{
|
||||
ParsedMapApi api("mwm://map?ll=1,2&n=PointName&backurl=%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5%3A%2F%2F%D0%BE%D1%82%D0%BA%D1%80%D0%BE%D0%B9%D0%A1%D1%81%D1%8B%D0%BB%D0%BA%D1%83");
|
||||
ParsedMapApi api(
|
||||
"mwm://"
|
||||
"map?ll=1,2&n=PointName&backurl=%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5%3A%2F%2F%D0%BE%D1%"
|
||||
"82%D0%BA%D1%80%D0%BE%D0%B9%D0%A1%D1%81%D1%8B%D0%BB%D0%BA%D1%83");
|
||||
TEST_EQUAL(api.GetGlobalBackUrl(), "приложение://откройСсылку", ());
|
||||
}
|
||||
{
|
||||
ParsedMapApi api("mwm://map?ll=1,2&n=PointName&backurl=%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5%3A%2F%2F%D0%BE%D1%82%D0%BA%D1%80%D0%BE%D0%B9%D0%A1%D1%81%D1%8B%D0%BB%D0%BA%D1%83");
|
||||
ParsedMapApi api(
|
||||
"mwm://"
|
||||
"map?ll=1,2&n=PointName&backurl=%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5%3A%2F%2F%D0%BE%D1%"
|
||||
"82%D0%BA%D1%80%D0%BE%D0%B9%D0%A1%D1%81%D1%8B%D0%BB%D0%BA%D1%83");
|
||||
TEST_EQUAL(api.GetGlobalBackUrl(), "приложение://откройСсылку", ());
|
||||
}
|
||||
{
|
||||
@@ -496,8 +516,7 @@ namespace
|
||||
string generatePartOfUrl(url_scheme::MapPoint const & point)
|
||||
{
|
||||
stringstream stream;
|
||||
stream << "&ll=" << std::to_string(point.m_lat) << "," << std::to_string(point.m_lon)
|
||||
<< "&n=" << point.m_name
|
||||
stream << "&ll=" << std::to_string(point.m_lat) << "," << std::to_string(point.m_lon) << "&n=" << point.m_name
|
||||
<< "&id=" << point.m_id;
|
||||
return stream.str();
|
||||
}
|
||||
@@ -513,7 +532,7 @@ string randomString(size_t size, uint32_t seed)
|
||||
|
||||
void generateRandomTest(uint32_t numberOfPoints, size_t stringLength)
|
||||
{
|
||||
vector <url_scheme::MapPoint> vect(numberOfPoints);
|
||||
vector<url_scheme::MapPoint> vect(numberOfPoints);
|
||||
for (uint32_t i = 0; i < numberOfPoints; ++i)
|
||||
{
|
||||
url_scheme::MapPoint point;
|
||||
@@ -543,7 +562,7 @@ void generateRandomTest(uint32_t numberOfPoints, size_t stringLength)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(100FullEnteriesRandomTest)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "map/power_management/power_manager.hpp"
|
||||
#include "map/power_management/power_management_schemas.hpp"
|
||||
#include "map/power_management/power_manager.hpp"
|
||||
|
||||
#include "platform//platform.hpp"
|
||||
|
||||
@@ -26,10 +26,7 @@ public:
|
||||
m_onFacilityEvents.push_back({facility, enabled});
|
||||
}
|
||||
|
||||
void OnPowerSchemeChanged(Scheme const actualConfig) override
|
||||
{
|
||||
m_onShemeEvents.push_back(actualConfig);
|
||||
}
|
||||
void OnPowerSchemeChanged(Scheme const actualConfig) override { m_onShemeEvents.push_back(actualConfig); }
|
||||
|
||||
struct FacilityState
|
||||
{
|
||||
@@ -45,13 +42,10 @@ void TestIsAllFacilitiesInState(PowerManager const & manager, bool state)
|
||||
{
|
||||
auto const count = static_cast<size_t>(Facility::Count);
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
TEST_EQUAL(manager.IsFacilityEnabled(static_cast<Facility>(i)), state, ());
|
||||
}
|
||||
}
|
||||
|
||||
void TestAllFacilitiesEnabledExcept(PowerManager const & manager,
|
||||
std::vector<Facility> const & disabledFacilities)
|
||||
void TestAllFacilitiesEnabledExcept(PowerManager const & manager, std::vector<Facility> const & disabledFacilities)
|
||||
{
|
||||
auto const count = static_cast<size_t>(Facility::Count);
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
@@ -109,14 +103,10 @@ UNIT_TEST(PowerManager_SetScheme)
|
||||
TEST_EQUAL(manager.GetScheme(), Scheme::Normal, ());
|
||||
manager.SetScheme(Scheme::EconomyMaximum);
|
||||
TEST_EQUAL(manager.GetScheme(), Scheme::EconomyMaximum, ());
|
||||
TestAllFacilitiesEnabledExcept(manager, {Facility::Buildings3d,
|
||||
Facility::PerspectiveView,
|
||||
Facility::TrackRecording,
|
||||
Facility::TrafficJams,
|
||||
Facility::GpsTrackingForTraffic,
|
||||
Facility::OsmEditsUploading,
|
||||
Facility::UgcUploading,
|
||||
Facility::BookmarkCloudUploading});
|
||||
TestAllFacilitiesEnabledExcept(
|
||||
manager, {Facility::Buildings3d, Facility::PerspectiveView, Facility::TrackRecording, Facility::TrafficJams,
|
||||
Facility::GpsTrackingForTraffic, Facility::OsmEditsUploading, Facility::UgcUploading,
|
||||
Facility::BookmarkCloudUploading});
|
||||
|
||||
TEST_EQUAL(subscriber.m_onShemeEvents.size(), 1, ());
|
||||
TEST_EQUAL(subscriber.m_onShemeEvents[0], Scheme::EconomyMaximum, ());
|
||||
@@ -144,8 +134,7 @@ UNIT_TEST(PowerManager_SetScheme)
|
||||
manager.SetScheme(Scheme::EconomyMedium);
|
||||
TEST_EQUAL(manager.GetScheme(), Scheme::EconomyMedium, ());
|
||||
|
||||
TestAllFacilitiesEnabledExcept(manager,
|
||||
{Facility::PerspectiveView, Facility::BookmarkCloudUploading});
|
||||
TestAllFacilitiesEnabledExcept(manager, {Facility::PerspectiveView, Facility::BookmarkCloudUploading});
|
||||
|
||||
TEST_EQUAL(subscriber.m_onShemeEvents.size(), 1, ());
|
||||
TEST_EQUAL(subscriber.m_onShemeEvents[0], Scheme::EconomyMedium, ());
|
||||
@@ -229,10 +218,8 @@ UNIT_TEST(PowerManager_OnBatteryLevelChanged)
|
||||
|
||||
manager.OnBatteryLevelReceived(28);
|
||||
|
||||
TestAllFacilitiesEnabledExcept(manager, {Facility::PerspectiveView,
|
||||
Facility::GpsTrackingForTraffic,
|
||||
Facility::BookmarkCloudUploading,
|
||||
Facility::MapDownloader});
|
||||
TestAllFacilitiesEnabledExcept(manager, {Facility::PerspectiveView, Facility::GpsTrackingForTraffic,
|
||||
Facility::BookmarkCloudUploading, Facility::MapDownloader});
|
||||
TEST_EQUAL(manager.GetScheme(), Scheme::Auto, ());
|
||||
|
||||
TEST_EQUAL(subscriber.m_onShemeEvents.size(), 0, ());
|
||||
|
||||
@@ -39,8 +39,7 @@ using Rules = vector<shared_ptr<MatchingRule>>;
|
||||
struct TestCafe : public TestPOI
|
||||
{
|
||||
public:
|
||||
TestCafe(m2::PointD const & center, string const & name, string const & lang)
|
||||
: TestPOI(center, name, lang)
|
||||
TestCafe(m2::PointD const & center, string const & name, string const & lang) : TestPOI(center, name, lang)
|
||||
{
|
||||
SetTypes({{"amenity", "cafe"}});
|
||||
}
|
||||
@@ -63,8 +62,7 @@ public:
|
||||
SearchAPITest()
|
||||
: m_infoGetter(CountryInfoReader::CreateCountryInfoGetter(GetPlatform()))
|
||||
, m_api(m_dataSource, m_storage, *m_infoGetter, 1 /* numThreads */, m_delegate)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
protected:
|
||||
Storage m_storage;
|
||||
@@ -80,7 +78,8 @@ UNIT_CLASS_TEST(SearchAPITest, MultipleViewportsRequests)
|
||||
TestCafe cafe3(m2::PointD(10, 10), "cafe 3", "en");
|
||||
TestCafe cafe4(m2::PointD(10.5, 10.5), "cafe 4", "en");
|
||||
|
||||
auto const id = BuildCountry("Wonderland", [&](TestMwmBuilder & builder) {
|
||||
auto const id = BuildCountry("Wonderland", [&](TestMwmBuilder & builder)
|
||||
{
|
||||
builder.Add(cafe1);
|
||||
builder.Add(cafe2);
|
||||
builder.Add(cafe3);
|
||||
@@ -99,7 +98,8 @@ UNIT_CLASS_TEST(SearchAPITest, MultipleViewportsRequests)
|
||||
params.m_query = "cafe ";
|
||||
params.m_inputLocale = "en";
|
||||
|
||||
params.m_onCompleted = [&](Results const & results) {
|
||||
params.m_onCompleted = [&](Results const & results)
|
||||
{
|
||||
TEST(!results.IsEndedCancelled(), ());
|
||||
|
||||
if (!results.IsEndMarker())
|
||||
@@ -147,7 +147,8 @@ UNIT_CLASS_TEST(SearchAPITest, Cancellation)
|
||||
promise<void> promise;
|
||||
auto future = promise.get_future();
|
||||
|
||||
params.m_onResults = [&](Results const & results, vector<ProductInfo> const &) {
|
||||
params.m_onResults = [&](Results const & results, vector<ProductInfo> const &)
|
||||
{
|
||||
TEST(!results.IsEndedCancelled(), ());
|
||||
|
||||
if (!results.IsEndMarker())
|
||||
@@ -172,7 +173,8 @@ UNIT_CLASS_TEST(SearchAPITest, Cancellation)
|
||||
|
||||
params.m_timeout = chrono::seconds(-1);
|
||||
|
||||
params.m_onResults = [&](Results const & results, vector<ProductInfo> const &) {
|
||||
params.m_onResults = [&](Results const & results, vector<ProductInfo> const &)
|
||||
{
|
||||
// The deadline has fired but Search API does not expose it.
|
||||
TEST(!results.IsEndedCancelled(), ());
|
||||
|
||||
@@ -201,8 +203,7 @@ UNIT_CLASS_TEST(SearchAPITest, BookmarksSearch)
|
||||
kml::SetDefaultStr(data.m_description, "They've got a cherry pie there that'll kill ya!");
|
||||
marks.emplace_back(0, data);
|
||||
kml::SetDefaultStr(data.m_name, "Silver Mustang Casino");
|
||||
kml::SetDefaultStr(data.m_description,
|
||||
"Joyful place, owners Bradley and Rodney are very friendly!");
|
||||
kml::SetDefaultStr(data.m_description, "Joyful place, owners Bradley and Rodney are very friendly!");
|
||||
marks.emplace_back(1, data);
|
||||
kml::SetDefaultStr(data.m_name, "Great Northern Hotel");
|
||||
kml::SetDefaultStr(data.m_description, "Clean place with a reasonable price");
|
||||
@@ -212,15 +213,15 @@ UNIT_CLASS_TEST(SearchAPITest, BookmarksSearch)
|
||||
m_api.OnBookmarksCreated(marks);
|
||||
m_api.OnViewportChanged(m2::RectD(-1, -1, 1, 1));
|
||||
|
||||
auto runTest = [&](string const & query, kml::MarkGroupId const & groupId,
|
||||
vector<kml::MarkId> const & expected) {
|
||||
auto runTest = [&](string const & query, kml::MarkGroupId const & groupId, vector<kml::MarkId> const & expected)
|
||||
{
|
||||
promise<vector<kml::MarkId>> idsPromise;
|
||||
auto idsFuture = idsPromise.get_future();
|
||||
|
||||
BookmarksSearchParams params;
|
||||
params.m_query = query;
|
||||
params.m_onResults = [&](vector<kml::MarkId> const & results,
|
||||
BookmarksSearchParams::Status status) {
|
||||
params.m_onResults = [&](vector<kml::MarkId> const & results, BookmarksSearchParams::Status status)
|
||||
{
|
||||
if (status != BookmarksSearchParams::Status::Completed)
|
||||
return;
|
||||
idsPromise.set_value(results);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "map/track_statistics.hpp"
|
||||
|
||||
#include "geometry/point_with_altitude.hpp"
|
||||
#include "geometry/mercator.hpp"
|
||||
#include "geometry/point_with_altitude.hpp"
|
||||
|
||||
#include "kml/types.hpp"
|
||||
|
||||
@@ -37,21 +37,13 @@ UNIT_TEST(TrackStatistics_FromMultiGeometry)
|
||||
auto const point1 = PointWithAltitude({0.0, 0.0}, 100);
|
||||
auto const point2 = PointWithAltitude({1.0, 1.0}, 150);
|
||||
auto const point3 = PointWithAltitude({2.0, 2.0}, 50);
|
||||
geometry.AddLine({
|
||||
point1,
|
||||
point2,
|
||||
point3
|
||||
});
|
||||
geometry.AddTimestamps({
|
||||
0,
|
||||
1,
|
||||
2
|
||||
});
|
||||
geometry.AddLine({point1, point2, point3});
|
||||
geometry.AddTimestamps({0, 1, 2});
|
||||
auto const ts = TrackStatistics(geometry);
|
||||
TEST_EQUAL(ts.m_minElevation, 50, ());
|
||||
TEST_EQUAL(ts.m_maxElevation, 150, ());
|
||||
TEST_EQUAL(ts.m_ascent, 50, ()); // Ascent from 100 -> 150
|
||||
TEST_EQUAL(ts.m_descent, 100, ()); // Descent from 150 -> 50
|
||||
TEST_EQUAL(ts.m_ascent, 50, ()); // Ascent from 100 -> 150
|
||||
TEST_EQUAL(ts.m_descent, 100, ()); // Descent from 150 -> 50
|
||||
TEST_EQUAL(ts.m_duration, 2, ());
|
||||
|
||||
double distance = 0;
|
||||
@@ -63,11 +55,7 @@ UNIT_TEST(TrackStatistics_FromMultiGeometry)
|
||||
UNIT_TEST(TrackStatistics_NoAltitudeAndTimestampPoints)
|
||||
{
|
||||
kml::MultiGeometry geometry;
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({0.0, 0.0}),
|
||||
PointWithAltitude({1.0, 1.0}),
|
||||
PointWithAltitude({2.0, 2.0})
|
||||
});
|
||||
geometry.AddLine({PointWithAltitude({0.0, 0.0}), PointWithAltitude({1.0, 1.0}), PointWithAltitude({2.0, 2.0})});
|
||||
|
||||
auto const ts = TrackStatistics(geometry);
|
||||
|
||||
@@ -81,97 +69,58 @@ UNIT_TEST(TrackStatistics_NoAltitudeAndTimestampPoints)
|
||||
UNIT_TEST(TrackStatistics_MultipleLines)
|
||||
{
|
||||
kml::MultiGeometry geometry;
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({0.0, 0.0}, 100),
|
||||
PointWithAltitude({1.0, 1.0}, 150),
|
||||
PointWithAltitude({1.0, 1.0}, 140)
|
||||
});
|
||||
geometry.AddTimestamps({
|
||||
0,
|
||||
1,
|
||||
2
|
||||
});
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({2.0, 2.0}, 50),
|
||||
PointWithAltitude({3.0, 3.0}, 75),
|
||||
PointWithAltitude({3.0, 3.0}, 60)
|
||||
});
|
||||
geometry.AddTimestamps({
|
||||
0,
|
||||
0,
|
||||
0
|
||||
});
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({4.0, 4.0}, 200),
|
||||
PointWithAltitude({5.0, 5.0}, 250)
|
||||
});
|
||||
geometry.AddTimestamps({
|
||||
4,
|
||||
5
|
||||
});
|
||||
geometry.AddLine(
|
||||
{PointWithAltitude({0.0, 0.0}, 100), PointWithAltitude({1.0, 1.0}, 150), PointWithAltitude({1.0, 1.0}, 140)});
|
||||
geometry.AddTimestamps({0, 1, 2});
|
||||
geometry.AddLine(
|
||||
{PointWithAltitude({2.0, 2.0}, 50), PointWithAltitude({3.0, 3.0}, 75), PointWithAltitude({3.0, 3.0}, 60)});
|
||||
geometry.AddTimestamps({0, 0, 0});
|
||||
geometry.AddLine({PointWithAltitude({4.0, 4.0}, 200), PointWithAltitude({5.0, 5.0}, 250)});
|
||||
geometry.AddTimestamps({4, 5});
|
||||
auto const ts = TrackStatistics(geometry);
|
||||
|
||||
TEST_EQUAL(ts.m_minElevation, 50, ());
|
||||
TEST_EQUAL(ts.m_maxElevation, 250, ());
|
||||
TEST_EQUAL(ts.m_ascent, 125, ()); // Ascent from 100 -> 150, 50 -> 75, 200 -> 250
|
||||
TEST_EQUAL(ts.m_descent, 25, ()); // Descent from 150 -> 140, 75 -> 60
|
||||
TEST_EQUAL(ts.m_ascent, 125, ()); // Ascent from 100 -> 150, 50 -> 75, 200 -> 250
|
||||
TEST_EQUAL(ts.m_descent, 25, ()); // Descent from 150 -> 140, 75 -> 60
|
||||
TEST_EQUAL(ts.m_duration, 3, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(TrackStatistics_WithGpsPoints)
|
||||
{
|
||||
const std::vector<std::vector<GpsInfo>> pointsData = {
|
||||
{ BuildGpsInfo(0.0, 0.0, 0, 0),
|
||||
BuildGpsInfo(1.0, 1.0, 50, 1),
|
||||
BuildGpsInfo(2.0, 2.0, 100, 2)
|
||||
},
|
||||
{
|
||||
BuildGpsInfo(3.0, 3.0, -50, 5)
|
||||
},
|
||||
{
|
||||
BuildGpsInfo(4.0, 4.0, 0, 10)
|
||||
}
|
||||
};
|
||||
std::vector<std::vector<GpsInfo>> const pointsData = {
|
||||
{BuildGpsInfo(0.0, 0.0, 0, 0), BuildGpsInfo(1.0, 1.0, 50, 1), BuildGpsInfo(2.0, 2.0, 100, 2)},
|
||||
{BuildGpsInfo(3.0, 3.0, -50, 5)},
|
||||
{BuildGpsInfo(4.0, 4.0, 0, 10)}};
|
||||
TrackStatistics ts;
|
||||
for (auto const & pointsList : pointsData)
|
||||
{
|
||||
for (auto const & point : pointsList)
|
||||
ts.AddGpsInfoPoint(point);
|
||||
}
|
||||
TEST_EQUAL(ts.m_minElevation, -50, ());
|
||||
TEST_EQUAL(ts.m_maxElevation, 100, ());
|
||||
TEST_EQUAL(ts.m_ascent, 150, ()); // Ascent from 0 -> 50, 50 -> 100, -50 -> 0
|
||||
TEST_EQUAL(ts.m_descent, 150, ()); // Descent from 100 -> -50
|
||||
TEST_EQUAL(ts.m_ascent, 150, ()); // Ascent from 0 -> 50, 50 -> 100, -50 -> 0
|
||||
TEST_EQUAL(ts.m_descent, 150, ()); // Descent from 100 -> -50
|
||||
TEST_EQUAL(ts.m_duration, 10, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(TrackStatistics_PositiveAndNegativeAltitudes)
|
||||
{
|
||||
kml::MultiGeometry geometry;
|
||||
geometry.AddLine({
|
||||
PointWithAltitude({0.0, 0.0}, -10),
|
||||
PointWithAltitude({1.0, 1.0}, 20),
|
||||
PointWithAltitude({2.0, 2.0}, -5),
|
||||
PointWithAltitude({3.0, 3.0}, 15)
|
||||
});
|
||||
geometry.AddLine({PointWithAltitude({0.0, 0.0}, -10), PointWithAltitude({1.0, 1.0}, 20),
|
||||
PointWithAltitude({2.0, 2.0}, -5), PointWithAltitude({3.0, 3.0}, 15)});
|
||||
auto const ts = TrackStatistics(geometry);
|
||||
|
||||
TEST_EQUAL(ts.m_minElevation, -10, ());
|
||||
TEST_EQUAL(ts.m_maxElevation, 20, ());
|
||||
TEST_EQUAL(ts.m_ascent, 50, ()); // Ascent from -10 -> 20 and -5 -> 15
|
||||
TEST_EQUAL(ts.m_descent, 25, ()); // Descent from 20 -> -5
|
||||
TEST_EQUAL(ts.m_ascent, 50, ()); // Ascent from -10 -> 20 and -5 -> 15
|
||||
TEST_EQUAL(ts.m_descent, 25, ()); // Descent from 20 -> -5
|
||||
}
|
||||
|
||||
UNIT_TEST(TrackStatistics_SmallAltitudeDelta)
|
||||
{
|
||||
const std::vector<GpsInfo> points = {
|
||||
BuildGpsInfo(0.0, 0.0, 0),
|
||||
BuildGpsInfo(1.0, 1.0, 0.2),
|
||||
BuildGpsInfo(2.0, 2.0, 0.4),
|
||||
BuildGpsInfo(3.0, 3.0, 0.6),
|
||||
BuildGpsInfo(4.0, 4.0, 0.8),
|
||||
BuildGpsInfo(5.0, 5.0, 1.0)
|
||||
};
|
||||
std::vector<GpsInfo> const points = {BuildGpsInfo(0.0, 0.0, 0), BuildGpsInfo(1.0, 1.0, 0.2),
|
||||
BuildGpsInfo(2.0, 2.0, 0.4), BuildGpsInfo(3.0, 3.0, 0.6),
|
||||
BuildGpsInfo(4.0, 4.0, 0.8), BuildGpsInfo(5.0, 5.0, 1.0)};
|
||||
|
||||
TrackStatistics ts;
|
||||
for (auto const & point : points)
|
||||
@@ -189,32 +138,21 @@ UNIT_TEST(TrackStatistics_MixedMultiGeometryAndGpsPoints)
|
||||
auto const point1 = PointWithAltitude({0.0, 0.0}, 100);
|
||||
auto const point2 = PointWithAltitude({1.0, 1.0}, 150);
|
||||
auto const point3 = PointWithAltitude({2.0, 2.0}, 50);
|
||||
geometry.AddLine({
|
||||
point1,
|
||||
point2,
|
||||
point3
|
||||
});
|
||||
geometry.AddTimestamps({
|
||||
5,
|
||||
6,
|
||||
7
|
||||
});
|
||||
geometry.AddLine({point1, point2, point3});
|
||||
geometry.AddTimestamps({5, 6, 7});
|
||||
|
||||
auto ts = TrackStatistics(geometry);
|
||||
|
||||
const std::vector<GpsInfo> points = {
|
||||
BuildGpsInfo(3.0, 3.0, 60, 8),
|
||||
BuildGpsInfo(4.0, 4.0, 160, 10),
|
||||
BuildGpsInfo(4.0, 4.0, 20, 15)
|
||||
};
|
||||
std::vector<GpsInfo> const points = {BuildGpsInfo(3.0, 3.0, 60, 8), BuildGpsInfo(4.0, 4.0, 160, 10),
|
||||
BuildGpsInfo(4.0, 4.0, 20, 15)};
|
||||
|
||||
for (auto const & point : points)
|
||||
ts.AddGpsInfoPoint(point);
|
||||
|
||||
TEST_EQUAL(ts.m_minElevation, 20, ());
|
||||
TEST_EQUAL(ts.m_maxElevation, 160, ());
|
||||
TEST_EQUAL(ts.m_ascent, 160, ()); // 50 + 10 + 100
|
||||
TEST_EQUAL(ts.m_descent, 240, ()); // 100 + 140
|
||||
TEST_EQUAL(ts.m_duration, 10, ()); // 10
|
||||
TEST_EQUAL(ts.m_ascent, 160, ()); // 50 + 10 + 100
|
||||
TEST_EQUAL(ts.m_descent, 240, ()); // 100 + 140
|
||||
TEST_EQUAL(ts.m_duration, 10, ()); // 10
|
||||
}
|
||||
} // namespace track_statistics_tests
|
||||
} // namespace track_statistics_tests
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
void TestTransliteration(Transliteration const & translit, std::string const & locale,
|
||||
std::string const & original, std::string const & expected)
|
||||
void TestTransliteration(Transliteration const & translit, std::string const & locale, std::string const & original,
|
||||
std::string const & expected)
|
||||
{
|
||||
std::string out;
|
||||
translit.Transliterate(original, StringUtf8Multilang::GetLangIndex(locale), out);
|
||||
@@ -31,7 +31,7 @@ UNIT_TEST(Transliteration_CompareSamples)
|
||||
TestTransliteration(translit, "he", "עברית", "bryt");
|
||||
TestTransliteration(translit, "el", "Ελληνικά", "Ellenika");
|
||||
TestTransliteration(translit, "zh_pinyin", "拼音", "pin yin");
|
||||
TestTransliteration(translit, "th", "ไทย", ""); // Thai-Latin transliteration is off.
|
||||
TestTransliteration(translit, "th", "ไทย", ""); // Thai-Latin transliteration is off.
|
||||
TestTransliteration(translit, "sr", "Српски", "Srpski");
|
||||
TestTransliteration(translit, "uk", "Українська", "Ukrayinska");
|
||||
TestTransliteration(translit, "fa", "فارسی", "farsy");
|
||||
|
||||
Reference in New Issue
Block a user