diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2017-11-14 15:24:18 +0300 |
---|---|---|
committer | Yuri Gorshenin <mipt.vi002@gmail.com> | 2017-11-16 15:58:07 +0300 |
commit | 1c214d57ce56ebe61672421abd4f5c25d6cbfa0b (patch) | |
tree | 1267ae1f3670aeffda590f6a8751185c5271a31d /indexer/indexer_tests_support | |
parent | 19e5ece8cdade7b6be065faed937c31480869f2b (diff) |
[booking] tests are unified + sponsored search mode + fix xcode build
Diffstat (limited to 'indexer/indexer_tests_support')
3 files changed, 3 insertions, 119 deletions
diff --git a/indexer/indexer_tests_support/test_mwm_environment.cpp b/indexer/indexer_tests_support/test_mwm_environment.cpp deleted file mode 100644 index ca686ef114..0000000000 --- a/indexer/indexer_tests_support/test_mwm_environment.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "indexer/indexer_tests_support/test_mwm_environment.hpp" - -#include <indexer/classificator_loader.hpp> - -namespace indexer -{ -namespace tests_support -{ -TestMwmEnvironment::TestMwmEnvironment() { classificator::Load(); } - -TestMwmEnvironment::~TestMwmEnvironment() -{ - for (auto const & file : m_mwmFiles) - Cleanup(file); -} - -void TestMwmEnvironment::Cleanup(platform::LocalCountryFile const & map) -{ - platform::CountryIndexes::DeleteFromDisk(map); - map.DeleteFromDisk(MapOptions::Map); -} - -bool TestMwmEnvironment::RemoveMwm(MwmSet::MwmId const & mwmId) -{ - auto const & file = mwmId.GetInfo()->GetLocalFile(); - auto const it = find(m_mwmFiles.begin(), m_mwmFiles.end(), file); - - if (it == m_mwmFiles.end()) - return false; - - Cleanup(*it); - m_mwmFiles.erase(it); - return true; -} -} // namespace tests_support -} // namespace indexer diff --git a/indexer/indexer_tests_support/test_mwm_environment.hpp b/indexer/indexer_tests_support/test_mwm_environment.hpp deleted file mode 100644 index 272c26a824..0000000000 --- a/indexer/indexer_tests_support/test_mwm_environment.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once - -#include "generator/generator_tests_support/test_feature.hpp" -#include "generator/generator_tests_support/test_mwm_builder.hpp" - -#include "platform/local_country_file_utils.hpp" - -#include "storage/country_info_getter.hpp" - -#include <indexer/index.hpp> - -#include <vector> - -namespace indexer -{ -namespace tests_support -{ -class TestMwmEnvironment -{ -public: - using MwmList = std::vector<platform::LocalCountryFile>; - - TestMwmEnvironment(); - ~TestMwmEnvironment(); - - template <typename TBuildFn> - MwmSet::MwmId BuildMwm(string const & name, TBuildFn && fn, int64_t version = 0) - { - m_mwmFiles.emplace_back(GetPlatform().WritableDir(), platform::CountryFile(name), version); - auto & file = m_mwmFiles.back(); - Cleanup(file); - - { - generator::tests_support::TestMwmBuilder builder(file, feature::DataHeader::country); - fn(builder); - } - - auto result = m_index.RegisterMap(file); - CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ()); - - auto const & id = result.first; - - auto const & info = id.GetInfo(); - if (info) - m_infoGetter.AddCountry(storage::CountryDef(name, info->m_limitRect)); - - CHECK(id.IsAlive(), ()); - - return id; - } - - template <typename Checker> - FeatureID FeatureIdForPoint(m2::PointD const & mercator, Checker const & checker) - { - m2::RectD const rect = - MercatorBounds::RectByCenterXYAndSizeInMeters(mercator, 0.2 /* rect width */); - FeatureID id; - auto const fn = [&id, &checker](FeatureType const & featureType) - { - if (checker(featureType)) - id = featureType.GetID(); - }; - m_index.ForEachInRect(fn, rect, scales::GetUpperScale()); - CHECK(id.IsValid(), ()); - return id; - } - - void Cleanup(platform::LocalCountryFile const & map); - bool RemoveMwm(MwmSet::MwmId const & mwmId); - - Index & GetIndex() { return m_index; } - Index const & GetIndex() const { return m_index; } - - MwmList & GetMwms() { return m_mwmFiles; } - MwmList const & GetMwms() const { return m_mwmFiles; } - -private: - Index m_index; - storage::CountryInfoGetterForTesting m_infoGetter; - MwmList m_mwmFiles; -}; -} // namespace tests_support -} // namespace indexer diff --git a/indexer/indexer_tests_support/test_with_custom_mwms.hpp b/indexer/indexer_tests_support/test_with_custom_mwms.hpp index 9fbc81614b..a1066cdea3 100644 --- a/indexer/indexer_tests_support/test_with_custom_mwms.hpp +++ b/indexer/indexer_tests_support/test_with_custom_mwms.hpp @@ -69,6 +69,9 @@ public: return BuildMwm(name, feature::DataHeader::country, std::forward<BuildFn>(fn)); } + Index & GetIndex() { return m_index; } + Index const & GetIndex() const { return m_index; } + protected: static void Cleanup(platform::LocalCountryFile const & file); |