MCPcopy Create free account
hub / github.com/comaps/comaps / CreateNoteTest

Method CreateNoteTest

libs/editor/editor_tests/osm_editor_test.cpp:850–900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

848}
849
850void EditorTest::CreateNoteTest()
851{
852 auto & editor = osm::Editor::Instance();
853
854 auto const mwmId = ConstructTestMwm([](TestMwmBuilder & builder)
855 {
856 builder.Add(TestCafe(m2::PointD(1.0, 1.0), "London Cafe", "en"));
857 builder.Add(TestCafe(m2::PointD(2.0, 2.0), "Cafe", "en"));
858 });
859
860 auto const createAndCheckNote =
861 [&editor](FeatureID const & fId, ms::LatLon const & pos, osm::Editor::NoteProblemType const noteType)
862 {
863 ScopedFile sf("test_notes.xml", ScopedFile::Mode::DoNotCreate);
864 editor.m_notes = Notes::MakeNotes(sf.GetFullPath(), true);
865 feature::TypesHolder holder;
866 holder.Assign(classif().GetTypeByPath({"amenity", "restaurant"}));
867 std::string defaultName = "Test name";
868 editor.CreateNote(pos, fId, holder, defaultName, noteType, "with comment");
869
870 auto const notes = editor.m_notes->GetNotes();
871 TEST_EQUAL(notes.size(), 1, ());
872 auto const & note = notes.front();
873 TEST(note.m_point.EqualDxDy(pos, 1e-10), ());
874 TEST(note.m_note.find("with comment") != std::string::npos, ());
875 TEST(note.m_note.find("OSM snapshot date") != std::string::npos, ());
876 TEST(note.m_note.find("restaurant") != std::string::npos, ());
877 TEST(note.m_note.find("Test name") != std::string::npos, ());
878 };
879
880 // Should match a piece of text in the editor note.
881 constexpr char const * kPlaceDoesNotExistMessage = "This place does not exist:";
882
883 ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor, &createAndCheckNote](FeatureType & ft)
884 {
885 createAndCheckNote(ft.GetID(), {1.0, 1.0}, osm::Editor::NoteProblemType::PlaceDoesNotExist);
886
887 auto notes = editor.m_notes->GetNotes();
888 TEST_NOT_EQUAL(notes.front().m_note.find(kPlaceDoesNotExistMessage), std::string::npos, ());
889 TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Obsolete, ());
890 });
891
892 ForEachCafeAtPoint(m_dataSource, m2::PointD(2.0, 2.0), [&editor, &createAndCheckNote](FeatureType & ft)
893 {
894 createAndCheckNote(ft.GetID(), {2.0, 2.0}, osm::Editor::NoteProblemType::General);
895
896 TEST_NOT_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Obsolete, ());
897 auto notes = editor.m_notes->GetNotes();
898 TEST_EQUAL(notes.front().m_note.find(kPlaceDoesNotExistMessage), std::string::npos, ());
899 });
900}
901
902void EditorTest::LoadMapEditsTest()
903{

Callers

nothing calls this directly

Calls 14

TESTFunction · 0.85
ForEachCafeAtPointFunction · 0.85
GetTypeByPathMethod · 0.80
GetNotesMethod · 0.80
frontMethod · 0.80
TestCafeClass · 0.70
AddMethod · 0.45
AssignMethod · 0.45
CreateNoteMethod · 0.45
sizeMethod · 0.45
EqualDxDyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected