31#pragma warning(disable:4996)
35#define numPointsInterpolation 100
79 const std::string& subMenuAValue,
const std::string& subMenuBValue) :
111 const std::string& left,
const std::string& right) :
148 const auto sumoHome = std::string(getenv(
"SUMO_HOME"));
155 std::ifstream strm(testFile);
158 std::cout <<
"Could not open test file '" + testFile +
"'." << std::endl;
161 std::cout <<
"Error loading test data files" << std::endl;
165 std::vector<std::pair<bool, std::string> > linesRaw;
167 while (std::getline(strm, line)) {
174 linesRaw.push_back(std::make_pair(
startWith(line,
"netedit."), line));
181 for (
const auto& clearLine : lines) {
245 return static_cast<FXuint
>(
246 std::chrono::duration_cast<std::chrono::milliseconds>(
247 std::chrono::steady_clock::now().time_since_epoch()
252const std::map<std::string, int>&
258const std::map<std::string, InternalTest::ContextualMenu>&
264const std::map<std::string, InternalTest::ViewPosition>&
270const std::map<std::string, InternalTest::Movement>&
288std::vector<InternalTest::ViewPosition>
290 const int offsetStartX,
const int offsetStartY,
292 const int offsetEndX,
const int offsetEndY)
const {
294 std::vector<InternalTest::ViewPosition> trajectory;
303 const int interpolatedX = int(from.getX() + t * (to.getX() - from.getX()));
304 const int interpolatedY = int(from.getY() + t * (to.getY() - from.getY()));
306 trajectory.push_back(
ViewPosition(interpolatedX, interpolatedY));
312std::map<std::string, int>
314 std::map<std::string, int> solution;
316 std::ifstream strm(filePath);
319 WRITE_ERRORF(
TL(
"Could not open attributes enum file '%'."), filePath);
323 while (std::getline(strm, line)) {
325 std::stringstream ss(line);
329 std::getline(ss, key,
' ');
330 std::getline(ss, value,
'\n');
333 WRITE_ERRORF(
TL(
"In internal test file, value '%' cannot be parsed to int."), value);
343std::map<std::string, InternalTest::ContextualMenu>
345 std::map<std::string, InternalTest::ContextualMenu> solution;
347 std::ifstream strm(filePath);
350 WRITE_ERRORF(
TL(
"Could not open view positions file '%'."), filePath);
354 while (std::getline(strm, line)) {
356 std::string mainMenuKey;
357 std::string mainMenuValue;
358 std::string subMenuAKey;
359 std::string subMenuAValue;
360 std::string subMenuBKey;
361 std::string subMenuBValue;
363 std::stringstream mainMenuSS(line);
364 std::getline(mainMenuSS, mainMenuKey,
' ');
365 std::getline(mainMenuSS, mainMenuValue,
'\n');
367 std::getline(strm, line);
368 std::stringstream subMenuASS(line);
369 std::getline(subMenuASS, subMenuAKey,
' ');
370 std::getline(subMenuASS, subMenuAValue,
'\n');
372 std::getline(strm, line);
373 std::stringstream subMenuBSS(line);
374 std::getline(subMenuBSS, subMenuBKey,
' ');
375 std::getline(subMenuBSS, subMenuBValue,
'\n');
378 WRITE_ERRORF(
TL(
"In internal test file, mainMenu value '%' cannot be parsed to int."), mainMenuValue);
380 WRITE_ERRORF(
TL(
"In internal test file, subMenuA value '%' cannot be parsed to int."), subMenuAValue);
382 WRITE_ERRORF(
TL(
"In internal test file, subMenuB value '%' cannot be parsed to int."), subMenuBValue);
393std::map<std::string, InternalTest::ViewPosition>
395 std::map<std::string, InternalTest::ViewPosition> solution;
397 std::ifstream strm(filePath);
400 WRITE_ERRORF(
TL(
"Could not open view positions file '%'."), filePath);
404 while (std::getline(strm, line)) {
406 std::stringstream ss(line);
411 std::getline(ss, key,
' ');
412 std::getline(ss, xValue,
' ');
413 std::getline(ss, yValue,
'\n');
416 WRITE_ERRORF(
TL(
"In internal test file, x value '%' cannot be parsed to int."), xValue);
418 WRITE_ERRORF(
TL(
"In internal test file, y value '%' cannot be parsed to int."), yValue);
428std::map<std::string, InternalTest::Movement>
430 std::map<std::string, InternalTest::Movement> solution;
432 std::ifstream strm(filePath);
435 WRITE_ERRORF(
TL(
"Could not open view positions file '%'."), filePath);
439 while (std::getline(strm, line)) {
441 std::stringstream ss(line);
445 std::string downValue;
446 std::string leftValue;
447 std::string rightValue;
448 std::getline(ss, key,
' ');
449 std::getline(ss, upValue,
' ');
450 std::getline(ss, downValue,
' ');
451 std::getline(ss, leftValue,
' ');
452 std::getline(ss, rightValue,
'\n');
455 WRITE_ERRORF(
TL(
"In internal test file, x value '%' cannot be parsed to int."), upValue);
457 WRITE_ERRORF(
TL(
"In internal test file, y value '%' cannot be parsed to int."), downValue);
459 WRITE_ERRORF(
TL(
"In internal test file, y value '%' cannot be parsed to int."), leftValue);
461 WRITE_ERRORF(
TL(
"In internal test file, y value '%' cannot be parsed to int."), rightValue);
471std::vector<std::string>
473 std::vector<std::string> results;
474 for (
const auto& lineRaw : linesRaw) {
476 results.push_back(lineRaw.second);
477 }
else if (results.size() > 0) {
478 results.back().append(lineRaw.second);
487 if (prefix.size() > str.size()) {
490 for (
int i = 0; i < (int)prefix.size(); i++) {
491 if (str[i] != prefix[i]) {
#define numPointsInterpolation
#define WRITE_ERRORF(...)
int getUp() const
get up value
int getLeft() const
get left value
int getDown() const
get down value
Movement()
default constructor
int getRight() const
get right value
int getY() const
get y value
int getX() const
get x value
ViewPosition()
default constructor
std::vector< InternalTest::ViewPosition > interpolateViewPositions(const InternalTest::ViewPosition &viewStartPosition, const int offsetStartX, const int offsetStartY, const InternalTest::ViewPosition &viewEndPosition, const int offsetEndX, const int offsetEndY) const
interpolate view positions
bool isRunning() const
check if test is running
void addTestSteps(InternalTestStep *internalTestStep)
add test steps
InternalTestStep * getCurrentStep() const
get current step
const std::map< std::string, InternalTest::ContextualMenu > & getContextualMenuOperations() const
get map with contextual menu operation jump steps
bool startWith(const std::string &str, const std::string &prefix) const
check if the given string start with
std::vector< std::string > cleanLines(const std::vector< std::pair< bool, std::string > > &linesRaw) const
clear lines
const std::map< std::string, int > & getAttributesEnum() const
get map with attributesEnum jump steps
InternalTest::ViewPosition myLastMovedPosition
last moved position
InternalTestStep * myLastTestStep
last test steps
InternalTestStep * myCurrentTestStep
current test step
std::map< std::string, int > parseAttributesEnumFile(const std::string filePath) const
parse attributesEnum file
std::map< std::string, InternalTest::ViewPosition > parseViewPositionsFile(const std::string filePath) const
parse viewPositions file
~InternalTest()
destructor
std::map< std::string, InternalTest::Movement > myMovements
vector with movements
std::map< std::string, InternalTest::ContextualMenu > myContextualMenuOperations
vector with contextual menu operation jump steps
std::map< std::string, InternalTest::ContextualMenu > parseContextualMenuOperationsFile(const std::string filePath) const
parse attributesEnum file
bool myRunning
flag to indicate if test is running
std::map< std::string, InternalTest::ViewPosition > myViewPositions
vector with view positions
std::map< std::string, int > myAttributesEnum
vector with attributesEnum jump steps
std::map< std::string, InternalTest::Movement > parseMovementsFile(const std::string filePath) const
parse movements file
const std::map< std::string, InternalTest::ViewPosition > & getViewPositions() const
get map with view position pairs
InternalTest()=delete
invalidate default constructor
void stopTests()
stop tests
FXint getTime() const
get currentTime
void updateLastMovedPosition(const int x, const int y)
update last moved position
InternalTestStep * setNextStep()
get current step and set next step
const InternalTest::ViewPosition & getLastMovedPosition() const
get last moved position
InternalTestStep * myInitialTestStep
initial test steps
const std::map< std::string, InternalTest::Movement > & getMovements() const
get map with movement pairs
InternalTestStep * getNextStep() const
get next step
void setNextStep(InternalTestStep *nextStep)
set next step
Some static methods for string processing.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool isInt(const std::string &sData)
check if the given sData can be converted to int