34 #include <vici/testmgr.h>
35 #include <vici/proc.h>
36 #include <vici/fdstream.h>
43 #include <condition_variable>
45 #include <QGraphicsView>
70 typedef std::vector< std::string >
ParamList;
92 void mouseDoubleClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
93 QPoint pos = QPoint(),
int delay=-1);
170 std::vector< std::pair<std::string, std::string > >
jumps;
191 ListOfLists::iterator seq;
193 std::string windowName;
201 std::condition_variable pauseCV;
204 std::condition_variable jumpCV;
242 void jumpThread(
csr tcname,
csr widgetName,
csr command,
const std::vector< std::string> ¶ms);
249 void sendAdaptor(
const std::string &tcname,
const std::string & widgetName,
250 const std::string & command,
251 const std::vector< std::string> ¶ms);
294 std::map< std::string, Adaptor * > adaptors;
296 void describeAdaptors();
299 void jumpThread(
csr tcname,
csr widgetName,
csr command,
const std::vector< std::string> ¶ms);
302 void runAdaptor(
const std::string &tcname,
const std::string & widgetName,
303 const std::string & command,
304 const std::vector< std::string > ¶ms);
308 void registerStandardWindow(QWidget *);
309 void registerMessageBox(QWidget *w);
310 void registerFileDialog(QWidget *w);
311 void registerFontDialog(QWidget *w);
312 void registerColorDialog(QWidget *w);
313 void registerInputDialog(QWidget *w);
314 void registerButtons(QWidget *w,
csr prefix );
315 void clean( std::string & );
318 void newActiveWindow( QWidget *);
324 std::set<TestsForWindowPtr> activeTests;
328 std::map< std::string, TestsForWindowPtr > testsForWindows;
331 std::map< std::string, TestsForWindowPtr > testCases;
332 void installDefaultTestCases();
335 std::map< std::pair<std::string, ConDes>, std::vector<TestAction> > actions;
338 std::map< std::string, std::string> variables;
346 void focusChanged(QWidget *, QWidget * );
468 void getScripts(std::map< std::string, std::string > &);
474 void addTest(
csr testName,
bool unreferenced );
515 template < VICI::gth::W
idgetType wt >
535 template < VICI::gth::W
idgetType wt,
class T >
549 :
AdaptorST<wt>(name, gth), w( reinterpret_cast<T *>(p)) {}
std::shared_ptr< TestsForWindow > TestsForWindowPtr
Provides for automatic destruction when the owner is deleted.
Definition: libgth.h:255
LuaScript(csr chunk)
Constructor.
Definition: libgth.cpp:1124
Adaptor(csr name, GTHTest *gth)
Constructor.
Definition: libgth.h:102
DefaultTestCase(csr nm)
Constructor.
Definition: libgth.h:433
Provides an interface to the script XML file.
Definition: libgth.h:447
const std::string & name
The name of the test case, as installed.
Definition: libgth.h:410
bool checkPaused()
Test if paused.
Definition: libgth.cpp:1069
void getScripts(std::map< std::string, std::string > &)
Get the script for a window.
Definition: script.cpp:325
void resume()
Resume execution of the thread.
Definition: libgth.cpp:1085
void runActions(csr testCase, ConDes)
Called by the constructor and destructor of a test case.
Definition: libgth.cpp:429
std::string assignmentRegex
Regular expression for specifying values for variables.
Definition: libgth.h:166
static void describe(ListOfLists &)
Get a list of commands and their parameters for the Adaptor.
void jumpNotify()
Notification that the action has completed.
Definition: libgth.cpp:1113
virtual std::string action(csr tcname, csr cmnd, const ParamList ¶ms)
Run the command on the Adaptor's widget.
static int luaVersion()
Allow test scripts to check if Lua is installed (>0) and the version (51, 53)
Definition: libgth.cpp:1164
void mouseDoubleClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=0, QPoint pos=QPoint(), int delay=-1)
Utility functions.
void addExecFilePath(csr fileName)
Insert the executable's path into the script.
Definition: script.cpp:109
Provides a means of getting scene coordinates in a QGraphicsView.
Definition: libgth.h:494
void addSequence()
Increment the sequence number.
Definition: libgth.cpp:1004
csr getWidgetName()
Get the name of the widget.
Definition: libgth.h:123
void endMainWindow()
Called when testing for the main window completes.
Definition: libgth.cpp:420
virtual void run()
Begin execution of the thread.
Definition: libgth.cpp:1033
GTHTest(csr name)
Costructor.
Definition: libgth.cpp:58
A class for allowing the user to suspend the test.
Definition: libgth.h:268
void getWindows(ParamList &)
Get a list of windows from the XML script.
Definition: script.cpp:203
std::vector< std::list< std::string > > ListOfLists
ListOfLists is used to describe the commands and parameters of an Adaptor.
Definition: libgth.h:73
virtual bool runTest()
Run the tests for the test case.
Definition: libgth.h:430
Provide the interface between the GUI applications and the GUI Test Harness.
std::shared_ptr< LuaScript > LuaScriptPtr
Provides for automatic destruction when the owner is deleted.
Definition: libgth.h:151
~TestsForWindow()
Destructor.
Definition: libgth.cpp:997
~DefaultTestCase()
Destructor.
Definition: libgth.h:438
void assignVariables(const TestAction &, csr result)
Applies a regular expression to the result to get values for variables.
Definition: libgth.cpp:497
GTHTestCase(csr name)
Constructor.
Definition: libgth.cpp:1217
bool eventFilter(QObject *obj, QEvent *event)
Report position of mouse click in a graphics view.
void addScript(csr chunk)
Add a Lua script.
Definition: libgth.cpp:1022
Provides a test case to use for actions that don't have an explicit test case.
Definition: libgth.h:427
std::string widgetName
The name of the widget.
Definition: libgth.h:163
The interpreter for the script commands.
Definition: libgth.h:536
std::vector< std::pair< std::string, std::string > > jumps
Pairs of regular expressions and jump labels.
Definition: libgth.h:170
Provides a thread for applying test cases to a window.
Definition: libgth.h:185
WidgetType
List the types of widgets that we can interact with during testing.
Definition: gth.h:43
void getTestActions(csr tnm, ConDes, std::vector< TestAction > &)
Get the test actions for a test case constructor or destructor.
Definition: script.cpp:250
std::string label
Destination label for jumps.
Definition: libgth.h:161
GTHTest * gthTest
Reference to the owner.
Definition: libgth.h:96
Responsible for installing a factory for the test case.
Definition: testmgr.h:585
void addTest(csr testCase)
Add a test case to the current sequence.
Definition: libgth.cpp:1014
int delay
Time to wait in milliseconds.
Definition: libgth.h:162
void addWindow(csr windowName, bool unreferenced)
Add the name of windows that are [not] referenced in the script.
Definition: script.cpp:140
GTHTest * myScenario
The owning scenario.
Definition: libgth.h:409
~GTHTest()
Destructor.
Definition: libgth.cpp:100
~GTHTestCase()
Destructor.
Definition: libgth.cpp:1232
void jumpThread(csr tcname, csr widgetName, csr command, const std::vector< std::string > ¶ms)
Method for thread jumping.
Definition: libgth.cpp:908
void addAction(csr testCase, ConDes, const TestAction &)
Add an action to a test case.
void regWidget(void *w, VICI::gth::WidgetType t, csr n)
Register a widget so that it can be found by name.
Definition: libgth.cpp:815
A single action that can be applied to a GUI.
Definition: libgth.h:159
virtual void runTests(csr scenarioName, cdi::ScenarioResults *)
Run an event loop and wait until the testing completes.
Definition: libgth.cpp:393
virtual std::string action(csr tcname, csr cmnd, const ParamList ¶ms)=0
Interpreter function.
ConDes
Enumerates the stages at which the actions for a test case can be run.
Definition: libgth.h:177
Manipulate path strings.
Definition: stringy.h:74
virtual ~Adaptor()
Destructor.
Definition: libgth.h:105
void getTestsForWindow(csr wnm, ListOfLists &)
Get a list of test cases for a window.
Definition: script.cpp:219
Responsible for storing the results of testing for a scenario.
Definition: testmgr.h:409
csr getName()
Get the name of the scenario.
Definition: libgth.h:357
csr getVar(csr)
Get the value of a variable from GTHTest.
Definition: libgth.cpp:1240
Provides a wrapper for a lua_State object.
Definition: libgth.h:132
Defines an abstract base class for widget adaptors.
Definition: libgth.h:88
csr getVar(csr varName) const
Get the value of a variable.
Definition: libgth.cpp:519
void create(const Path &fname, csr root_element)
Create a new xml file and document.
Definition: xml.cpp:108
void addWidgetType(csr widgetType, const ListOfLists &)
Update description of commands for a widget type.
Definition: script.cpp:176
VICI::gth::WidgetType getType()
Get the type of the adaptor.
Definition: libgth.h:557
virtual void windowHasRegistered(GTHWindowWidget *)
Called to notify of a new window registering itself.
Definition: libgth.cpp:762
std::vector< std::string > ParamList
ParamList is used for the parameters of a command.
Definition: libgth.h:67
AdaptorT(void *p, csr name, GTHTest *gth)
Constructor.
Definition: libgth.h:548
std::shared_ptr< ScriptXML > ScriptXmlPtr
Provide for automatic destruction when owner is deleted.
Definition: libgth.h:76
AdaptorST(csr name, GTHTest *gth)
Constructor.
Definition: libgth.h:521
MouseEventReporter(QGraphicsView *v)
Constructor.
Definition: libgth.h:502
void pause()
Pause the thread.
Definition: libgth.cpp:1060
void jumpThread(csr tcname, csr widgetName, csr command, const std::vector< std::string > ¶ms)
Run the action in the GUI thread.
Definition: libgth.cpp:1095
void sendAdaptor(const std::string &tcname, const std::string &widgetName, const std::string &command, const std::vector< std::string > ¶ms)
A signal containing the adaptor to run in the GUI thread.
std::string scenarioName
The name of the scenario, as used when installed.
Definition: testmgr.h:429
virtual VICI::gth::WidgetType getType()=0
Get the type of the adaptor.
An AbstractTest derived class for testing GUI programs.
Definition: libgth.h:289
std::string command
The command to run.
Definition: libgth.h:164
cdi::ScenarioResults * results
Reference to the results.
Definition: libgth.h:366
void addWidget(csr widgetName, csr widgetType)
Update the list of widgets and their types.
Definition: script.cpp:164
Interface for test cases that do gui testing.
Definition: libgth.h:406
ScriptXML(const VICI::Path &, bool create)
Constructor.
Definition: script.cpp:38
virtual bool willRunTests()
Indicate that the scenario will take over from the Tester.
Definition: libgth.h:360
const std::string & csr
short cut for string constants
Definition: vici.h:80
virtual void windowHasDeregistered(GTHWindowWidget *)
Called to notify that a window has deregistered itself,.
Definition: libgth.cpp:772
bool eventFilter(QObject *obj, QEvent *event)
Called to process events.
Definition: libgth.cpp:952
void substVars(const ParamList &, ParamList &)
Substitute variables for their values in the parameters.
Definition: libgth.cpp:532
void testingCompleted()
This signal is emitted when the main window tests have completed.
~ScriptXML()
Destructor.
Definition: script.cpp:95
TestCaseT(csr nm)
Constructor.
Definition: testmgr.h:592
void addTest(csr testName, bool unreferenced)
Add the name of test cases that are [not] referenced in the script.
Definition: script.cpp:120
TestsForWindow(GTHTest *, csr window, bool isMainWindow)
Constructor.
Definition: libgth.cpp:982
ParamList params
The parameters for the command.
Definition: libgth.h:165
A C++ wrapper for libxml2.
Definition: xml.h:73
std::string widgetName
The name of the widget as set when it was registered.
Definition: libgth.h:99
ParamList assignmentNames
The variables to accept the values.
Definition: libgth.h:167
Responsible for installing a factory to create scenarios of the required type.
Definition: testmgr.h:453
UserEscaper(bool &flag)
Constructor.
Definition: libgth.h:274
std::string call(csr cmnd, const ParamList ¶ms)
Run a function in the Lua chunk.
Definition: libgth.cpp:1178
Provides project wide GUI components.
std::string getJump(const TestAction &, csr result)
Applies regular expressions to the result to find a jump label.
Definition: libgth.cpp:560
std::string prefix()
get thread and time
Definition: libgth.cpp:891
Adds a static method to Adaptor to describe it;.
Definition: libgth.h:516
~LuaScript()
Destructor.
Definition: libgth.cpp:1153
csr name()
Get the name of the window.
Definition: libgth.h:227