30#pragma warning(disable:4996)
34#define numPointsInterpolation 100
78 const std::string& subMenuAValue,
const std::string& subMenuBValue) :
110 const std::string& left,
const std::string& right) :
147 const auto sumoHome = std::string(getenv(
"SUMO_HOME"));
154 std::ifstream strm(testFile);
157 std::cout <<
"Could not open test file '" + testFile +
"'." << std::endl;
160 std::cout <<
"Error loading test data files" << std::endl;
164 std::vector<std::pair<bool, std::string> > linesRaw;
166 while (std::getline(strm, line)) {
173 linesRaw.push_back(std::make_pair(
startWith(line,
"netedit."), line));
180 for (
const auto& clearLine : lines) {
244 return static_cast<FXuint
>(
245 std::chrono::duration_cast<std::chrono::milliseconds>(
246 std::chrono::steady_clock::now().time_since_epoch()
251const std::map<std::string, int>&
257const std::map<std::string, InternalTest::ContextualMenu>&
263const std::map<std::string, InternalTest::ViewPosition>&
269const std::map<std::string, InternalTest::Movement>&
287std::vector<InternalTest::ViewPosition>
289 const int offsetStartX,
const int offsetStartY,
291 const int offsetEndX,
const int offsetEndY)
const {
293 std::vector<InternalTest::ViewPosition> trajectory;
302 const int interpolatedX = int(from.getX() + t * (to.getX() - from.getX()));
303 const int interpolatedY = int(from.getY() + t * (to.getY() - from.getY()));
305 trajectory.push_back(
ViewPosition(interpolatedX, interpolatedY));
311std::map<std::string, int>
313 std::map<std::string, int> solution;
315 std::ifstream strm(filePath);
318 WRITE_ERRORF(
TL(
"Could not open attributes enum file '%'."), filePath);
322 while (std::getline(strm, line)) {
324 std::stringstream ss(line);
328 std::getline(ss, key,
' ');
329 std::getline(ss, value,
'\n');
332 WRITE_ERRORF(
TL(
"In internal test file, value '%' cannot be parsed to int."), value);
342std::map<std::string, InternalTest::ContextualMenu>
344 std::map<std::string, InternalTest::ContextualMenu> solution;
346 std::ifstream strm(filePath);
349 WRITE_ERRORF(
TL(
"Could not open view positions file '%'."), filePath);
353 while (std::getline(strm, line)) {
355 std::string mainMenuKey;
356 std::string mainMenuValue;
357 std::string subMenuAKey;
358 std::string subMenuAValue;
359 std::string subMenuBKey;
360 std::string subMenuBValue;
362 std::stringstream mainMenuSS(line);
363 std::getline(mainMenuSS, mainMenuKey,
' ');
364 std::getline(mainMenuSS, mainMenuValue,
'\n');
366 std::getline(strm, line);
367 std::stringstream subMenuASS(line);
368 std::getline(subMenuASS, subMenuAKey,
' ');
369 std::getline(subMenuASS, subMenuAValue,
'\n');
371 std::getline(strm, line);
372 std::stringstream subMenuBSS(line);
373 std::getline(subMenuBSS, subMenuBKey,
' ');
374 std::getline(subMenuBSS, subMenuBValue,
'\n');
377 WRITE_ERRORF(
TL(
"In internal test file, mainMenu value '%' cannot be parsed to int."), mainMenuValue);
379 WRITE_ERRORF(
TL(
"In internal test file, subMenuA value '%' cannot be parsed to int."), subMenuAValue);
381 WRITE_ERRORF(
TL(
"In internal test file, subMenuB value '%' cannot be parsed to int."), subMenuBValue);
392std::map<std::string, InternalTest::ViewPosition>
394 std::map<std::string, InternalTest::ViewPosition> solution;
396 std::ifstream strm(filePath);
399 WRITE_ERRORF(
TL(
"Could not open view positions file '%'."), filePath);
403 while (std::getline(strm, line)) {
405 std::stringstream ss(line);
410 std::getline(ss, key,
' ');
411 std::getline(ss, xValue,
' ');
412 std::getline(ss, yValue,
'\n');
415 WRITE_ERRORF(
TL(
"In internal test file, x value '%' cannot be parsed to int."), xValue);
417 WRITE_ERRORF(
TL(
"In internal test file, y value '%' cannot be parsed to int."), yValue);
427std::map<std::string, InternalTest::Movement>
429 std::map<std::string, InternalTest::Movement> solution;
431 std::ifstream strm(filePath);
434 WRITE_ERRORF(
TL(
"Could not open view positions file '%'."), filePath);
438 while (std::getline(strm, line)) {
440 std::stringstream ss(line);
444 std::string downValue;
445 std::string leftValue;
446 std::string rightValue;
447 std::getline(ss, key,
' ');
448 std::getline(ss, upValue,
' ');
449 std::getline(ss, downValue,
' ');
450 std::getline(ss, leftValue,
' ');
451 std::getline(ss, rightValue,
'\n');
454 WRITE_ERRORF(
TL(
"In internal test file, x value '%' cannot be parsed to int."), upValue);
456 WRITE_ERRORF(
TL(
"In internal test file, y value '%' cannot be parsed to int."), downValue);
458 WRITE_ERRORF(
TL(
"In internal test file, y value '%' cannot be parsed to int."), leftValue);
460 WRITE_ERRORF(
TL(
"In internal test file, y value '%' cannot be parsed to int."), rightValue);
470std::vector<std::string>
472 std::vector<std::string> results;
473 for (
const auto& lineRaw : linesRaw) {
475 results.push_back(lineRaw.second);
476 }
else if (results.size() > 0) {
477 results.back().append(lineRaw.second);
486 if (prefix.size() > str.size()) {
489 for (
int i = 0; i < (int)prefix.size(); i++) {
490 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