[ads] "download on map" banner place is added into ads engine. Five ads partners are added.

This commit is contained in:
Arsentiy Milchakov 2020-03-17 11:48:35 +03:00 committed by Aleksey Belousov
parent cbc943c2c2
commit a3ff5ec083
36 changed files with 1341 additions and 101 deletions

View file

@ -250,9 +250,8 @@ booking::filter::Tasks MakeBookingFilterTasks(booking::filter::Params && availab
auto const banners = adsEngine.GetSearchBanners();
auto const & purchase = GetFramework().GetPurchase();
bool const hasSubscription = purchase && purchase->IsSubscriptionActive(SubscriptionType::RemoveAds);
if (!hasSubscription && !banners.empty())
{
if (!hasSubscription && !banners.empty()) {
auto coreBanners = banner_helpers::MatchPriorityBanners(banners, manager.lastQuery);
[[MWMBannersCache cache] refreshWithCoreBanners:coreBanners];
}
@ -391,21 +390,19 @@ booking::filter::Tasks MakeBookingFilterTasks(booking::filter::Params && availab
auto const & purchase = GetFramework().GetPurchase();
bool const hasSubscription = purchase && purchase->IsSubscriptionActive(SubscriptionType::RemoveAds);
if (!hasSubscription && !banners.empty())
{
if (!hasSubscription && !banners.empty()) {
self.banners = [[MWMSearchBanners alloc] initWithSearchIndex:itemsIndex];
__weak auto weakSelf = self;
[[MWMBannersCache cache]
getWithCoreBanners:banner_helpers::MatchPriorityBanners(banners, self.lastQuery)
cacheOnly:YES
loadNew:reloadBanner
completion:^(id<MWMBanner> ad, BOOL isAsync) {
__strong auto self = weakSelf;
if (!self)
return;
NSAssert(isAsync == NO, @"Banner is not from cache!");
[self.banners add:ad];
}];
[[MWMBannersCache cache] getWithCoreBanners:banner_helpers::MatchPriorityBanners(banners, self.lastQuery)
cacheOnly:YES
loadNew:reloadBanner
completion:^(id<MWMBanner> ad, BOOL isAsync) {
__strong auto self = weakSelf;
if (!self)
return;
NSAssert(isAsync == NO, @"Banner is not from cache!");
[self.banners add:ad];
}];
}
}
else

View file

@ -47,6 +47,8 @@ set(
displacement_mode_manager.hpp
displayed_categories_modifiers.cpp
displayed_categories_modifiers.hpp
download_on_map_ads_delegate.cpp
download_on_map_ads_delegate.hpp
elevation_info.cpp
elevation_info.hpp
everywhere_search_callback.cpp

View file

@ -0,0 +1,47 @@
#include "map/download_on_map_ads_delegate.hpp"
namespace ads
{
DownloadOnMapDelegate::DownloadOnMapDelegate(storage::CountryInfoGetter const & infoGetter,
storage::Storage const & storage,
promo::Api const & promoApi, Purchase const & purchase)
: m_countryInfoGetter(infoGetter)
, m_storage(storage)
, m_promoApi(promoApi)
, m_purchase(purchase)
{
}
storage::CountryId DownloadOnMapDelegate::GetCountryId(m2::PointD const & pos)
{
return m_countryInfoGetter.GetRegionCountryId(pos);
}
storage::CountriesVec DownloadOnMapDelegate::GetTopmostNodesFor(storage::CountryId const & mwmId) const
{
storage::CountriesVec countries;
m_storage.GetTopmostNodesFor(mwmId, countries);
return countries;
}
std::string DownloadOnMapDelegate::GetMwmTopCityGeoId(storage::CountryId const & mwmId) const
{
auto const & cities = m_storage.GetMwmTopCityGeoIds();
auto const it = cities.find(mwmId);
if (it == cities.cend())
return {};
return strings::to_string(it->second.GetEncodedId());
}
std::string DownloadOnMapDelegate::GetLinkForGeoId(std::string const & id) const
{
return m_promoApi.GetLinkForDownloader(id);
}
bool DownloadOnMapDelegate::IsAdsRemoved() const
{
return m_purchase.IsSubscriptionActive(SubscriptionType::RemoveAds);
}
} // namespace ads

View file

@ -0,0 +1,40 @@
#pragma once
#include "map/purchase.hpp"
#include "partners_api/ads/ads_engine.hpp"
#include "partners_api/promo_api.hpp"
#include "storage/country_info_getter.hpp"
#include "storage/storage.hpp"
#include "storage/storage_defines.hpp"
#include "geometry/point2d.hpp"
#include <string>
namespace ads
{
class DownloadOnMapDelegate : public Engine::Delegate
{
public:
DownloadOnMapDelegate(storage::CountryInfoGetter const & infoGetter,
storage::Storage const & storage, promo::Api const & promoApi,
Purchase const & purchase);
// Engine::Delegate overrides:
bool IsAdsRemoved() const override;
// DownloadOnMapContainer::Delegate overrides:
storage::CountryId GetCountryId(m2::PointD const & pos) override;
storage::CountriesVec GetTopmostNodesFor(storage::CountryId const & mwmId) const override;
std::string GetMwmTopCityGeoId(storage::CountryId const & mwmId) const override;
std::string GetLinkForGeoId(std::string const & id) const override;
private:
storage::CountryInfoGetter const & m_countryInfoGetter;
storage::Storage const & m_storage;
promo::Api const & m_promoApi;
Purchase const & m_purchase;
};
} // namespace ads

View file

@ -3,6 +3,7 @@
#include "map/catalog_headers_provider.hpp"
#include "map/chart_generator.hpp"
#include "map/displayed_categories_modifiers.hpp"
#include "map/download_on_map_ads_delegate.hpp"
#include "map/everywhere_search_params.hpp"
#include "map/gps_tracker.hpp"
#include "map/notifications/notification_manager_delegate.hpp"
@ -516,7 +517,8 @@ Framework::Framework(FrameworkParams const & params)
m_isolinesManager.SetEnabled(LoadIsolinesEnabled());
m_adsEngine = make_unique<ads::Engine>();
m_adsEngine = make_unique<ads::Engine>(
make_unique<ads::DownloadOnMapDelegate>(*m_infoGetter, m_storage, *m_promoApi, *m_purchase));
InitTransliteration();
LOG(LDEBUG, ("Transliterators initialized"));
@ -556,6 +558,7 @@ Framework::~Framework()
// Must be destroyed implicitly at the start of destruction,
// since it stores raw pointers to other subsystems.
m_adsEngine.reset();
m_purchase.reset();
osm::Editor & editor = osm::Editor::Instance();
@ -2564,9 +2567,7 @@ std::optional<place_page::Info> Framework::BuildPlacePageInfo(
return {};
outInfo.SetBuildInfo(buildInfo);
if (m_purchase && !m_purchase->IsSubscriptionActive(SubscriptionType::RemoveAds))
outInfo.SetAdsEngine(m_adsEngine.get());
outInfo.SetAdsEngine(m_adsEngine.get());
if (buildInfo.IsUserMarkMatchingEnabled())
{

View file

@ -852,6 +852,7 @@ public:
private:
std::unique_ptr<search::CityFinder> m_cityFinder;
CachingAddressGetter m_addressGetter;
// Ads engine must be destroyed before Storage, CountryInfoGetter and Purchase.
std::unique_ptr<ads::Engine> m_adsEngine;
// The order matters here: storage::CountryInfoGetter and
// search::CityFinder must be initialized before

View file

@ -1,4 +1,5 @@
#include "map/place_page_info.hpp"
#include "map/bookmark_helpers.hpp"
#include "map/reachable_by_taxi_checker.hpp"

View file

@ -11,14 +11,24 @@ set(
ads/ads_utils.cpp
ads/ads_utils.hpp
ads/banner.hpp
ads/bookmark_catalog_ads.cpp
ads/bookmark_catalog_ads.hpp
ads/facebook_ads.cpp
ads/facebook_ads.hpp
ads/google_ads.cpp
ads/google_ads.hpp
ads/mopub_ads.cpp
ads/mopub_ads.hpp
ads/mts_ads.cpp
ads/mts_ads.hpp
ads/rb_ads.cpp
ads/rb_ads.hpp
ads/skyeng_ads.cpp
ads/skyeng_ads.hpp
ads/tinkoff_allairlines_ads.cpp
ads/tinkoff_allairlines_ads.hpp
ads/tinkoff_insurance_ads.cpp
ads/tinkoff_insurance_ads.hpp
booking_api.cpp
booking_api.hpp
booking_availability_params.cpp

View file

@ -38,10 +38,10 @@ void PoiContainer::AppendExcludedTypes(
}
std::string PoiContainer::GetBanner(feature::TypesHolder const & types,
storage::CountryId const & countryId,
storage::CountriesVec const & countryIds,
std::string const & userLanguage) const
{
if (!HasBanner(types, countryId, userLanguage))
if (!HasBanner(types, countryIds, userLanguage))
return {};
auto const it = m_typesToBanners.Find(types);
@ -57,10 +57,21 @@ std::string PoiContainer::GetBannerForOtherTypesForTesting() const
}
bool PoiContainer::HasBanner(feature::TypesHolder const & types,
storage::CountryId const & countryId,
storage::CountriesVec const & countryIds,
std::string const & userLanguage) const
{
return (IsCountrySupported(countryId) || IsLanguageSupported(userLanguage)) &&
auto const isCountryExcluded =
std::any_of(countryIds.begin(), countryIds.end(),
[this](auto const & id) { return IsCountryExcluded(id); });
if (isCountryExcluded)
return false;
auto isCountrySupported = std::any_of(countryIds.begin(), countryIds.end(),
[this](auto const & id) { return IsCountrySupported(id); });
// When all countries are not supported - check user`s language.
return (isCountrySupported || IsLanguageSupported(userLanguage)) &&
!m_excludedTypes.Contains(types);
}
@ -68,4 +79,45 @@ std::string PoiContainer::GetBannerForOtherTypes() const
{
return {};
}
DownloadOnMapContainer::DownloadOnMapContainer(Delegate & delegate)
: m_delegate(delegate)
{
}
std::string DownloadOnMapContainer::GetBanner(storage::CountryId const & mwmId,
m2::PointD const & userPos,
std::string const & userLanguage) const
{
if (!HasBanner(mwmId, userPos, userLanguage))
return {};
return GetBannerInternal();
}
bool DownloadOnMapContainer::HasBanner(storage::CountryId const & downloadMwmId,
m2::PointD const & userPos,
std::string const & userLanguage) const
{
auto const userPosMwm = m_delegate.GetCountryId(userPos);
auto userPosCountries = m_delegate.GetTopmostNodesFor(userPosMwm);
userPosCountries.push_back(userPosMwm);
auto downloadMwmCountries = m_delegate.GetTopmostNodesFor(downloadMwmId);
downloadMwmCountries.push_back(downloadMwmId);
return !std::any_of(userPosCountries.begin(), userPosCountries.end(),
[this](auto const & id) { return IsUserPosCountryExcluded(id); }) &&
!std::any_of(downloadMwmCountries.begin(), downloadMwmCountries.end(),
[this](auto const & id) { return IsCountryExcluded(id); }) &&
std::any_of(userPosCountries.begin(), userPosCountries.end(),
[this](auto const & id) { return IsUserPosCountrySupported(id); }) &&
std::any_of(downloadMwmCountries.begin(), downloadMwmCountries.end(),
[this](auto const & id) { return IsCountrySupported(id); }) &&
IsLanguageSupported(userLanguage);
}
std::string DownloadOnMapContainer::GetBannerInternal() const
{
return {};
}
} // namespace ads

View file

@ -26,35 +26,38 @@ class PoiContainerBase
public:
virtual ~PoiContainerBase() = default;
virtual std::string GetBanner(feature::TypesHolder const & types,
storage::CountryId const & countryId,
storage::CountriesVec const & countryIds,
std::string const & userLanguage) const = 0;
private:
virtual bool HasBanner(feature::TypesHolder const & types, storage::CountryId const & countryId,
virtual bool HasBanner(feature::TypesHolder const & types,
storage::CountriesVec const & countryIds,
std::string const & userLanguage) const = 0;
virtual std::string GetBannerForOtherTypes() const = 0;
};
// Class which matches feature types and banner ids.
class PoiContainer : public PoiContainerBase,
public WithSupportedLanguages,
public WithSupportedCountries
protected WithSupportedLanguages,
protected WithSupportedCountries
{
public:
PoiContainer();
// PoiContainerBase overrides:
std::string GetBanner(feature::TypesHolder const & types, storage::CountryId const & countryId,
std::string GetBanner(feature::TypesHolder const & types,
storage::CountriesVec const & countryIds,
std::string const & userLanguage) const override;
std::string GetBannerForOtherTypesForTesting() const;
protected:
void AppendEntry(std::initializer_list<std::initializer_list<char const *>> && types,
std::string const & id);
void AppendExcludedTypes(std::initializer_list<std::initializer_list<char const *>> && types);
private:
bool HasBanner(feature::TypesHolder const & types, storage::CountryId const & countryId,
bool HasBanner(feature::TypesHolder const & types, storage::CountriesVec const & countryIds,
std::string const & userLanguage) const override;
std::string GetBannerForOtherTypes() const override;
@ -77,4 +80,37 @@ private:
DISALLOW_COPY(SearchContainerBase);
};
class DownloadOnMapContainer : protected WithSupportedLanguages,
protected WithSupportedCountries,
protected WithSupportedUserPos
{
public:
class Delegate
{
public:
virtual ~Delegate() = default;
virtual storage::CountryId GetCountryId(m2::PointD const & pos) = 0;
virtual storage::CountriesVec GetTopmostNodesFor(storage::CountryId const & mwmId) const = 0;
virtual std::string GetMwmTopCityGeoId(storage::CountryId const & mwmId) const = 0;
virtual std::string GetLinkForGeoId(std::string const & id) const = 0;
};
DownloadOnMapContainer(Delegate & delegate);
virtual ~DownloadOnMapContainer() = default;
virtual std::string GetBanner(storage::CountryId const & mwmId, m2::PointD const & userPos,
std::string const & userLanguage) const;
protected:
Delegate & m_delegate;
private:
virtual bool HasBanner(storage::CountryId const & mwmId, m2::PointD const & userPos,
std::string const & userLanguage) const;
virtual std::string GetBannerInternal() const;
DISALLOW_COPY(DownloadOnMapContainer);
};
} // namespace ads

View file

@ -1,64 +1,86 @@
#include "partners_api/ads/ads_engine.hpp"
#include "partners_api/ads/bookmark_catalog_ads.hpp"
#include "partners_api/ads/facebook_ads.hpp"
#include "partners_api/ads/google_ads.hpp"
#include "partners_api/ads/mopub_ads.hpp"
#include "partners_api/ads/mts_ads.hpp"
#include "partners_api/ads/rb_ads.hpp"
#include "partners_api/ads/skyeng_ads.hpp"
#include "partners_api/ads/tinkoff_allairlines_ads.hpp"
#include "partners_api/ads/tinkoff_insurance_ads.hpp"
#include "indexer/feature_data.hpp"
#include <memory>
#include <utility>
namespace
{
template <typename T, typename... Args>
std::vector<ads::Banner> GetBanners(T const & bannerContainer, bool isAdsRemoved,
Args const &... params)
{
if (isAdsRemoved)
return {};
std::vector<ads::Banner> result;
for (auto const & item : bannerContainer)
{
if (!item.m_enabled)
continue;
auto const bannerId = item.m_container->GetBanner(params...);
if (!bannerId.empty())
{
result.emplace_back(item.m_type, bannerId);
}
}
return result;
}
} // namespace
namespace ads
{
Engine::Engine()
Engine::Engine(std::unique_ptr<Delegate> delegate)
: m_delegate(std::move(delegate))
{
ASSERT(m_delegate != nullptr, ());
// The banner systems are placed by priority. First has a top priority.
m_poiBanners.emplace_back(Banner::Type::RB, std::make_unique<Rb>());
m_poiBanners.emplace_back(Banner::Type::Mopub, std::make_unique<Mopub>());
m_searchBanners.emplace_back(Banner::Type::Facebook, std::make_unique<FacebookSearch>());
m_downloadOnMapBanners.emplace_back(Banner::Type::TinkoffAllAirlines,
std::make_unique<TinkoffAllAirlines>(*m_delegate));
m_downloadOnMapBanners.emplace_back(Banner::Type::TinkoffInsurance,
std::make_unique<TinkoffInsurance>(*m_delegate));
m_downloadOnMapBanners.emplace_back(Banner::Type::Mts, std::make_unique<Mts>(*m_delegate));
m_downloadOnMapBanners.emplace_back(Banner::Type::Skyeng, std::make_unique<Skyeng>(*m_delegate));
m_downloadOnMapBanners.emplace_back(Banner::Type::BookmarkCatalog,
std::make_unique<BookmarkCatalog>(*m_delegate));
}
std::vector<Banner> Engine::GetPoiBanners(feature::TypesHolder const & types,
storage::CountriesVec const & countryIds,
std::string const & userLanguage) const
{
std::vector<Banner> result;
for (auto const & item : m_poiBanners)
{
if (!item.m_enabled)
continue;
for (auto const & countryId : countryIds)
{
auto const bannerId = item.m_container->GetBanner(types, countryId, userLanguage);
// We need to add banner for every banner system just once.
if (!bannerId.empty())
{
result.emplace_back(item.m_type, bannerId);
break;
}
}
}
return result;
return GetBanners(m_poiBanners, m_delegate->IsAdsRemoved(), types, countryIds, userLanguage);
}
std::vector<Banner> Engine::GetSearchBanners() const
{
std::vector<Banner> result;
return GetBanners(m_searchBanners, m_delegate->IsAdsRemoved());
}
for (auto const & item : m_searchBanners)
{
auto const bannerId = item.m_container->GetBanner();
if (!bannerId.empty())
result.emplace_back(item.m_type, bannerId);
}
return result;
std::vector<Banner> Engine::GetDownloadOnMapBanners(storage::CountryId const & downloadMwmId,
m2::PointD const & userPos,
std::string const & userLanguage) const
{
return GetBanners(m_downloadOnMapBanners, m_delegate->IsAdsRemoved(), downloadMwmId, userPos,
userLanguage);
}
void Engine::DisableAdProvider(Banner::Type const type, Banner::Place const place)
@ -67,6 +89,8 @@ void Engine::DisableAdProvider(Banner::Type const type, Banner::Place const plac
{
case Banner::Place::Search: return SetAdProviderEnabled(m_searchBanners, type, false);
case Banner::Place::Poi: return SetAdProviderEnabled(m_poiBanners, type, false);
case Banner::Place::DownloadOnMap:
return SetAdProviderEnabled(m_downloadOnMapBanners, type, false);
}
}
} // namespace ads

View file

@ -17,12 +17,21 @@ namespace ads
class Engine
{
public:
Engine();
class Delegate : public DownloadOnMapContainer::Delegate
{
public:
virtual bool IsAdsRemoved() const = 0;
};
explicit Engine(std::unique_ptr<Delegate> delegate);
std::vector<Banner> GetPoiBanners(feature::TypesHolder const & types,
storage::CountriesVec const & countryIds,
std::string const & userLanguage) const;
std::vector<Banner> GetSearchBanners() const;
std::vector<Banner> GetDownloadOnMapBanners(storage::CountryId const & downloadMwmId,
m2::PointD const & userPos,
std::string const & userLanguage) const;
void DisableAdProvider(Banner::Type const type, Banner::Place const place);
@ -53,7 +62,10 @@ private:
}
}
std::unique_ptr<Delegate> m_delegate;
std::vector<ContainerItem<PoiContainerBase>> m_poiBanners;
std::vector<ContainerItem<SearchContainerBase>> m_searchBanners;
std::vector<ContainerItem<DownloadOnMapContainer>> m_downloadOnMapBanners;
};
} // namespace ads

View file

@ -28,9 +28,43 @@ void WithSupportedCountries::AppendSupportedCountries(
m_supportedCountries.insert(countries.begin(), countries.end());
}
void WithSupportedCountries::AppendExcludedCountries(
std::initializer_list<storage::CountryId> const & countries)
{
m_excludedCountries.insert(countries.begin(), countries.end());
}
bool WithSupportedCountries::IsCountrySupported(storage::CountryId const & countryId) const
{
return m_supportedCountries.empty() ||
m_supportedCountries.find(countryId) != m_supportedCountries.cend();
return m_excludedCountries.find(countryId) == m_excludedCountries.cend() &&
(m_supportedCountries.empty() ||
m_supportedCountries.find(countryId) != m_supportedCountries.cend());
}
bool WithSupportedCountries::IsCountryExcluded(storage::CountryId const & countryId) const
{
return m_excludedCountries.find(countryId) != m_excludedCountries.cend();
}
void WithSupportedUserPos::AppendSupportedUserPosCountries(
std::initializer_list<storage::CountryId> const & countries)
{
m_countries.AppendSupportedCountries(countries);
}
void WithSupportedUserPos::AppendExcludedUserPosCountries(
std::initializer_list<storage::CountryId> const & countries)
{
m_countries.AppendExcludedCountries(countries);
}
bool WithSupportedUserPos::IsUserPosCountrySupported(storage::CountryId const & countryId) const
{
return m_countries.IsCountrySupported(countryId);
}
bool WithSupportedUserPos::IsUserPosCountryExcluded(storage::CountryId const & countryId) const
{
return m_countries.IsCountryExcluded(countryId);
}
} // namespace ads

View file

@ -11,7 +11,7 @@ namespace ads
{
class WithSupportedLanguages
{
protected:
public:
virtual ~WithSupportedLanguages() = default;
void AppendSupportedUserLanguages(std::initializer_list<std::string> const & languages);
@ -23,14 +23,31 @@ private:
class WithSupportedCountries
{
protected:
public:
virtual ~WithSupportedCountries() = default;
void AppendSupportedCountries(std::initializer_list<storage::CountryId> const & countries);
void AppendExcludedCountries(std::initializer_list<storage::CountryId> const & countries);
bool IsCountrySupported(storage::CountryId const & countryId) const;
bool IsCountryExcluded(storage::CountryId const & countryId) const;
private:
// All countries are supported when empty.
std::unordered_set<storage::CountryId> m_supportedCountries;
std::unordered_set<storage::CountryId> m_excludedCountries;
};
class WithSupportedUserPos
{
public:
virtual ~WithSupportedUserPos() = default;
void AppendSupportedUserPosCountries(std::initializer_list<storage::CountryId> const & countries);
void AppendExcludedUserPosCountries(std::initializer_list<storage::CountryId> const & countries);
bool IsUserPosCountrySupported(storage::CountryId const & countryId) const;
bool IsUserPosCountryExcluded(storage::CountryId const & countryId) const;
private:
WithSupportedCountries m_countries;
};
} // namespace ads

View file

@ -12,6 +12,7 @@ struct Banner
{
Search = 0,
Poi = 1,
DownloadOnMap = 2,
};
enum class Type : uint8_t
@ -20,6 +21,11 @@ struct Banner
Facebook = 1,
RB = 2,
Mopub = 3,
TinkoffAllAirlines = 4,
TinkoffInsurance = 5,
Mts = 6,
Skyeng = 7,
BookmarkCatalog = 8,
};
Banner() = default;
@ -37,6 +43,11 @@ inline std::string DebugPrint(Banner::Type type)
case Banner::Type::Facebook: return "Facebook";
case Banner::Type::RB: return "RB";
case Banner::Type::Mopub: return "Mopub";
case Banner::Type::TinkoffAllAirlines: return "TinkoffAllAirlines";
case Banner::Type::TinkoffInsurance: return "TinkoffInsurance";
case Banner::Type::Mts: return "Mts";
case Banner::Type::Skyeng: return "Skyeng";
case Banner::Type::BookmarkCatalog: return "BookmarkCatalog";
}
UNREACHABLE();
}

View file

@ -0,0 +1,20 @@
#include "partners_api/ads/bookmark_catalog_ads.hpp"
namespace ads
{
BookmarkCatalog::BookmarkCatalog(Delegate & delegate)
: DownloadOnMapContainer(delegate)
{
}
std::string BookmarkCatalog::GetBanner(storage::CountryId const & mwmId, m2::PointD const & userPos,
std::string const & userLanguage) const
{
auto const cityGeoId = m_delegate.GetMwmTopCityGeoId(mwmId);
if (!cityGeoId.empty())
return m_delegate.GetLinkForGeoId(cityGeoId);
return {};
}
} // namespace ads

View file

@ -0,0 +1,15 @@
#pragma once
#include "partners_api/ads/ads_base.hpp"
namespace ads
{
class BookmarkCatalog : public DownloadOnMapContainer
{
public:
BookmarkCatalog(Delegate & delegate);
std::string GetBanner(storage::CountryId const & mwmId, m2::PointD const & userPos,
std::string const & userLanguage) const override;
};
} // namespace ads

View file

@ -0,0 +1,31 @@
#include "partners_api/ads/mts_ads.hpp"
namespace
{
std::initializer_list<std::string> const kSupportedLanguages = {"ru"};
std::initializer_list<storage::CountryId> const kSupportedCountries = {
"Italy", "France", "Germany", "Spain", "Ukraine", "Turkey",
"Belarus", "Thailand", "Portugal", "Cyprus", "Romania", "United Arab Emirates",
"Kazakhstan", "Montenegro", "Croatia", "Bulgaria", "South Korea", "Armenia",
"Israel", "Tunisia", "Egypt", "Saudi Arabia", "Kyrgyzstan", "Gibraltar"};
std::initializer_list<storage::CountryId> const kExcludedUserPosCountries = {"Russian Federation"};
} // namespace
namespace ads
{
Mts::Mts(Delegate & delegate)
: DownloadOnMapContainer(delegate)
{
AppendSupportedUserLanguages(kSupportedLanguages);
AppendSupportedCountries(kSupportedCountries);
AppendExcludedUserPosCountries(kExcludedUserPosCountries);
}
std::string Mts::GetBannerInternal() const
{
return "https://ad.adriver.ru/cgi-bin/click.cgi?"
"sid=1&bt=103&ad=694606&pid=3030352&bid=6563398&bn=6563398&rnd=1435429146";
}
} // namespace ads

View file

@ -0,0 +1,15 @@
#pragma once
#include "partners_api/ads/ads_base.hpp"
namespace ads
{
class Mts : public DownloadOnMapContainer
{
public:
Mts(Delegate & delegate);
private:
std::string GetBannerInternal() const override;
};
} // namespace ads

View file

@ -0,0 +1,280 @@
#include "partners_api/ads/skyeng_ads.hpp"
namespace
{
std::initializer_list<std::string> const kSupportedLanguages = {"ru"};
std::initializer_list<storage::CountryId> const kSupportedCountries = {
"Russia_Tatarstan",
"Russia_Voronezh Oblast",
"Russia_Tver Oblast",
"Russia_Tula Oblast",
"Russia_Kaliningrad Oblast",
"Russia_Smolensk Oblast",
"Russia_Bashkortostan",
"Russia_Stavropol Krai",
"Russia_Nizhny Novgorod Oblast",
"Russia_Samara Oblast",
"Russia_Chelyabinsk Oblast",
"Russia_Vladimir Oblast",
"Russia_Pskov Oblast",
"Russia_Novosibirsk Oblast",
"Russia_Kaluga Oblast",
"Russia_Yaroslavl Oblast",
"Russia_Novgorod Oblast",
"Russia_Lipetsk Oblast",
"Russia_Volgograd Oblast",
"Russia_Republic of Karelia_South",
"Russia_Perm Krai_South",
"Russia_Krasnoyarsk Krai_South",
"Russia_Saratov Oblast",
"Russia_Ryazan Oblast",
"Russia_Primorsky Krai",
"Russia_Kabardino-Balkaria",
"Russia_North Ossetia-Alania",
"Russia_Bryansk Oblast",
"Russia_Irkutsk Oblast",
"Russia_Ulyanovsk Oblast",
"Russia_Vologda Oblast",
"Russia_Kursk Oblast",
"Russia_Orenburg Oblast",
"Russia_Belgorod Oblast",
"Russia_Tyumen Oblast",
"Russia_Kemerov Oblast",
"Russia_Murmansk Oblast",
"Russia_Yugra_Surgut",
"Russia_Oryol Oblast",
"Russia_Altai Krai",
"Russia_Omsk Oblast",
"Russia_Sverdlovsk Oblast_North",
"Russia_Karachay-Cherkessia",
"Russia_Khabarovsk Krai",
"Russia_Udmurt Republic",
"Russia_Chuvashia",
"Russia_Republic of Dagestan",
"Russia_Penza Oblast",
"Russia_Arkhangelsk Oblast_Central",
"Russia_Tambov Oblast",
"Russia_Ivanovo Oblast",
"Russia_Kostroma Oblast",
"Russia_Kirov Oblast",
"Russia_Republic of Kalmykia",
"Russia_Tomsk Oblast",
"Russia_Kurgan Oblast",
"Russia_Astrakhan Oblast",
"Russia_Republic of Mordovia",
"Russia_Republic of Karelia_North",
"Russia_Mari El",
"Russia_Perm Krai_North",
"Russia_Buryatia",
"Russia_Komi Republic",
"Russia_Sakhalin Oblast",
"Russia_Altai Republic",
"Russia_Ingushetia",
"Russia_Yugra_Khanty",
"Russia_Chechen Republic",
"Russia_Yamalo-Nenets Autonomous Okrug",
"Russia_Sakha Republic",
"Russia_Kamchatka Krai",
"Russia_Amur Oblast",
"Russia_Zabaykalsky Krai",
"Russia_Khakassia",
"Russia_Arkhangelsk Oblast_North",
"Russia_Krasnoyarsk Krai_North",
"Russia_Jewish Autonomous Oblast",
"Russia_Magadan Oblast",
"Russia_Nenets Autonomous Okrug",
"Russia_Tuva",
"Russia_Chukotka Autonomous Okrug",
"US_Wyoming",
"US_Wisconsin_North",
"US_Wisconsin_Milwaukee",
"US_Wisconsin_Madison",
"US_Wisconsin_Eau Claire",
"US_West Virginia",
"US_Washington_Yakima",
"US_Washington_Seattle",
"US_Washington_Coast",
"US_Virginia_Roanoke",
"US_Virginia_Richmond",
"US_Virginia_Norfolk",
"US_Virginia_Lynchburg",
"US_Virginia_Alexandria",
"US_Vermont",
"US_Utah_South",
"US_Utah_North",
"US_United States Minor Outlying Islands",
"US_Texas_West",
"US_Texas_Wako",
"US_Texas_Victoria",
"US_Texas_Tyler",
"US_Texas_Southwest",
"US_Texas_San Antonio",
"US_Texas_Lubbock",
"US_Texas_Houston",
"US_Texas_Dallas",
"US_Texas_Austin",
"US_Texas_Amarillo",
"US_Tennessee_West",
"US_Tennessee_East",
"US_South Dakota",
"US_South Carolina_Florence",
"US_South Carolina_Columbia",
"US_South Carolina_Charleston",
"US_Rhode Island",
"US_Puerto Rico",
"US_Pennsylvania_Scranton",
"US_Pennsylvania_Reading",
"US_Pennsylvania_Pittsburgh",
"US_Pennsylvania_Central",
"US_Oregon_West",
"US_Oregon_Portland",
"US_Oregon_Eugene",
"US_Oklahoma_West",
"US_Oklahoma_Tulsa",
"US_Oklahoma_Oklahoma",
"US_Oklahoma_East",
"US_Ohio_Toledo",
"US_Ohio_Columbus",
"US_Ohio_Cleveland",
"US_Ohio_Cincinnati",
"US_North Dakota_Minot",
"US_North Dakota_East",
"US_North Dakota_Bismarck",
"US_North Carolina_Wilson",
"US_North Carolina_Wilmington",
"US_North Carolina_Raleigh",
"US_North Carolina_Greensboro",
"US_North Carolina_Charlotte",
"US_North Carolina_Asheville",
"US_New York_West",
"US_New York_North",
"US_New York_New York",
"US_New York_East",
"US_New Mexico_Roswell",
"US_New Mexico_Albuquerque",
"US_New Jersey_South",
"US_New Jersey_North",
"US_New Hampshire",
"US_Nevada",
"US_Nebraska_West",
"US_Nebraska_East",
"US_Montana_West",
"US_Montana_East",
"US_Missouri_St Louis",
"US_Missouri_Springfield",
"US_Missouri_Kansas",
"US_Missouri_East",
"US_Mississippi_North",
"US_Mississippi_Gulfport",
"US_Minnesota_Saint Cloud",
"US_Minnesota_Rochester",
"US_Minnesota_North",
"US_Minnesota_Minneapolis",
"US_Michigan_North",
"US_Michigan_Lansing",
"US_Michigan_Grand Rapids",
"US_Michigan_Detroit",
"US_Massachusetts_West",
"US_Massachusetts_Southeastern",
"US_Massachusetts_Plymouth",
"US_Massachusetts_Central",
"US_Massachusetts_Boston",
"US_Maryland_Baltimore",
"US_Maryland_and_DC",
"US_Maine",
"US_Louisiana_New Orleans",
"US_Louisiana_Central",
"US_Kentucky_West",
"US_Kentucky_Louisville",
"US_Kentucky_East",
"US_Kansas_Wichita",
"US_Kansas_West",
"US_Kansas_East",
"US_Iowa_West",
"US_Iowa_Waterloo",
"US_Iowa_Des Moines",
"US_Indiana_North",
"US_Indiana_Indianapolis",
"US_Indiana_Evansville",
"US_Illinois_Springfield",
"US_Illinois_South",
"US_Illinois_Rockford",
"US_Illinois_Elgin",
"US_Illinois_Chickago",
"US_Idaho_South",
"US_Idaho_North",
"US_Hawaii",
"US_Guam",
"US_Georgia_South",
"US_Georgia_North",
"US_Georgia_Macon",
"US_Georgia_Atlanta",
"US_Florida_Tampa",
"US_Florida_Orlando",
"US_Florida_Miami",
"US_Florida_Jacksonville",
"US_Florida_Gainesville",
"US_Delaware",
"US_Connecticut",
"US_Colorado_South",
"US_Colorado_Denver",
"US_Colorado_Aspen",
"US_California_Santa_Clara_Santa Cruz",
"US_California_Santa_Clara_Palo Alto",
"US_California_San Diego",
"US_California_Sacramento_Stockton",
"US_California_Sacramento_Sacramento",
"US_California_Sacramento_Fresno",
"US_California_Redding",
"US_California_LA North",
"US_California_LA",
"US_California_Chico",
"US_California_Bakersfield_Lancaster",
"US_California_Bakersfield_Bakersfield",
"US_Arkansas_South",
"US_Arkansas_North",
"US_Arizona_Tucson",
"US_Arizona_Phoenix",
"US_Arizona_Flagstaff",
"US_Alaska",
"US_Alabama_Montgomery",
"US_Alabama_Birmingham",
"UK_Wales",
"UK_Scotland_South",
"UK_Scotland_North",
"UK_Northern Ireland",
"UK_England_Yorkshire and the Humber",
"UK_England_West Midlands",
"UK_England_South West England_Cornwall",
"UK_England_South West England_Bristol",
"UK_England_South East_Oxford",
"UK_England_South East_Brighton",
"UK_England_North West England_Manchester",
"UK_England_North West England_Lancaster",
"UK_England_North East England",
"UK_England_Greater London",
"UK_England_East of England_Norfolk",
"UK_England_East of England_Essex",
"UK_England_East Midlands",
"Ireland_Northern Counties",
"Ireland_Munster",
"Ireland_Leinster",
"Ireland_Connacht"
};
} // namespace
namespace ads
{
Skyeng::Skyeng(Delegate & delegate)
: DownloadOnMapContainer(delegate)
{
AppendSupportedUserLanguages(kSupportedLanguages);
AppendSupportedCountries(kSupportedCountries);
}
std::string Skyeng::GetBannerInternal() const
{
return "http://promo.skyeng.ru/mapsme-adult";
}
} // namespace ads

View file

@ -0,0 +1,15 @@
#pragma once
#include "partners_api/ads/ads_base.hpp"
namespace ads
{
class Skyeng : public DownloadOnMapContainer
{
public:
Skyeng(Delegate & delegate);
private:
std::string GetBannerInternal() const override;
};
} // namespace ads

View file

@ -0,0 +1,199 @@
#include "partners_api/ads/tinkoff_allairlines_ads.hpp"
namespace
{
std::initializer_list<std::string> const kSupportedLanguages = {"ru"};
std::initializer_list<storage::CountryId> const kSupportedCountries = {
"Germany",
"Poland",
"Ukraine",
"Turkey",
"Finland",
"Belarus",
"China",
"Japan",
"Thailand",
"India",
"Switzerland",
"Norway",
"Belgium",
"Sweden",
"Georgia",
"Kazakhstan",
"South Ossetia",
"Armenia",
"Egypt",
"Argentina",
"Mongolia",
"Uzbekistan",
"Cambodia",
"Liechtenstein",
"Iceland",
"Myanmar",
"Taiwan",
"Saudi Arabia",
"Macedonia",
"Chile",
"Peru",
"Kyrgyzstan",
"Turkmenistan",
"Syria",
"Seychelles",
"Oman",
"Gibraltar",
"Pakistan",
"Qatar",
"Venezuela",
"New Zealand South",
"New Zealand North",
"Tajikistan",
"Colombia",
"Nagorno-Karabakh",
"The Bahamas",
"Republic of Kosovo",
"Antarctica",
"Iraq",
"North Korea",
"Laos",
"Mauritius",
"Algeria",
"British Indian Ocean Territory",
"Afghanistan",
"Ecuador",
"Bahrain",
"Sudan",
"Jamaica",
"Zimbabwe",
"Zambia",
"Yemen",
"Lebanon",
"Bolivia",
"Kuwait",
"Greenland",
"Kenya",
"Vanuatu",
"Panama",
"Uruguay",
"Madagascar",
"Tokelau",
"Haiti",
"Cameroon",
"Dominica",
"Faroe Islands",
"Costa Rica",
"Papua New Guinea",
"United States Virgin Islands",
"Congo-Kinshasa",
"Tonga",
"Uganda",
"Belize",
"Swaziland",
"Tuvalu",
"Nigeria",
"Namibia",
"South Sudan",
"Paraguay",
"Campo de Hielo Sur",
"The Gambia",
"Honduras",
"Cayman Islands",
"South Georgia and the South Sandwich Islands",
"Botswana",
"Bangladesh",
"Kingdom of Lesotho",
"Libya",
"Caribisch Nederland",
"Turks and Caicos Islands",
"Solomon Islands",
"East Timor",
"Senegal",
"Mali",
"Cape Verde",
"Barbados",
"Bermuda",
"Antigua and Barbuda",
"Martinique",
"Nauru",
"Saint Martin",
"Fiji",
"Guadeloupe",
"Jersey",
"Guernsey",
"Ethiopia",
"Grenada",
"Burundi",
"Sao Tome and Principe",
"Saint Lucia",
"Palau",
"Rwanda",
"Central African Republic",
"Nicaragua",
"Kiribati",
"Bhutan",
"Falkland Islands",
"Guatemala",
"Guinea-Bissau",
"Anguilla",
"Somalia",
"Pitcairn Islands",
"Mauritania",
"Montserrat",
"Niger",
"Liberia",
"Saint Kitts and Nevis",
"British Virgin Islands",
"Djibouti",
"Samoa",
"Saint Vincent and the Grenadines",
"Chad",
"Eritrea",
"Sierra Leone",
"Mozambique",
"Benin",
"Saint Barthelemy",
"Saint Helena Ascension and Tristan da Cunha",
"Marshall Islands",
"Brunei",
"Isle of Man",
"Guinea",
"Federated States of Micronesia",
"Niue",
"Comoros",
"Sahrawi Arab Democratic Republic",
"Congo-Brazzaville",
"Angola",
"Cook Islands",
"Suriname",
"Malawi",
"Willis Island",
"Trinidad and Tobago",
"Gabon",
"Togo",
"Equatorial Guinea",
"Guyana",
"Burkina Faso",
"El Salvador",
"Ghana",
"Cote dIvoire"
};
std::initializer_list<storage::CountryId> const kSupportedUserPosCountries = {"Russian Federation"};
} // namespace
namespace ads
{
TinkoffAllAirlines::TinkoffAllAirlines(Delegate & delegate)
: DownloadOnMapContainer(delegate)
{
AppendSupportedUserLanguages(kSupportedLanguages);
AppendSupportedCountries(kSupportedCountries);
AppendSupportedUserPosCountries(kSupportedUserPosCountries);
}
std::string TinkoffAllAirlines::GetBannerInternal() const
{
return "https://www.tinkoff.ru/cards/credit-cards/all-airlines/form/?"
"promo_code=MAPSME&utm_source=mapsme_allairlines&utm_medium=dsp.fix";
}
} // namespace ads

View file

@ -0,0 +1,15 @@
#pragma once
#include "partners_api/ads/ads_base.hpp"
namespace ads
{
class TinkoffAllAirlines : public DownloadOnMapContainer
{
public:
TinkoffAllAirlines(Delegate & delegate);
private:
std::string GetBannerInternal() const override;
};
} // namespace ads

View file

@ -0,0 +1,87 @@
#include "partners_api/ads/tinkoff_insurance_ads.hpp"
namespace
{
std::initializer_list<std::string> const kSupportedLanguages = {"ru"};
std::initializer_list<storage::CountryId> const kSupportedCountries = {
"France",
"Spain",
"Czech",
"Crimea",
"Netherlands",
"Austria",
"Greece",
"Slovakia",
"Estonia",
"Hungary",
"Lithuania",
"Abkhazia",
"Portugal",
"Latvia",
"Cyprus",
"Romania",
"Slovenia",
"Indonesia",
"Canada",
"Vietnam",
"United Arab Emirates",
"Montenegro",
"Croatia",
"Bulgaria",
"Denmark",
"South Korea",
"Brazil",
"Mexico",
"Philippines",
"Israel",
"South Africa",
"Azerbaijan",
"Serbia",
"Australia",
"Bosnia and Herzegovina",
"Morocco",
"Tunisia",
"Sri Lanka",
"Cuba",
"Iran",
"French Polynesia",
"Nepal",
"Ireland",
"Malaysia",
"Wallis and Futuna",
"San Marino",
"Monaco",
"Moldova",
"Singapore",
"Dominican Republic",
"Malta",
"Jordan",
"Palestine",
"Jerusalem",
"Maldives",
"Andorra",
"Tanzania",
"Luxembourg",
"Albania"
};
std::initializer_list<storage::CountryId> const kSupportedUserPosCountries = {"Russian Federation"};
} // namespace
namespace ads
{
TinkoffInsurance::TinkoffInsurance(Delegate & delegate)
: DownloadOnMapContainer(delegate)
{
AppendSupportedUserLanguages(kSupportedLanguages);
AppendSupportedCountries(kSupportedCountries);
AppendSupportedUserPosCountries(kSupportedUserPosCountries);
}
std::string TinkoffInsurance::GetBannerInternal() const
{
return "http://tinkoff.ru/insurance/travel/form/?"
"utm_source=mapsme_vzr&utm_medium=dsp.fix&has_promo=1&promo=MAPSME10";
}
} // namespace ads

View file

@ -0,0 +1,15 @@
#pragma once
#include "partners_api/ads/ads_base.hpp"
namespace ads
{
class TinkoffInsurance : public DownloadOnMapContainer
{
public:
TinkoffInsurance(Delegate & delegate);
private:
std::string GetBannerInternal() const override;
};
} // namespace ads

View file

@ -6,6 +6,8 @@ set(
SRC
ads_engine_tests.cpp
booking_tests.cpp
bookmark_catalog_ads_tests.cpp
download_on_map_container_delegate.hpp
facebook_tests.cpp
freenow_tests.cpp
google_tests.cpp
@ -14,12 +16,15 @@ set(
# Megafon project is disabled until the contract is renewed or extended.
# megafon_countries_tests.cpp
mopub_tests.cpp
mts_tests.cpp
promo_tests.cpp
rb_tests.cpp
rutaxi_tests.cpp
skyeng_tests.cpp
taxi_engine_tests.cpp
taxi_places_tests.cpp
# Uber taxi project is disabled.
tinkoff_airlines_tests.cpp
tinkoff_insurance_tests.cpp
# uber_tests.cpp
yandex_tests.cpp
)

View file

@ -10,8 +10,23 @@
#include "partners_api/ads/mopub_ads.hpp"
#include "partners_api/ads/rb_ads.hpp"
#include <memory>
namespace
{
class DummyDelegate : public ads::Engine::Delegate
{
public:
// ads::Engine::Delegate
bool IsAdsRemoved() const override { return false; }
// ads::DownloadOnMapContainer::Delegate
storage::CountryId GetCountryId(m2::PointD const & pos) override { return {}; }
storage::CountriesVec GetTopmostNodesFor(storage::CountryId const & mwmId) const override { return {}; };
std::string GetMwmTopCityGeoId(storage::CountryId const & mwmId) const override { return {}; };
std::string GetLinkForGeoId(std::string const & id) const override { return {}; };
};
void CheckCountAndTypes(std::vector<ads::Banner> const & banners)
{
TEST_EQUAL(banners.size(), 2, ());
@ -32,7 +47,7 @@ UNIT_TEST(AdsEngine_Smoke)
{
classificator::Load();
Classificator const & c = classif();
ads::Engine engine;
ads::Engine engine(std::make_unique<DummyDelegate>());
ads::Mopub mopub;
{
feature::TypesHolder holder;

View file

@ -0,0 +1,36 @@
#include "testing/testing.hpp"
#include "partners_api/partners_api_tests/download_on_map_container_delegate.hpp"
#include "partners_api/ads/bookmark_catalog_ads.hpp"
UNIT_TEST(BokmarkCatalogAds_GetBanner)
{
DownloadOnMapContainerDelegateForTesting delegate;
ads::BookmarkCatalog catalogAds(delegate);
{
delegate.SetTopCityGeoId("123");
delegate.SetLinkForGeoId("123");
auto const banner = catalogAds.GetBanner("", {}, "");
TEST(!banner.empty(), ());
}
{
delegate.SetTopCityGeoId("123");
delegate.SetLinkForGeoId("");
auto const banner = catalogAds.GetBanner("", {}, "");
TEST(banner.empty(), ());
}
{
delegate.SetTopCityGeoId("");
delegate.SetLinkForGeoId("123");
auto const banner = catalogAds.GetBanner("", {}, "");
TEST(banner.empty(), ());
}
{
delegate.SetTopCityGeoId("");
delegate.SetLinkForGeoId("");
auto const banner = catalogAds.GetBanner("", {}, "");
TEST(banner.empty(), ());
}
}

View file

@ -0,0 +1,40 @@
#pragma once
#include "partners_api/ads/ads_base.hpp"
#include "storage/storage_defines.hpp"
#include "geometry/point2d.hpp"
#include <string>
class DownloadOnMapContainerDelegateForTesting : public ads::DownloadOnMapContainer::Delegate
{
public:
void SetCountryId(storage::CountryId const & countryId) { m_countryId = countryId; }
void SetTopmostNodes(storage::CountriesVec const & topmostNodes)
{
m_topmostNodes = topmostNodes;
}
void SetTopCityGeoId(std::string const & topCityGeoId) { m_topCityGeoId = topCityGeoId; }
void SetLinkForGeoId(std::string const & linkForGeoId) { m_linkForGeoId = linkForGeoId; }
// ads::DownloadOnMapContainer::Delegate
storage::CountryId GetCountryId(m2::PointD const & pos) override { return m_countryId; }
storage::CountriesVec GetTopmostNodesFor(storage::CountryId const & mwmId) const override
{
return m_topmostNodes;
}
std::string GetMwmTopCityGeoId(storage::CountryId const & mwmId) const override
{
return m_topCityGeoId;
}
std::string GetLinkForGeoId(std::string const & id) const override { return m_linkForGeoId; }
private:
storage::CountryId m_countryId;
storage::CountriesVec m_topmostNodes;
std::string m_topCityGeoId;
std::string m_linkForGeoId;
};

View file

@ -1,11 +1,11 @@
#include "testing/testing.hpp"
#include "partners_api/ads/facebook_ads.hpp"
#include "indexer/classificator.hpp"
#include "indexer/classificator_loader.hpp"
#include "indexer/feature_data.hpp"
#include "partners_api/ads/facebook_ads.hpp"
namespace
{
UNIT_TEST(Facebook_BannerInSearch)
@ -23,41 +23,46 @@ UNIT_TEST(Facebook_GetBanner)
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "dentist"}));
TEST_EQUAL(facebook.GetBanner(holder, "Brazil", "ru"), facebook.GetBannerForOtherTypesForTesting(), ());
TEST_EQUAL(facebook.GetBanner(holder, {"Brazil"}, "ru"),
facebook.GetBannerForOtherTypesForTesting(), ());
holder.Add(c.GetTypeByPath({"amenity", "pub"}));
TEST_EQUAL(facebook.GetBanner(holder, "Cuba", "ru"), facebook.GetBannerForOtherTypesForTesting(), ());
TEST_EQUAL(facebook.GetBanner(holder, {"Cuba"}, "ru"),
facebook.GetBannerForOtherTypesForTesting(), ());
}
{
feature::TypesHolder holder;
holder.Add(c.GetTypeByPath({"amenity", "restaurant"}));
TEST_EQUAL(facebook.GetBanner(holder, "Any country", "ru"), facebook.GetBannerForOtherTypesForTesting(), ());
TEST_EQUAL(facebook.GetBanner(holder, {"Any country"}, "ru"),
facebook.GetBannerForOtherTypesForTesting(), ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"tourism", "information", "map"}));
TEST_EQUAL(facebook.GetBanner(holder, "Russia", "ru"), facebook.GetBannerForOtherTypesForTesting(), ());
TEST_EQUAL(facebook.GetBanner(holder, {"Russia"}, "ru"),
facebook.GetBannerForOtherTypesForTesting(), ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"shop", "ticket"}));
TEST_EQUAL(facebook.GetBanner(holder, "USA", "ru"), facebook.GetBannerForOtherTypesForTesting(), ());
TEST_EQUAL(facebook.GetBanner(holder, {"USA"}, "ru"),
facebook.GetBannerForOtherTypesForTesting(), ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "toilets"}));
auto const bannerId = facebook.GetBannerForOtherTypesForTesting();
TEST_EQUAL(facebook.GetBanner(holder, "Spain", "ru"), bannerId, ());
TEST_EQUAL(facebook.GetBanner(holder, {"Spain"}, "ru"), bannerId, ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"sponsored", "opentable"}));
auto const bannerId = facebook.GetBannerForOtherTypesForTesting();
TEST_EQUAL(facebook.GetBanner(holder, "Denmark", "ru"), bannerId, ());
TEST_EQUAL(facebook.GetBanner(holder, {"Denmark"}, "ru"), bannerId, ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"sponsored", "booking"}));
TEST_EQUAL(facebook.GetBanner(holder, "India", "ru"), "", ());
TEST_EQUAL(facebook.GetBanner(holder, {"India"}, "ru"), "", ());
}
}
} // namespace

