/****************************************************************************/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 InternalTest.h14/// @author Pablo Alvarez Lopez15/// @date Mar 202516///17// Class used for internal tests18/****************************************************************************/19#pragma once20#include <config.h>2122#include <string>23#include <vector>24#include <map>2526#include <utils/foxtools/fxheader.h>2728// ===========================================================================29// class declaration30// ===========================================================================3132class InternalTestStep;3334// ===========================================================================35// class definitions36// ===========================================================================3738class InternalTest : public FXObject {3940public:41/// @brief view position42class ViewPosition {4344public:45/// @brief default constructor46ViewPosition();4748/// @brief parameter constructor (string)49ViewPosition(const int xValue, const int yValue);5051/// @brief parameter constructor52ViewPosition(const std::string& xValue, const std::string& yValue);5354/// @brief get x value55int getX() const;5657/// @brief get y value58int getY() const;5960private:61/// @brief x value62int myX = 0;6364/// @brief y value65int myY = 0;66};6768/// @brief contextual menu69struct ContextualMenu {7071public:72/// @brief default constructor73ContextualMenu();7475/// @brief constructor76ContextualMenu(const std::string& mainMenuValue, const std::string& subMenuAValue,77const std::string& subMenuBValue);7879/// @brief get main menu position80int getMainMenuPosition() const;8182/// @brief get submenu A position83int getSubMenuAPosition() const;8485/// @brief get submenu B position86int getSubMenuBPosition() const;8788private:89/// @brief main manue90int myMainMenu = 0;9192/// @brief submenu A93int mySubMenuA = 0;9495/// @brief submenu B96int mySubMenuB = 0;97};9899/// @brief view position100class Movement {101102public:103/// @brief default constructor104Movement();105106/// @brief constructor107Movement(const std::string& up, const std::string& down,108const std::string& left, const std::string& right);109110/// @brief get up value111int getUp() const;112113/// @brief get down value114int getDown() const;115116/// @brief get left value117int getLeft() const;118119/// @brief get right value120int getRight() const;121122private:123/// @brief up value124int myUp = 0;125126/// @brief down value127int myDown = 0;128129/// @brief left value130int myLeft = 0;131132/// @brief right value133int myRight = 0;134};135136/// @brief constructor137InternalTest(const std::string& testFile);138139/// @brief destructor140~InternalTest();141142/// @name functions related with test steps143/// @{144145/// @brief add test steps146void addTestSteps(InternalTestStep* internalTestStep);147148/// @brief get current step149InternalTestStep* getCurrentStep() const;150151/// @brief get current step and set next step152InternalTestStep* setNextStep();153154/// @}155156/// @brief check if test is running157bool isRunning() const;158159/// @brief stop tests160void stopTests();161162/// @brief get currentTime163FXint getTime() const;164165/// @brief get map with attributesEnum jump steps166const std::map<std::string, int>& getAttributesEnum() const;167168/// @brief get map with contextual menu operation jump steps169const std::map<std::string, InternalTest::ContextualMenu>& getContextualMenuOperations() const;170171/// @brief get map with view position pairs172const std::map<std::string, InternalTest::ViewPosition>& getViewPositions() const;173174/// @brief get map with movement pairs175const std::map<std::string, InternalTest::Movement>& getMovements() const;176177/// @brief get last moved position178const InternalTest::ViewPosition& getLastMovedPosition() const;179180/// @brief update last moved position181void updateLastMovedPosition(const int x, const int y);182183/// @brief interpolate view positions184std::vector<InternalTest::ViewPosition> interpolateViewPositions(185const InternalTest::ViewPosition& viewStartPosition,186const int offsetStartX, const int offsetStartY,187const InternalTest::ViewPosition& viewEndPosition,188const int offsetEndX, const int offsetEndY) const;189190protected:191/// @brief initial test steps192InternalTestStep* myInitialTestStep = nullptr;193194/// @brief last test steps195InternalTestStep* myLastTestStep = nullptr;196197/// @brief current test step198InternalTestStep* myCurrentTestStep = nullptr;199200/// @brief flag to indicate if test is running201bool myRunning = false;202203/// @brief flag to check if test was finished204bool myTestFinished = false;205206/// @brief vector with attributesEnum jump steps207std::map<std::string, int> myAttributesEnum;208209/// @brief vector with contextual menu operation jump steps210std::map<std::string, InternalTest::ContextualMenu> myContextualMenuOperations;211212/// @brief vector with view positions213std::map<std::string, InternalTest::ViewPosition> myViewPositions;214215/// @brief vector with movements216std::map<std::string, InternalTest::Movement> myMovements;217218/// @brief last moved position219InternalTest::ViewPosition myLastMovedPosition;220221/// @brief parse attributesEnum file222std::map<std::string, int> parseAttributesEnumFile(const std::string filePath) const;223224/// @brief parse attributesEnum file225std::map<std::string, InternalTest::ContextualMenu> parseContextualMenuOperationsFile(const std::string filePath) const;226227/// @brief parse viewPositions file228std::map<std::string, InternalTest::ViewPosition> parseViewPositionsFile(const std::string filePath) const;229230/// @brief parse movements file231std::map<std::string, InternalTest::Movement> parseMovementsFile(const std::string filePath) const;232233/// @brief clear lines234std::vector<std::string> cleanLines(const std::vector<std::pair<bool, std::string> >& linesRaw) const;235236/// @brief check if the given string start with237bool startWith(const std::string& str, const std::string& prefix) const;238239private:240/// @brief invalidate default constructor241InternalTest() = delete;242243/// @brief Invalidated copy constructor.244InternalTest(const InternalTest&) = delete;245246/// @brief Invalidated assignment operator247InternalTest& operator=(const InternalTest& src) = delete;248};249250251