/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 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 typeKey function253void typeKey() const;254255/// @brief process contextualMenuOperation function256void contextualMenuOperation() const;257258/// @brief process protect elements function259void protectElements() const;260261/// @brief process waitDeleteWarning function262void waitDeleteWarning() const;263264/// @brief process modifyAttribute function265void modifyAttribute(const int overlappedTabs) const;266267/// @brief process modifyBoolAttribute function268void modifyBoolAttribute(const int overlappedTabs) const;269270/// @brief process modifyColorAttribute function271void modifyColorAttribute(const int overlappedTabs) const;272273/// @brief process modifyVClassDialog_DisallowAll function274void modifyVClassDialog_NoDisallowAll(const int overlappedTabs) const;275276/// @brief process modifyVClassDialog_DisallowAll function277void modifyVClassDialog_DisallowAll(const int overlappedTabs) const;278279/// @brief process modifyVClassDialog_Cancel function280void modifyVClassDialog_Cancel(const int overlappedTabs) const;281282/// @brief process modifyVClassDialog_Reset function283void modifyVClassDialog_Reset(const int overlappedTabs) const;284285/// @brief process modifyVTypeDialogAttribute function286void modifyVTypeDialogAttribute() const;287288/// @brief process createConnection function289void createConnection(const std::string& keyModifier) const;290291/// @brief process createCrossing function292void createCrossing() const;293294/// @brief process modifyCrossingDefaultValue function295void modifyCrossingDefaultValue() const;296297/// @brief process modifyCrossingDefaultBoolValue function298void modifyCrossingDefaultBoolValue() const;299300/// @brief process crossingClearEdges function301void crossingClearEdges() const;302303/// @brief process crossingInvertEdges function304void crossingInvertEdges() const;305306/// @brief process createConnectionEdit function307void saveConnectionEdit() const;308309/// @brief process fixCrossings function310void fixCrossings();311312/// @brief process fixStoppingPlace function313void fixStoppingPlace();314315/// @brief process fixRoutes function316void fixRoute();317318/// @brief process createTLS function319void createTLS(const int overlappedTabs) const;320321/// @brief process Copy TLS function322void copyTLS() const;323324/// @brief process join TLS function325void joinTSL() const;326327/// @brief process disJoin TLS function328void disJoinTLS() const;329330/// @brief process delete TLS function331void deleteTLS() const;332333/// @brief process modifyTLSTable function334void modifyTLSTable();335336/// @brief process resetSingleTLSPhases function337void resetSingleTLSPhases() const;338339/// @brief process resetAllTLSPhases function340void resetAllTLSPhases() const;341342/// @brief process pressTLSPhaseButton function343void pressTLSPhaseButton() const;344345/// @brief process addPhase function346void addPhase(const std::string& type);347348/// @brief process pressTLSButton function349void pressTLSButton(const std::string& type);350351/// @brief process checkParameters function352void checkParameters(const int overlappedTabs) const;353354/// @brief process checkDoubleParameters function355void checkDoubleParameters(const int overlappedTabs) const;356357/// @brief process changeEditMode function358void changeEditMode();359360/// @brief process save existent function361void saveExistentFile();362363/// @brief process check undo-redo function364void checkUndoRedo() const;365366/// @brief process delete function367void deleteFunction() const;368369/// @brief process selection function370void selection() const;371372/// @brief process selectNetworkItems function373void selectNetworkItems() const;374375/// @brief process lockSelection function376void lockSelection() const;377378/// @brief process selectionRectangle function379void selectionRectangle() const;380381/// @brief process createDataSet function382void createDataSet() const;383384/// @brief process createDataInterval function385void createDataInterval() const;386387/// @brief process openAboutDialog function388void openAboutDialog();389390/// @brief process load file function391void loadFile();392393/// @brief process save new file function394void saveNewFile();395396/// @brief process save file as function397void saveFileAs();398399/// @brief process reload file function400void reloadFile();401402/// @brief process select edge type function403void selectEdgeType();404405/// @brief process create new edge type function406void createNewEdgeType();407408/// @brief process overwriting accept function409void overwritingAccept();410411/// @brief process overwriting cancel function412void overwritingCancel();413414/// @brief process overwriting abort function415void overwritingAbort();416417/// @brief process overwriting apply to all function418void overwritingApplyToAll();419420/// @brief process undo function421void undo() const;422423/// @brief process redo function424void redo() const;425426/// @brief process changeSupermode function427void changeSupermode();428429/// @brief process changeMode function430void changeMode();431432/// @brief process changeElement function433void changeElement() const;434435/// @bief process changePlan function436void changePlan() const;437438/// @brief process computeJunctions function439void computeJunctions();440441/// @brief process computeJunctionsVolatileOptions function442void computeJunctionsVolatileOptions();443444/// @brief process selectChild function445void selectAdditionalChild();446447/// @brief process createRectangledShape function448void createRectangledShape();449450/// @brief process createSquaredShape function451void createSquaredShape();452453/// @brief process createLineShape function454void createLineShape();455456/// @brief process createMeanData function457void createMeanData();458459/// @brief process deleteMeanData function460void deleteMeanData();461462/// @brief process copyMeanData function463void copyMeanData();464465/// @brief process quit function466void quit();467468/// @brief check int argument469bool checkIntArgument(const std::string& argument) const;470471/// @brief get int argument472int getIntArgument(const std::string& argument) const;473474/// @brief check bool argument475bool checkBoolArgument(const std::string& argument) const;476477/// @brief get bool argument478bool getBoolArgument(const std::string& argument) const;479480/// @brief check string argument481bool checkStringArgument(const std::string& argument) const;482483/// @brief get string argument484std::string getStringArgument(const std::string& argument) const;485486/// @brief strip spaces487std::string stripSpaces(const std::string& str) const;488489/// @brief write error490void writeError(const std::string& function, const int overlapping,491const std::string& expected) const;492493/// @brief create shape494void createShape(const InternalTest::ViewPosition& viewPosition,495const int sizeX, const int sizeY, const bool close,496const bool line) const;497498/// @name modify attribute functions499/// @{500501/// @brief modify attribute502void modifyStringAttribute(Category category, const int tabs, const int overlappedTabs, const std::string& value) const;503504/// @brief modify bool attribute505void modifyBoolAttribute(Category category, const int tabs, const int overlappedTabs) const;506507/// @}508509/// @name undo-redo functions510/// @{511512/// @brief process check undo function513void buildUndo(const int number) const;514515/// @brief process check redo function516void buildRedo(const int number) const;517518/// @}519520/// @name key functions521/// @{522523/// @brief translate key524std::pair<FXint, FXString> translateKey(const std::string& key) const;525526/// @brief build key press event527FXEvent* buildKeyPressEvent(const std::string& key) const;528529/// @brief build key release event530FXEvent* buildKeyReleaseEvent(const std::string& key) const;531532/// @brief build a key press and key release (used for tabs, spaces, enter, etc)533void buildPressKeyEvent(Category category, const std::string& key, const bool updateView) const;534535/// @brief build a two key press and key release (used for tabs, spaces, enter, etc)536void buildTwoPressKeyEvent(Category category, const std::string& keyA, const std::string& keyB, const bool updateView) const;537538/// @}539540/// @name mouse functions541/// @{542543/// @brief build mouse click event544void buildMouseClick(const InternalTest::ViewPosition& viewPosition,545const int offsetX, const int offsetY,546const std::string& button, const std::string& keyModifier) const;547548/// @brief build mouse dragdrop549void buildMouseDragDrop(const InternalTest::ViewPosition& viewStartPosition,550const int offsetStartX, const int offsetStartY,551const InternalTest::ViewPosition& viewEndPosition,552const int offsetEndX, const int offsetEndY,553const std::string& keyModifier) const;554555/// @brief build mouse move event556FXEvent* buildMouseMoveEvent(const InternalTest::ViewPosition& viewPosition,557const int offsetX, const int offsetY, const int clickedButton,558const std::string& keyModifier, const int numberOfClicks) const;559560/// @brief build mouse left click press event561FXEvent* buildMouseClickEvent(FXSelType type, const InternalTest::ViewPosition& viewPosition,562const int offsetX, const int offsetY, const std::string& keyModifier,563const int numberOfClicks) const;564565/// @brief write click info566void writeClickInfo(const InternalTest::ViewPosition& viewPosition,567const int offsetX, const int offsetY,568const std::string modifier) const;569570/// @}571572/// @brief invalidate default constructor573InternalTestStep() = delete;574575/// @brief Invalidated copy constructor.576InternalTestStep(const InternalTestStep&) = delete;577578/// @brief Invalidated assignment operator579InternalTestStep& operator=(const InternalTestStep&) = delete;580};581582583