View file

@ -16,49 +16,49 @@ UNIT_TEST(Mopub_GetBanner)
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "dentist"}));
TEST_EQUAL(mopub.GetBanner(holder, "Brazil", "ru"), mopub.GetBannerForOtherTypesForTesting(), ());
TEST_EQUAL(mopub.GetBanner(holder, {"Brazil"}, "ru"), mopub.GetBannerForOtherTypesForTesting(), ());
holder.Add(c.GetTypeByPath({"amenity", "pub"}));
TEST_EQUAL(mopub.GetBanner(holder, "Cuba", "ru"), mopub.GetBannerForOtherTypesForTesting(), ());
TEST_EQUAL(mopub.GetBanner(holder, {"Cuba"}, "ru"), mopub.GetBannerForOtherTypesForTesting(), ());
}
{
feature::TypesHolder holder;
holder.Add(c.GetTypeByPath({"amenity", "restaurant"}));
TEST_EQUAL(mopub.GetBanner(holder, "Any country", "ru"), "d298f205fb8a47aaafb514d2b5b8cf55", ());
TEST_EQUAL(mopub.GetBanner(holder, {"Any country"}, "ru"), "d298f205fb8a47aaafb514d2b5b8cf55", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"tourism", "information", "map"}));
TEST_EQUAL(mopub.GetBanner(holder, "Russia", "ru"), "d298f205fb8a47aaafb514d2b5b8cf55", ());
TEST_EQUAL(mopub.GetBanner(holder, {"Russia"}, "ru"), "d298f205fb8a47aaafb514d2b5b8cf55", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"highway", "speed_camera"}));
TEST_EQUAL(mopub.GetBanner(holder, "Egypt", "ru"), "fbd54c31a20347a6b5d6654510c542a4", ());
TEST_EQUAL(mopub.GetBanner(holder, {"Egypt"}, "ru"), "fbd54c31a20347a6b5d6654510c542a4", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"building"}));
TEST_EQUAL(mopub.GetBanner(holder, "Russia", "ru"), "fbd54c31a20347a6b5d6654510c542a4", ());
TEST_EQUAL(mopub.GetBanner(holder, {"Russia"}, "ru"), "fbd54c31a20347a6b5d6654510c542a4", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"shop", "ticket"}));
TEST_EQUAL(mopub.GetBanner(holder, "USA", "ru"), "d298f205fb8a47aaafb514d2b5b8cf55", ());
TEST_EQUAL(mopub.GetBanner(holder, {"USA"}, "ru"), "d298f205fb8a47aaafb514d2b5b8cf55", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "toilets"}));
TEST_EQUAL(mopub.GetBanner(holder, "Spain", "ru"), mopub.GetBannerForOtherTypesForTesting(), ());
TEST_EQUAL(mopub.GetBanner(holder, {"Spain"}, "ru"), mopub.GetBannerForOtherTypesForTesting(), ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"sponsored", "opentable"}));
TEST_EQUAL(mopub.GetBanner(holder, "Denmark", "ru"), mopub.GetBannerForOtherTypesForTesting(), ());
TEST_EQUAL(mopub.GetBanner(holder, {"Denmark"}, "ru"), mopub.GetBannerForOtherTypesForTesting(), ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"sponsored", "booking"}));
TEST_EQUAL(mopub.GetBanner(holder, "India", "ru"), "", ());
TEST_EQUAL(mopub.GetBanner(holder, {"India"}, "ru"), "", ());
}
}
} // namespace

