diff options
author | tatiana-yan <tatiana.kondakova@gmail.com> | 2018-07-25 17:14:11 +0300 |
---|---|---|
committer | Sergey Yershov <syershov@maps.me> | 2018-07-25 18:00:19 +0300 |
commit | 4e146ec1ed8f8aed0d07ab6f0fe49d067b4c9901 (patch) | |
tree | f10a4efbfa9fddf58eb2bf8c4a5411d0541227b6 /editor | |
parent | 279dda49d08a301e0cf5da9e5789e95cd0f9addd (diff) |
[editor] Test count features by EditableDataSorce
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_tests/osm_editor_test.cpp | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/editor/editor_tests/osm_editor_test.cpp b/editor/editor_tests/osm_editor_test.cpp index b90d892d9c..97a9907c50 100644 --- a/editor/editor_tests/osm_editor_test.cpp +++ b/editor/editor_tests/osm_editor_test.cpp @@ -12,6 +12,7 @@ #include "indexer/data_source_helpers.hpp" #include "indexer/feature_source.hpp" #include "indexer/ftypes_matcher.hpp" +#include "indexer/scales.hpp" #include "platform/platform_tests_support/scoped_file.hpp" @@ -127,6 +128,15 @@ uint32_t CountFeaturesInRect(MwmSet::MwmId const & mwmId, m2::RectD const & rect return counter; } + +uint32_t CountFeatureTypeInRectByDataSource(DataSource const & dataSource, m2::RectD const & rect) +{ + auto const scale = scales::GetUpperScale(); + uint32_t counter = 0; + dataSource.ForEachInRect([&counter](FeatureType const &) { ++counter; }, rect, scale); + + return counter; +} } // namespace namespace editor @@ -748,27 +758,58 @@ void EditorTest::ForEachFeatureInMwmRectAndScaleTest() { auto const mwmId = ConstructTestMwm([](TestMwmBuilder & builder) { - builder.Add(TestCafe(m2::PointD(1.0, 1.0), "London Cafe", "en")); + builder.Add(TestCafe(m2::PointD(1.0, 1.0), "Untouched Cafe", "en")); + builder.Add(TestCafe(m2::PointD(3.0, 3.0), "Cafe to modify", "en")); + builder.Add(TestCafe(m2::PointD(5.0, 5.0), "Cafe to delete", "en")); - builder.Add(TestPOI(m2::PointD(100, 100), "Corner Post", "default")); + builder.Add(TestPOI(m2::PointD(100.0, 100.0), "Corner Post", "default")); }); + ForEachCafeAtPoint(m_dataSource, m2::PointD(3.0, 3.0), [](FeatureType & ft) { + auto & editor = osm::Editor::Instance(); + TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Untouched, ()); + osm::EditableMapObject emo; - CreateCafeAtPoint({10.0, 10.0}, mwmId, emo); - } + FillEditableMapObject(editor, ft, emo); + emo.SetBuildingLevels("1"); + TEST_EQUAL(editor.SaveEditedFeature(emo), osm::Editor::SaveResult::SavedSuccessfully, ()); + TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Modified, ()); + }); + + ForEachCafeAtPoint(m_dataSource, m2::PointD(5.0, 5.0), [](FeatureType & ft) + { + auto & editor = osm::Editor::Instance(); + TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Untouched, ()); + editor.DeleteFeature(ft.GetID()); + TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Deleted, ()); + }); + { osm::EditableMapObject emo; - CreateCafeAtPoint({20.0, 20.0}, mwmId, emo); + CreateCafeAtPoint({7.0, 7.0}, mwmId, emo); } + { osm::EditableMapObject emo; - CreateCafeAtPoint({22.0, 22.0}, mwmId, emo); + CreateCafeAtPoint({9.0, 9.0}, mwmId, emo); } + // Finds created features only. TEST_EQUAL(CountFeaturesInRect(mwmId, {0.0, 0.0, 2.0, 2.0}), 0, ()); - TEST_EQUAL(CountFeaturesInRect(mwmId, {9.0, 9.0, 21.0, 21.0}), 2, ()); - TEST_EQUAL(CountFeaturesInRect(mwmId, {9.0, 9.0, 23.0, 23.0}), 3, ()); + TEST_EQUAL(CountFeaturesInRect(mwmId, {2.0, 2.0, 4.0, 4.0}), 0, ()); + TEST_EQUAL(CountFeaturesInRect(mwmId, {4.0, 4.0, 6.0, 6.0}), 0, ()); + TEST_EQUAL(CountFeaturesInRect(mwmId, {6.0, 6.0, 8.0, 8.0}), 1, ()); + TEST_EQUAL(CountFeaturesInRect(mwmId, {8.0, 8.0, 10.0, 10.0}), 1, ()); + TEST_EQUAL(CountFeaturesInRect(mwmId, {0.0, 0.0, 10.0, 10.0}), 2, ()); + + // Finds all features except deleted. + TEST_EQUAL(CountFeatureTypeInRectByDataSource(m_dataSource, {0.0, 0.0, 2.0, 2.0}), 1, ()); + TEST_EQUAL(CountFeatureTypeInRectByDataSource(m_dataSource, {2.0, 2.0, 4.0, 4.0}), 1, ()); + TEST_EQUAL(CountFeatureTypeInRectByDataSource(m_dataSource, {4.0, 4.0, 6.0, 6.0}), 0, ()); + TEST_EQUAL(CountFeatureTypeInRectByDataSource(m_dataSource, {6.0, 6.0, 8.0, 8.0}), 1, ()); + TEST_EQUAL(CountFeatureTypeInRectByDataSource(m_dataSource, {8.0, 8.0, 10.0, 10.0}), 1, ()); + TEST_EQUAL(CountFeatureTypeInRectByDataSource(m_dataSource, {0.0, 0.0, 10.0, 10.0}), 4, ()); } void EditorTest::CreateNoteTest() |