From 58521e565f49ba4b8034de0eb763b4d9de3915f2 Mon Sep 17 00:00:00 2001 From: maj00r <73280030+maj00r@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:07:41 +0100 Subject: [PATCH] test(editor): the cases of the aerial photo with no fuss, and fs_3 with the line in place of the question ph_1: the photo turned off with the button of the toolbar stays off over the wizard's //$o on 1 when the scenery is opened again, on again after the next. ph_2: the first L in a scenery placed on the map asks nothing, the terrain loads in the background with its line in the panel of the laying, Without terrain stops it. ph_3: the tracks drawn over the photo in the top view zoomed in under 0.5 m a pixel, not without the photo. ph_4: the button and ~ are the user's choice, the terrain of the model made afterwards doesn't turn the photo on again, F1 opens. fs_3 still checks the answer Without terrain, now the button of the line which took the place of the question in a window, and that no window asks. New for the scripts: expect photo , expect terrain , toolbar , orthophoto forget, and the key grave (~) for tap. --- application/editormode.h | 2 ++ application/editormodeselftest.cpp | 7 ++-- application/editormodeselftestexpect.cpp | 19 +++++++++-- application/editormodeselftestterrain.cpp | 17 ++++++++++ application/editormodeviewport.cpp | 15 +++++++++ application/scriptedinput.cpp | 2 +- tests/editor/README.md | 14 ++++++-- tests/editor/cases/fs_3_without_terrain.txt | 8 +++-- tests/editor/cases/ph_1_photo_per_scenery.txt | 33 +++++++++++++++++++ .../editor/cases/ph_2_terrain_no_question.txt | 31 +++++++++++++++++ tests/editor/cases/ph_3_tracks_over_photo.txt | 19 +++++++++++ tests/editor/cases/ph_4_toolbar_toggle.txt | 29 ++++++++++++++++ 12 files changed, 185 insertions(+), 11 deletions(-) create mode 100644 tests/editor/cases/ph_1_photo_per_scenery.txt create mode 100644 tests/editor/cases/ph_2_terrain_no_question.txt create mode 100644 tests/editor/cases/ph_3_tracks_over_photo.txt create mode 100644 tests/editor/cases/ph_4_toolbar_toggle.txt diff --git a/application/editormode.h b/application/editormode.h index 2b2986293..565c28812 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -961,6 +961,8 @@ class editor_mode : public application_mode, private editor_track::observer, pri void render_viewport_overlays(); // the tools of the field of work, in the order of the toolbar void work_area_tools(std::vector &Buttons); + // the button of the toolbar of the key or the name given clicked, for the self-test; false: none such + bool press_toolbar(std::string const &Name); // the tools of the field of work in the toolbar, as icons with their names void render_toolbar_tools(); // what the row of the toolbar holds, written at its left end: the fields of work, the tools diff --git a/application/editormodeselftest.cpp b/application/editormodeselftest.cpp index beac5837d..c7be720d8 100644 --- a/application/editormodeselftest.cpp +++ b/application/editormodeselftest.cpp @@ -124,7 +124,10 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c // terrainfill ... the area outlined filled, as the fill tool does it // terrainturn the textures of the palette entry turned // terrainwater [size] material and repeat of a body of water; terrainwaterdefault -// orthophoto [in scene 0|1] the imagery layer on, placed and fitted as given +// orthophoto [in scene 0|1] the imagery layer on, placed and fitted as given; orthophoto off: turned +// off as the user does it, for the scenery; orthophoto forget: what the editor keeps of the photo of +// the scenery (whether it's on, its origin) forgotten +// toolbar the button of the toolbar of the field of work with the key or the name clicked (toolbar ~: the photo) // orthoarea ... | clear the download area through the points of the world, as drawn on the map; orthoareapause 0|1 // orthohires 0|1 the 4K tiles on or off; orthostats logs the tiles, the area and the requests made // orthosettings [on|radius|opacity|lift|height|year|hires|drape|scene ]... the settings of the orthophoto changed as its @@ -179,7 +182,7 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c // mouse , mouseat the cursor moved to the point of the window, or to where the point of the scene is seen, as the mouse moves it // glide [shot] the cursor led to where the point is seen in steps, frames apart, a screenshot after each step with shot // button , wheel the buttons and the wheel of the mouse, with the keys held -// press , release , tap a key held, let go, or both (ctrl, shift, alt, esc, enter, backspace, del, space, tab, a..z, 0..9, f1..f12) +// press , release , tap a key held, let go, or both (ctrl, shift, alt, esc, enter, backspace, del, space, tab, grave (~), a..z, 0..9, f1..f12) // softcursor <0|1> the cursor drawn into the picture, for screenshots // type the characters typed into the text field with the focus // screenshot diff --git a/application/editormodeselftestexpect.cpp b/application/editormodeselftestexpect.cpp index 72d3b3b29..23ccd6844 100644 --- a/application/editormodeselftestexpect.cpp +++ b/application/editormodeselftestexpect.cpp @@ -20,6 +20,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "utilities/utilities.h" #include "world/Track.h" +#include "imgui/imgui.h" #include #include @@ -403,7 +404,10 @@ void expect_terrain(std::string const &What, std::istringstream &Words, std::map auto const state{States.find(key)}; if (state == States.end()) { - expectation(false, What, "no state " + key, "grow, area or prompt"); + std::string keys; + for (auto const &[name, value] : States) + keys += (keys.empty() ? "" : ", ") + name; + expectation(false, What, "no state " + key, keys); return; } expectation(state->second == (wanted != 0), What, state->second ? "1" : "0", std::to_string(wanted)); @@ -488,7 +492,8 @@ struct shown_state std::string refusal; // by the cursor, while it's shown std::string status_line; glm::dvec3 lay_cursor{0.0}; - std::map terrain; // grow, area, prompt + std::map terrain; // grow, area, prompt, loading, question + std::map photo; // on, chosen, zoom4k, tracksover std::string tool; std::map windows; // shortcuts, settings, weather, orthophoto std::optional selected; // where the node selected stands @@ -509,6 +514,8 @@ bool expect_shown(std::string const &Kind, std::string const &What, std::istring expect_lay_cursor(What, Words, Shown.lay_cursor); else if (Kind == "terrain") expect_terrain(What, Words, Shown.terrain); + else if (Kind == "photo") + expect_terrain(What, Words, Shown.photo); else if (Kind == "tool") expect_tool(What, Words, Shown.tool); else if (Kind == "window") @@ -585,7 +592,13 @@ editor_mode::selftest_result editor_mode::selftest_expect(std::string const &com else { shown_state shown{m_switch.status, ui()->refusal_shown(), ui()->status_line(), m_lay.mouse, - {{"grow", m_nmt_state.grow}, {"area", EditorSettings.terrain_model().area}, {"prompt", m_nmt_state.prompt}}, tool_name(ui()->mode()), + {{"grow", m_nmt_state.grow}, + {"area", EditorSettings.terrain_model().area}, + {"prompt", m_nmt_state.prompt}, + {"loading", m_nmt_state.offer_loading}, + {"question", ImGui::IsPopupOpen(nullptr, ImGuiPopupFlags_AnyPopupId)}}, + {{"on", m_orthophoto.enabled()}, {"chosen", m_orthophoto_chosen}, {"zoom4k", m_orthophoto.zoom_hires()}, {"tracksover", m_track_lines_drawn > 0}}, + tool_name(ui()->mode()), {{"shortcuts", m_shortcuts_open}, {"settings", m_settings_open}, {"weather", m_environment_open}, {"orthophoto", m_orthophoto_window}}, std::nullopt, shown_lay_panel(), shown_switch_panel()}; if (m_node != nullptr) diff --git a/application/editormodeselftestterrain.cpp b/application/editormodeselftestterrain.cpp index 354f98a4e..0adfa9b5d 100644 --- a/application/editormodeselftestterrain.cpp +++ b/application/editormodeselftestterrain.cpp @@ -63,6 +63,14 @@ editor_mode::selftest_result editor_mode::selftest_terrain(std::string const &co WriteLog("SELFTEST orthophoto off"); return selftest_result::handled; } + if (words.str().find(" forget") != std::string::npos) + { + // what the editor keeps of the photo of the scenery forgotten: its choice and its origin, as for a scenery never opened + EditorSettings.orthophoto_forget(m_orthophoto_scenery); + EditorSettings.save(); + WriteLog("SELFTEST orthophoto forget " + m_orthophoto_scenery); + return selftest_result::handled; + } int fit{1}; int inscene{0}; float height{0.0f}; @@ -76,6 +84,15 @@ editor_mode::selftest_result editor_mode::selftest_terrain(std::string const &co WriteLog(format("SELFTEST orthophoto at %.0f %.0f, radius %d, %s%s", config.north, config.east, config.radius, config.drape ? "fitted" : "flat", config.in_scene ? ", in the scene" : "")); return selftest_result::handled; } + if (command == "toolbar") + { + // the button of the toolbar of the key or the name given clicked + std::string name; + words >> name; + auto const pressed{press_toolbar(name)}; + WriteLog(format("SELFTEST toolbar %s: %s, orthophoto %d", name.c_str(), pressed ? "pressed" : "no such button", m_orthophoto.enabled() ? 1 : 0)); + return selftest_result::handled; + } if (command == "orthoarea") { // the download area through the points of the world (x, z), as drawn on the map; clear: none diff --git a/application/editormodeviewport.cpp b/application/editormodeviewport.cpp index a5c805b26..0658b1c6d 100644 --- a/application/editormodeviewport.cpp +++ b/application/editormodeviewport.cpp @@ -264,6 +264,21 @@ void editor_mode::work_area_tools(std::vector &Buttons) } } +bool editor_mode::press_toolbar(std::string const &Name) +{ + std::vector buttons; + work_area_tools(buttons); + for (auto const &button : buttons) + if ((button.key != nullptr && Name == button.key) || Name == button.label) + { + if (false == button.enabled || false == static_cast(button.action)) + return false; + button.action(); + return true; + } + return false; +} + editor_mode::section_tool const &editor_mode::surroundings_tool(nodebank_panel::edit_mode const Mode) { // in the order of the edit modes: select, copy to bank, insert, brush, area fill diff --git a/application/scriptedinput.cpp b/application/scriptedinput.cpp index 8f35d8cfe..63cc0ec66 100644 --- a/application/scriptedinput.cpp +++ b/application/scriptedinput.cpp @@ -29,7 +29,7 @@ namespace int key_named(std::string const &Name) { static std::map const names{{"ctrl", GLFW_KEY_LEFT_CONTROL}, {"shift", GLFW_KEY_LEFT_SHIFT}, {"alt", GLFW_KEY_LEFT_ALT}, {"esc", GLFW_KEY_ESCAPE}, {"enter", GLFW_KEY_ENTER}, {"backspace", GLFW_KEY_BACKSPACE}, - {"del", GLFW_KEY_DELETE}, {"space", GLFW_KEY_SPACE}, {"tab", GLFW_KEY_TAB}}; + {"del", GLFW_KEY_DELETE}, {"space", GLFW_KEY_SPACE}, {"tab", GLFW_KEY_TAB}, {"grave", GLFW_KEY_GRAVE_ACCENT}}; if (auto const found{names.find(Name)}; found != names.end()) return found->second; if (Name.size() == 1 && std::isalpha(static_cast(Name[0]))) diff --git a/tests/editor/README.md b/tests/editor/README.md index 40f36195b..f47d98ef2 100644 --- a/tests/editor/README.md +++ b/tests/editor/README.md @@ -85,7 +85,8 @@ The expectations (`expect ...`), each logged as `SELFTEST PASS ` or | `expect refusal ` | what the cursor tells while it's shown (a refusal or a warning) holds the text, or doesn't | | `expect statusline ` | the status line of the editor (also shown in the layers window) holds the text, or doesn't | | `expect laycursor ` | the point the line of the lay tool goes to from its last point clicked, in the plan | -| `expect terrain <0\|1>` | the terrain model is made under the tracks as they're laid / around the camera within the download area / the question of the terrain of a new scenery is open | +| `expect terrain <0\|1>` | the terrain model is made under the tracks as they're laid / around the camera within the download area / the line of the terrain of a new scenery is shown in the panel of the laying / its terrain is being loaded in the background / a window asking (a modal popup) is open | +| `expect photo <0\|1>` | the aerial photo is shown / it was turned on or off by the user or the scenery (the terrain model leaves it be) / the 4K photos are asked for by themselves, the view zoomed in / the tracks were drawn over the view in the last frame (the top view) | | `expect laypanel ` | the state of the panel of the lay tool, as the step at its top tells it, and whether its settings are shown or folded to the line of their summary | | `expect switchpanel ` | the state of the panel of the switch tool, as the step at its top tells it | | `expect steps ` | the steps of the history Ctrl+Z takes back, the ones made together counted once: none made by a change refused | @@ -162,7 +163,7 @@ and the first steps in the editor (P1 of the plan of the editor's interface): | --- | --- | | `fs_1_preview_over_panel` | while the pointer is over a panel the line the lay tool shows stays as it was, no leg following the pointer under the panel; back over the view it follows again | | `fs_2_switch_refusal_cleared` | a switch refused is told in the panel of the switch tool and by the cursor, not in the status line as well, and what it told goes once the next switch is laid | -| `fs_3_without_terrain` | the answer Without terrain to the question of the terrain of a new scenery turns off the terrain made of the terrain model by itself: under the tracks as they're laid and around the camera within the download area | +| `fs_3_without_terrain` | Without terrain, the button of the line of the terrain of a new scenery (no question in a window any more), turns off the terrain made of the terrain model by itself: under the tracks as they're laid and around the camera within the download area | and the consistency of the interface of the editor (P2 of the plan of the editor's interface): @@ -203,6 +204,15 @@ and the rest of the editing on the model (E4b), with the setting on: | `m_13_parallel` | the parallel tool beside a line of the model lays a line of the model, its arc concentric at the spacing, one step | | `m_14_layer_origin` | a line of the model saved into a file under an origin and opened again: nothing taken for changed by hand, also after a second save | +and the aerial photo with no fuss (stage 3 of laying the tracks over the aerial photos): + +| case | checks | +| --- | --- | +| `ph_1_photo_per_scenery` | the photo turned on or off is the scenery's, kept with the editor: off over the wizard's `//$o on 1` after a reopen, on again after the next | +| `ph_2_terrain_no_question` | the first L in a new scenery placed on the map asks nothing: the terrain loads in the background, the line in the panel of the laying tells it, Without terrain stops it | +| `ph_3_tracks_over_photo` | in the top view zoomed in under 0.5 m a pixel the tracks are drawn over the photo; without the photo they aren't | +| `ph_4_toolbar_toggle` | the photo button of the toolbar of the tracks and ~ turn the photo on and off as the user's choice, the terrain of the model doesn't turn it on again; F1 lists ~ | + and the assumptions of the project and the norms enforced when laying (`editor-project-setup.md`): | case | checks | diff --git a/tests/editor/cases/fs_3_without_terrain.txt b/tests/editor/cases/fs_3_without_terrain.txt index a56bc93a4..ce30ece81 100644 --- a/tests/editor/cases/fs_3_without_terrain.txt +++ b/tests/editor/cases/fs_3_without_terrain.txt @@ -1,7 +1,8 @@ -# First steps: the answer Without terrain to the question of the terrain of a new empty scenery turns off the terrain made of the +# First steps: Without terrain, the button of the line of the terrain of a new empty scenery, turns off the terrain made of the # terrain model by itself: under the tracks as they're laid (the checkbox of the layers) and around the camera within the download -# area (the checkbox of the terrain panel), so nothing of the model is asked for. The question asked as the first L in an empty -# scenery asks it (the fixture has tracks, so it isn't asked by itself) +# area (the checkbox of the terrain panel), so nothing of the model is asked for. The line is shown as the first L in an empty +# scenery shows it, in place of the question asked in a window before (the fixture has tracks, so it isn't shown by itself); the +# fixture isn't placed on the map, so nothing is loaded meanwhile wait 5 nmtsettings grow 1 wait 2 @@ -9,6 +10,7 @@ expect terrain grow 1 nmtquestion open wait 3 expect terrain prompt 1 +expect terrain question 0 nmtquestion flat wait 3 expect terrain prompt 0 diff --git a/tests/editor/cases/ph_1_photo_per_scenery.txt b/tests/editor/cases/ph_1_photo_per_scenery.txt new file mode 100644 index 000000000..9bb754db0 --- /dev/null +++ b/tests/editor/cases/ph_1_photo_per_scenery.txt @@ -0,0 +1,33 @@ +# The aerial photo is the scenery's. The wizard's //$o on 1 with nothing chosen in the scenery: on. Turned off with the button of the +# toolbar it stays off when the scenery is opened again, though the scenery says on; turned on again, on after a reopen. Kept with +# the editor, not with the save: the scenery isn't saved. The fixture isn't placed on the map, so no photo is downloaded +#> append //$o on 1 +wait 5 +# what an earlier run kept of the photo of this scenery forgotten +orthophoto forget +quit +#> reopen +wait 5 +expect photo on 1 +expect photo chosen 1 +tap f3 +wait 2 +toolbar ~ +wait 2 +expect photo on 0 +quit +#> reopen +wait 5 +# the user's off goes over the scenery's on +expect photo on 0 +tap f3 +wait 2 +toolbar ~ +wait 2 +expect photo on 1 +quit +#> reopen +wait 5 +expect photo on 1 +orthophoto forget +quit diff --git a/tests/editor/cases/ph_2_terrain_no_question.txt b/tests/editor/cases/ph_2_terrain_no_question.txt new file mode 100644 index 000000000..95304e3ef --- /dev/null +++ b/tests/editor/cases/ph_2_terrain_no_question.txt @@ -0,0 +1,31 @@ +# The first L in a new scenery asks nothing: where the scenery lies on the map the terrain loads in the background and a line in the +# panel of the laying tells it, with the button to go without; no window in the way of the laying. The fixture has tracks, so the +# offer is started as the first L starts it (nmtquestion open), after the scenery was placed on the map (in Warsaw, the photo of one tile) +wait 5 +nmtsettings grow 1 +wait 2 +tap f3 +wait 2 +tap l +wait 3 +orthophoto 482500 634000 0 1 0 +wait 3 +nmtquestion open +wait 5 +expect terrain question 0 +expect terrain prompt 1 +expect terrain loading 1 +expect laypanel ready shown +# the photo doesn't wait for the terrain: it's on and its tile asked for while the terrain is still to come +expect photo on 1 +# Without terrain: nothing of the model loaded any more, the line gone +nmtquestion flat +wait 3 +expect terrain prompt 0 +expect terrain loading 0 +expect terrain grow 0 +expect terrain area 0 +nmtquestion restore +wait 2 +orthophoto forget +quit diff --git a/tests/editor/cases/ph_3_tracks_over_photo.txt b/tests/editor/cases/ph_3_tracks_over_photo.txt new file mode 100644 index 000000000..c91ba5266 --- /dev/null +++ b/tests/editor/cases/ph_3_tracks_over_photo.txt @@ -0,0 +1,19 @@ +# In the top view the tracks laid are drawn over the photo, which is drawn over the view, also zoomed in (under 0.5 m a pixel, where they +# were left to the 3d tracks the photo covers): the rails of a1 at about 0.17 m a pixel. Without the photo no lines over them there. The +# origin is outside Poland, so no photo is downloaded +wait 5 +tap f3 +wait 2 +camera 0 200 50 0 0 50.5 +ortho 40 whole +wait 3 +orthophoto 50 50 0 1 0 +wait 3 +expect photo on 1 +expect photo tracksover 1 +orthophoto off +wait 3 +expect photo on 0 +expect photo tracksover 0 +orthophoto forget +quit diff --git a/tests/editor/cases/ph_4_toolbar_toggle.txt b/tests/editor/cases/ph_4_toolbar_toggle.txt new file mode 100644 index 000000000..7f44ff524 --- /dev/null +++ b/tests/editor/cases/ph_4_toolbar_toggle.txt @@ -0,0 +1,29 @@ +# The photo in the toolbar of the tracks: its button and ~ turn it on and off for the scenery, as the user's choice, and the terrain +# made of the model around the camera doesn't turn it on again behind the user (~ turned it off before without it counting as a choice, +# and the terrain turned it on again). ~ is in the shortcuts (F1). In Warsaw: the photo of one tile, the terrain of the model around +wait 5 +tap f3 +wait 2 +orthophoto 482500 634000 0 1 0 +wait 3 +expect photo on 1 +tap grave +wait 2 +expect photo on 0 +expect photo chosen 1 +nmtmake around 100 +wait 10 +expect photo on 0 +toolbar ~ +wait 2 +expect photo on 1 +toolbar ~ +wait 2 +expect photo on 0 +tap f1 +wait 3 +expect window shortcuts 1 +tap f1 +wait 2 +orthophoto forget +quit