Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/tests/InternalTestStep.h
193716 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 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.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Mar 2025
17
///
18
// Single operation used in InternalTests
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/dialogs/GNEDialogEnum.h>
24
#include <utils/foxtools/fxheader.h>
25
26
#include "InternalTest.h"
27
28
// ===========================================================================
29
// class definitions
30
// ===========================================================================
31
32
class InternalTestStep {
33
34
public:
35
/// @name category step
36
enum class Category {
37
META, // Meta step (used for packing set of steps like click or write)
38
INIT, // Setup and start step
39
FINISH, // Write last line
40
APP, // send signal to APP (Either GUIAppWindows or GNEApplicationWindow)
41
VIEW, // send signal to view (either GUIView or GNEViewNet)
42
TLS_PHASES, // send signal to TLS Phases module (used for TLS Phases)
43
TLS_PHASETABLE, // send signal to TLSTable (used for TLS Phases)
44
DIALOG, // send signal to dialog (used for modal dialogs)
45
};
46
47
/// @brief dialog arguments, used for certain modal dialogs that can not be edited using tab
48
class DialogArgument {
49
50
public:
51
/// @name basic actions
52
enum class Action {
53
ACCEPT, // press accept button
54
CANCEL, // press cancel button
55
RESET, // press reset button
56
ABORT, // abort dialog
57
CUSTOM, // custom action
58
NONE, // no action
59
};
60
61
/// @brief constructor for basic actions
62
DialogArgument(DialogType type, Action action);
63
64
/// @brief constructor for basic actions
65
DialogArgument(DialogType type, const std::string& customAction);
66
67
/// @brief constructor for basic actions and index
68
DialogArgument(DialogType type, const std::string& customAction, const int index);
69
70
/// @brief constructor for custom actions and prefix to remove in the action
71
DialogArgument(DialogType type, const std::string& prefixToRemove, const std::string& customAction);
72
73
/// @brief get type
74
DialogType getType() const;
75
76
/// @brief get basic action
77
Action getAction() const;
78
79
/// @brief get custom action
80
const std::string& getCustomAction() const;
81
82
/// @brief get index
83
int getIndex() const;
84
85
protected:
86
/// @brief dialog type
87
DialogType myType = DialogType::DEFAULT;
88
89
/// @brief basic action
90
Action myAction = Action::NONE;
91
92
/// @brief action to be carried out in the dialog
93
std::string myCustomAction;
94
95
/// @brief index
96
int myIndex = 0;
97
98
private:
99
/// @brief invalidated default constructor
100
DialogArgument() = delete;
101
102
/// @brief invalidated copy constructor
103
DialogArgument(const DialogArgument&) = delete;
104
};
105
106
/// @brief struct used for test TLS Tables
107
class TLSTableTest {
108
109
public:
110
/// brief default constructor for phases
111
TLSTableTest(FXSelector sel_, const int row_);
112
113
/// brief default constructor with text
114
TLSTableTest(FXSelector sel_, const int row_, const int column_, const std::string& text_);
115
116
/// @brief selector
117
const FXSelector sel = 0;
118
119
/// @brief x coordinate
120
const int row = 0;
121
122
/// @brief y coordinate
123
const int column = 0;
124
125
/// @brief text
126
const std::string text = "";
127
128
private:
129
/// @brief invalidated default constructor
130
TLSTableTest() = delete;
131
132
/// @brief invalidated copy constructor
133
TLSTableTest(const TLSTableTest&) = delete;
134
};
135
136
/// @brief constructor for parsing step in string format
137
InternalTestStep(InternalTest* testSystem, const std::string& step);
138
139
/// @brief constructor for shortcuts
140
InternalTestStep(InternalTest* testSystem, FXSelector messageType, FXSelector messageID,
141
Category category, const std::string& description);
142
143
/// @brief constructor for input events (click, keyPress, etc.)
144
InternalTestStep(InternalTest* testSystem, FXSelector messageType, Category category,
145
FXEvent* event, const bool updateView, const std::string& description);
146
147
/// @brief constructor for dialog arguments
148
InternalTestStep(InternalTest* testSystem, DialogArgument* dialogArgument,
149
const std::string& description);
150
151
/// @brief destructor
152
~InternalTestStep();
153
154
/// @name next step management
155
/// @{
156
157
/// @brief get next step
158
InternalTestStep* getNextStep() const;
159
160
/// @brief set next step
161
void setNextStep(InternalTestStep* nextStep);
162
163
/// @}
164
165
/// @brief get message type
166
FXSelector getMessageType() const;
167
168
/// @brief get message ID
169
FXSelector getMessageID() const;
170
171
/// @brief get dialog argument
172
DialogArgument* getDialogArgument() const;
173
174
/// @brief get TLS Table test
175
TLSTableTest* getTLSTableTest() const;
176
177
/// @brief get selector (based in messageType and messageID)
178
FXSelector getSelector() const;
179
180
/// @brief check if update view
181
bool updateView() const;
182
183
/// @brief get category
184
Category getCategory() const;
185
186
/// @brief get event associated with this step
187
void* getEvent() const;
188
189
/// @brief get description
190
const std::string& getDescription() const;
191
192
private:
193
/// @brief test system parent
194
InternalTest* myTestSystem = nullptr;
195
196
/// @brief next step in the test
197
InternalTestStep* myNextStep = nullptr;
198
199
/// @brief message type (by default SEL_COMMAND)
200
FXSelector myMessageType = SEL_COMMAND;
201
202
/// @brief message ID
203
FXSelector myMessageID = 0;
204
205
/// @brief step category
206
Category myCategory = Category::META;
207
208
/// @brief flag to enable or disable view after execute step
209
bool myUpdateView = false;
210
211
/// @brief description
212
std::string myDescription;
213
214
/// @brief arguments
215
std::vector<std::string> myArguments;
216
217
/// @brief list of events associated with this step
218
FXEvent* myEvent = nullptr;
219
220
/// @brief dialog argument
221
DialogArgument* myDialogArgument = nullptr;
222
223
/// @brief TLS Table test
224
TLSTableTest* myTLSTableTest = nullptr;
225
226
/// @brief parse function and arguments
227
std::string parseStep(const std::string& rowText);
228
229
/// @brief parse arguments
230
void parseArguments(const std::string& arguments);
231
232
/// @brief process setupAndStart function
233
void setupAndStart();
234
235
/// @brief finish function
236
void finish();
237
238
/// @brief process click function
239
void mouseClick(const std::string& button, const std::string& modifier) const;
240
241
/// @brief process click function
242
void leftClickOffset(const std::string& button) const;
243
244
/// @brief process moveElementHorizontal function
245
void moveElementHorizontal() const;
246
247
/// @brief process moveElementVertical function
248
void moveElementVertical() const;
249
250
/// @brief process moveElement function
251
void moveElement() const;
252
253
/// @brief process focusOnFrame function
254
void focusOnFrame() const;
255
256
/// @brief process typeKey function
257
void typeKey() const;
258
259
/// @brief process contextualMenuOperation function
260
void contextualMenuOperation() const;
261
262
/// @brief process protect elements function
263
void protectElements() const;
264
265
/// @brief process waitDeleteWarning function
266
void waitDeleteWarning() const;
267
268
/// @brief process modifyAttribute function
269
void modifyAttribute(const int overlappedTabs) const;
270
271
/// @brief process modifyBoolAttribute function
272
void modifyBoolAttribute(const int overlappedTabs) const;
273
274
/// @brief process modifyColorAttribute function
275
void modifyColorAttribute(const int overlappedTabs) const;
276
277
/// @brief process modifyVClassDialog_DisallowAll function
278
void modifyVClassDialog_NoDisallowAll(const int overlappedTabs) const;
279
280
/// @brief process modifyVClassDialog_DisallowAll function
281
void modifyVClassDialog_DisallowAll(const int overlappedTabs) const;
282
283
/// @brief process modifyVClassDialog_Cancel function
284
void modifyVClassDialog_Cancel(const int overlappedTabs) const;
285
286
/// @brief process modifyVClassDialog_Reset function
287
void modifyVClassDialog_Reset(const int overlappedTabs) const;
288
289
/// @brief process modifyVTypeDialogAttribute function
290
void modifyVTypeDialogAttribute() const;
291
292
/// @brief process createConnection function
293
void createConnection(const std::string& keyModifier) const;
294
295
/// @brief process createCrossing function
296
void createCrossing() const;
297
298
/// @brief process modifyCrossingDefaultValue function
299
void modifyCrossingDefaultValue() const;
300
301
/// @brief process modifyCrossingDefaultBoolValue function
302
void modifyCrossingDefaultBoolValue() const;
303
304
/// @brief process crossingClearEdges function
305
void crossingClearEdges() const;
306
307
/// @brief process crossingInvertEdges function
308
void crossingInvertEdges() const;
309
310
/// @brief process createConnectionEdit function
311
void saveConnectionEdit() const;
312
313
/// @brief process fixCrossings function
314
void fixCrossings();
315
316
/// @brief process fixStoppingPlace function
317
void fixStoppingPlace();
318
319
/// @brief process fixRoutes function
320
void fixRoute();
321
322
/// @brief process createTLS function
323
void createTLS(const int overlappedTabs) const;
324
325
/// @brief process Copy TLS function
326
void copyTLS() const;
327
328
/// @brief process join TLS function
329
void joinTSL() const;
330
331
/// @brief process disJoin TLS function
332
void disJoinTLS() const;
333
334
/// @brief process delete TLS function
335
void deleteTLS() const;
336
337
/// @brief process modifyTLSTable function
338
void modifyTLSTable();
339
340
/// @brief process resetSingleTLSPhases function
341
void resetSingleTLSPhases() const;
342
343
/// @brief process resetAllTLSPhases function
344
void resetAllTLSPhases() const;
345
346
/// @brief process pressTLSPhaseButton function
347
void pressTLSPhaseButton() const;
348
349
/// @brief process addPhase function
350
void addPhase(const std::string& type);
351
352
/// @brief process pressTLSButton function
353
void pressTLSButton(const std::string& type);
354
355
/// @brief process checkParameters function
356
void checkParameters(const int overlappedTabs) const;
357
358
/// @brief process checkDoubleParameters function
359
void checkDoubleParameters(const int overlappedTabs) const;
360
361
/// @brief process changeEditMode function
362
void changeEditMode();
363
364
/// @brief process save existent function
365
void saveExistentFile();
366
367
/// @brief process check undo-redo function
368
void checkUndoRedo() const;
369
370
/// @brief process delete function
371
void deleteFunction() const;
372
373
/// @brief process selection function
374
void selection() const;
375
376
/// @brief process selectNetworkItems function
377
void selectNetworkItems() const;
378
379
/// @brief process lockSelection function
380
void lockSelection() const;
381
382
/// @brief process selectionRectangle function
383
void selectionRectangle() const;
384
385
/// @brief process createDataSet function
386
void createDataSet() const;
387
388
/// @brief process createDataInterval function
389
void createDataInterval() const;
390
391
/// @brief process openAboutDialog function
392
void openAboutDialog();
393
394
/// @brief process load file function
395
void loadFile();
396
397
/// @brief process save new file function
398
void saveNewFile();
399
400
/// @brief process save file as function
401
void saveFileAs();
402
403
/// @brief process save unified file as function
404
void saveUnifiedFileAs();
405
406
/// @brief process reload file function
407
void reloadFile();
408
409
/// @brief process select edge type function
410
void selectEdgeType();
411
412
/// @brief process create new edge type function
413
void createNewEdgeType();
414
415
/// @brief process overwriting accept function
416
void overwritingAccept();
417
418
/// @brief process overwriting cancel function
419
void overwritingCancel();
420
421
/// @brief process overwriting abort function
422
void overwritingAbort();
423
424
/// @brief process overwriting apply to all function
425
void overwritingApplyToAll();
426
427
/// @brief process undo function
428
void undo() const;
429
430
/// @brief process redo function
431
void redo() const;
432
433
/// @brief process changeSupermode function
434
void changeSupermode();
435
436
/// @brief process changeMode function
437
void changeMode();
438
439
/// @brief process changeElement function
440
void changeElement() const;
441
442
/// @bief process changePlan function
443
void changePlan() const;
444
445
/// @brief process computeJunctions function
446
void computeJunctions();
447
448
/// @brief process computeJunctionsVolatileOptions function
449
void computeJunctionsVolatileOptions();
450
451
/// @brief process joinJunctions function
452
void joinJunctions();
453
454
/// @brief process selectChild function
455
void selectAdditionalChild();
456
457
/// @brief process createRectangledShape function
458
void createRectangledShape();
459
460
/// @brief process createSquaredShape function
461
void createSquaredShape();
462
463
/// @brief process createLineShape function
464
void createLineShape();
465
466
/// @brief process createMeanData function
467
void createMeanData();
468
469
/// @brief process deleteMeanData function
470
void deleteMeanData();
471
472
/// @brief process copyMeanData function
473
void copyMeanData();
474
475
/// @brief process quit function
476
void quit();
477
478
/// @brief check int argument
479
bool checkIntArgument(const std::string& argument) const;
480
481
/// @brief get int argument
482
int getIntArgument(const std::string& argument) const;
483
484
/// @brief check bool argument
485
bool checkBoolArgument(const std::string& argument) const;
486
487
/// @brief get bool argument
488
bool getBoolArgument(const std::string& argument) const;
489
490
/// @brief check string argument
491
bool checkStringArgument(const std::string& argument) const;
492
493
/// @brief get string argument
494
std::string getStringArgument(const std::string& argument) const;
495
496
/// @brief strip spaces
497
std::string stripSpaces(const std::string& str) const;
498
499
/// @brief write error
500
void writeError(const std::string& function, const int overlapping,
501
const std::string& expected) const;
502
503
/// @brief create shape
504
void createShape(const InternalTest::ViewPosition& viewPosition,
505
const int sizeX, const int sizeY, const bool close,
506
const bool line) const;
507
508
/// @name modify attribute functions
509
/// @{
510
511
/// @brief modify attribute
512
void modifyStringAttribute(Category category, const int tabs, const int overlappedTabs, const std::string& value) const;
513
514
/// @brief modify bool attribute
515
void modifyBoolAttribute(Category category, const int tabs, const int overlappedTabs) const;
516
517
/// @}
518
519
/// @name undo-redo functions
520
/// @{
521
522
/// @brief process check undo function
523
void buildUndo(const int number) const;
524
525
/// @brief process check redo function
526
void buildRedo(const int number) const;
527
528
/// @}
529
530
/// @name key functions
531
/// @{
532
533
/// @brief translate key
534
std::pair<FXint, FXString> translateKey(const std::string& key) const;
535
536
/// @brief build key press event
537
FXEvent* buildKeyPressEvent(const std::string& key) const;
538
539
/// @brief build key release event
540
FXEvent* buildKeyReleaseEvent(const std::string& key) const;
541
542
/// @brief build a key press and key release (used for tabs, spaces, enter, etc)
543
void buildPressKeyEvent(Category category, const std::string& key, const bool updateView) const;
544
545
/// @brief build a two key press and key release (used for tabs, spaces, enter, etc)
546
void buildTwoPressKeyEvent(Category category, const std::string& keyA, const std::string& keyB, const bool updateView) const;
547
548
/// @}
549
550
/// @name mouse functions
551
/// @{
552
553
/// @brief build mouse click event
554
void buildMouseClick(const InternalTest::ViewPosition& viewPosition,
555
const int offsetX, const int offsetY,
556
const std::string& button, const std::string& keyModifier) const;
557
558
/// @brief build mouse dragdrop
559
void buildMouseDragDrop(const InternalTest::ViewPosition& viewStartPosition,
560
const int offsetStartX, const int offsetStartY,
561
const InternalTest::ViewPosition& viewEndPosition,
562
const int offsetEndX, const int offsetEndY,
563
const std::string& keyModifier) const;
564
565
/// @brief build mouse move event
566
FXEvent* buildMouseMoveEvent(const InternalTest::ViewPosition& viewPosition,
567
const int offsetX, const int offsetY, const int clickedButton,
568
const std::string& keyModifier, const int numberOfClicks) const;
569
570
/// @brief build mouse left click press event
571
FXEvent* buildMouseClickEvent(FXSelType type, const InternalTest::ViewPosition& viewPosition,
572
const int offsetX, const int offsetY, const std::string& keyModifier,
573
const int numberOfClicks) const;
574
575
/// @brief write click info
576
void writeClickInfo(const InternalTest::ViewPosition& viewPosition,
577
const int offsetX, const int offsetY,
578
const std::string modifier) const;
579
580
/// @}
581
582
/// @brief invalidate default constructor
583
InternalTestStep() = delete;
584
585
/// @brief Invalidated copy constructor.
586
InternalTestStep(const InternalTestStep&) = delete;
587
588
/// @brief Invalidated assignment operator
589
InternalTestStep& operator=(const InternalTestStep&) = delete;
590
};
591
592