View file

@ -0,0 +1,40 @@
#include "testing/testing.hpp"
#include "partners_api/partners_api_tests/download_on_map_container_delegate.hpp"
#include "partners_api/ads/mts_ads.hpp"
UNIT_TEST(Mts_GetBanner)
{
DownloadOnMapContainerDelegateForTesting delegate;
ads::Mts mts(delegate);
{
delegate.SetTopmostNodes({"France"});
auto const banner = mts.GetBanner("", {}, "ru");
TEST(!banner.empty(), ());
}
{
delegate.SetTopmostNodes({"France"});
auto const banner = mts.GetBanner("", {}, "en");
TEST(banner.empty(), ());
}
{
delegate.SetTopmostNodes({"France"});
delegate.SetCountryId("Russian Federation");
auto const banner = mts.GetBanner("", {}, "ru");
TEST(banner.empty(), ());
}
{
delegate.SetTopmostNodes({"France", "Thailand"});
delegate.SetCountryId("Russian Federation");
auto const banner = mts.GetBanner("", {}, "ru");
TEST(banner.empty(), ());
}
{
delegate.SetTopmostNodes({"France", "Thailand"});
delegate.SetCountryId("Cote dIvoire");
auto const banner = mts.GetBanner("", {}, "ru");
TEST(!banner.empty(), ());
}
}

