| 1074 | } |
| 1075 | |
| 1076 | void EditorTest::SaveTransactionTest() |
| 1077 | { |
| 1078 | ScopedOptionalSaveStorage optionalSaveStorage; |
| 1079 | auto & editor = osm::Editor::Instance(); |
| 1080 | |
| 1081 | auto const mwmId = BuildMwm("GB", [](TestMwmBuilder & builder) |
| 1082 | { |
| 1083 | builder.Add(TestCafe(m2::PointD(1.0, 1.0), "London Cafe1", "en")); |
| 1084 | builder.Add(TestCafe(m2::PointD(4.0, 4.0), "London Cafe2", "en")); |
| 1085 | |
| 1086 | builder.Add(TestPOI(m2::PointD(6.0, 6.0), "Corner Post", "default")); |
| 1087 | }); |
| 1088 | |
| 1089 | auto const rfMwmId = BuildMwm( |
| 1090 | "RF", [](TestMwmBuilder & builder) { builder.Add(TestCafe(m2::PointD(10.0, 10.0), "Moscow Cafe1", "en")); }); |
| 1091 | |
| 1092 | ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); |
| 1093 | |
| 1094 | ForEachCafeAtPoint(m_dataSource, m2::PointD(10.0, 10.0), [](FeatureType & ft) { SetBuildingLevelsToOne(ft); }); |
| 1095 | |
| 1096 | auto const features = editor.m_features.Get(); |
| 1097 | |
| 1098 | TEST_EQUAL(features->size(), 2, ()); |
| 1099 | TEST_EQUAL(features->begin()->second.size(), 1, ()); |
| 1100 | TEST_EQUAL(features->rbegin()->second.size(), 1, ()); |
| 1101 | |
| 1102 | optionalSaveStorage.AllowSave(false); |
| 1103 | |
| 1104 | { |
| 1105 | auto saveResult = osm::Editor::SaveResult::NothingWasChanged; |
| 1106 | ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&saveResult](FeatureType & ft) |
| 1107 | { |
| 1108 | auto & editor = osm::Editor::Instance(); |
| 1109 | |
| 1110 | osm::EditableMapObject emo; |
| 1111 | emo.SetFromFeatureType(ft); |
| 1112 | emo.SetEditableProperties(editor.GetEditableProperties(ft)); |
| 1113 | SetBuildingLevels(emo, "5"); |
| 1114 | |
| 1115 | saveResult = editor.SaveEditedFeature(emo); |
| 1116 | }); |
| 1117 | |
| 1118 | TEST_EQUAL(saveResult, osm::Editor::SaveResult::NoFreeSpaceError, ()); |
| 1119 | |
| 1120 | auto const features = editor.m_features.Get(); |
| 1121 | auto const mwmIt = features->find(mwmId); |
| 1122 | |
| 1123 | TEST(mwmIt != features->end(), ()); |
| 1124 | TEST_EQUAL(mwmIt->second.size(), 1, ()); |
| 1125 | } |
| 1126 | |
| 1127 | { |
| 1128 | auto saveResult = osm::Editor::SaveResult::NothingWasChanged; |
| 1129 | ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&saveResult](FeatureType & ft) |
| 1130 | { |
| 1131 | auto & editor = osm::Editor::Instance(); |
| 1132 | |
| 1133 | osm::EditableMapObject emo; |
nothing calls this directly
no test coverage detected