| 1036 | } |
| 1037 | |
| 1038 | void EditorTest::SaveEditedFeatureTest() |
| 1039 | { |
| 1040 | auto & editor = osm::Editor::Instance(); |
| 1041 | |
| 1042 | auto const mwmId = ConstructTestMwm([](TestMwmBuilder & builder) |
| 1043 | { |
| 1044 | builder.Add(TestCafe(m2::PointD(1.0, 1.0), "London Cafe1", "en")); |
| 1045 | |
| 1046 | builder.Add(TestPOI(m2::PointD(10, 10), "Corner Post", "default")); |
| 1047 | }); |
| 1048 | |
| 1049 | osm::EditableMapObject emo; |
| 1050 | |
| 1051 | editor.CreatePoint(classif().GetTypeByPath({"amenity", "cafe"}), {4.0, 4.0}, mwmId, emo); |
| 1052 | emo.SetHouseNumber("12"); |
| 1053 | TEST_EQUAL(editor.GetFeatureStatus(emo.GetID()), FeatureStatus::Untouched, ()); |
| 1054 | TEST_EQUAL(editor.SaveEditedFeature(emo), osm::Editor::SaveResult::SavedSuccessfully, ()); |
| 1055 | TEST_EQUAL(editor.GetFeatureStatus(emo.GetID()), FeatureStatus::Created, ()); |
| 1056 | TEST_EQUAL(editor.SaveEditedFeature(emo), osm::Editor::SaveResult::NothingWasChanged, ()); |
| 1057 | TEST_EQUAL(editor.GetFeatureStatus(emo.GetID()), FeatureStatus::Created, ()); |
| 1058 | |
| 1059 | ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) |
| 1060 | { |
| 1061 | osm::EditableMapObject emo; |
| 1062 | FillEditableMapObject(editor, ft, emo); |
| 1063 | TEST_EQUAL(editor.SaveEditedFeature(emo), osm::Editor::SaveResult::NothingWasChanged, ()); |
| 1064 | TEST_EQUAL(editor.GetFeatureStatus(emo.GetID()), FeatureStatus::Untouched, ()); |
| 1065 | emo.SetHouseNumber("4a"); |
| 1066 | TEST_EQUAL(editor.SaveEditedFeature(emo), osm::Editor::SaveResult::SavedSuccessfully, ()); |
| 1067 | TEST_EQUAL(editor.GetFeatureStatus(emo.GetID()), FeatureStatus::Modified, ()); |
| 1068 | TEST_EQUAL(editor.SaveEditedFeature(emo), osm::Editor::SaveResult::NothingWasChanged, ()); |
| 1069 | TEST_EQUAL(editor.GetFeatureStatus(emo.GetID()), FeatureStatus::Modified, ()); |
| 1070 | emo.SetHouseNumber(""); |
| 1071 | TEST_EQUAL(editor.SaveEditedFeature(emo), osm::Editor::SaveResult::SavedSuccessfully, ()); |
| 1072 | TEST_EQUAL(editor.GetFeatureStatus(emo.GetID()), FeatureStatus::Untouched, ()); |
| 1073 | }); |
| 1074 | } |
| 1075 | |
| 1076 | void EditorTest::SaveTransactionTest() |
| 1077 | { |
nothing calls this directly
no test coverage detected