forked from organicmaps/organicmaps
Merge pull request #3361 from ygorshenin/tests-for-common-categories
[search] Added a couple of tests for common categories.
This commit is contained in:
commit
fa50703e5e
5 changed files with 37 additions and 8 deletions
|
@ -167,7 +167,7 @@ void TestPOI::Serialize(FeatureBuilder1 & fb) const
|
|||
auto const & classificator = classif();
|
||||
|
||||
for (auto const & path : m_types)
|
||||
fb.SetType(classificator.GetTypeByPath(path));
|
||||
fb.AddType(classificator.GetTypeByPath(path));
|
||||
|
||||
if (!m_houseNumber.empty())
|
||||
fb.AddHouseNumber(m_houseNumber);
|
||||
|
|
|
@ -48,12 +48,20 @@ bool TestMwmBuilder::Add(FeatureBuilder1 & fb)
|
|||
{
|
||||
CHECK(m_collector, ("It's not possible to add features after call to Finish()."));
|
||||
|
||||
if (fb.PreSerialize() && fb.RemoveInvalidTypes())
|
||||
if (!fb.PreSerialize())
|
||||
{
|
||||
(*m_collector)(fb);
|
||||
return true;
|
||||
LOG(LWARNING, ("Can't pre-serialize feature."));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (!fb.RemoveInvalidTypes())
|
||||
{
|
||||
LOG(LWARNING, ("No types."));
|
||||
return false;
|
||||
}
|
||||
|
||||
(*m_collector)(fb);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TestMwmBuilder::Finish()
|
||||
|
|
|
@ -3,12 +3,23 @@
|
|||
#include "search/processor_factory.hpp"
|
||||
#include "search/search_tests_support/test_search_request.hpp"
|
||||
|
||||
#include "indexer/classificator_loader.hpp"
|
||||
#include "indexer/map_style.hpp"
|
||||
#include "indexer/map_style_reader.hpp"
|
||||
#include "indexer/scales.hpp"
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
namespace search
|
||||
{
|
||||
// TestWithClassificator ---------------------------------------------------------------------------
|
||||
TestWithClassificator::TestWithClassificator()
|
||||
{
|
||||
GetStyleReader().SetCurrentStyle(MapStyleMerged);
|
||||
classificator::Load();
|
||||
}
|
||||
|
||||
// SearchTest --------------------------------------------------------------------------------------
|
||||
SearchTest::SearchTest()
|
||||
: m_platform(GetPlatform())
|
||||
, m_scopedLog(LDEBUG)
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "storage/country_decl.hpp"
|
||||
#include "storage/country_info_getter.hpp"
|
||||
|
||||
#include "indexer/classificator_loader.hpp"
|
||||
#include "indexer/mwm_set.hpp"
|
||||
|
||||
#include "geometry/rect2d.hpp"
|
||||
|
@ -29,7 +28,7 @@ namespace search
|
|||
class TestWithClassificator
|
||||
{
|
||||
public:
|
||||
TestWithClassificator() { classificator::Load(); }
|
||||
TestWithClassificator();
|
||||
};
|
||||
|
||||
class SearchTest : public TestWithClassificator
|
||||
|
|
|
@ -477,15 +477,23 @@ UNIT_CLASS_TEST(ProcessorV2Test, TestCategories)
|
|||
TestPOI busStop(m2::PointD(0.00005, 0.0005), "ATM Bus Stop", "en");
|
||||
busStop.SetTypes({{"highway", "bus_stop"}});
|
||||
|
||||
TestPOI cafe(m2::PointD(0.0001, 0.0001), "Cafe", "en");
|
||||
cafe.SetTypes({{"amenity", "cafe"}, {"internet_access", "wlan"}});
|
||||
|
||||
TestPOI toi(m2::PointD(0.0001, 0.0001), "", "en");
|
||||
toi.SetTypes({{"amenity", "toilets"}});
|
||||
|
||||
BuildWorld([&](TestMwmBuilder & builder)
|
||||
{
|
||||
builder.Add(sanFrancisco);
|
||||
});
|
||||
auto wonderlandId = BuildCountry(countryName, [&](TestMwmBuilder & builder)
|
||||
{
|
||||
builder.Add(busStop);
|
||||
builder.Add(cafe);
|
||||
builder.Add(named);
|
||||
builder.Add(noname);
|
||||
builder.Add(busStop);
|
||||
builder.Add(toi);
|
||||
});
|
||||
|
||||
SetViewport(m2::RectD(m2::PointD(-0.5, -0.5), m2::PointD(0.5, 0.5)));
|
||||
|
@ -535,6 +543,9 @@ UNIT_CLASS_TEST(ProcessorV2Test, TestCategories)
|
|||
|
||||
// Tests that inexistent hashtagged categories do not crash.
|
||||
TEST(ResultsMatch("#void-", TRules{}), ());
|
||||
|
||||
TEST(ResultsMatch("wifi", {ExactMatch(wonderlandId, cafe)}), ());
|
||||
TEST(ResultsMatch("toilet", {ExactMatch(wonderlandId, toi)}), ());
|
||||
}
|
||||
} // namespace
|
||||
} // namespace search
|
||||
|
|
Loading…
Add table
Reference in a new issue