View file

@ -16,66 +16,66 @@ UNIT_TEST(Rb_GetBanner)
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "dentist"}));
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), "7", ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), "7", ());
holder.Add(c.GetTypeByPath({"amenity", "pub"}));
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), "7", ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), "7", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "restaurant"}));
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), "1", ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), "1", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"tourism", "information", "map"}));
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), "5", ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), "5", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"shop", "ticket"}));
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), "2", ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), "2", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "bank"}));
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), "8", ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), "8", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "atm"}));
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), "8", ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), "8", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "bureau_de_change"}));
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), "8", ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), "8", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "atm"}));
TEST_EQUAL(rb.GetBanner(holder, "Brazil", "en"), "", ());
TEST_EQUAL(rb.GetBanner(holder, {"Brazil"}, "en"), "", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"amenity", "toilets"}));
auto const bannerId = rb.GetBannerForOtherTypesForTesting();
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), bannerId, ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), bannerId, ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"sponsored", "opentable"}));
auto const bannerId = rb.GetBannerForOtherTypesForTesting();
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), bannerId, ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), bannerId, ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"sponsored", "opentable"}));
TEST_EQUAL(rb.GetBanner(holder, "Brazil", "ru"), "14", ());
TEST_EQUAL(rb.GetBanner(holder, {"Brazil"}, "ru"), "14", ());
}
{
feature::TypesHolder holder;
holder.Assign(c.GetTypeByPath({"sponsored", "booking"}));
TEST_EQUAL(rb.GetBanner(holder, "Russian Federation", "ru"), "", ());
TEST_EQUAL(rb.GetBanner(holder, {"Russian Federation"}, "ru"), "", ());
}
}
} // namespace

