forked from organicmaps/organicmaps
banners fix
This commit is contained in:
parent
894adf314d
commit
f37c23537d
3 changed files with 65 additions and 36 deletions
|
@ -36,13 +36,18 @@ std::vector<Banner> Engine::GetBanners(feature::TypesHolder const & types,
|
|||
storage::TCountriesVec const & countryIds) const
|
||||
{
|
||||
std::vector<Banner> banners;
|
||||
for (auto const & countryId : countryIds)
|
||||
|
||||
for (auto const & item : m_containers)
|
||||
{
|
||||
for (auto const & item : m_containers)
|
||||
for (auto const & countryId : countryIds)
|
||||
{
|
||||
auto const bannerId = item.m_container->GetBannerId(types, countryId);
|
||||
// We need to add banner for every banner system just once.
|
||||
if (!bannerId.empty())
|
||||
{
|
||||
banners.emplace_back(item.m_type, bannerId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,72 +34,96 @@ UNIT_TEST(AdsEngine_Smoke)
|
|||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "dentist"}));
|
||||
TEST(engine.HasBanner(holder, "Ukraine"), ());
|
||||
auto result = engine.GetBanners(holder, "Ukraine");
|
||||
TEST(engine.HasBanner(holder, {"Ukraine"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Ukraine"});
|
||||
CheckCountAndTypes(result);
|
||||
CheckIds(result, {"7", "185237551520383_1384652351578891"});
|
||||
|
||||
holder.Add(c.GetTypeByPath({"amenity", "pub"}));
|
||||
TEST(engine.HasBanner(holder, "Ukraine"), ());
|
||||
result = engine.GetBanners(holder, "Ukraine");
|
||||
TEST(engine.HasBanner(holder, {"Ukraine"}), ());
|
||||
result = engine.GetBanners(holder, {"Ukraine"});
|
||||
CheckCountAndTypes(result);
|
||||
CheckIds(result, {"7", "185237551520383_1384652351578891"});
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"tourism", "information", "map"}));
|
||||
TEST(engine.HasBanner(holder, "Moldova"), ());
|
||||
auto result = engine.GetBanners(holder, "Moldova");
|
||||
TEST(engine.HasBanner(holder, {"Moldova"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Moldova"});
|
||||
CheckCountAndTypes(result);
|
||||
CheckIds(result, {"5", "185237551520383_1384651734912286"});
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"shop", "ticket"}));
|
||||
TEST(engine.HasBanner(holder, "Russia"), ());
|
||||
auto result = engine.GetBanners(holder, "Russia");
|
||||
TEST(engine.HasBanner(holder, {"Russian Federation"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Russian Federation"});
|
||||
CheckCountAndTypes(result);
|
||||
CheckIds(result, {"2", "185237551520383_1384650804912379"});
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "bank"}));
|
||||
TEST(engine.HasBanner(holder, "Belarus"), ());
|
||||
auto result = engine.GetBanners(holder, "Belarus");
|
||||
TEST(engine.HasBanner(holder, {"Belarus"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Belarus"});
|
||||
CheckCountAndTypes(result);
|
||||
CheckIds(result, {"8", "185237551520383_1384652658245527"});
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "pub"}));
|
||||
TEST(engine.HasBanner(holder, {"Spain", "Ukraine"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Spain", "Ukraine"});
|
||||
CheckCountAndTypes(result);
|
||||
CheckIds(result, {"1", "185237551520383_1384650164912443"});
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "pub"}));
|
||||
TEST(engine.HasBanner(holder, {"Ukraine", "Spain"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Ukraine", "Spain"});
|
||||
CheckCountAndTypes(result);
|
||||
CheckIds(result, {"1", "185237551520383_1384650164912443"});
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "pub"}));
|
||||
TEST(engine.HasBanner(holder, {"Spain"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Spain"});
|
||||
CheckIds(result, {"185237551520383_1384650164912443"});
|
||||
TEST_EQUAL(result[0].m_type, ads::Banner::Type::Facebook, ());
|
||||
}
|
||||
ads::Rb rb;
|
||||
ads::Facebook facebook;
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "toilets"}));
|
||||
TEST(engine.HasBanner(holder, "Armenia"), ());
|
||||
auto result = engine.GetBanners(holder, "Armenia");
|
||||
TEST(engine.HasBanner(holder, {"Armenia"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Armenia"});
|
||||
CheckCountAndTypes(result);
|
||||
CheckIds(result, {rb.GetBannerIdForOtherTypes(), facebook.GetBannerIdForOtherTypes()});
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "toilets"}));
|
||||
TEST(engine.HasBanner(holder, {"Armenia", "Azerbaijan Region"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Armenia", "Azerbaijan Region"});
|
||||
CheckCountAndTypes(result);
|
||||
CheckIds(result, {rb.GetBannerIdForOtherTypes(), facebook.GetBannerIdForOtherTypes()});
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"sponsored", "opentable"}));
|
||||
TEST(engine.HasBanner(holder, "Brazil"), ());
|
||||
auto result = engine.GetBanners(holder, "Brazil");
|
||||
TEST(engine.HasBanner(holder, {"Brazil"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Brazil"});
|
||||
CheckIds(result, {facebook.GetBannerIdForOtherTypes()});
|
||||
TEST_EQUAL(result[0].m_type, ads::Banner::Type::Facebook, ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "pub"}));
|
||||
TEST(engine.HasBanner(holder, "Spain"), ());
|
||||
auto result = engine.GetBanners(holder, "Spain");
|
||||
CheckIds(result, {"185237551520383_1384650164912443"});
|
||||
TEST_EQUAL(result[0].m_type, ads::Banner::Type::Facebook, ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"sponsored", "booking"}));
|
||||
TEST(!engine.HasBanner(holder, "Russia"), ());
|
||||
auto result = engine.GetBanners(holder, "Russia");
|
||||
TEST(!engine.HasBanner(holder, {"Russian Federation"}), ());
|
||||
auto result = engine.GetBanners(holder, {"Russian Federation"});
|
||||
TEST(result.empty(), ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,34 +16,34 @@ UNIT_TEST(Rb_GetBanner)
|
|||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "dentist"}));
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), "7", ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "7", ());
|
||||
holder.Add(c.GetTypeByPath({"amenity", "pub"}));
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), "7", ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "7", ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "restaurant"}));
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), "1", ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "1", ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"tourism", "information", "map"}));
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), "5", ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "5", ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"shop", "ticket"}));
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), "2", ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "2", ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "bank"}));
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), "8", ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "8", ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "atm"}));
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), "8", ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "8", ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
|
@ -54,13 +54,13 @@ UNIT_TEST(Rb_GetBanner)
|
|||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"amenity", "toilets"}));
|
||||
auto const bannerId = rb.GetBannerIdForOtherTypes();
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), bannerId, ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), bannerId, ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"sponsored", "opentable"}));
|
||||
auto const bannerId = rb.GetBannerIdForOtherTypes();
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), bannerId, ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), bannerId, ());
|
||||
}
|
||||
{
|
||||
feature::TypesHolder holder;
|
||||
|
@ -70,7 +70,7 @@ UNIT_TEST(Rb_GetBanner)
|
|||
{
|
||||
feature::TypesHolder holder;
|
||||
holder.Assign(c.GetTypeByPath({"sponsored", "booking"}));
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russia"), "", ());
|
||||
TEST_EQUAL(rb.GetBannerId(holder, "Russian Federation"), "", ());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
|
Loading…
Add table
Reference in a new issue