Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/tests/InternalTestStep.h
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.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 typeKey function
254
void typeKey() const;
255
256
/// @brief process contextualMenuOperation function
257
void contextualMenuOperation() const;
258
259
/// @brief process protect elements function
260
void protectElements() const;
261
262
/// @brief process waitDeleteWarning function
263
void waitDeleteWarning() const;
264
265
/// @brief process modifyAttribute function
266
void modifyAttribute(const int overlappedTabs) const;
267
268
/// @brief process modifyBoolAttribute function
269
void modifyBoolAttribute(const int overlappedTabs) const;
270
271
/// @brief process modifyColorAttribute function
272
void modifyColorAttribute(const int overlappedTabs) const;
273
274
/// @brief process modifyVClassDialog_DisallowAll function
275
void modifyVClassDialog_NoDisallowAll(const int overlappedTabs) const;
276
277
/// @brief process modifyVClassDialog_DisallowAll function
278
void modifyVClassDialog_DisallowAll(const int overlappedTabs) const;
279
280
/// @brief process modifyVClassDialog_Cancel function
281
void modifyVClassDialog_Cancel(const int overlappedTabs) const;
282
283
/// @brief process modifyVClassDialog_Reset function
284
void modifyVClassDialog_Reset(const int overlappedTabs) const;
285
286
/// @brief process modifyVTypeDialogAttribute function
287
void modifyVTypeDialogAttribute() const;
288
289
/// @brief process createConnection function
290
void createConnection(const std::string& keyModifier) const;
291
292
/// @brief process createCrossing function
293
void createCrossing() const;
294
295
/// @brief process modifyCrossingDefaultValue function
296
void modifyCrossingDefaultValue() const;
297
298
/// @brief process modifyCrossingDefaultBoolValue function
299
void modifyCrossingDefaultBoolValue() const;
300
301
/// @brief process crossingClearEdges function
302
void crossingClearEdges() const;
303
304
/// @brief process crossingInvertEdges function
305
void crossingInvertEdges() const;
306
307
/// @brief process createConnectionEdit function
308
void saveConnectionEdit() const;
309
310
/// @brief process fixCrossings function
311
void fixCrossings();
312
313
/// @brief process fixStoppingPlace function
314
void fixStoppingPlace();
315
316
/// @brief process fixRoutes function
317
void fixRoute();
318
319
/// @brief process createTLS function
320
void createTLS(const int overlappedTabs) const;
321
322
/// @brief process Copy TLS function
323
void copyTLS() const;
324
325
/// @brief process join TLS function
326
void joinTSL() const;
327
328
/// @brief process disJoin TLS function
329
void disJoinTLS() const;
330
331
/// @brief process delete TLS function
332
void deleteTLS() const;
333
334
/// @brief process modifyTLSTable function
335
void modifyTLSTable();
336
337
/// @brief process resetSingleTLSPhases function
338
void resetSingleTLSPhases() const;
339
340
/// @brief process resetAllTLSPhases function
341
void resetAllTLSPhases() const;
342
343
/// @brief process pressTLSPhaseButton function
344
void pressTLSPhaseButton() const;
345
346
/// @brief process addPhase function
347
void addPhase(const std::string& type);
348
349
/// @brief process pressTLSButton function
350
void pressTLSButton(const std::string& type);
351
352
/// @brief process checkParameters function
353
void checkParameters(const int overlappedTabs) const;
354
355
/// @brief process checkDoubleParameters function
356
void checkDoubleParameters(const int overlappedTabs) const;
357
358
/// @brief process changeEditMode function
359
void changeEditMode();
360
361
/// @brief process save existent function
362
void saveExistentFile();
363
364
/// @brief process check undo-redo function
365
void checkUndoRedo() const;
366
367
/// @brief process delete function
368
void deleteFunction() const;
369
370
/// @brief process selection function
371
void selection() const;
372
373
/// @brief process selectNetworkItems function
374
void selectNetworkItems() const;
375
376
/// @brief process lockSelection function
377
void lockSelection() const;
378
379
/// @brief process selectionRectangle function
380
void selectionRectangle() const;
381
382
/// @brief process createDataSet function
383
void createDataSet() const;
384
385
/// @brief process createDataInterval function
386
void createDataInterval() const;
387
388
/// @brief process openAboutDialog function
389
void openAboutDialog();
390
391
/// @brief process load file function
392
void loadFile();
393
394
/// @brief process save new file function
395
void saveNewFile();
396
397
/// @brief process save file as function
398
void saveFileAs();
399
400
/// @brief process reload file function
401
void reloadFile();
402
403
/// @brief process select edge type function
404
void selectEdgeType();
405
406
/// @brief process create new edge type function
407
void createNewEdgeType();
408
409
/// @brief process overwriting accept function
410
void overwritingAccept();
411
412
/// @brief process overwriting cancel function
413
void overwritingCancel();
414
415
/// @brief process overwriting abort function
416
void overwritingAbort();
417
418
/// @brief process overwriting apply to all function
419
void overwritingApplyToAll();
420
421
/// @brief process undo function
422
void undo() const;
423
424
/// @brief process redo function
425
void redo() const;
426
427
/// @brief process changeSupermode function
428
void changeSupermode();
429
430
/// @brief process changeMode function
431
void changeMode();
432
433
/// @brief process changeElement function
434
void changeElement() const;
435
436
/// @bief process changePlan function
437
void changePlan() const;
438
439
/// @brief process computeJunctions function
440
void computeJunctions();
441
442
/// @brief process computeJunctionsVolatileOptions function
443
void computeJunctionsVolatileOptions();
444
445
/// @brief process selectChild function
446
void selectAdditionalChild();
447
448
/// @brief process createRectangledShape function
449
void createRectangledShape();
450
451
/// @brief process createSquaredShape function
452
void createSquaredShape();
453
454
/// @brief process createLineShape function
455
void createLineShape();
456
457
/// @brief process createMeanData function
458
void createMeanData();
459
460
/// @brief process deleteMeanData function
461
void deleteMeanData();
462
463
/// @brief process copyMeanData function
464
void copyMeanData();
465
466
/// @brief process quit function
467
void quit();
468
469
/// @brief check int argument
470
bool checkIntArgument(const std::string& argument) const;
471
472
/// @brief get int argument
473
int getIntArgument(const std::string& argument) const;
474
475
/// @brief check bool argument
476
bool checkBoolArgument(const std::string& argument) const;
477
478
/// @brief get bool argument
479
bool getBoolArgument(const std::string& argument) const;
480
481
/// @brief check string argument
482
bool checkStringArgument(const std::string& argument) const;
483
484
/// @brief get string argument
485
std::string getStringArgument(const std::string& argument) const;
486
487
/// @brief strip spaces
488
std::string stripSpaces(const std::string& str) const;
489
490
/// @brief write error
491
void writeError(const std::string& function, const int overlapping,
492
const std::string& expected) const;
493
494
/// @brief create shape
495
void createShape(const InternalTest::ViewPosition& viewPosition,
496
const int sizeX, const int sizeY, const bool close,
497
const bool line) const;
498
499
/// @name modify attribute functions
500
/// @{
501
502
/// @brief modify attribute
503
void modifyStringAttribute(Category category, const int tabs, const int overlappedTabs, const std::string& value) const;
504
505
/// @brief modify bool attribute
506
void modifyBoolAttribute(Category category, const int tabs, const int overlappedTabs) const;
507
508
/// @}
509
510
/// @name undo-redo functions
511
/// @{
512
513
/// @brief process check undo function
514
void buildUndo(const int number) const;
515
516
/// @brief process check redo function
517
void buildRedo(const int number) const;
518
519
/// @}
520
521
/// @name key functions
522
/// @{
523
524
/// @brief translate key
525
std::pair<FXint, FXString> translateKey(const std::string& key) const;
526
527
/// @brief build key press event
528
FXEvent* buildKeyPressEvent(const std::string& key) const;
529
530
/// @brief build key release event
531
FXEvent* buildKeyReleaseEvent(const std::string& key) const;
532
533
/// @brief build a key press and key release (used for tabs, spaces, enter, etc)
534
void buildPressKeyEvent(Category category, const std::string& key, const bool updateView) const;
535
536
/// @brief build a two key press and key release (used for tabs, spaces, enter, etc)
537
void buildTwoPressKeyEvent(Category category, const std::string& keyA, const std::string& keyB, const bool updateView) const;
538
539
/// @}
540
541
/// @name mouse functions
542
/// @{
543
544
/// @brief build mouse click event
545
void buildMouseClick(const InternalTest::ViewPosition& viewPosition,
546
const int offsetX, const int offsetY,
547
const std::string& button, const std::string& keyModifier) const;
548
549
/// @brief build mouse dragdrop
550
void buildMouseDragDrop(const InternalTest::ViewPosition& viewStartPosition,
551
const int offsetStartX, const int offsetStartY,
552
const InternalTest::ViewPosition& viewEndPosition,
553
const int offsetEndX, const int offsetEndY,
554
const std::string& keyModifier) const;
555
556
/// @brief build mouse move event
557
FXEvent* buildMouseMoveEvent(const InternalTest::ViewPosition& viewPosition,
558
const int offsetX, const int offsetY, const int clickedButton,
559
const std::string& keyModifier, const int numberOfClicks) const;
560
561
/// @brief build mouse left click press event
562
FXEvent* buildMouseClickEvent(FXSelType type, const InternalTest::ViewPosition& viewPosition,
563
const int offsetX, const int offsetY, const std::string& keyModifier,
564
const int numberOfClicks) const;
565
566
/// @brief write click info
567
void writeClickInfo(const InternalTest::ViewPosition& viewPosition,
568
const int offsetX, const int offsetY,
569
const std::string modifier) const;
570
571
/// @}
572
573
/// @brief invalidate default constructor
574
InternalTestStep() = delete;
575
576
/// @brief Invalidated copy constructor.
577
InternalTestStep(const InternalTestStep&) = delete;
578
579
/// @brief Invalidated assignment operator
580
InternalTestStep& operator=(const InternalTestStep&) = delete;
581
};
582
583