| 270 | } |
| 271 | |
| 272 | void EditorTest::SetIndexTest() |
| 273 | { |
| 274 | // osm::Editor::SetIndex was called in constructor. |
| 275 | auto & editor = osm::Editor::Instance(); |
| 276 | |
| 277 | auto const gbMwmId = BuildMwm("GB", [](TestMwmBuilder & builder) |
| 278 | { |
| 279 | TestCafe cafe({1.0, 1.0}, "London Cafe", "en"); |
| 280 | TestStreet street({{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}}, "Test street", "en"); |
| 281 | cafe.SetStreetName(street.GetName("en")); |
| 282 | builder.Add(street); |
| 283 | builder.Add(cafe); |
| 284 | builder.Add(TestCafe({3.0, 3.0}, "London Cafe", "en")); |
| 285 | builder.Add(TestCafe({4.0, 4.0}, "London Cafe", "en")); |
| 286 | builder.Add(TestCafe({4.0, 4.0}, "London Cafe", "en")); |
| 287 | builder.Add(TestCafe({4.0, 4.0}, "London Cafe", "en")); |
| 288 | }); |
| 289 | |
| 290 | auto const mwmId = editor.GetMwmIdByMapName("GB"); |
| 291 | |
| 292 | TEST_EQUAL(gbMwmId, mwmId, ()); |
| 293 | |
| 294 | osm::EditableMapObject emo; |
| 295 | CreateCafeAtPoint({2.0, 2.0}, gbMwmId, emo); |
| 296 | |
| 297 | ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) |
| 298 | { |
| 299 | auto const firstPtr = editor.GetOriginalMapObject(ft.GetID()); |
| 300 | TEST(firstPtr, ()); |
| 301 | SetBuildingLevelsToOne(ft); |
| 302 | auto const secondPtr = editor.GetOriginalMapObject(ft.GetID()); |
| 303 | TEST(secondPtr, ()); |
| 304 | TEST_EQUAL(firstPtr->GetID(), secondPtr->GetID(), ()); |
| 305 | }); |
| 306 | |
| 307 | ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) |
| 308 | { |
| 309 | TEST_EQUAL(editor.GetOriginalFeatureStreet(ft.GetID()), "Test street", ()); |
| 310 | |
| 311 | EditFeature(ft, [](osm::EditableMapObject & emo) |
| 312 | { |
| 313 | osm::LocalizedStreet ls{"Some street", ""}; |
| 314 | emo.SetStreet(ls); |
| 315 | }); |
| 316 | TEST_EQUAL(editor.GetOriginalFeatureStreet(ft.GetID()), "Test street", ()); |
| 317 | }); |
| 318 | |
| 319 | uint32_t counter = 0; |
| 320 | editor.ForEachFeatureAtPoint([&counter](FeatureType & ft) { ++counter; }, {100.0, 100.0}); |
| 321 | |
| 322 | TEST_EQUAL(counter, 0, ()); |
| 323 | |
| 324 | counter = 0; |
| 325 | editor.ForEachFeatureAtPoint([&counter](FeatureType & ft) { ++counter; }, {3.0, 3.0}); |
| 326 | |
| 327 | TEST_EQUAL(counter, 1, ()); |
| 328 | |
| 329 | counter = 0; |
nothing calls this directly
no test coverage detected