Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/tests/InternalTestStep.cpp
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file InternalTestStep.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Mar 2025
17
///
18
// Single operation used in InternalTests
19
/****************************************************************************/
20
#include <config.h>
21
22
#include <fxkeys.h>
23
24
#include <utils/gui/windows/GUIAppEnum.h>
25
#include <utils/gui/windows/GUISUMOAbstractView.h>
26
27
#include "InternalTestStep.h"
28
29
// ===========================================================================
30
// static member definitions
31
// ===========================================================================
32
33
// this offsets corresponds to the offset of the test magenta square
34
constexpr int MOUSE_OFFSET_X = 24;
35
constexpr int MOUSE_OFFSET_Y = 25;
36
constexpr int MOUSE_REFERENCE_X = 304;
37
constexpr int MOUSE_REFERENCE_Y = 168;
38
39
// ===========================================================================
40
// member method definitions
41
// ===========================================================================
42
43
// ---------------------------------------------------------------------------
44
// InternalTestStep::DialogArgument - public methods
45
// ---------------------------------------------------------------------------
46
47
InternalTestStep::DialogArgument::DialogArgument(DialogType type, Action action) :
48
myType(type),
49
myAction(action) {
50
}
51
52
53
InternalTestStep::DialogArgument::DialogArgument(DialogType type, const std::string& customAction) :
54
myType(type),
55
myAction(InternalTestStep::DialogArgument::Action::CUSTOM),
56
myCustomAction(customAction) {
57
}
58
59
60
InternalTestStep::DialogArgument::DialogArgument(DialogType type, const std::string& customAction, const int index) :
61
myType(type),
62
myAction(InternalTestStep::DialogArgument::Action::CUSTOM),
63
myCustomAction(customAction),
64
myIndex(index) {
65
}
66
67
68
InternalTestStep::DialogArgument::DialogArgument(DialogType type, const std::string& prefixToRemove, const std::string& customAction) :
69
myType(type),
70
myAction(InternalTestStep::DialogArgument::Action::CUSTOM),
71
myCustomAction(customAction) {
72
// remove prefix from custom action
73
if (prefixToRemove.size() > 0) {
74
const auto pos = customAction.find(prefixToRemove);
75
if (pos != std::string::npos) {
76
myCustomAction.erase(pos, prefixToRemove.length());
77
}
78
}
79
}
80
81
82
DialogType
83
InternalTestStep::DialogArgument::getType() const {
84
return myType;
85
}
86
87
88
InternalTestStep::DialogArgument::Action
89
InternalTestStep::DialogArgument::getAction() const {
90
return myAction;
91
}
92
93
94
const std::string&
95
InternalTestStep::DialogArgument::getCustomAction() const {
96
return myCustomAction;
97
}
98
99
100
int
101
InternalTestStep::DialogArgument::getIndex() const {
102
return myIndex;
103
}
104
105
// ---------------------------------------------------------------------------
106
// InternalTestStep::TLSTableTest - public methods
107
// ---------------------------------------------------------------------------
108
109
InternalTestStep::TLSTableTest::TLSTableTest(FXSelector sel_, const int row_) :
110
sel(sel_),
111
row(row_) {
112
}
113
114
115
InternalTestStep::TLSTableTest::TLSTableTest(FXSelector sel_, const int row_, const int column_, const std::string& text_) :
116
sel(sel_),
117
row(row_),
118
column(column_),
119
text(text_) {
120
}
121
122
// ---------------------------------------------------------------------------
123
// InternalTestStep - public methods
124
// ---------------------------------------------------------------------------
125
126
InternalTestStep::InternalTestStep(InternalTest* testSystem, const std::string& step) :
127
myTestSystem(testSystem) {
128
// add this testStep to test system
129
testSystem->addTestSteps(this);
130
// get overlapped tabs
131
const int overlappedTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.editElements.overlapped");
132
// parse step
133
const auto function = parseStep(step);
134
// set description based in function
135
myDescription = "Process function: " + function;
136
// continue depending of function
137
if (function == "setupAndStart") {
138
setupAndStart();
139
} else if (function == "finish") {
140
finish();
141
} else if ((function == "leftClick") || (function == "leftClickData")) {
142
mouseClick("left", "");
143
} else if (function == "leftClickControl") {
144
mouseClick("left", "control");
145
} else if (function == "leftClickShift") {
146
mouseClick("left", "shift");
147
} else if (function == "rightClick") {
148
mouseClick("right", "");
149
} else if (function == "rightClickControl") {
150
mouseClick("right", "control");
151
} else if (function == "rightClickShift") {
152
mouseClick("right", "shift");
153
} else if (function == "leftClickOffset") {
154
leftClickOffset("left");
155
} else if (function == "typeKey") {
156
typeKey();
157
} else if (function == "moveElementHorizontal") {
158
moveElementHorizontal();
159
} else if (function == "moveElementVertical") {
160
moveElementVertical();
161
} else if (function == "moveElement") {
162
moveElement();
163
} else if (function == "contextualMenuOperation") {
164
contextualMenuOperation();
165
} else if (function == "protectElements") {
166
protectElements();
167
} else if (function == "waitDeleteWarning") {
168
waitDeleteWarning();
169
} else if (function == "modifyAttribute") {
170
modifyAttribute(0);
171
} else if (function == "modifyAttributeOverlapped") {
172
modifyAttribute(overlappedTabs);
173
} else if (function == "modifyBoolAttribute") {
174
modifyBoolAttribute(0);
175
} else if (function == "modifyBoolAttributeOverlapped") {
176
modifyBoolAttribute(overlappedTabs);
177
} else if (function == "modifyColorAttribute") {
178
modifyColorAttribute(0);
179
} else if (function == "modifyColorAttributeOverlapped") {
180
modifyColorAttribute(overlappedTabs);
181
} else if (function == "modifyVClassDialog_NoDisallowAll") {
182
modifyVClassDialog_NoDisallowAll(0);
183
} else if (function == "modifyVClassDialogOverlapped_NoDisallowAll") {
184
modifyVClassDialog_NoDisallowAll(overlappedTabs);
185
} else if (function == "modifyVClassDialog_DisallowAll") {
186
modifyVClassDialog_DisallowAll(0);
187
} else if (function == "modifyVClassDialogOverlapped_DisallowAll") {
188
modifyVClassDialog_DisallowAll(overlappedTabs);
189
} else if (function == "modifyVClassDialog_Cancel") {
190
modifyVClassDialog_Cancel(0);
191
} else if (function == "modifyVClassDialogOverlapped_Cancel") {
192
modifyVClassDialog_Cancel(overlappedTabs);
193
} else if (function == "modifyVClassDialog_Reset") {
194
modifyVClassDialog_Reset(0);
195
} else if (function == "modifyVClassDialogOverlapped_Reset") {
196
modifyVClassDialog_Reset(overlappedTabs);
197
} else if (function == "modifyVTypeDialogAttribute") {
198
modifyVTypeDialogAttribute();
199
} else if (function == "createConnection") {
200
createConnection("");
201
} else if (function == "createCrossing") {
202
createCrossing();
203
} else if (function == "modifyCrossingDefaultValue") {
204
modifyCrossingDefaultValue();
205
} else if (function == "modifyCrossingDefaultBoolValue") {
206
modifyCrossingDefaultBoolValue();
207
} else if (function == "crossingClearEdges") {
208
crossingClearEdges();
209
} else if (function == "crossingInvertEdges") {
210
crossingInvertEdges();
211
} else if (function == "createConnectionConflict") {
212
createConnection("control");
213
} else if (function == "createConnectionYield") {
214
createConnection("shift");
215
} else if (function == "saveConnectionEdit") {
216
saveConnectionEdit();
217
} else if (function == "fixCrossings") {
218
fixCrossings();
219
} else if (function == "fixStoppingPlace") {
220
fixStoppingPlace();
221
} else if (function == "fixRoute") {
222
fixRoute();
223
} else if (function == "createTLS") {
224
createTLS(0);
225
} else if (function == "createTLSOverlapped") {
226
createTLS(overlappedTabs);
227
} else if (function == "copyTLS") {
228
copyTLS();
229
} else if (function == "joinTSL") {
230
joinTSL();
231
} else if (function == "disJoinTLS") {
232
disJoinTLS();
233
} else if (function == "deleteTLS") {
234
deleteTLS();
235
} else if (function == "modifyTLSTable") {
236
modifyTLSTable();
237
} else if (function == "resetSingleTLSPhases") {
238
resetSingleTLSPhases();
239
} else if (function == "resetAllTLSPhases") {
240
resetAllTLSPhases();
241
} else if (function == "pressTLSPhaseButton") {
242
pressTLSPhaseButton();
243
} else if (function == "addDefaultPhase") {
244
addPhase("default");
245
} else if (function == "addDuplicatePhase") {
246
addPhase("duplicate");
247
} else if (function == "addRedPhase") {
248
addPhase("red");
249
} else if (function == "addYellowPhase") {
250
addPhase("yellow");
251
} else if (function == "addGreenPhase") {
252
addPhase("green");
253
} else if (function == "addGreenPriorityPhase") {
254
addPhase("priorityGreen");
255
} else if (function == "tlsDeletePhase") {
256
addPhase("deletePhase");
257
} else if (function == "tlsMoveUp") {
258
addPhase("moveUp");
259
} else if (function == "tlsMoveDown") {
260
addPhase("moveDown");
261
} else if (function == "tlsCleanStates") {
262
pressTLSButton("cleanStates");
263
} else if (function == "tlsAddStates") {
264
pressTLSButton("addStates");
265
} else if (function == "tlsGroupSignal") {
266
pressTLSButton("groupSignal");
267
} else if (function == "tlsUngroupSignal") {
268
pressTLSButton("ungroupSignal");
269
} else if (function == "checkParameters") {
270
checkParameters(0);
271
} else if (function == "checkParametersOverlapped") {
272
checkParameters(overlappedTabs);
273
} else if (function == "checkDoubleParameters") {
274
checkDoubleParameters(0);
275
} else if (function == "checkDoubleParametersOverlapped") {
276
checkDoubleParameters(overlappedTabs);
277
} else if (function == "changeEditMode") {
278
changeEditMode();
279
} else if (function == "changeSupermode") {
280
changeSupermode();
281
} else if (function == "changeMode") {
282
changeMode();
283
} else if (function == "changeElement") {
284
changeElement();
285
} else if (function == "changePlan") {
286
changePlan();
287
} else if (function == "computeJunctions") {
288
computeJunctions();
289
} else if (function == "computeJunctionsVolatileOptions") {
290
computeJunctionsVolatileOptions();
291
} else if (function == "selectAdditionalChild") {
292
selectAdditionalChild();
293
} else if (function == "createRectangledShape") {
294
createRectangledShape();
295
} else if (function == "createSquaredShape") {
296
createSquaredShape();
297
} else if (function == "createLineShape") {
298
createLineShape();
299
} else if (function == "createMeanData") {
300
createMeanData();
301
} else if (function == "deleteMeanData") {
302
deleteMeanData();
303
} else if (function == "copyMeanData") {
304
copyMeanData();
305
} else if (function == "saveExistentFile") {
306
saveExistentFile();
307
} else if (function == "checkUndoRedo") {
308
checkUndoRedo();
309
} else if (function == "delete") {
310
deleteFunction();
311
} else if (function == "selection") {
312
selection();
313
} else if (function == "selectNetworkItems") {
314
selectNetworkItems();
315
} else if (function == "lockSelection") {
316
lockSelection();
317
} else if (function == "selectionRectangle") {
318
selectionRectangle();
319
} else if (function == "createDataSet") {
320
createDataSet();
321
} else if (function == "createDataInterval") {
322
createDataInterval();
323
} else if (function == "openAboutDialog") {
324
openAboutDialog();
325
} else if (function == "loadFile") {
326
loadFile();
327
} else if (function == "saveNewFile") {
328
saveNewFile();
329
} else if (function == "saveFileAs") {
330
saveFileAs();
331
} else if (function == "reloadFile") {
332
reloadFile();
333
} else if (function == "selectEdgeType") {
334
selectEdgeType();
335
} else if (function == "createNewEdgeType") {
336
createNewEdgeType();
337
} else if (function == "overwritingAccept") {
338
overwritingAccept();
339
} else if (function == "overwritingCancel") {
340
overwritingCancel();
341
} else if (function == "overwritingAbort") {
342
overwritingAbort();
343
} else if (function == "overwritingApplyToAll") {
344
overwritingApplyToAll();
345
} else if (function == "undo") {
346
undo();
347
} else if (function == "redo") {
348
redo();
349
} else if (function == "quit") {
350
quit();
351
} else if (function.size() > 0) {
352
std::cout << "Function " + function + " not implemented in InternalTestStep" << std::endl;
353
throw ProcessError();
354
}
355
}
356
357
358
InternalTestStep::InternalTestStep(InternalTest* testSystem, FXSelector messageType,
359
FXSelector messageID, Category category,
360
const std::string& description) :
361
myTestSystem(testSystem),
362
myMessageType(messageType),
363
myMessageID(messageID),
364
myCategory(category),
365
myDescription(description) {
366
// add this testStep to test system
367
testSystem->addTestSteps(this);
368
}
369
370
371
InternalTestStep::InternalTestStep(InternalTest* testSystem, FXSelector messageType,
372
Category category, FXEvent* event, const bool updateView,
373
const std::string& description) :
374
myTestSystem(testSystem),
375
myMessageType(messageType),
376
myCategory(category),
377
myUpdateView(updateView),
378
myDescription(description),
379
myEvent(event) {
380
// add this testStep to test system
381
testSystem->addTestSteps(this);
382
}
383
384
385
InternalTestStep::InternalTestStep(InternalTest* testSystem, DialogArgument* dialogArgument,
386
const std::string& description) :
387
myTestSystem(testSystem),
388
myCategory(InternalTestStep::Category::DIALOG),
389
myUpdateView(false),
390
myDescription(description),
391
myDialogArgument(dialogArgument) {
392
// add this testStep to test system
393
testSystem->addTestSteps(this);
394
}
395
396
397
InternalTestStep::~InternalTestStep() {
398
if (myEvent) {
399
delete myEvent;
400
}
401
if (myDialogArgument) {
402
delete myDialogArgument;
403
}
404
if (myTLSTableTest) {
405
delete myTLSTableTest;
406
}
407
}
408
409
410
InternalTestStep*
411
InternalTestStep::getNextStep() const {
412
return myNextStep;
413
}
414
415
416
void
417
InternalTestStep::setNextStep(InternalTestStep* nextStep) {
418
myNextStep = nextStep;
419
}
420
421
422
FXSelector
423
InternalTestStep::getMessageType() const {
424
return myMessageType;
425
}
426
427
428
FXSelector
429
InternalTestStep::getMessageID() const {
430
return myMessageID;
431
}
432
433
434
InternalTestStep::DialogArgument*
435
InternalTestStep::getDialogArgument() const {
436
return myDialogArgument;
437
}
438
439
440
InternalTestStep::TLSTableTest*
441
InternalTestStep::getTLSTableTest() const {
442
return myTLSTableTest;
443
}
444
445
446
FXSelector
447
InternalTestStep::getSelector() const {
448
return FXSEL(myMessageType, myMessageID);
449
}
450
451
452
bool
453
InternalTestStep::updateView() const {
454
return myUpdateView;
455
}
456
457
458
InternalTestStep::Category
459
InternalTestStep::getCategory() const {
460
return myCategory;
461
}
462
463
464
void*
465
InternalTestStep::getEvent() const {
466
return myEvent;
467
}
468
469
470
const std::string&
471
InternalTestStep::getDescription() const {
472
return myDescription;
473
}
474
475
476
std::string
477
InternalTestStep::parseStep(const std::string& rowText) {
478
// first check if this is the netedit.setupAndStart function
479
if (rowText.find("netedit.setupAndStart") != std::string::npos) {
480
return "setupAndStart";
481
} else if (rowText.find("netedit.finish") != std::string::npos) {
482
return "finish";
483
} else if (rowText.compare(0, 8, "netedit.") != 0) {
484
// proces only lines that start with "netedit."
485
return "";
486
} else {
487
std::string functionName;
488
// make a copy to help editing row
489
std::string rowStr = rowText;
490
// every function has the format <function>(<argument1>, <argument2>,....,)
491
if (rowText.empty() || (rowText.front() == '(') || (rowText.back() != ')')) {
492
writeError("parseStep", 0, "function(arguments)");
493
return "";
494
}
495
// first extract function
496
while (rowStr.size() > 0) {
497
if (rowStr.front() == '(') {
498
break;
499
} else {
500
functionName.push_back(rowStr.front());
501
rowStr.erase(rowStr.begin());
502
}
503
}
504
// remove prefix "netedit." (size 8) from function
505
functionName = functionName.substr(8);
506
// check if there are at least two characters (to avoid cases like 'function)')
507
if (rowStr.size() < 2) {
508
writeError("parseStep", 0, "function(arguments)");
509
return functionName;
510
}
511
// remove both pharentesis
512
rowStr.erase(rowStr.begin());
513
rowStr.pop_back();
514
// now parse arguments
515
parseArguments(rowStr);
516
// remove "netedit." from frunction
517
return functionName;
518
}
519
}
520
521
522
void
523
InternalTestStep::parseArguments(const std::string& arguments) {
524
std::string current;
525
bool inQuotes = false;
526
for (size_t i = 0; i < arguments.length(); ++i) {
527
char c = arguments[i];
528
if (c == '\"' || c == '\'') {
529
// Toggle quote state
530
inQuotes = !inQuotes;
531
current.push_back(c);
532
} else if (c == ',' && !inQuotes) {
533
// End of argument
534
if (!current.empty()) {
535
// Trim leading/trailing whitespace
536
size_t start = current.find_first_not_of(" \t");
537
size_t end = current.find_last_not_of(" \t");
538
myArguments.push_back(current.substr(start, end - start + 1));
539
current.clear();
540
}
541
} else {
542
current += c;
543
}
544
}
545
// Add the last argument
546
if (!current.empty()) {
547
size_t start = current.find_first_not_of(" \t");
548
size_t end = current.find_last_not_of(" \t");
549
myArguments.push_back(current.substr(start, end - start + 1));
550
}
551
// inQuotes MUST be false, in other case we have a case like < "argument1", argument2, "argument3 >
552
if (inQuotes) {
553
writeError("parseArguments", 0, "<\"argument\", \"argument\">");
554
myArguments.clear();
555
}
556
}
557
558
559
void
560
InternalTestStep::setupAndStart() {
561
myCategory = Category::INIT;
562
// print in console the following lines
563
std::cout << "TestFunctions: Netedit opened successfully" << std::endl;
564
std::cout << "Finding reference" << std::endl;
565
std::cout << "TestFunctions: 'reference.png' found. Position: " <<
566
toString(MOUSE_REFERENCE_X) << " - " <<
567
toString(MOUSE_REFERENCE_Y) << std::endl;
568
// set first mouse position
569
myTestSystem->updateLastMovedPosition(MOUSE_REFERENCE_X, MOUSE_REFERENCE_Y);
570
}
571
572
573
void
574
InternalTestStep::finish() {
575
myCategory = Category::FINISH;
576
myUpdateView = false;
577
std::cout << "TestFunctions: Netedit closed successfully" << std::endl;
578
}
579
580
581
void
582
InternalTestStep::mouseClick(const std::string& button, const std::string& modifier) const {
583
if ((myArguments.size() != 2) || (myTestSystem->getViewPositions().count(myArguments[1]) == 0)) {
584
writeError("leftClick", 0, "<reference, position>");
585
} else {
586
// parse view position
587
const auto& viewPosition = myTestSystem->getViewPositions().at(myArguments[1]);
588
// build mouse click
589
buildMouseClick(viewPosition, 0, 0, button, modifier);
590
// print info
591
writeClickInfo(viewPosition, 0, 0, modifier);
592
}
593
}
594
595
596
void
597
InternalTestStep::leftClickOffset(const std::string& button) const {
598
if ((myArguments.size() != 4) || (myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
599
!checkIntArgument(myArguments[2]) || !checkIntArgument(myArguments[3])) {
600
writeError("leftClickOffset", 0, "<reference, position, int, int>");
601
} else {
602
// parse view position
603
const auto& viewPosition = myTestSystem->getViewPositions().at(myArguments[1]);
604
const int x = getIntArgument(myArguments[2]);
605
const int y = getIntArgument(myArguments[3]);
606
// build mouse click
607
buildMouseClick(viewPosition, x, y, button, "");
608
// print info
609
writeClickInfo(viewPosition, x, y, button);
610
}
611
}
612
613
614
void
615
InternalTestStep::moveElementHorizontal() const {
616
if ((myArguments.size() != 3) || (myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
617
(myTestSystem->getMovements().count(myArguments[2]) == 0)) {
618
writeError("moveElementHorizontal", 0, "<reference, position, radius>");
619
} else {
620
// get parameters
621
const auto& referencePosition = myTestSystem->getViewPositions().at("netedit.positions.reference");
622
const auto& position = myTestSystem->getViewPositions().at(myArguments[1]);
623
const auto& radius = myTestSystem->getMovements().at(myArguments[2]);
624
// click over reference
625
buildMouseClick(referencePosition, 0, 0, "left", "");
626
// drag and drop
627
buildMouseDragDrop(position, 0, 0, position, radius.getRight(), 0, "");
628
buildMouseDragDrop(position, radius.getRight(), 0, position, radius.getLeft(), 0, "");
629
// write info
630
writeClickInfo(position, 0, 0, "");
631
}
632
}
633
634
635
void
636
InternalTestStep::moveElementVertical() const {
637
if ((myArguments.size() != 3) || (myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
638
(myTestSystem->getMovements().count(myArguments[2]) == 0)) {
639
writeError("moveElementVertical", 0, "<reference, position, radius>");
640
} else {
641
// get parameters
642
const auto& referencePosition = myTestSystem->getViewPositions().at("netedit.positions.reference");
643
const auto& position = myTestSystem->getViewPositions().at(myArguments[1]);
644
const auto& radius = myTestSystem->getMovements().at(myArguments[2]);
645
// click over reference
646
buildMouseClick(referencePosition, 0, 0, "left", "");
647
// drag and drop
648
buildMouseDragDrop(position, 0, 0, position, 0, radius.getUp(), "");
649
buildMouseDragDrop(position, radius.getRight(), 0, position, 0, radius.getDown(), "");
650
// write info
651
writeClickInfo(position, 0, 0, "");
652
}
653
}
654
655
656
void
657
InternalTestStep::moveElement() const {
658
if ((myArguments.size() != 3) || (myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
659
(myTestSystem->getMovements().count(myArguments[2]) == 0)) {
660
writeError("moveElement", 0, "<reference, position, radius>");
661
} else {
662
// get parameters
663
const auto& referencePosition = myTestSystem->getViewPositions().at("netedit.positions.reference");
664
const auto& position = myTestSystem->getViewPositions().at(myArguments[1]);
665
const auto& radius = myTestSystem->getMovements().at(myArguments[2]);
666
// click over reference
667
buildMouseClick(referencePosition, 0, 0, "left", "");
668
// drag and drop
669
buildMouseDragDrop(position, 0, 0, position, radius.getRight(), 0, "");
670
buildMouseDragDrop(position, radius.getRight(), 0, position, radius.getRight(), radius.getDown(), "");
671
// drag and drop
672
buildMouseDragDrop(position, radius.getRight(), radius.getDown(), position, radius.getLeft(), radius.getDown(), "");
673
buildMouseDragDrop(position, radius.getLeft(), radius.getDown(), position, radius.getLeft(), radius.getUp(), "");
674
}
675
}
676
677
678
void
679
InternalTestStep::typeKey() const {
680
if (myArguments.size() != 1) {
681
writeError("typeKey", 0, "<key>");
682
} else {
683
buildPressKeyEvent(Category::APP, getStringArgument(myArguments[0]), true);
684
}
685
}
686
687
688
void
689
InternalTestStep::contextualMenuOperation() const {
690
if ((myArguments.size() != 3) || (myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
691
(myTestSystem->getContextualMenuOperations().count(myArguments[2]) == 0)) {
692
writeError("contextualMenuOperation", 0, "<reference, position, contextualMenuOperations>");
693
} else {
694
// parse arguments
695
const auto& viewPosition = myTestSystem->getViewPositions().at(myArguments[1]);
696
const auto& contextualMenu = myTestSystem->getContextualMenuOperations().at(myArguments[2]);
697
// build mouse click
698
buildMouseClick(viewPosition, 0, 0, "right", "");
699
// jump to the element
700
for (int i = 0; i < contextualMenu.getMainMenuPosition(); i++) {
701
buildPressKeyEvent(Category::APP, "down", false);
702
}
703
// type space for select
704
buildPressKeyEvent(Category::APP, "space", false);
705
// jump to the subMenuA
706
if (contextualMenu.getSubMenuAPosition() > 0) {
707
for (int i = 0; i < contextualMenu.getSubMenuAPosition(); i++) {
708
buildPressKeyEvent(Category::APP, "down", false);
709
}
710
// type space for select
711
buildPressKeyEvent(Category::APP, "space", false);
712
}
713
// jump to the subMenuB
714
if (contextualMenu.getSubMenuBPosition() > 0) {
715
for (int i = 0; i < contextualMenu.getSubMenuBPosition(); i++) {
716
buildPressKeyEvent(Category::APP, "down", false);
717
}
718
// type space for select
719
buildPressKeyEvent(Category::APP, "space", false);
720
}
721
}
722
}
723
724
725
void
726
InternalTestStep::protectElements() const {
727
if (myArguments.size() != 0) {
728
writeError("protectElements", 0, "<>");
729
} else {
730
// go to delete mode
731
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_D_MODE_SINGLESIMULATIONSTEP_DELETE, Category::APP, "delete mode");
732
// focus frame
733
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus delete frame");
734
// jump to the element
735
for (int i = 0; i < myTestSystem->getAttributesEnum().at("netedit.attrs.frames.delete.protectElements"); i++) {
736
buildPressKeyEvent(Category::APP, "tab", false);
737
}
738
// press enter to confirm changes (updating view)
739
buildPressKeyEvent(Category::APP, "space", true);
740
}
741
}
742
743
744
void
745
InternalTestStep::waitDeleteWarning() const {
746
if (myArguments.size() != 0) {
747
writeError("waitDeleteWarning", 0, "<>");
748
} else {
749
// nothing to do (wait for delete warning doesnt' appear in internal test)
750
}
751
}
752
753
754
void
755
InternalTestStep::modifyAttribute(const int overlappedTabs) const {
756
if ((myArguments.size() != 2) || !checkIntArgument(myArguments[0]) ||
757
!checkStringArgument(myArguments[1])) {
758
writeError("modifyAttribute", overlappedTabs, "<int/attributeEnum, \"string\">");
759
} else {
760
// modify attribute
761
modifyStringAttribute(Category::APP, getIntArgument(myArguments[0]), overlappedTabs, getStringArgument(myArguments[1]));
762
}
763
}
764
765
766
void
767
InternalTestStep::modifyBoolAttribute(const int overlappedTabs) const {
768
if ((myArguments.size() != 1) || !checkIntArgument(myArguments[0])) {
769
writeError("modifyBoolAttribute", overlappedTabs, "<int/attributeEnum>");
770
} else {
771
// modify bool attribute
772
modifyBoolAttribute(Category::APP, getIntArgument(myArguments[0]), overlappedTabs);
773
}
774
}
775
776
777
void
778
InternalTestStep::modifyColorAttribute(const int overlappedTabs) const {
779
if ((myArguments.size() != 1) || !checkIntArgument(myArguments[0])) {
780
writeError("modifyColorAttribute", overlappedTabs, "<int/attributeEnum>");
781
} else {
782
// open dialog
783
modifyBoolAttribute(Category::APP, getIntArgument(myArguments[0]), overlappedTabs);
784
// select vClass
785
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::COLOR, "139,131,120"), "set color");
786
// press accept
787
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::COLOR, DialogArgument::Action::ACCEPT), "accept vClasses");
788
}
789
}
790
791
792
void
793
InternalTestStep::modifyVClassDialog_NoDisallowAll(const int overlappedTabs) const {
794
if ((myArguments.size() != 2) || !checkIntArgument(myArguments[0]) ||
795
!checkIntArgument(myArguments[1])) {
796
writeError("modifyVClassDialog_NoDisallowAll", overlappedTabs, "<int/attributeEnum, int/attributeEnum>");
797
} else {
798
// open dialog
799
modifyBoolAttribute(Category::APP, getIntArgument(myArguments[0]), overlappedTabs);
800
// select vClass
801
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, "netedit.attrs.dialog.allowVClass.", myArguments[1]), "select vClass");
802
// press accept
803
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, DialogArgument::Action::ACCEPT), "accept vClasses");
804
}
805
}
806
807
808
void
809
InternalTestStep::modifyVClassDialog_DisallowAll(const int overlappedTabs) const {
810
if ((myArguments.size() != 2) || !checkIntArgument(myArguments[0]) ||
811
!checkIntArgument(myArguments[1])) {
812
writeError("modifyVClassDialog_DisallowAll", overlappedTabs, "<int/attributeEnum, int/attributeEnum>");
813
} else {
814
// open dialog
815
modifyBoolAttribute(Category::APP, getIntArgument(myArguments[0]), overlappedTabs);
816
// select vClass
817
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, "disallowAll"), "disallow all");
818
// select vClass
819
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, "netedit.attrs.dialog.allowVClass.", myArguments[1]), "select vClass");
820
// press accept
821
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, DialogArgument::Action::ACCEPT), "accept vClasses");
822
}
823
}
824
825
826
void
827
InternalTestStep::modifyVClassDialog_Cancel(const int overlappedTabs) const {
828
if ((myArguments.size() != 2) ||
829
!checkIntArgument(myArguments[0]) ||
830
!checkIntArgument(myArguments[1])) {
831
writeError("modifyVClassDialog_Cancel", overlappedTabs, "<int/attributeEnum, int/attributeEnum>");
832
} else {
833
// open dialog
834
modifyBoolAttribute(Category::APP, getIntArgument(myArguments[0]), overlappedTabs);
835
// select vClass
836
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, "disallowAll"), "disallow all");
837
// select vClass
838
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, "netedit.attrs.dialog.allowVClass.", myArguments[1]), "select vClass");
839
// press accept
840
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, DialogArgument::Action::CANCEL), "accept vClasses");
841
}
842
}
843
844
845
void
846
InternalTestStep::modifyVClassDialog_Reset(const int overlappedTabs) const {
847
if ((myArguments.size() != 2) || !checkIntArgument(myArguments[0]) ||
848
!checkIntArgument(myArguments[1])) {
849
writeError("modifyVClassDialog_Reset", overlappedTabs, "<int/attributeEnum, int/attributeEnum>");
850
} else {
851
// open dialog
852
modifyBoolAttribute(Category::APP, getIntArgument(myArguments[0]), overlappedTabs);
853
// select vClass
854
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, "disallowAll"), "disallow all");
855
// select vClass
856
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, "netedit.attrs.dialog.allowVClass.", myArguments[1]), "select vClass");
857
// press reset
858
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, DialogArgument::Action::RESET), "accept vClasses");
859
// press accept
860
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::VCLASS, DialogArgument::Action::ACCEPT), "accept vClasses");
861
}
862
}
863
864
865
void
866
InternalTestStep::modifyVTypeDialogAttribute() const {
867
if ((myArguments.size() != 3) || !checkStringArgument(myArguments[0]) ||
868
!checkIntArgument(myArguments[1]) || !checkStringArgument(myArguments[2])) {
869
writeError("modifyVTypeDialogAttribute", 0, "<str, int/attributeEnum, str>");
870
} else {
871
// get arguments
872
const auto operation = getStringArgument(myArguments[0]);
873
const auto tabs = getIntArgument(myArguments[1]);
874
const auto value = getStringArgument(myArguments[2]);
875
// first check if open dialog
876
if (operation == "open") {
877
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.type.buttons.dialog"), 0);
878
}
879
// print info
880
std::cout << value << std::endl;
881
// focus dialog
882
buildTwoPressKeyEvent(Category::DIALOG, "alt", "f", false);
883
// jump to the element
884
for (int i = 0; i < tabs; i++) {
885
buildPressKeyEvent(Category::DIALOG, "tab", false);
886
}
887
// write attribute character by character
888
if (value.empty()) {
889
buildPressKeyEvent(Category::DIALOG, "delete", false);
890
} else {
891
for (const char c : value) {
892
buildPressKeyEvent(Category::DIALOG, {c}, false);
893
}
894
}
895
// press enter to confirm changes (updating view)
896
buildPressKeyEvent(Category::DIALOG, "enter", false);
897
// finally check if close dialog
898
if (operation == "close") {
899
buildTwoPressKeyEvent(Category::DIALOG, "alt", "a", false);
900
buildPressKeyEvent(Category::DIALOG, "enter", false);
901
}
902
}
903
}
904
905
906
void
907
InternalTestStep::createConnection(const std::string& keyModifier) const {
908
if ((myArguments.size() != 3) ||
909
(myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
910
(myTestSystem->getViewPositions().count(myArguments[2]) == 0)) {
911
writeError("createConnection", 0, "<reference, position, position>");
912
} else {
913
// parse view position
914
const auto& fromLane = myTestSystem->getViewPositions().at(myArguments[1]);
915
const auto& toLane = myTestSystem->getViewPositions().at(myArguments[2]);
916
// build mouse click from
917
buildMouseClick(fromLane, 0, 0, "left", keyModifier);
918
writeClickInfo(fromLane, 0, 0, "");
919
// build mouse click from
920
buildMouseClick(toLane, 0, 0, "left", keyModifier);
921
writeClickInfo(toLane, 0, 0, "");
922
}
923
}
924
925
926
void
927
InternalTestStep::createCrossing() const {
928
if ((myArguments.size() != 1) || !checkBoolArgument(myArguments[0])) {
929
writeError("createCrossing", 0, "<bool>");
930
} else {
931
if (getBoolArgument(myArguments[0])) {
932
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.crossing.createTLS.button"), 0);
933
} else {
934
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.crossing.create.button"), 0);
935
}
936
}
937
}
938
939
940
void
941
InternalTestStep::modifyCrossingDefaultValue() const {
942
if ((myArguments.size() != 2) || !checkIntArgument(myArguments[0]) || !checkStringArgument(myArguments[1])) {
943
writeError("modifyCrossingDefaultValue", 0, "<int, value>");
944
} else {
945
const int tabs = getIntArgument(myArguments[0]);
946
const auto value = getStringArgument(myArguments[1]);
947
modifyStringAttribute(Category::APP, tabs, myTestSystem->getAttributesEnum().at("netedit.attrs.crossing.firstField"), value);
948
}
949
}
950
951
952
void
953
InternalTestStep::modifyCrossingDefaultBoolValue() const {
954
if ((myArguments.size() != 1) || !checkIntArgument(myArguments[0])) {
955
writeError("modifyCrossingDefaultBoolValue", 0, "<int>");
956
} else {
957
const int tabs = getIntArgument(myArguments[0]);
958
modifyBoolAttribute(Category::APP, tabs, myTestSystem->getAttributesEnum().at("netedit.attrs.crossing.firstField"));
959
}
960
}
961
962
963
void
964
InternalTestStep::crossingClearEdges() const {
965
if (myArguments.size() != 0) {
966
writeError("crossingClearEdges", 0, "<>");
967
} else {
968
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.crossing.clearEdges"), 0);
969
}
970
}
971
972
973
void
974
InternalTestStep::crossingInvertEdges() const {
975
if (myArguments.size() != 0) {
976
writeError("crossingInvertEdges", 0, "<>");
977
} else {
978
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.crossing.invertEdges"), 0);
979
}
980
}
981
982
983
void
984
InternalTestStep::saveConnectionEdit() const {
985
if (myArguments.size() != 0) {
986
writeError("saveConnectionEdit", 0, "<>");
987
} else {
988
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.connection.saveConnections"), 0);
989
}
990
}
991
992
993
void
994
InternalTestStep::fixCrossings() {
995
if ((myArguments.size() != 1) || !checkStringArgument(myArguments[0])) {
996
writeError("fixCrossings", 0, "<str>");
997
} else {
998
// save config
999
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_CTRL_SHIFT_E_SAVENETEDITCONFIG,
1000
Category::APP, "save netedit config");
1001
// fix crossings
1002
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FIX_NETWORKELEMENTS, getStringArgument(myArguments[0])), "fix crossings");
1003
// accept changes
1004
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FIX_NETWORKELEMENTS, DialogArgument::Action::ACCEPT), "accept fix");
1005
}
1006
}
1007
1008
1009
void
1010
InternalTestStep::fixStoppingPlace() {
1011
if ((myArguments.size() != 1) || !checkStringArgument(myArguments[0])) {
1012
writeError("fixStoppingPlace", 0, "<str>");
1013
} else {
1014
// save config
1015
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_CTRL_SHIFT_E_SAVENETEDITCONFIG,
1016
Category::APP, "save netedit config");
1017
// fix stoppingPlace
1018
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FIX_ADDITIONALELEMENTS, getStringArgument(myArguments[0])), "fix stoppingPlace in dialog");
1019
// accept changes
1020
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FIX_ADDITIONALELEMENTS, DialogArgument::Action::ACCEPT), "accept fix");
1021
}
1022
}
1023
1024
1025
void
1026
InternalTestStep::fixRoute() {
1027
if ((myArguments.size() != 1) || !checkStringArgument(myArguments[0])) {
1028
writeError("fixRoute", 0, "<str>");
1029
} else {
1030
// save config
1031
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_CTRL_SHIFT_E_SAVENETEDITCONFIG,
1032
Category::APP, "save netedit config");
1033
// fix route
1034
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FIX_DEMANDELEMENTS, getStringArgument(myArguments[0])), "fix route in dialog");
1035
// accept changes
1036
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FIX_DEMANDELEMENTS, DialogArgument::Action::ACCEPT), "accept fix");
1037
}
1038
}
1039
1040
1041
void
1042
InternalTestStep::createTLS(const int overlappedTabs) const {
1043
if (myArguments.size() != 0) {
1044
writeError("createTLS", overlappedTabs, "<>");
1045
} else {
1046
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.create"), overlappedTabs);
1047
}
1048
}
1049
1050
1051
void
1052
InternalTestStep::copyTLS() const {
1053
if ((myArguments.size() != 1) || !checkBoolArgument(myArguments[0])) {
1054
writeError("copyTLS", 0, "<bool>");
1055
} else {
1056
if (getBoolArgument(myArguments[0])) {
1057
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.copyJoined"), 0);
1058
} else {
1059
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.copySingle"), 0);
1060
}
1061
}
1062
}
1063
1064
1065
void
1066
InternalTestStep::joinTSL() const {
1067
if (myArguments.size() != 0) {
1068
writeError("joinTSL", 0, "<>");
1069
} else {
1070
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.joinTLS"), 0);
1071
}
1072
}
1073
1074
1075
void
1076
InternalTestStep::disJoinTLS() const {
1077
if (myArguments.size() != 0) {
1078
writeError("disJoinTLS", 0, "<>");
1079
} else {
1080
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.disjoinTLS"), 0);
1081
}
1082
}
1083
1084
1085
void
1086
InternalTestStep::deleteTLS() const {
1087
if ((myArguments.size() != 1) || !checkBoolArgument(myArguments[0])) {
1088
writeError("deleteTLS", 0, "<bool>");
1089
} else {
1090
if (getBoolArgument(myArguments[0])) {
1091
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.deleteJoined"), 0);
1092
} else {
1093
modifyBoolAttribute(Category::APP, myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.deleteSingle"), 0);
1094
}
1095
}
1096
}
1097
1098
1099
void
1100
InternalTestStep::modifyTLSTable() {
1101
if ((myArguments.size() != 3) || !checkIntArgument(myArguments[0]) ||
1102
!checkIntArgument(myArguments[1]) || !checkStringArgument(myArguments[2])) {
1103
writeError("modifyTLSTable", 0, "<row, int/attributeEnum, \"string\">");
1104
} else {
1105
myCategory = Category::TLS_PHASETABLE;
1106
// get row
1107
const int row = getIntArgument(myArguments[0]);
1108
const int column = getIntArgument(myArguments[1]);
1109
const std::string text = getStringArgument(myArguments[2]);
1110
// modify attribute
1111
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_TEXTFIELD, row, column, text);
1112
// show text
1113
std::cout << text << std::endl;
1114
}
1115
}
1116
1117
1118
void
1119
InternalTestStep::resetSingleTLSPhases() const {
1120
if ((myArguments.size() != 1) || !checkBoolArgument(myArguments[0])) {
1121
writeError("resetSingleTLSPhases", 0, "<bool>");
1122
} else {
1123
if (getBoolArgument(myArguments[0])) {
1124
modifyBoolAttribute(myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.resetPhaseSingle"));
1125
} else {
1126
modifyBoolAttribute(myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.resetPhaseJoined"));
1127
}
1128
}
1129
}
1130
1131
1132
void
1133
InternalTestStep::resetAllTLSPhases() const {
1134
if ((myArguments.size() != 1) || !checkBoolArgument(myArguments[0])) {
1135
writeError("resetAllTLSPhases", 0, "<bool>");
1136
} else {
1137
if (getBoolArgument(myArguments[0])) {
1138
modifyBoolAttribute(myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.resetAllJoined"));
1139
} else {
1140
modifyBoolAttribute(myTestSystem->getAttributesEnum().at("netedit.attrs.TLS.resetAllSingle"));
1141
}
1142
}
1143
}
1144
1145
1146
void
1147
InternalTestStep::pressTLSPhaseButton() const {
1148
if ((myArguments.size() != 1) || !checkIntArgument(myArguments[0])) {
1149
writeError("pressTLSPhaseButton", 0, "<int/attributeEnum>");
1150
} else {
1151
modifyBoolAttribute(getIntArgument(myArguments[0]));
1152
}
1153
}
1154
1155
1156
void
1157
InternalTestStep::addPhase(const std::string& type) {
1158
if ((myArguments.size() != 1) || !checkIntArgument(myArguments[0])) {
1159
writeError("addPhase" + type, 0, "<int/attributeEnum>");
1160
} else {
1161
myCategory = Category::TLS_PHASETABLE;
1162
// get row
1163
const int row = getIntArgument(myArguments[0]);
1164
// continue depending of the type of phase
1165
if (type == "default") {
1166
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_ADDPHASE, row);
1167
} else if (type == "duplicate") {
1168
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_COPYPHASE, row);
1169
} else if (type == "red") {
1170
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_ADDPHASEALLRED, row);
1171
} else if (type == "yellow") {
1172
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_ADDPHASEALLYELLOW, row);
1173
} else if (type == "green") {
1174
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_ADDPHASEALLGREEN, row);
1175
} else if (type == "priorityGreen") {
1176
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_ADDPHASEALLGREENPRIORITY, row);
1177
} else if (type == "deletePhase") {
1178
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_REMOVEPHASE, row);
1179
} else if (type == "moveUp") {
1180
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_MOVEUPPHASE, row);
1181
} else if (type == "moveDown") {
1182
myTLSTableTest = new TLSTableTest(MID_GNE_TLSTABLE_MOVEDOWNPHASE, row);
1183
}
1184
}
1185
}
1186
1187
1188
void
1189
InternalTestStep::pressTLSButton(const std::string& type) {
1190
if (myArguments.size() != 0) {
1191
writeError("pressTLSButton" + type, 0, "<>");
1192
} else {
1193
myCategory = Category::TLS_PHASES;
1194
// continue depending of the type of phase
1195
if (type == "cleanStates") {
1196
myMessageID = MID_GNE_TLSFRAME_PHASES_CLEANUP;
1197
} else if (type == "addStates") {
1198
myMessageID = MID_GNE_TLSFRAME_PHASES_ADDUNUSED;
1199
} else if (type == "groupSignal") {
1200
myMessageID = MID_GNE_TLSFRAME_PHASES_GROUPSTATES;
1201
} else if (type == "ungroupSignal") {
1202
myMessageID = MID_GNE_TLSFRAME_PHASES_UNGROUPSTATES;
1203
}
1204
}
1205
}
1206
1207
1208
void
1209
InternalTestStep::checkParameters(const int overlappedTabs) const {
1210
if ((myArguments.size() != 2) || !checkIntArgument(myArguments[1])) {
1211
writeError("checkParameters", overlappedTabs, "<int/attributeEnum>");
1212
} else {
1213
const int tabs = getIntArgument(myArguments[1]);
1214
// check different values
1215
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "dummyGenericParameters");
1216
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1|key2|key3");
1217
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1=value1|key2=value2|key3=value3");
1218
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1=|key2=|key3=");
1219
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "");
1220
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1duplicated=value1|key1duplicated=value2|key3=value3");
1221
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1=valueDuplicated|key2=valueDuplicated|key3=valueDuplicated");
1222
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "keyInvalid.;%>%$$=value1|key2=value2|key3=value3");
1223
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1=valueInvalid%;%$<>$$%|key2=value2|key3=value3");
1224
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "keyFinal1=value1|keyFinal2=value2|keyFinal3=value3");
1225
// check undo-redo
1226
buildUndo(9);
1227
buildRedo(9);
1228
}
1229
}
1230
1231
1232
void
1233
InternalTestStep::checkDoubleParameters(const int overlappedTabs) const {
1234
if ((myArguments.size() != 2) || !checkIntArgument(myArguments[1])) {
1235
writeError("checkDoubleParameters", overlappedTabs, "<int/attributeEnum>");
1236
} else {
1237
const int tabs = getIntArgument(myArguments[1]);
1238
// check different values
1239
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "dummyGenericParameters");
1240
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1|key2|key3");
1241
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1=1|key2=2|key3=3");
1242
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1=|key2=|key3=");
1243
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "");
1244
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1duplicated=1|key1duplicated=2|key3=3");
1245
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1=Duplicated|key2=Duplicated|key3=Duplicated");
1246
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "keyInvalid.;%>%$$=1|key2=2|key3=3");
1247
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "key1=Invalid%;%$<>$$%|key2=2|key3=3");
1248
modifyStringAttribute(Category::APP, tabs, overlappedTabs, "keyFinal1=1|keyFinal2=2|keyFinal3=3");
1249
// check undo-redo
1250
buildUndo(9);
1251
buildRedo(9);
1252
}
1253
}
1254
1255
1256
void
1257
InternalTestStep::changeEditMode() {
1258
if ((myArguments.size() != 1) || (myTestSystem->getAttributesEnum().count(myArguments[0]) == 0)) {
1259
writeError("changeEditMode", 0, "<int/attributeEnum>");
1260
} else {
1261
myCategory = Category::APP;
1262
// network
1263
if (myArguments[0] == "netedit.attrs.modes.network.grid") {
1264
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_TOGGLEGRID;
1265
} else if (myArguments[0] == "netedit.attrs.modes.network.junctionShape") {
1266
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_TOGGLEDRAWJUNCTIONSHAPE;
1267
} else if (myArguments[0] == "netedit.attrs.modes.network.spreadVehicle") {
1268
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_DRAWSPREADVEHICLES;
1269
} else if (myArguments[0] == "netedit.attrs.modes.network.showDemandElements") {
1270
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_SHOWDEMANDELEMENTS;
1271
} else if (myArguments[0] == "netedit.attrs.modes.network.selectLane") {
1272
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_SELECTEDGES;
1273
} else if (myArguments[0] == "netedit.attrs.modes.network.showConnections") {
1274
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_SHOWCONNECTIONS;
1275
} else if (myArguments[0] == "netedit.attrs.modes.network.hideConnetions") {
1276
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_HIDECONNECTIONS;
1277
} else if (myArguments[0] == "netedit.attrs.modes.network.showSubAdditionals") {
1278
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_SHOWSUBADDITIONALS;
1279
} else if (myArguments[0] == "netedit.attrs.modes.network.showTAZElements") {
1280
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_SHOWTAZELEMENTS;
1281
} else if (myArguments[0] == "netedit.attrs.modes.network.automaticSelectJunctions") {
1282
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_EXTENDSELECTION;
1283
} else if (myArguments[0] == "netedit.attrs.modes.network.applyAllPhases") {
1284
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_CHANGEALLPHASES;
1285
} else if (myArguments[0] == "netedit.attrs.modes.network.mergingJunction") {
1286
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_MERGEAUTOMATICALLY;
1287
} else if (myArguments[0] == "netedit.attrs.modes.network.showBubbles") {
1288
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_SHOWBUBBLES;
1289
} else if (myArguments[0] == "netedit.attrs.modes.network.moveElevation") {
1290
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_MOVEELEVATION;
1291
} else if (myArguments[0] == "netedit.attrs.modes.network.chainMode") {
1292
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_CHAINEDGES;
1293
} else if (myArguments[0] == "netedit.attrs.modes.network.twoWayMode") {
1294
myMessageID = MID_GNE_NETWORKVIEWOPTIONS_AUTOOPPOSITEEDGES;
1295
// demand
1296
} else if (myArguments[0] == "netedit.attrs.modes.demand.grid") {
1297
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_SHOWGRID;
1298
} else if (myArguments[0] == "netedit.attrs.modes.demand.junctionShape") {
1299
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_TOGGLEDRAWJUNCTIONSHAPE;
1300
} else if (myArguments[0] == "netedit.attrs.modes.demand.spreadVehicle") {
1301
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_DRAWSPREADVEHICLES;
1302
} else if (myArguments[0] == "netedit.attrs.modes.demand.showNonInspected") {
1303
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_HIDENONINSPECTED;
1304
} else if (myArguments[0] == "netedit.attrs.modes.demand.showShapes") {
1305
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_HIDESHAPES;
1306
} else if (myArguments[0] == "netedit.attrs.modes.demand.showAllTrips") {
1307
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_SHOWTRIPS;
1308
} else if (myArguments[0] == "netedit.attrs.modes.demand.showPersonPlans") {
1309
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_SHOWALLPERSONPLANS;
1310
} else if (myArguments[0] == "netedit.attrs.modes.demand.lockPerson") {
1311
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_LOCKPERSON;
1312
} else if (myArguments[0] == "netedit.attrs.modes.demand.showContainerPlans") {
1313
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_SHOWALLCONTAINERPLANS;
1314
} else if (myArguments[0] == "netedit.attrs.modes.demand.lockContainer") {
1315
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_LOCKCONTAINER;
1316
} else if (myArguments[0] == "netedit.attrs.modes.demand.showOverlappedRoutes") {
1317
myMessageID = MID_GNE_DEMANDVIEWOPTIONS_SHOWOVERLAPPEDROUTES;
1318
// data
1319
} else if (myArguments[0] == "netedit.attrs.modes.data.junctionShape") {
1320
myMessageID = MID_GNE_DATAVIEWOPTIONS_TOGGLEDRAWJUNCTIONSHAPE;
1321
} else if (myArguments[0] == "netedit.attrs.modes.data.showAdditionals") {
1322
myMessageID = MID_GNE_DATAVIEWOPTIONS_SHOWADDITIONALS;
1323
} else if (myArguments[0] == "netedit.attrs.modes.data.showShapes") {
1324
myMessageID = MID_GNE_DATAVIEWOPTIONS_SHOWSHAPES;
1325
} else if (myArguments[0] == "netedit.attrs.modes.data.showDemandElements") {
1326
myMessageID = MID_GNE_DATAVIEWOPTIONS_SHOWDEMANDELEMENTS;
1327
} else if (myArguments[0] == "netedit.attrs.modes.data.TAZRelDrawingMode") {
1328
myMessageID = MID_GNE_DATAVIEWOPTIONS_TAZRELDRAWING;
1329
} else if (myArguments[0] == "netedit.attrs.modes.data.TAZFill") {
1330
myMessageID = MID_GNE_DATAVIEWOPTIONS_TAZDRAWFILL;
1331
} else if (myArguments[0] == "netedit.attrs.modes.data.TAZRelOnlyFrom") {
1332
myMessageID = MID_GNE_DATAVIEWOPTIONS_TAZRELONLYFROM;
1333
} else if (myArguments[0] == "netedit.attrs.modes.data.TAZRelOnlyTo") {
1334
myMessageID = MID_GNE_DATAVIEWOPTIONS_TAZRELONLYTO;
1335
} else {
1336
writeError("changeEditMode", 0, "<enum>");
1337
}
1338
}
1339
}
1340
1341
1342
void
1343
InternalTestStep::saveExistentFile() {
1344
if ((myArguments.size() != 1) ||
1345
!checkStringArgument(myArguments[0])) {
1346
writeError("save", 0, "<\"string\">");
1347
} else {
1348
myCategory = Category::APP;
1349
const auto savingType = getStringArgument(myArguments[0]);
1350
if (savingType == "network") {
1351
myMessageID = MID_HOTKEY_CTRL_S_STOPSIMULATION_SAVENETWORK;
1352
} else if (savingType == "additionals") {
1353
myMessageID = MID_HOTKEY_CTRL_SHIFT_A_SAVEADDITIONALELEMENTS;
1354
} else if (savingType == "demands") {
1355
myMessageID = MID_HOTKEY_CTRL_SHIFT_D_SAVEDEMANDELEMENTS;
1356
} else if (savingType == "datas") {
1357
myMessageID = MID_HOTKEY_CTRL_SHIFT_B_SAVEDATAELEMENTS;
1358
} else if (savingType == "meanDatas") {
1359
myMessageID = MID_HOTKEY_CTRL_SHIFT_M_SAVEMEANDATAELEMENTS;
1360
} else if (savingType == "sumoConfig") {
1361
myMessageID = MID_HOTKEY_CTRL_SHIFT_S_SAVESUMOCONFIG;
1362
} else if (savingType == "neteditConfig") {
1363
myMessageID = MID_HOTKEY_CTRL_SHIFT_E_SAVENETEDITCONFIG;
1364
} else {
1365
writeError("save", 0, "<neteditConfig>");
1366
}
1367
}
1368
}
1369
1370
1371
void
1372
InternalTestStep::checkUndoRedo() const {
1373
if (myArguments.size() != 1) {
1374
writeError("checkUndoRedo", 0, "<referencePosition>");
1375
} else {
1376
const int numUndoRedos = 9;
1377
buildUndo(numUndoRedos);
1378
buildRedo(numUndoRedos);
1379
}
1380
}
1381
1382
1383
void
1384
InternalTestStep::deleteFunction() const {
1385
if (myArguments.size() != 0) {
1386
writeError("delete", 0, "<>");
1387
} else {
1388
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_DEL, Category::APP, "delete element");
1389
}
1390
}
1391
1392
1393
void
1394
InternalTestStep::selection() const {
1395
if (myArguments.size() != 1 || !checkStringArgument(myArguments[0])) {
1396
writeError("selection", 0, "<selection operation>");
1397
} else {
1398
const std::string selectionType = getStringArgument(myArguments[0]);
1399
// get number of tabls
1400
int numTabs = 0;
1401
if (selectionType == "default") {
1402
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.default");
1403
} else if (selectionType == "save") {
1404
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.save");
1405
} else if (selectionType == "load") {
1406
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.load");
1407
} else if (selectionType == "add") {
1408
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.add");
1409
} else if (selectionType == "remove") {
1410
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.remove");
1411
} else if (selectionType == "keep") {
1412
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.keep");
1413
} else if (selectionType == "replace") {
1414
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.replace");
1415
} else if (selectionType == "clear") {
1416
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.clear");
1417
} else if (selectionType == "invert") {
1418
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.invert");
1419
} else if (selectionType == "invertData") {
1420
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.invertData");
1421
} else if (selectionType == "delete") {
1422
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.basic.delete");
1423
}
1424
// focus frame
1425
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus selection frame");
1426
// jump to the element
1427
for (int i = 0; i < numTabs; i++) {
1428
buildPressKeyEvent(Category::APP, "tab", false);
1429
}
1430
if (selectionType == "save") {
1431
buildPressKeyEvent(Category::APP, "enter", false);
1432
// complete
1433
} else if (selectionType == "load") {
1434
buildPressKeyEvent(Category::APP, "enter", false);
1435
// complete
1436
} else {
1437
buildPressKeyEvent(Category::APP, "space", true);
1438
}
1439
}
1440
}
1441
1442
1443
void
1444
InternalTestStep::selectNetworkItems() const {
1445
if (myArguments.size() != 3 || !checkStringArgument(myArguments[0]) ||
1446
!checkStringArgument(myArguments[1]) || !checkStringArgument(myArguments[2])) {
1447
writeError("selectNetworkItems", 0, "<element/int, \"attribute\", \"value\">");
1448
} else {
1449
const std::string element = getStringArgument(myArguments[0]);
1450
const std::string attribute = getStringArgument(myArguments[1]);
1451
const std::string value = getStringArgument(myArguments[2]);
1452
// focus frame
1453
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus selelection frame");
1454
// got to type
1455
for (int i = 0; i < myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.networkItem.type"); i++) {
1456
buildPressKeyEvent(Category::APP, "tab", false);
1457
}
1458
// set network element
1459
for (const char c : "Network elements") {
1460
buildPressKeyEvent(Category::APP, {c}, false);
1461
}
1462
// show info
1463
std::cout << "Network elements" << std::endl;
1464
// got to type
1465
for (int i = 0; i < myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.networkItem.subType"); i++) {
1466
buildPressKeyEvent(Category::APP, "tab", false);
1467
}
1468
// set network element
1469
for (const char c : element) {
1470
buildPressKeyEvent(Category::APP, {c}, false);
1471
}
1472
// show info
1473
std::cout << element << std::endl;
1474
// got to attribute
1475
for (int i = 0; i < myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.networkItem.attribute"); i++) {
1476
buildPressKeyEvent(Category::APP, "tab", false);
1477
}
1478
// set attribute
1479
for (const char c : attribute) {
1480
buildPressKeyEvent(Category::APP, {c}, false);
1481
}
1482
// show info
1483
std::cout << attribute << std::endl;
1484
// got to value
1485
for (int i = 0; i < myTestSystem->getAttributesEnum().at("netedit.attrs.frames.selection.networkItem.value"); i++) {
1486
buildPressKeyEvent(Category::APP, "tab", false);
1487
}
1488
// set value
1489
for (const char c : value) {
1490
buildPressKeyEvent(Category::APP, {c}, false);
1491
}
1492
// show info
1493
std::cout << value << std::endl;
1494
// press enter to confirm changes (updating view)
1495
buildPressKeyEvent(Category::APP, "enter", true);
1496
}
1497
}
1498
1499
1500
void
1501
InternalTestStep::lockSelection() const {
1502
if (myArguments.size() != 1 || !checkIntArgument(myArguments[0])) {
1503
writeError("lockSelection", 0, "<element/int, \"attribute\", \"value\">");
1504
} else {
1505
// get argument
1506
const auto lockType = getIntArgument(myArguments[0]);
1507
// continue depending of lock type
1508
if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.junctions")) {
1509
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_JUNCTION, Category::APP, "lock junctions");
1510
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.edges")) {
1511
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_EDGE, Category::APP, "lock edges");
1512
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.lanes")) {
1513
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_LANE, Category::APP, "lock lanes");
1514
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.connections")) {
1515
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_CONNECTION, Category::APP, "lock connections");
1516
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.crossings")) {
1517
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_CROSSING, Category::APP, "lock crossings");
1518
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.walkingAreas")) {
1519
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_WALKINGAREA, Category::APP, "lock walking areas");
1520
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.additionals")) {
1521
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_ADDITIONALELEMENT, Category::APP, "lock additionals");
1522
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.tazs")) {
1523
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_TAZ, Category::APP, "lock TAZs");
1524
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.wires")) {
1525
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_WIRE, Category::APP, "lock wires");
1526
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.polygons")) {
1527
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_POLYGON, Category::APP, "lock polygons");
1528
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.pois")) {
1529
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_POI, Category::APP, "lock POIs");
1530
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.walkableAreas")) {
1531
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_JPS_WALKABLEAREA, Category::APP, "lock walkableAreas");
1532
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.obstacles")) {
1533
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_JPS_OBSTACLE, Category::APP, "lock obstacles");
1534
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.selected")) {
1535
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_SELECTEDELEMENTS, Category::APP, "lock selected elements");
1536
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.lockAll")) {
1537
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_LOCK_ALLELEMENTS, Category::APP, "lock all elements");
1538
} else if (lockType == myTestSystem->getAttributesEnum().at("netedit.attrs.selection.lockSelectionNetwork.unlockAll")) {
1539
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_GNE_UNLOCK_ALLELEMENTS, Category::APP, "unlock all elements");
1540
}
1541
}
1542
}
1543
1544
1545
void
1546
InternalTestStep::selectionRectangle() const {
1547
if (myArguments.size() != 3 || (myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
1548
(myTestSystem->getViewPositions().count(myArguments[2]) == 0)) {
1549
writeError("selectionRectangle", 0, "<viewPosition, viewPosition>");
1550
} else {
1551
// get position
1552
const auto& from = myTestSystem->getViewPositions().at(myArguments[1]);
1553
const auto& to = myTestSystem->getViewPositions().at(myArguments[2]);
1554
// go to selection mode
1555
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_S_MODE_STOPSIMULATION_SELECT, Category::APP, "selection mode");
1556
// drag and drop
1557
buildMouseDragDrop(from, 0, 0, to, 0, 0, "shift");
1558
}
1559
}
1560
1561
1562
void
1563
InternalTestStep::createDataSet() const {
1564
if ((myArguments.size() != 1) || !checkStringArgument(myArguments[0])) {
1565
writeError("createDataSet", 0, "<dataSetId>");
1566
} else {
1567
// get dataSetId
1568
const auto& dataSetId = getStringArgument(myArguments[0]);
1569
// show info
1570
std::cout << dataSetId << std::endl;
1571
// focus frame
1572
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus data frame");
1573
// jump to select additional argument
1574
for (int i = 0; i < 2; i++) {
1575
buildPressKeyEvent(Category::APP, "tab", false);
1576
}
1577
// create new dataSet
1578
buildPressKeyEvent(Category::APP, "space", true);
1579
// write additional character by character
1580
for (const char c : dataSetId) {
1581
buildPressKeyEvent(Category::APP, {c}, false);
1582
}
1583
// go to create new dataSet
1584
buildPressKeyEvent(Category::APP, "tab", false);
1585
// press enter to confirm changes (updating view)
1586
buildPressKeyEvent(Category::APP, "space", true);
1587
}
1588
}
1589
1590
1591
void
1592
InternalTestStep::createDataInterval() const {
1593
if ((myArguments.size() != 2) || !checkStringArgument(myArguments[0]) || !checkStringArgument(myArguments[1])) {
1594
writeError("createDataInterval", 0, "<begin, end>");
1595
} else {
1596
// get begin and end
1597
const auto& begin = getStringArgument(myArguments[0]);
1598
const auto& end = getStringArgument(myArguments[1]);
1599
// show info
1600
std::cout << begin << std::endl;
1601
std::cout << end << std::endl;
1602
// focus frame
1603
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus data frame");
1604
// jump to create interval
1605
for (int i = 0; i < 6; i++) {
1606
buildPressKeyEvent(Category::APP, "tab", false);
1607
}
1608
// create new interval
1609
buildPressKeyEvent(Category::APP, "space", true);
1610
// go to begin
1611
buildPressKeyEvent(Category::APP, "tab", false);
1612
// write begin character by character
1613
for (const char c : begin) {
1614
buildPressKeyEvent(Category::APP, {c}, false);
1615
}
1616
// go to begin
1617
buildPressKeyEvent(Category::APP, "tab", false);
1618
// write end character by character
1619
for (const char c : end) {
1620
buildPressKeyEvent(Category::APP, {c}, false);
1621
}
1622
// go to create button
1623
buildPressKeyEvent(Category::APP, "tab", false);
1624
// press button
1625
buildPressKeyEvent(Category::APP, "space", true);
1626
}
1627
}
1628
1629
1630
void
1631
InternalTestStep::openAboutDialog() {
1632
if (myArguments.size() != 0) {
1633
writeError("openAboutDialog", 0, "<>");
1634
} else {
1635
myCategory = Category::APP;
1636
myMessageID = MID_HOTKEY_F12_ABOUT;
1637
// close dialog
1638
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::ABOUT, DialogArgument::Action::ACCEPT), "close about dialog");
1639
}
1640
}
1641
1642
1643
void
1644
InternalTestStep::loadFile() {
1645
if ((myArguments.size() != 5) || !checkIntArgument(myArguments[4])) {
1646
writeError("loadFile", 0, "<referencePosition, type, file, extension, extensionIndex>");
1647
} else {
1648
myCategory = Category::APP;
1649
// get type and file
1650
const auto type = getStringArgument(myArguments[1]);
1651
const auto file = getStringArgument(myArguments[2]);
1652
const auto extension = getStringArgument(myArguments[3]);
1653
const auto extensionIndex = getIntArgument(myArguments[4]);
1654
// get working directory
1655
std::string workingDirectory = FXSystem::getCurrentDirectory().text();
1656
const auto sandboxDirectory = std::getenv("TEXTTEST_SANDBOX");
1657
if (sandboxDirectory) {
1658
workingDirectory = sandboxDirectory;
1659
}
1660
// continue depending of type
1661
if (type == "neteditConfig") {
1662
myMessageID = MID_HOTKEY_CTRL_E_EDITSELECTION_LOADNETEDITCONFIG;
1663
} else if (type == "sumoConfig") {
1664
myMessageID = MID_HOTKEY_CTRL_M_OPENSUMOCONFIG;
1665
} else if (type == "netconvertConfig") {
1666
myMessageID = MID_HOTKEY_CTRL_SHIFT_O_OPENNETCONVERTFILE;
1667
} else if (type == "network") {
1668
myMessageID = MID_HOTKEY_CTRL_O_OPENSIMULATION_OPENNETWORK;
1669
} else if (type == "trafficLights") {
1670
myMessageID = MID_HOTKEY_CTRL_K_OPENTLSPROGRAMS;
1671
} else if (type == "edgeTypes") {
1672
myMessageID = MID_HOTKEY_CTRL_H_APPSETTINGS_OPENEDGETYPES;
1673
} else if (type == "additional") {
1674
myMessageID = MID_HOTKEY_CTRL_A_STARTSIMULATION_OPENADDITIONALELEMENTS;
1675
} else if (type == "demand") {
1676
myMessageID = MID_HOTKEY_CTRL_D_SINGLESIMULATIONSTEP_OPENDEMANDELEMENTS;
1677
} else if (type == "data") {
1678
myMessageID = MID_HOTKEY_CTRL_B_EDITBREAKPOINT_OPENDATAELEMENTS;
1679
} else if (type == "meanData") {
1680
myMessageID = MID_GNE_TOOLBARFILE_OPENMEANDATAELEMENTS;
1681
} else {
1682
WRITE_ERRORF("Invalid type '%' used in function loadFile", type);
1683
}
1684
// write info
1685
std::cout << file << "." << extension << std::endl;
1686
// set filename dialog
1687
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FILE, workingDirectory + "/" + file + "." + extension, extensionIndex), "filepath");
1688
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FILE, DialogArgument::Action::ACCEPT), "go to directory");
1689
}
1690
}
1691
1692
1693
void
1694
InternalTestStep::saveNewFile() {
1695
if ((myArguments.size() != 4) || !checkIntArgument(myArguments[3])) {
1696
writeError("saveNewFile", 0, "<referencePosition, type, extension, extensionIndex>");
1697
} else {
1698
myCategory = Category::APP;
1699
// get type and file
1700
const auto type = getStringArgument(myArguments[1]);
1701
const auto extension = getStringArgument(myArguments[2]);
1702
const auto extensionIndex = getIntArgument(myArguments[3]);
1703
std::string file;
1704
// get working directory
1705
std::string workingDirectory = FXSystem::getCurrentDirectory().text();
1706
const auto sandboxDirectory = std::getenv("TEXTTEST_SANDBOX");
1707
if (sandboxDirectory) {
1708
workingDirectory = sandboxDirectory;
1709
}
1710
// continue depending of type
1711
if (type == "neteditConfig") {
1712
myMessageID = MID_HOTKEY_CTRL_SHIFT_E_SAVENETEDITCONFIG;
1713
file = "netedit2." + extension;
1714
} else if (type == "sumoConfig") {
1715
myMessageID = MID_HOTKEY_CTRL_SHIFT_S_SAVESUMOCONFIG;
1716
file = "sumo2." + extension;
1717
} else if (type == "xml") {
1718
myMessageID = MID_HOTKEY_CTRL_L_SAVEASPLAINXML;
1719
file = "net2." + extension;
1720
} else if (type == "joinedJunctions") {
1721
myMessageID = MID_GNE_SAVEJOINEDJUNCTIONS;
1722
file = "joinedjunctions2." + extension;
1723
} else if (type == "network") {
1724
myMessageID = MID_HOTKEY_CTRL_S_STOPSIMULATION_SAVENETWORK;
1725
file = "net2." + extension;
1726
} else if (type == "trafficLights") {
1727
myMessageID = MID_HOTKEY_CTRL_SHIFT_K_SAVETLS;
1728
file = "trafficlights2." + extension;
1729
} else if (type == "edgeTypes") {
1730
myMessageID = MID_HOTKEY_CTRL_SHIFT_H_SAVEEDGETYPES;
1731
file = "edgetypes2." + extension;
1732
} else if (type == "additional") {
1733
myMessageID = MID_HOTKEY_CTRL_SHIFT_A_SAVEADDITIONALELEMENTS;
1734
file = "additionals2." + extension;
1735
} else if (type == "demand") {
1736
myMessageID = MID_HOTKEY_CTRL_SHIFT_D_SAVEDEMANDELEMENTS;
1737
file = "routes2." + extension;
1738
} else if (type == "data") {
1739
myMessageID = MID_HOTKEY_CTRL_SHIFT_B_SAVEDATAELEMENTS;
1740
file = "datas2." + extension;
1741
} else if (type == "meanData") {
1742
myMessageID = MID_HOTKEY_CTRL_SHIFT_M_SAVEMEANDATAELEMENTS;
1743
file = "meandatas2.dat." + extension;
1744
} else {
1745
WRITE_ERRORF("Invalid type '%' used in function loadFile", type);
1746
}
1747
// write info
1748
std::cout << file << std::endl;
1749
// set filename dialog
1750
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FILE, workingDirectory + "/" + file, extensionIndex), "filepath");
1751
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FILE, DialogArgument::Action::ACCEPT), "go to directory");
1752
}
1753
}
1754
1755
1756
void
1757
InternalTestStep::saveFileAs() {
1758
if (myArguments.size() != 3) {
1759
writeError("saveFileAs", 0, "<referencePosition, type, bool>");
1760
} else {
1761
myCategory = Category::APP;
1762
// get type and file
1763
const auto type = getStringArgument(myArguments[1]);
1764
std::string file;
1765
// get working directory
1766
std::string workingDirectory = FXSystem::getCurrentDirectory().text();
1767
const auto sandboxDirectory = std::getenv("TEXTTEST_SANDBOX");
1768
if (sandboxDirectory) {
1769
workingDirectory = sandboxDirectory;
1770
}
1771
// continue depending of type
1772
if (type == "neteditConfig") {
1773
myMessageID = MID_GNE_TOOLBARFILE_SAVENETEDITCONFIG_AS;
1774
file = "netedit3.netecfg";
1775
} else if (type == "sumoConfig") {
1776
myMessageID = MID_GNE_TOOLBARFILE_SAVESUMOCONFIG_AS;
1777
file = "sumo3.sumocfg";
1778
} else if (type == "network") {
1779
myMessageID = MID_GNE_TOOLBARFILE_SAVENETWORK_AS;
1780
file = "net3.net.xml";
1781
} else if (type == "trafficLights") {
1782
myMessageID = MID_GNE_TOOLBARFILE_SAVETLSPROGRAMS_AS;
1783
file = "trafficlights3.tll.xml";
1784
} else if (type == "edgeTypes") {
1785
myMessageID = MID_GNE_TOOLBARFILE_SAVEEDGETYPES_AS;
1786
file = "edgetypes3.typ.xml";
1787
} else if (type == "additional") {
1788
myMessageID = MID_GNE_TOOLBARFILE_SAVEADDITIONALELEMENTS_UNIFIED;
1789
file = "additionals3.add.xml";
1790
} else if (type == "jupedsim") {
1791
myMessageID = MID_GNE_TOOLBARFILE_SAVEJUPEDSIMELEMENTS_AS;
1792
file = "additionals3.add.xml";
1793
} else if (type == "demand") {
1794
myMessageID = MID_GNE_TOOLBARFILE_SAVEDEMANDELEMENTS_UNIFIED;
1795
file = "routes3.rou.xml";
1796
} else if (type == "data") {
1797
myMessageID = MID_GNE_TOOLBARFILE_SAVEDATAELEMENTS_UNIFIED;
1798
file = "datas3.dat.xml";
1799
} else if (type == "meanData") {
1800
myMessageID = MID_GNE_TOOLBARFILE_SAVEMEANDATAELEMENTS_UNIFIED;
1801
file = "meandatas3.dat.add.xml";
1802
} else {
1803
WRITE_ERRORF("Invalid type '%' used in function loadFile", type);
1804
}
1805
// write info
1806
std::cout << file << std::endl;
1807
// set filename dialog
1808
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FILE, workingDirectory + "/" + file), "filepath");
1809
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::FILE, DialogArgument::Action::ACCEPT), "go to directory");
1810
}
1811
}
1812
1813
1814
void
1815
InternalTestStep::reloadFile() {
1816
if (myArguments.size() != 3) {
1817
writeError("reloadFile", 0, "<referencePosition, type, bool>");
1818
} else {
1819
myCategory = Category::APP;
1820
// get type and file
1821
const auto type = getStringArgument(myArguments[1]);
1822
// continue depending of type
1823
if (type == "neteditConfig") {
1824
myMessageID = MID_GNE_TOOLBARFILE_RELOAD_NETEDITCONFIG;
1825
} else if (type == "sumoConfig") {
1826
myMessageID = MID_GNE_TOOLBARFILE_RELOAD_SUMOCONFIG;
1827
} else if (type == "network") {
1828
myMessageID = MID_GNE_TOOLBARFILE_RELOADNETWORK;
1829
} else if (type == "edgeTypes") {
1830
myMessageID = MID_GNE_TOOLBARFILE_RELOAD_EDGETYPES;
1831
} else if (type == "trafficLights") {
1832
myMessageID = MID_GNE_TOOLBARFILE_RELOAD_TLSPROGRAMS;
1833
} else if (type == "additional") {
1834
myMessageID = MID_GNE_TOOLBARFILE_RELOAD_ADDITIONALELEMENTS;
1835
} else if (type == "demand") {
1836
myMessageID = MID_GNE_TOOLBARFILE_RELOAD_DEMANDELEMENTS;
1837
} else if (type == "data") {
1838
myMessageID = MID_GNE_TOOLBARFILE_RELOAD_DATAELEMENTS;
1839
} else if (type == "meanData") {
1840
myMessageID = MID_GNE_TOOLBARFILE_RELOAD_MEANDATAELEMENTS;
1841
} else {
1842
WRITE_ERRORF("Invalid type '%' used in function reloadFile", type);
1843
}
1844
}
1845
}
1846
1847
1848
void
1849
InternalTestStep::selectEdgeType() {
1850
if (myArguments.size() != 0) {
1851
writeError("selectEdgeType", 0, "<>");
1852
} else {
1853
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus edge frame");
1854
// got to type
1855
for (int i = 0; i < myTestSystem->getAttributesEnum().at("netedit.attrs.edge.edgeType.select"); i++) {
1856
buildPressKeyEvent(Category::APP, "tab", false);
1857
}
1858
// select edge type
1859
buildPressKeyEvent(Category::APP, "space", true);
1860
}
1861
}
1862
1863
1864
void
1865
InternalTestStep::createNewEdgeType() {
1866
if (myArguments.size() != 1 && checkBoolArgument(myArguments[0])) {
1867
writeError("createNewEdgeType", 0, "<bool>");
1868
} else {
1869
const auto existent = getBoolArgument(myArguments[0]);
1870
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus edge frame");
1871
if (existent) {
1872
for (int i = 0; i < myTestSystem->getAttributesEnum().at("netedit.attrs.edge.edgeType.createExistent"); i++) {
1873
buildPressKeyEvent(Category::APP, "tab", false);
1874
}
1875
} else {
1876
for (int i = 0; i < myTestSystem->getAttributesEnum().at("netedit.attrs.edge.edgeType.createNew"); i++) {
1877
buildPressKeyEvent(Category::APP, "tab", false);
1878
}
1879
}
1880
// select edge type
1881
buildPressKeyEvent(Category::APP, "space", true);
1882
}
1883
}
1884
1885
1886
void
1887
InternalTestStep::overwritingAccept() {
1888
myCategory = Category::DIALOG;
1889
myDialogArgument = new DialogArgument(DialogType::OVERWRITE, DialogArgument::Action::ACCEPT);
1890
myDescription = "accept overwriting";
1891
}
1892
1893
1894
void
1895
InternalTestStep::overwritingCancel() {
1896
myCategory = Category::DIALOG;
1897
myDialogArgument = new DialogArgument(DialogType::OVERWRITE, DialogArgument::Action::CANCEL);
1898
myDescription = "discard overwriting";
1899
}
1900
1901
1902
void
1903
InternalTestStep::overwritingAbort() {
1904
myCategory = Category::DIALOG;
1905
myDialogArgument = new DialogArgument(DialogType::OVERWRITE, DialogArgument::Action::ABORT);
1906
myDescription = "abort overwriting";
1907
}
1908
1909
1910
void
1911
InternalTestStep::overwritingApplyToAll() {
1912
myCategory = Category::DIALOG;
1913
myDialogArgument = new DialogArgument(DialogType::OVERWRITE, "applyToAll");
1914
myDescription = "apply to all";
1915
}
1916
1917
1918
void
1919
InternalTestStep::undo() const {
1920
if ((myArguments.size() != 2) || !checkIntArgument(myArguments[1])) {
1921
writeError("undo", 0, "<referencePosition, int>");
1922
} else {
1923
// do undo
1924
buildUndo(getIntArgument(myArguments[1]));
1925
}
1926
}
1927
1928
1929
void
1930
InternalTestStep::redo() const {
1931
if ((myArguments.size() != 2) || !checkIntArgument(myArguments[1])) {
1932
writeError("redo", 0, "<referencePosition, int>");
1933
} else {
1934
// do redo
1935
buildRedo(getIntArgument(myArguments[1]));
1936
}
1937
}
1938
1939
1940
void
1941
InternalTestStep::changeSupermode() {
1942
if ((myArguments.size() != 1) ||
1943
!checkStringArgument(myArguments[0])) {
1944
writeError("supermode", 0, "<\"string\">");
1945
} else {
1946
myCategory = Category::APP;
1947
const std::string supermode = getStringArgument(myArguments[0]);
1948
if (supermode == "network") {
1949
myMessageID = MID_HOTKEY_F2_SUPERMODE_NETWORK;
1950
} else if (supermode == "demand") {
1951
myMessageID = MID_HOTKEY_F3_SUPERMODE_DEMAND;
1952
} else if (supermode == "data") {
1953
myMessageID = MID_HOTKEY_F4_SUPERMODE_DATA;
1954
} else {
1955
writeError("supermode", 0, "<network/demand/data>");
1956
}
1957
}
1958
}
1959
1960
1961
void
1962
InternalTestStep::changeMode() {
1963
if ((myArguments.size() != 1) ||
1964
!checkStringArgument(myArguments[0])) {
1965
writeError("changeMode", 0, "<\"string\">");
1966
} else {
1967
// set category and enable upate view
1968
myCategory = Category::APP;
1969
myUpdateView = true;
1970
// get mode
1971
const std::string mode = getStringArgument(myArguments[0]);
1972
// set description
1973
myDescription = "Change mode to '" + mode + "'";
1974
// continue depending of mode
1975
if (mode == "inspect") {
1976
myMessageID = MID_HOTKEY_I_MODE_INSPECT;
1977
} else if (mode == "delete") {
1978
myMessageID = MID_HOTKEY_D_MODE_SINGLESIMULATIONSTEP_DELETE;
1979
} else if (mode == "select") {
1980
myMessageID = MID_HOTKEY_S_MODE_STOPSIMULATION_SELECT;
1981
} else if (mode == "move") {
1982
myMessageID = MID_HOTKEY_M_MODE_MOVE_MEANDATA;
1983
} else if ((mode == "createEdge") || (mode == "edgeData")) {
1984
myMessageID = MID_HOTKEY_E_MODE_EDGE_EDGEDATA;
1985
} else if ((mode == "trafficLight") || (mode == "type") || (mode == "TLS")) {
1986
myMessageID = MID_HOTKEY_T_MODE_TLS_TYPE;
1987
} else if ((mode == "connection") || (mode == "container")) {
1988
myMessageID = MID_HOTKEY_C_MODE_CONNECT_CONTAINER;
1989
} else if ((mode == "prohibition") || (mode == "containerPlan")) {
1990
myMessageID = MID_HOTKEY_H_MODE_PROHIBITION_CONTAINERPLAN;
1991
} else if ((mode == "crossing") || (mode == "route") || (mode == "edgeRelData")) {
1992
myMessageID = MID_HOTKEY_R_MODE_CROSSING_ROUTE_EDGERELDATA;
1993
} else if ((mode == "additional") || (mode == "stop")) {
1994
myMessageID = MID_HOTKEY_A_MODE_STARTSIMULATION_ADDITIONALS_STOPS;
1995
} else if ((mode == "wire") || (mode == "routeDistribution")) {
1996
myMessageID = MID_HOTKEY_W_MODE_WIRE_ROUTEDISTRIBUTION;
1997
} else if ((mode == "taz") || (mode == "TAZ") || (mode == "TAZRelData")) {
1998
myMessageID = MID_HOTKEY_Z_MODE_TAZ_TAZREL;
1999
} else if ((mode == "shape") || (mode == "person")) {
2000
myMessageID = MID_HOTKEY_P_MODE_POLYGON_PERSON;
2001
} else if ((mode == "decal") || (mode == "typeDistribution")) {
2002
myMessageID = MID_HOTKEY_U_MODE_DECAL_TYPEDISTRIBUTION;
2003
} else if (mode == "personPlan") {
2004
myMessageID = MID_HOTKEY_L_MODE_PERSONPLAN;
2005
} else if (mode == "vehicle") {
2006
myMessageID = MID_HOTKEY_V_MODE_VEHICLE;
2007
} else if (mode == "meanData") {
2008
myMessageID = MID_HOTKEY_M_MODE_MOVE_MEANDATA;
2009
} else {
2010
writeError("changeMode", 0, "<inspect/delete/select/move...>");
2011
}
2012
}
2013
}
2014
2015
2016
void
2017
InternalTestStep::changeElement() const {
2018
if ((myArguments.size() != 2) ||
2019
!checkStringArgument(myArguments[0])) {
2020
writeError("changeElement", 0, "<\"frame\", \"string\">");
2021
} else {
2022
const std::string frame = getStringArgument(myArguments[0]);
2023
const std::string element = getStringArgument(myArguments[1]);
2024
int numTabs = -1;
2025
// continue depending of frame
2026
if (frame == "additionalFrame") {
2027
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.additional");
2028
} else if (frame == "shapeFrame") {
2029
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.shape");
2030
} else if (frame == "vehicleFrame") {
2031
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.vehicle");
2032
} else if (frame == "routeFrame") {
2033
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.route");
2034
} else if (frame == "personFrame") {
2035
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.person");
2036
} else if (frame == "containerFrame") {
2037
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.container");
2038
} else if (frame == "personPlanFrame") {
2039
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.personPlan");
2040
} else if (frame == "containerPlanFrame") {
2041
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.containerPlan");
2042
} else if (frame == "stopFrame") {
2043
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.stop");
2044
} else if (frame == "meanDataFrame") {
2045
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changeElement.meanData");
2046
} else {
2047
WRITE_ERRORF("Invalid frame '%' used in function changeElement", frame);
2048
}
2049
if (numTabs >= 0) {
2050
// show info
2051
std::cout << element << std::endl;
2052
// focus frame
2053
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus " + frame);
2054
// jump to select additional argument
2055
for (int i = 0; i < numTabs; i++) {
2056
buildPressKeyEvent(Category::APP, "tab", false);
2057
}
2058
// write additional character by character
2059
for (const char c : element) {
2060
buildPressKeyEvent(Category::APP, {c}, false);
2061
}
2062
// press enter to confirm changes (updating view)
2063
buildPressKeyEvent(Category::APP, "enter", true);
2064
}
2065
}
2066
}
2067
2068
2069
void
2070
InternalTestStep::changePlan() const {
2071
if ((myArguments.size() != 3) ||
2072
!checkStringArgument(myArguments[0]) ||
2073
!checkStringArgument(myArguments[1]) ||
2074
!checkBoolArgument(myArguments[2])) {
2075
writeError("changePlan", 0, "<\"type\", \"plan\", true/false>");
2076
} else {
2077
// get arguments
2078
const std::string type = getStringArgument(myArguments[0]);
2079
const std::string plan = getStringArgument(myArguments[1]);
2080
const bool flow = getBoolArgument(myArguments[2]);
2081
// check plan
2082
if ((type != "person") && (type != "container")) {
2083
WRITE_ERRORF("invalid plan type '%' used in changePlan()", type);
2084
} else {
2085
// calculate num tabs
2086
int numTabs = 0;
2087
if (flow) {
2088
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changePlan." + type + "Flow");
2089
} else {
2090
numTabs = myTestSystem->getAttributesEnum().at("netedit.attrs.frames.changePlan." + type);
2091
}
2092
// focus frame
2093
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus plan frame");
2094
// jump to select additional argument
2095
for (int i = 0; i < numTabs; i++) {
2096
buildPressKeyEvent(Category::APP, "tab", false);
2097
}
2098
// write additional character by character
2099
for (const char c : plan) {
2100
buildPressKeyEvent(Category::APP, {c}, false);
2101
}
2102
// print info
2103
std::cout << plan << std::endl;
2104
// press enter to confirm changes (updating view)
2105
buildPressKeyEvent(Category::APP, "enter", true);
2106
}
2107
}
2108
}
2109
2110
2111
void
2112
InternalTestStep::computeJunctions() {
2113
if (myArguments.size() > 0) {
2114
writeError("computeJunctions", 0, "<>");
2115
} else {
2116
myCategory = Category::APP;
2117
myMessageID = MID_HOTKEY_F5_COMPUTE_NETWORK_DEMAND;
2118
}
2119
}
2120
2121
2122
void
2123
InternalTestStep::computeJunctionsVolatileOptions() {
2124
if (myArguments.size() != 1) {
2125
writeError("computeJunctionsVolatileOptions", 0, "<yes/no/esc>");
2126
} else {
2127
myCategory = Category::APP;
2128
myMessageID = MID_HOTKEY_SHIFT_F5_COMPUTEJUNCTIONS_VOLATILE;
2129
// get argument
2130
const auto dialogArgument = getStringArgument(myArguments[0]);
2131
// press space to confirm changes (updating view)
2132
if (dialogArgument == "yes") {
2133
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::QUESTION, DialogArgument::Action::ACCEPT), "close accepting");
2134
} else if (dialogArgument == "no") {
2135
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::QUESTION, DialogArgument::Action::CANCEL), "close canceling");
2136
} else {
2137
new InternalTestStep(myTestSystem, new DialogArgument(DialogType::QUESTION, DialogArgument::Action::ABORT), "close aborting");
2138
}
2139
}
2140
}
2141
2142
2143
void
2144
InternalTestStep::selectAdditionalChild() {
2145
if ((myArguments.size() != 2) ||
2146
!checkIntArgument(myArguments[0]) ||
2147
!checkIntArgument(myArguments[1])) {
2148
writeError("selectAdditionalChild", 0, "<int, int>");
2149
} else {
2150
const auto tabs = getIntArgument(myArguments[0]);
2151
const auto downs = getIntArgument(myArguments[1]);
2152
// focus frame
2153
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "select additional child");
2154
// jump to the element
2155
for (int i = 0; i < tabs; i++) {
2156
buildPressKeyEvent(Category::APP, "tab", false);
2157
}
2158
// jump to the element
2159
for (int i = 0; i < downs; i++) {
2160
buildPressKeyEvent(Category::APP, "down", false);
2161
}
2162
// select additional child
2163
buildPressKeyEvent(Category::APP, "space", true);
2164
// leave
2165
buildPressKeyEvent(Category::APP, "tab", true);
2166
}
2167
}
2168
2169
2170
void
2171
InternalTestStep::createRectangledShape() {
2172
if ((myArguments.size() != 5) ||
2173
(myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
2174
!checkIntArgument(myArguments[2]) ||
2175
!checkIntArgument(myArguments[3]) ||
2176
!checkBoolArgument(myArguments[4])) {
2177
writeError("createRectangledShape", 0, "<viewPosition, sizeX, sizeY, true/false>");
2178
} else {
2179
// create shape
2180
createShape(myTestSystem->getViewPositions().at(myArguments[1]),
2181
getIntArgument(myArguments[2]),
2182
getIntArgument(myArguments[3]),
2183
getBoolArgument(myArguments[4]),
2184
false);
2185
}
2186
}
2187
2188
2189
void
2190
InternalTestStep::createSquaredShape() {
2191
if ((myArguments.size() != 4) ||
2192
(myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
2193
!checkIntArgument(myArguments[2]) ||
2194
!checkBoolArgument(myArguments[3])) {
2195
writeError("createSquaredShape", 0, "<viewPosition, size, true/false>");
2196
} else {
2197
// create shape
2198
createShape(myTestSystem->getViewPositions().at(myArguments[1]),
2199
getIntArgument(myArguments[2]),
2200
getIntArgument(myArguments[2]),
2201
getBoolArgument(myArguments[3]),
2202
false);
2203
}
2204
}
2205
2206
2207
void
2208
InternalTestStep::createLineShape() {
2209
if ((myArguments.size() != 5) ||
2210
(myTestSystem->getViewPositions().count(myArguments[1]) == 0) ||
2211
!checkIntArgument(myArguments[2]) ||
2212
!checkIntArgument(myArguments[3]) ||
2213
!checkBoolArgument(myArguments[4])) {
2214
writeError("createLineShape", 0, "<viewPosition, sizeX, sizeY, true/false>");
2215
} else {
2216
// create shape
2217
createShape(myTestSystem->getViewPositions().at(myArguments[1]),
2218
getIntArgument(myArguments[2]),
2219
getIntArgument(myArguments[3]),
2220
getBoolArgument(myArguments[4]),
2221
true);
2222
}
2223
}
2224
2225
2226
void
2227
InternalTestStep::createMeanData() {
2228
if (myArguments.size() != 0) {
2229
writeError("createMeanData", 0, "<>");
2230
} else {
2231
modifyBoolAttribute(Category::APP, 5, 0);
2232
}
2233
}
2234
2235
2236
void
2237
InternalTestStep::deleteMeanData() {
2238
if (myArguments.size() != 0) {
2239
writeError("deleteMeanData", 0, "<>");
2240
} else {
2241
modifyBoolAttribute(Category::APP, 6, 0);
2242
}
2243
}
2244
2245
2246
void
2247
InternalTestStep::copyMeanData() {
2248
if (myArguments.size() != 0) {
2249
writeError("copyMeanData", 0, "<>");
2250
} else {
2251
modifyBoolAttribute(Category::APP, 7, 0);
2252
}
2253
}
2254
2255
2256
void
2257
InternalTestStep::quit() {
2258
if (myArguments.size() == 0) {
2259
writeError("quit", 0, "<neteditProcess>");
2260
} else {
2261
myCategory = Category::APP;
2262
myMessageID = MID_HOTKEY_CTRL_Q_CLOSE;
2263
//don't update view if we're closing to avoid problems with drawGL
2264
myUpdateView = false;
2265
}
2266
}
2267
2268
2269
bool
2270
InternalTestStep::checkIntArgument(const std::string& argument) const {
2271
if (StringUtils::isInt(argument)) {
2272
return true;
2273
} else if (myTestSystem->getAttributesEnum().count(argument) > 0) {
2274
return true;
2275
} else {
2276
return false;
2277
}
2278
}
2279
2280
2281
int
2282
InternalTestStep::getIntArgument(const std::string& argument) const {
2283
if (StringUtils::isInt(argument)) {
2284
return StringUtils::toInt(argument);
2285
} else {
2286
return myTestSystem->getAttributesEnum().at(argument);
2287
}
2288
}
2289
2290
2291
bool
2292
InternalTestStep::checkBoolArgument(const std::string& argument) const {
2293
if (argument == "True") {
2294
return true;
2295
} else if (argument == "False") {
2296
return true;
2297
} else {
2298
return false;
2299
}
2300
}
2301
2302
2303
bool
2304
InternalTestStep::getBoolArgument(const std::string& argument) const {
2305
if (argument == "True") {
2306
return true;
2307
} else {
2308
return false;
2309
}
2310
}
2311
2312
2313
bool
2314
InternalTestStep::checkStringArgument(const std::string& argument) const {
2315
if (argument.size() < 2) {
2316
return false;
2317
} else if ((argument.front() != argument.back()) || ((argument.front() != '\'') && ((argument.front() != '\"')))) {
2318
return false;
2319
} else {
2320
return true;
2321
}
2322
}
2323
2324
2325
std::string
2326
InternalTestStep::getStringArgument(const std::string& argument) const {
2327
std::string argumentParsed;
2328
for (int i = 1; i < ((int)argument.size() - 1); i++) {
2329
argumentParsed.push_back(argument[i]);
2330
}
2331
return argumentParsed;
2332
}
2333
2334
2335
std::string
2336
InternalTestStep::stripSpaces(const std::string& str) const {
2337
auto start = std::find_if_not(str.begin(), str.end(), isspace);
2338
auto end = std::find_if_not(str.rbegin(), str.rend(), isspace).base();
2339
if (start < end) {
2340
return std::string(start, end);
2341
} else {
2342
return "";
2343
}
2344
}
2345
2346
2347
void
2348
InternalTestStep::writeError(const std::string& function, const int overlapping, const std::string& expected) const {
2349
if (overlapping > 0) {
2350
WRITE_ERRORF("Invalid internal testStep function '%Ovelapped', requires '%' arguments ", function, expected);
2351
} else {
2352
WRITE_ERRORF("Invalid internal testStep function '%', requires '%' arguments ", function, expected);
2353
}
2354
// also print arguments
2355
if (myArguments.size() > 0) {
2356
WRITE_ERROR("Arguments: ");
2357
for (const auto& arg : myArguments) {
2358
WRITE_ERROR(stripSpaces(arg));
2359
}
2360
}
2361
}
2362
2363
2364
void
2365
InternalTestStep::createShape(const InternalTest::ViewPosition& viewPosition,
2366
const int sizeX, const int sizeY, const bool close,
2367
const bool line) const {
2368
// calculate half-sizes
2369
const int halfSizeX = int(sizeX * -0.5);
2370
const int halfSizeY = int(sizeY * -0.5);
2371
// focus frame
2372
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus frame");
2373
// press enter to start drawing
2374
buildPressKeyEvent(Category::APP, "enter", true);
2375
// first edge
2376
buildMouseClick(viewPosition, 0, 0, "left", "");
2377
writeClickInfo(viewPosition, 0, 0, "");
2378
// second edge
2379
if (!line) {
2380
buildMouseClick(viewPosition, 0, halfSizeY, "left", "");
2381
writeClickInfo(viewPosition, 0, halfSizeY, "");
2382
}
2383
// third edge
2384
buildMouseClick(viewPosition, halfSizeX, halfSizeY, "left", "");
2385
writeClickInfo(viewPosition, halfSizeX, halfSizeY, "");
2386
// four edge
2387
if (!line) {
2388
buildMouseClick(viewPosition, halfSizeX, 0, "left", "");
2389
writeClickInfo(viewPosition, halfSizeX, 0, "");
2390
}
2391
// check if close polygon
2392
if (close) {
2393
buildMouseClick(viewPosition, 0, 0, "left", "");
2394
writeClickInfo(viewPosition, 0, 0, "");
2395
}
2396
// press enter to end drawing
2397
buildPressKeyEvent(Category::APP, "enter", true);
2398
}
2399
2400
2401
void
2402
InternalTestStep::modifyStringAttribute(Category category, const int tabs, const int overlappedTabs, const std::string& value) const {
2403
// print info
2404
std::cout << value << std::endl;
2405
// focus frame
2406
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, category, "focus frame");
2407
// jump to the element
2408
for (int i = 0; i < (tabs + overlappedTabs); i++) {
2409
buildPressKeyEvent(category, "tab", false);
2410
}
2411
// write attribute character by character
2412
if (value.empty()) {
2413
buildPressKeyEvent(category, "delete", false);
2414
} else {
2415
for (const char c : value) {
2416
buildPressKeyEvent(category, {c}, false);
2417
}
2418
}
2419
// press enter to confirm changes (updating view)
2420
buildPressKeyEvent(category, "enter", true);
2421
}
2422
2423
2424
void
2425
InternalTestStep::modifyBoolAttribute(Category category, const int tabs, const int overlappedTabs) const {
2426
// focus frame
2427
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, category, "focus frame");
2428
// jump to the element
2429
for (int i = 0; i < (tabs + overlappedTabs); i++) {
2430
buildPressKeyEvent(category, "tab", false);
2431
}
2432
// toogle attribute
2433
buildPressKeyEvent(category, "space", true);
2434
}
2435
2436
2437
void
2438
InternalTestStep::buildUndo(const int number) const {
2439
// get reference position
2440
const auto& referencePosition = myTestSystem->getViewPositions().at("netedit.positions.reference");
2441
// focus frame
2442
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus frame");
2443
// go to inspect mode
2444
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_I_MODE_INSPECT, Category::APP, "inspect mode");
2445
// click over reference
2446
std::cout << "TestFunctions: Clicked over position " <<
2447
toString(MOUSE_REFERENCE_X) << " - " <<
2448
toString(MOUSE_REFERENCE_Y) << std::endl;
2449
// build mouse click
2450
buildMouseClick(referencePosition, 0, 0, "left", "");
2451
// undo
2452
for (int i = 0; i < number; i++) {
2453
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_CTRL_Z_UNDO, Category::APP, "undo");
2454
}
2455
}
2456
2457
2458
void
2459
InternalTestStep::buildRedo(const int number) const {
2460
// get reference position
2461
const auto& referencePosition = myTestSystem->getViewPositions().at("netedit.positions.reference");
2462
// focus frame
2463
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_SHIFT_F12_FOCUSUPPERELEMENT, Category::APP, "focus frame");
2464
// go to inspect mode
2465
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_I_MODE_INSPECT, Category::APP, "inspect mode");
2466
// click over reference
2467
std::cout << "TestFunctions: Clicked over position " <<
2468
toString(MOUSE_REFERENCE_X) << " - " <<
2469
toString(MOUSE_REFERENCE_Y) << std::endl;
2470
// build mouse click
2471
buildMouseClick(referencePosition, 0, 0, "left", "");
2472
// undo
2473
for (int i = 0; i < number; i++) {
2474
new InternalTestStep(myTestSystem, SEL_COMMAND, MID_HOTKEY_CTRL_Y_REDO, Category::APP, "redo");
2475
}
2476
}
2477
2478
2479
std::pair<FXint, FXString>
2480
InternalTestStep::translateKey(const std::string& key) const {
2481
std::pair<FXint, FXString> solution;
2482
// check if key is a single character
2483
if (key.size() == 1) {
2484
solution.first = FXint(key.front());
2485
solution.second.append(key.front());
2486
} else {
2487
// continue depending of key
2488
if (key == "backspace") {
2489
solution.first = KEY_BackSpace;
2490
solution.second = "\b";
2491
} else if (key == "space") {
2492
solution.first = KEY_space;
2493
} else if (key == "tab") {
2494
solution.first = KEY_Tab;
2495
solution.second = "\t";
2496
} else if (key == "clear") {
2497
solution.first = KEY_Clear;
2498
} else if (key == "enter" || key == "return") {
2499
solution.first = KEY_Return;
2500
solution.second = "\n";
2501
} else if (key == "pause") {
2502
solution.first = KEY_Pause;
2503
} else if (key == "sys_req") {
2504
solution.first = KEY_Sys_Req;
2505
} else if (key == "esc" || key == "escape") {
2506
solution.first = KEY_Escape;
2507
solution.second = "\x1B";
2508
} else if (key == "delete") {
2509
solution.first = KEY_Delete;
2510
solution.second = "\x7F";
2511
} else if (key == "multi_key") {
2512
solution.first = KEY_Multi_key;
2513
// function
2514
} else if (key == "shift") {
2515
solution.first = KEY_Shift_L;
2516
} else if (key == "control") {
2517
solution.first = KEY_Control_L;
2518
// Cursor
2519
} else if (key == "home") {
2520
solution.first = KEY_Home;
2521
} else if (key == "left") {
2522
solution.first = KEY_Left;
2523
} else if (key == "up") {
2524
solution.first = KEY_Up;
2525
} else if (key == "right") {
2526
solution.first = KEY_Right;
2527
} else if (key == "down") {
2528
solution.first = KEY_Down;
2529
} else if (key == "prior" || key == "page_up") {
2530
solution.first = KEY_Page_Up;
2531
} else if (key == "next" || key == "page_down") {
2532
solution.first = KEY_Page_Down;
2533
} else if (key == "end") {
2534
solution.first = KEY_End;
2535
} else if (key == "begin") {
2536
solution.first = KEY_Begin;
2537
// Function keys
2538
} else if (key == "f1") {
2539
solution.first = KEY_F1;
2540
} else if (key == "f2") {
2541
solution.first = KEY_F2;
2542
} else if (key == "f3") {
2543
solution.first = KEY_F3;
2544
} else if (key == "f4") {
2545
solution.first = KEY_F4;
2546
} else if (key == "f5") {
2547
solution.first = KEY_F5;
2548
} else if (key == "f6") {
2549
solution.first = KEY_F6;
2550
} else if (key == "f7") {
2551
solution.first = KEY_F7;
2552
} else if (key == "f8") {
2553
solution.first = KEY_F8;
2554
} else if (key == "f9") {
2555
solution.first = KEY_F9;
2556
} else if (key == "f10") {
2557
solution.first = KEY_F10;
2558
} else if (key == "f11" || key == "l1") {
2559
solution.first = KEY_F11;
2560
} else if (key == "f12" || key == "l2") {
2561
solution.first = KEY_F12;
2562
} else {
2563
writeError("translateKey", 0, "<key>");
2564
solution.first = KEY_VoidSymbol;
2565
}
2566
}
2567
return solution;
2568
}
2569
2570
2571
FXEvent*
2572
InternalTestStep::buildKeyPressEvent(const std::string& key) const {
2573
const auto keyValues = translateKey(key);
2574
FXEvent* keyPressEvent = new FXEvent();
2575
// set event values
2576
keyPressEvent->time = myTestSystem->getTime();
2577
keyPressEvent->synthetic = true;
2578
keyPressEvent->type = SEL_KEYPRESS;
2579
keyPressEvent->code = keyValues.first;
2580
keyPressEvent->text = keyValues.second;
2581
return keyPressEvent;
2582
}
2583
2584
2585
FXEvent*
2586
InternalTestStep::buildKeyReleaseEvent(const std::string& key) const {
2587
const auto keyValues = translateKey(key);
2588
FXEvent* keyPressEvent = new FXEvent();
2589
// set event values
2590
keyPressEvent->time = myTestSystem->getTime();
2591
keyPressEvent->synthetic = true;
2592
keyPressEvent->type = SEL_KEYPRESS;
2593
keyPressEvent->code = keyValues.first;
2594
keyPressEvent->text = keyValues.second;
2595
// special case for shift and control
2596
return keyPressEvent;
2597
}
2598
2599
2600
void
2601
InternalTestStep::buildPressKeyEvent(Category category, const std::string& key, const bool updateView) const {
2602
new InternalTestStep(myTestSystem, SEL_KEYPRESS, category, buildKeyPressEvent(key), updateView, "key '" + key + "' pressed");
2603
new InternalTestStep(myTestSystem, SEL_KEYRELEASE, category, buildKeyReleaseEvent(key), updateView, "key '" + key + "' released");
2604
}
2605
2606
2607
void
2608
InternalTestStep::buildTwoPressKeyEvent(Category category, const std::string& keyA, const std::string& keyB, const bool updateView) const {
2609
// create both events using keyB
2610
auto pressEvent = buildKeyPressEvent(keyB);
2611
auto releaseEvent = buildKeyPressEvent(keyB);
2612
// check if set state
2613
if (keyA == "shift") {
2614
pressEvent->state = SHIFTMASK;
2615
releaseEvent->state = SHIFTMASK;
2616
} else if (keyA == "control") {
2617
pressEvent->state = CONTROLMASK;
2618
releaseEvent->state = CONTROLMASK;
2619
} else if (keyA == "alt") {
2620
pressEvent->state = ALTMASK;
2621
releaseEvent->state = ALTMASK;
2622
}
2623
new InternalTestStep(myTestSystem, SEL_KEYPRESS, category, pressEvent, updateView, "keys '" + keyA + "' + '" + keyB + "' pressed");
2624
new InternalTestStep(myTestSystem, SEL_KEYRELEASE, category, releaseEvent, updateView, "keys '" + keyA + "' + '" + keyB + " pressed");
2625
}
2626
2627
2628
void
2629
InternalTestStep::buildMouseClick(const InternalTest::ViewPosition& viewPosition,
2630
const int offsetX, const int offsetY,
2631
const std::string& button, const std::string& keyModifier) const {
2632
// move mouse move
2633
new InternalTestStep(myTestSystem, SEL_MOTION, Category::VIEW,
2634
buildMouseMoveEvent(viewPosition, offsetX, offsetY, 0, "", 0),
2635
true, "mouse moved to click position");
2636
// continue depending of mouse
2637
if (button == "left") {
2638
new InternalTestStep(myTestSystem, SEL_LEFTBUTTONPRESS, Category::VIEW,
2639
buildMouseClickEvent(SEL_LEFTBUTTONPRESS, viewPosition, offsetX, offsetY, keyModifier, 1),
2640
true, "mouse button " + button + " pressed");
2641
new InternalTestStep(myTestSystem, SEL_LEFTBUTTONRELEASE, Category::VIEW,
2642
buildMouseClickEvent(SEL_LEFTBUTTONRELEASE, viewPosition, offsetX, offsetY, keyModifier, 1),
2643
true, "mouse button " + button + " released");
2644
} else if (button == "center") {
2645
new InternalTestStep(myTestSystem, SEL_MIDDLEBUTTONPRESS, Category::VIEW,
2646
buildMouseClickEvent(SEL_MIDDLEBUTTONPRESS, viewPosition, offsetX, offsetY, keyModifier, 1),
2647
true, "mouse button " + button + " pressed");
2648
new InternalTestStep(myTestSystem, SEL_MIDDLEBUTTONRELEASE, Category::VIEW,
2649
buildMouseClickEvent(SEL_MIDDLEBUTTONRELEASE, viewPosition, offsetX, offsetY, keyModifier, 1),
2650
true, "mouse button " + button + " released");
2651
} else if (button == "right") {
2652
new InternalTestStep(myTestSystem, SEL_RIGHTBUTTONPRESS, Category::VIEW,
2653
buildMouseClickEvent(SEL_RIGHTBUTTONPRESS, viewPosition, offsetX, offsetY, keyModifier, 1),
2654
true, "mouse button " + button + " pressed");
2655
new InternalTestStep(myTestSystem, SEL_RIGHTBUTTONRELEASE, Category::VIEW,
2656
buildMouseClickEvent(SEL_RIGHTBUTTONRELEASE, viewPosition, offsetX, offsetY, keyModifier, 1),
2657
true, "mouse button " + button + " released");
2658
}
2659
}
2660
2661
2662
void
2663
InternalTestStep::buildMouseDragDrop(const InternalTest::ViewPosition& viewStartPosition,
2664
const int offsetStartX, const int offsetStartY,
2665
const InternalTest::ViewPosition& viewEndPosition,
2666
const int offsetEndX, const int offsetEndY,
2667
const std::string& keyModifier) const {
2668
// move mouse interpolating
2669
const auto interpolationSteps = myTestSystem->interpolateViewPositions(viewStartPosition, offsetStartX, offsetStartY, viewEndPosition, offsetEndX, offsetEndY);
2670
// move mouse move
2671
new InternalTestStep(myTestSystem, SEL_MOTION, Category::VIEW,
2672
buildMouseMoveEvent(viewStartPosition, offsetStartX, offsetStartY, 0, "", 0),
2673
true, "mouse moved to click position (dragDrop)");
2674
// press button
2675
new InternalTestStep(myTestSystem, SEL_LEFTBUTTONPRESS, Category::VIEW,
2676
buildMouseClickEvent(SEL_LEFTBUTTONPRESS, viewStartPosition, offsetStartX, offsetStartY, keyModifier, 1),
2677
true, "mouse button left pressed (dragDrop)");
2678
// move mouse button
2679
for (const auto& position : interpolationSteps) {
2680
new InternalTestStep(myTestSystem, SEL_MOTION, Category::VIEW,
2681
buildMouseMoveEvent(position, 0, 0, LEFTBUTTON, "leftButton", 1),
2682
true, "mouse moved (dragDrop)");
2683
}
2684
// release button
2685
new InternalTestStep(myTestSystem, SEL_LEFTBUTTONRELEASE, Category::VIEW,
2686
buildMouseClickEvent(SEL_LEFTBUTTONRELEASE, viewEndPosition, offsetEndX, offsetEndY, keyModifier, 1),
2687
true, "mouse button left released (dragDrop)");
2688
}
2689
2690
2691
FXEvent*
2692
InternalTestStep::buildMouseMoveEvent(const InternalTest::ViewPosition& viewPosition,
2693
const int offsetX, const int offsetY, const int clickedButton,
2694
const std::string& keyModifier, const int numberOfClicks) const {
2695
FXEvent* moveEvent = new FXEvent();
2696
// set event values
2697
moveEvent->time = myTestSystem->getTime();
2698
moveEvent->type = SEL_MOTION;
2699
moveEvent->synthetic = true;
2700
moveEvent->win_x = viewPosition.getX() + MOUSE_OFFSET_X + offsetX;
2701
moveEvent->win_y = viewPosition.getY() + MOUSE_OFFSET_Y + offsetY;
2702
moveEvent->last_x = myTestSystem->getLastMovedPosition().getX();
2703
moveEvent->last_y = myTestSystem->getLastMovedPosition().getY();
2704
moveEvent->click_x = 0;
2705
moveEvent->click_y = 0;
2706
moveEvent->moved = true;
2707
moveEvent->rect = FXRectangle(0, 0, 0, 0);
2708
moveEvent->click_button = clickedButton;
2709
moveEvent->click_count = numberOfClicks;
2710
moveEvent->code = 0;
2711
// set modifier
2712
if (keyModifier == "control") {
2713
moveEvent->state = CONTROLMASK;
2714
} else if (keyModifier == "shift") {
2715
moveEvent->state = SHIFTMASK;
2716
} else if (keyModifier == "leftButton") {
2717
moveEvent->state = LEFTBUTTONMASK;
2718
} else {
2719
moveEvent->state = 0;
2720
}
2721
// update last moved position
2722
myTestSystem->updateLastMovedPosition(moveEvent->win_x, moveEvent->win_y);
2723
return moveEvent;
2724
}
2725
2726
2727
FXEvent*
2728
InternalTestStep::buildMouseClickEvent(FXSelType type, const InternalTest::ViewPosition& viewPosition,
2729
const int offsetX, const int offsetY, const std::string& keyModifier,
2730
const int numberOfClicks) const {
2731
FXEvent* clickEvent = new FXEvent();
2732
// set event values
2733
clickEvent->time = myTestSystem->getTime();
2734
clickEvent->type = type;
2735
clickEvent->synthetic = true;
2736
clickEvent->win_x = viewPosition.getX() + MOUSE_OFFSET_X + offsetX;
2737
clickEvent->win_y = viewPosition.getY() + MOUSE_OFFSET_Y + offsetY;
2738
clickEvent->click_x = viewPosition.getX() + MOUSE_OFFSET_X + offsetX;
2739
clickEvent->click_y = viewPosition.getY() + MOUSE_OFFSET_Y + offsetY;
2740
clickEvent->last_x = myTestSystem->getLastMovedPosition().getX();
2741
clickEvent->last_y = myTestSystem->getLastMovedPosition().getY();
2742
clickEvent->click_count = numberOfClicks;
2743
clickEvent->moved = false;
2744
clickEvent->rect = FXRectangle(0, 0, 0, 0);
2745
// set button
2746
if ((type == SEL_LEFTBUTTONPRESS) || (type == SEL_LEFTBUTTONRELEASE)) {
2747
clickEvent->click_button = LEFTBUTTON;
2748
clickEvent->code = LEFTBUTTON;
2749
} else if ((type == SEL_MIDDLEBUTTONPRESS) || (type == SEL_MIDDLEBUTTONRELEASE)) {
2750
clickEvent->click_button = MIDDLEBUTTON;
2751
clickEvent->code = MIDDLEBUTTON;
2752
} else if ((type == SEL_RIGHTBUTTONPRESS) || (type == SEL_RIGHTBUTTONRELEASE)) {
2753
clickEvent->click_button = RIGHTBUTTON;
2754
clickEvent->code = RIGHTBUTTON;
2755
} else {
2756
clickEvent->click_button = 0;
2757
clickEvent->code = 0;
2758
}
2759
// set modifier
2760
if (keyModifier == "control") {
2761
clickEvent->state = CONTROLMASK;
2762
} else if (keyModifier == "shift") {
2763
clickEvent->state = SHIFTMASK;
2764
} else {
2765
clickEvent->state = 0;
2766
}
2767
return clickEvent;
2768
}
2769
2770
2771
void
2772
InternalTestStep::writeClickInfo(const InternalTest::ViewPosition& viewPosition,
2773
const int offsetX, const int offsetY,
2774
const std::string modifier) const {
2775
if (modifier == "control") {
2776
std::cout << "TestFunctions: Clicked with Control key pressed over position " <<
2777
toString(viewPosition.getX() + MOUSE_REFERENCE_X + offsetX) << " - " <<
2778
toString(viewPosition.getY() + MOUSE_REFERENCE_Y + offsetY) << std::endl;
2779
} else if (modifier == "shift") {
2780
std::cout << "TestFunctions: Clicked with Shift key pressed over position " <<
2781
toString(viewPosition.getX() + MOUSE_REFERENCE_X + offsetX) << " - " <<
2782
toString(viewPosition.getY() + MOUSE_REFERENCE_Y) << std::endl;
2783
} else {
2784
std::cout << "TestFunctions: Clicked over position " <<
2785
toString(viewPosition.getX() + MOUSE_REFERENCE_X + offsetX) << " - " <<
2786
toString(viewPosition.getY() + MOUSE_REFERENCE_Y + offsetY) << std::endl;
2787
}
2788
}
2789
2790
/****************************************************************************/
2791
2792