View file

@ -0,0 +1,44 @@
#include "testing/testing.hpp"
#include "partners_api/partners_api_tests/download_on_map_container_delegate.hpp"
#include "partners_api/ads/skyeng_ads.hpp"
UNIT_TEST(Skyeng_GetBanner)
{
DownloadOnMapContainerDelegateForTesting delegate;
ads::Skyeng skyeng(delegate);
{
auto const banner = skyeng.GetBanner("Russia_Tambov Oblast", {}, "ru");
TEST(!banner.empty(), ());
}
{
auto const banner = skyeng.GetBanner("US_North Carolina_Raleigh", {}, "ru");
TEST(!banner.empty(), ());
}
{
auto const banner = skyeng.GetBanner("Russia_Tambov Oblast", {}, "en");
TEST(banner.empty(), ());
}
{
auto const banner = skyeng.GetBanner("US_North Carolina_Raleigh", {}, "en");
TEST(banner.empty(), ());
}
{
auto const banner = skyeng.GetBanner("Russia_Moscow", {}, "ru");
TEST(banner.empty(), ());
}
{
auto const banner = skyeng.GetBanner("Cote dIvoire", {}, "ru");
TEST(banner.empty(), ());
}
{
auto const banner = skyeng.GetBanner("Russia_Moscow", {}, "en");
TEST(banner.empty(), ());
}
{
auto const banner = skyeng.GetBanner("Cote dIvoire", {}, "en");
TEST(banner.empty(), ());
}
}

