/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file InternalTestStep.h14/// @author Pablo Alvarez Lopez15/// @date Mar 202516///17// Single operation used in InternalTests18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/dialogs/GNEDialogEnum.h>23#include <utils/foxtools/fxheader.h>2425#include "InternalTest.h"2627// ===========================================================================28// class definitions29// ===========================================================================3031class InternalTestStep {3233public:34/// @name category step35enum class Category {36META, // Meta step (used for packing set of steps like click or write)37INIT, // Setup and start step38FINISH, // Write last line39APP, // send signal to APP (Either GUIAppWindows or GNEApplicationWindow)40VIEW, // send signal to view (either GUIView or GNEViewNet)41TLS_PHASES, // send signal to TLS Phases module (used for TLS Phases)42TLS_PHASETABLE, // send signal to TLSTable (used for TLS Phases)43DIALOG, // send signal to dialog (used for modal dialogs)44};4546/// @brief dialog arguments, used for certain modal dialogs that can not be edited using tab47class DialogArgument {4849public:50/// @name basic actions51enum class Action {52ACCEPT, // press accept button53CANCEL, // press cancel button54RESET, // press reset button55ABORT, // abort dialog56CUSTOM, // custom action57NONE, // no action58};5960/// @brief constructor for basic actions61DialogArgument(DialogType type, Action action);6263/// @brief constructor for basic actions64DialogArgument(DialogType type, const std::string& customAction);6566/// @brief constructor for basic actions and index67DialogArgument(DialogType type, const std::string& customAction, const int index);6869/// @brief constructor for custom actions and prefix to remove in the action70DialogArgument(DialogType type, const std::string& prefixToRemove, const std::string& customAction);7172/// @brief get type73DialogType getType() const;7475/// @brief get basic action76Action getAction() const;7778/// @brief get custom action79const std::string& getCustomAction() const;8081/// @brief get index82int getIndex() const;8384protected:85/// @brief dialog type86DialogType myType = DialogType::DEFAULT;8788/// @brief basic action89Action myAction = Action::NONE;9091/// @brief action to be carried out in the dialog92std::string myCustomAction;9394/// @brief index95int myIndex = 0;9697private:98/// @brief invalidated default constructor99DialogArgument() = delete;100101/// @brief invalidated copy constructor102DialogArgument(const DialogArgument&) = delete;103};104105/// @brief struct used for test TLS Tables106class TLSTableTest {107108public:109/// brief default constructor for phases110TLSTableTest(FXSelector sel_, const int row_);111112/// brief default constructor with text113TLSTableTest(FXSelector sel_, const int row_, const int column_, const std::string& text_);114115/// @brief selector116const FXSelector sel = 0;117118/// @brief x coordinate119const int row = 0;120121/// @brief y coordinate122const int column = 0;123124/// @brief text125const std::string text = "";126127private:128/// @brief invalidated default constructor129TLSTableTest() = delete;130131/// @brief invalidated copy constructor132TLSTableTest(const TLSTableTest&) = delete;133};134135/// @brief constructor for parsing step in string format136InternalTestStep(InternalTest* testSystem, const std::string& step);137138/// @brief constructor for shortcuts139InternalTestStep(InternalTest* testSystem, FXSelector messageType, FXSelector messageID,140Category category, const std::string& description);141142/// @brief constructor for input events (click, keyPress, etc.)143InternalTestStep(InternalTest* testSystem, FXSelector messageType, Category category,144FXEvent* event, const bool updateView, const std::string& description);145146/// @brief constructor for dialog arguments147InternalTestStep(InternalTest* testSystem, DialogArgument* dialogArgument,148const std::string& description);149150/// @brief destructor151~InternalTestStep();152153/// @name next step management154/// @{155156/// @brief get next step157InternalTestStep* getNextStep() const;158159/// @brief set next step160void setNextStep(InternalTestStep* nextStep);161162/// @}163164/// @brief get message type165FXSelector getMessageType() const;166167/// @brief get message ID168FXSelector getMessageID() const;169170/// @brief get dialog argument171DialogArgument* getDialogArgument() const;172173/// @brief get TLS Table test174TLSTableTest* getTLSTableTest() const;175176/// @brief get selector (based in messageType and messageID)177FXSelector getSelector() const;178179/// @brief check if update view180bool updateView() const;181182/// @brief get category183Category getCategory() const;184185/// @brief get event associated with this step186void* getEvent() const;187188/// @brief get description189const std::string& getDescription() const;190191private:192/// @brief test system parent193InternalTest* myTestSystem = nullptr;194195/// @brief next step in the test196InternalTestStep* myNextStep = nullptr;197198/// @brief message type (by default SEL_COMMAND)199FXSelector myMessageType = SEL_COMMAND;200201/// @brief message ID202FXSelector myMessageID = 0;203204/// @brief step category205Category myCategory = Category::META;206207/// @brief flag to enable or disable view after execute step208bool myUpdateView = false;209210/// @brief description211std::string myDescription;212213/// @brief arguments214std::vector<std::string> myArguments;215216/// @brief list of events associated with this step217FXEvent* myEvent = nullptr;218219/// @brief dialog argument220DialogArgument* myDialogArgument = nullptr;221222/// @brief TLS Table test223TLSTableTest* myTLSTableTest = nullptr;224225/// @brief parse function and arguments226std::string parseStep(const std::string& rowText);227228/// @brief parse arguments229void parseArguments(const std::string& arguments);230231/// @brief process setupAndStart function232void setupAndStart();233234/// @brief finish function235void finish();236237/// @brief process click function238void mouseClick(const std::string& button, const std::string& modifier) const;239240/// @brief process click function241void leftClickOffset(const std::string& button) const;242243/// @brief process moveElementHorizontal function244void moveElementHorizontal() const;245246/// @brief process moveElementVertical function247void moveElementVertical() const;248249/// @brief process moveElement function250void moveElement() const;251252/// @brief process focusOnFrame function253void focusOnFrame() const;254255/// @brief process typeKey function256void typeKey() const;257258/// @brief process contextualMenuOperation function259void contextualMenuOperation() const;260261/// @brief process protect elements function262void protectElements() const;263264/// @brief process waitDeleteWarning function265void waitDeleteWarning() const;266267/// @brief process modifyAttribute function268void modifyAttribute(const int overlappedTabs) const;269270/// @brief process modifyBoolAttribute function271void modifyBoolAttribute(const int overlappedTabs) const;272273/// @brief process modifyColorAttribute function274void modifyColorAttribute(const int overlappedTabs) const;275276/// @brief process modifyVClassDialog_DisallowAll function277void modifyVClassDialog_NoDisallowAll(const int overlappedTabs) const;278279/// @brief process modifyVClassDialog_DisallowAll function280void modifyVClassDialog_DisallowAll(const int overlappedTabs) const;281282/// @brief process modifyVClassDialog_Cancel function283void modifyVClassDialog_Cancel(const int overlappedTabs) const;284285/// @brief process modifyVClassDialog_Reset function286void modifyVClassDialog_Reset(const int overlappedTabs) const;287288/// @brief process modifyVTypeDialogAttribute function289void modifyVTypeDialogAttribute() const;290291/// @brief process createConnection function292void createConnection(const std::string& keyModifier) const;293294/// @brief process createCrossing function295void createCrossing() const;296297/// @brief process modifyCrossingDefaultValue function298void modifyCrossingDefaultValue() const;299300/// @brief process modifyCrossingDefaultBoolValue function301void modifyCrossingDefaultBoolValue() const;302303/// @brief process crossingClearEdges function304void crossingClearEdges() const;305306/// @brief process crossingInvertEdges function307void crossingInvertEdges() const;308309/// @brief process createConnectionEdit function310void saveConnectionEdit() const;311312/// @brief process fixCrossings function313void fixCrossings();314315/// @brief process fixStoppingPlace function316void fixStoppingPlace();317318/// @brief process fixRoutes function319void fixRoute();320321/// @brief process createTLS function322void createTLS(const int overlappedTabs) const;323324/// @brief process Copy TLS function325void copyTLS() const;326327/// @brief process join TLS function328void joinTSL() const;329330/// @brief process disJoin TLS function331void disJoinTLS() const;332333/// @brief process delete TLS function334void deleteTLS() const;335336/// @brief process modifyTLSTable function337void modifyTLSTable();338339/// @brief process resetSingleTLSPhases function340void resetSingleTLSPhases() const;341342/// @brief process resetAllTLSPhases function343void resetAllTLSPhases() const;344345/// @brief process pressTLSPhaseButton function346void pressTLSPhaseButton() const;347348/// @brief process addPhase function349void addPhase(const std::string& type);350351/// @brief process pressTLSButton function352void pressTLSButton(const std::string& type);353354/// @brief process checkParameters function355void checkParameters(const int overlappedTabs) const;356357/// @brief process checkDoubleParameters function358void checkDoubleParameters(const int overlappedTabs) const;359360/// @brief process changeEditMode function361void changeEditMode();362363/// @brief process save existent function364void saveExistentFile();365366/// @brief process check undo-redo function367void checkUndoRedo() const;368369/// @brief process delete function370void deleteFunction() const;371372/// @brief process selection function373void selection() const;374375/// @brief process selectNetworkItems function376void selectNetworkItems() const;377378/// @brief process lockSelection function379void lockSelection() const;380381/// @brief process selectionRectangle function382void selectionRectangle() const;383384/// @brief process createDataSet function385void createDataSet() const;386387/// @brief process createDataInterval function388void createDataInterval() const;389390/// @brief process openAboutDialog function391void openAboutDialog();392393/// @brief process load file function394void loadFile();395396/// @brief process save new file function397void saveNewFile();398399/// @brief process save file as function400void saveFileAs();401402/// @brief process save unified file as function403void saveUnifiedFileAs();404405/// @brief process reload file function406void reloadFile();407408/// @brief process select edge type function409void selectEdgeType();410411/// @brief process create new edge type function412void createNewEdgeType();413414/// @brief process overwriting accept function415void overwritingAccept();416417/// @brief process overwriting cancel function418void overwritingCancel();419420/// @brief process overwriting abort function421void overwritingAbort();422423/// @brief process overwriting apply to all function424void overwritingApplyToAll();425426/// @brief process undo function427void undo() const;428429/// @brief process redo function430void redo() const;431432/// @brief process changeSupermode function433void changeSupermode();434435/// @brief process changeMode function436void changeMode();437438/// @brief process changeElement function439void changeElement() const;440441/// @bief process changePlan function442void changePlan() const;443444/// @brief process computeJunctions function445void computeJunctions();446447/// @brief process computeJunctionsVolatileOptions function448void computeJunctionsVolatileOptions();449450/// @brief process joinJunctions function451void joinJunctions();452453/// @brief process selectChild function454void selectAdditionalChild();455456/// @brief process createRectangledShape function457void createRectangledShape();458459/// @brief process createSquaredShape function460void createSquaredShape();461462/// @brief process createLineShape function463void createLineShape();464465/// @brief process createMeanData function466void createMeanData();467468/// @brief process deleteMeanData function469void deleteMeanData();470471/// @brief process copyMeanData function472void copyMeanData();473474/// @brief process quit function475void quit();476477/// @brief check int argument478bool checkIntArgument(const std::string& argument) const;479480/// @brief get int argument481int getIntArgument(const std::string& argument) const;482483/// @brief check bool argument484bool checkBoolArgument(const std::string& argument) const;485486/// @brief get bool argument487bool getBoolArgument(const std::string& argument) const;488489/// @brief check string argument490bool checkStringArgument(const std::string& argument) const;491492/// @brief get string argument493std::string getStringArgument(const std::string& argument) const;494495/// @brief strip spaces496std::string stripSpaces(const std::string& str) const;497498/// @brief write error499void writeError(const std::string& function, const int overlapping,500const std::string& expected) const;501502/// @brief create shape503void createShape(const InternalTest::ViewPosition& viewPosition,504const int sizeX, const int sizeY, const bool close,505const bool line) const;506507/// @name modify attribute functions508/// @{509510/// @brief modify attribute511void modifyStringAttribute(Category category, const int tabs, const int overlappedTabs, const std::string& value) const;512513/// @brief modify bool attribute514void modifyBoolAttribute(Category category, const int tabs, const int overlappedTabs) const;515516/// @}517518/// @name undo-redo functions519/// @{520521/// @brief process check undo function522void buildUndo(const int number) const;523524/// @brief process check redo function525void buildRedo(const int number) const;526527/// @}528529/// @name key functions530/// @{531532/// @brief translate key533std::pair<FXint, FXString> translateKey(const std::string& key) const;534535/// @brief build key press event536FXEvent* buildKeyPressEvent(const std::string& key) const;537538/// @brief build key release event539FXEvent* buildKeyReleaseEvent(const std::string& key) const;540541/// @brief build a key press and key release (used for tabs, spaces, enter, etc)542void buildPressKeyEvent(Category category, const std::string& key, const bool updateView) const;543544/// @brief build a two key press and key release (used for tabs, spaces, enter, etc)545void buildTwoPressKeyEvent(Category category, const std::string& keyA, const std::string& keyB, const bool updateView) const;546547/// @}548549/// @name mouse functions550/// @{551552/// @brief build mouse click event553void buildMouseClick(const InternalTest::ViewPosition& viewPosition,554const int offsetX, const int offsetY,555const std::string& button, const std::string& keyModifier) const;556557/// @brief build mouse dragdrop558void buildMouseDragDrop(const InternalTest::ViewPosition& viewStartPosition,559const int offsetStartX, const int offsetStartY,560const InternalTest::ViewPosition& viewEndPosition,561const int offsetEndX, const int offsetEndY,562const std::string& keyModifier) const;563564/// @brief build mouse move event565FXEvent* buildMouseMoveEvent(const InternalTest::ViewPosition& viewPosition,566const int offsetX, const int offsetY, const int clickedButton,567const std::string& keyModifier, const int numberOfClicks) const;568569/// @brief build mouse left click press event570FXEvent* buildMouseClickEvent(FXSelType type, const InternalTest::ViewPosition& viewPosition,571const int offsetX, const int offsetY, const std::string& keyModifier,572const int numberOfClicks) const;573574/// @brief write click info575void writeClickInfo(const InternalTest::ViewPosition& viewPosition,576const int offsetX, const int offsetY,577const std::string modifier) const;578579/// @}580581/// @brief invalidate default constructor582InternalTestStep() = delete;583584/// @brief Invalidated copy constructor.585InternalTestStep(const InternalTestStep&) = delete;586587/// @brief Invalidated assignment operator588InternalTestStep& operator=(const InternalTestStep&) = delete;589};590591592