View file

@ -0,0 +1,39 @@
#include "testing/testing.hpp"
#include "partners_api/partners_api_tests/download_on_map_container_delegate.hpp"
#include "partners_api/ads/tinkoff_allairlines_ads.hpp"
UNIT_TEST(TinkoffAirlines_GetBanner)
{
DownloadOnMapContainerDelegateForTesting delegate;
ads::TinkoffAllAirlines tinkoffAirlines(delegate);
{
delegate.SetTopmostNodes({"Germany", "Russian Federation"});
auto const banner = tinkoffAirlines.GetBanner("", {}, "ru");
TEST(!banner.empty(), ());
}
{
delegate.SetTopmostNodes({"Germany", "Russian Federation"});
auto const banner = tinkoffAirlines.GetBanner("", {}, "en");
TEST(banner.empty(), ());
}
{
delegate.SetTopmostNodes({"Germany", "Cote dIvoire"});
auto const banner = tinkoffAirlines.GetBanner("", {}, "ru");
TEST(banner.empty(), ());
}
{
delegate.SetTopmostNodes({"Norway"});
delegate.SetCountryId("Russian Federation");
auto const banner = tinkoffAirlines.GetBanner("", {}, "ru");
TEST(!banner.empty(), ());
}
{
delegate.SetTopmostNodes({"Norway"});
delegate.SetCountryId("Ukraine");
auto const banner = tinkoffAirlines.GetBanner("", {}, "ru");
TEST(banner.empty(), ());
}
}

View file

@ -0,0 +1,39 @@
#include "testing/testing.hpp"
#include "partners_api/partners_api_tests/download_on_map_container_delegate.hpp"
#include "partners_api/ads/tinkoff_insurance_ads.hpp"
UNIT_TEST(TinkoffInsurance_GetBanner)
{
DownloadOnMapContainerDelegateForTesting delegate;
ads::TinkoffInsurance tinkoffInsurance(delegate);
{
delegate.SetTopmostNodes({"France", "Russian Federation"});
auto const banner = tinkoffInsurance.GetBanner("", {}, "ru");
TEST(!banner.empty(), ());
}
{
delegate.SetTopmostNodes({"France", "Russian Federation"});
auto const banner = tinkoffInsurance.GetBanner("", {}, "en");
TEST(banner.empty(), ());
}
{
delegate.SetTopmostNodes({"France", "Cote dIvoire"});
auto const banner = tinkoffInsurance.GetBanner("", {}, "ru");
TEST(banner.empty(), ());
}
{
delegate.SetTopmostNodes({"Nepal"});
delegate.SetCountryId("Russian Federation");
auto const banner = tinkoffInsurance.GetBanner("", {}, "ru");
TEST(!banner.empty(), ());
}
{
delegate.SetTopmostNodes({"Nepal"});
delegate.SetCountryId("Norway");
auto const banner = tinkoffInsurance.GetBanner("", {}, "ru");
TEST(banner.empty(), ());
}
}