Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Ben Boeckel
QtTesting
Commits
4d42969a
Commit
4d42969a
authored
Apr 25, 2012
by
Benjamin Long
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Few modifications for a easier integration with paraview
parent
d3f17f78
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
29 deletions
+46
-29
Examples/TestingDemo.cxx
Examples/TestingDemo.cxx
+3
-3
pqEventDispatcher.cxx
pqEventDispatcher.cxx
+3
-3
pqEventDispatcher.h
pqEventDispatcher.h
+0
-1
pqEventPlayer.cxx
pqEventPlayer.cxx
+9
-5
pqEventSource.h
pqEventSource.h
+1
-1
pqObjectNaming.cxx
pqObjectNaming.cxx
+19
-7
pqObjectNaming.h
pqObjectNaming.h
+6
-2
pqTestUtility.cxx
pqTestUtility.cxx
+4
-6
pqTestUtility.h
pqTestUtility.h
+1
-1
No files found.
Examples/TestingDemo.cxx
View file @
4d42969a
...
...
@@ -82,7 +82,7 @@ public:
~
XMLEventSource
()
{
delete
this
->
XMLStream
;
}
protected:
virtual
bool
setContent
(
const
QString
&
xmlfilename
)
virtual
void
setContent
(
const
QString
&
xmlfilename
)
{
delete
this
->
XMLStream
;
this
->
XMLStream
=
NULL
;
...
...
@@ -91,7 +91,7 @@ protected:
if
(
!
xml
.
open
(
QIODevice
::
ReadOnly
))
{
qDebug
()
<<
"Failed to load "
<<
xmlfilename
;
return
false
;
return
;
}
QByteArray
data
=
xml
.
readAll
();
this
->
XMLStream
=
new
QXmlStreamReader
(
data
);
...
...
@@ -114,7 +114,7 @@ protected:
{
qDebug
()
<<
"Invalid xml"
<<
endl
;
}
return
true
;
return
;
}
int
getNextEvent
(
QString
&
widget
,
QString
&
command
,
QString
&
...
...
pqEventDispatcher.cxx
View file @
4d42969a
...
...
@@ -49,6 +49,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
using
namespace
std
;
//-----------------------------------------------------------------------------
namespace
{
static
QList
<
QPointer
<
QTimer
>
>
RegisteredTimers
;
...
...
@@ -83,7 +84,6 @@ pqEventDispatcher::pqEventDispatcher(QObject* parentObject) :
this
->
PlayBackPaused
=
false
;
this
->
PlayBackOneStep
=
false
;
this
->
PlayBackStoped
=
false
;
this
->
TimeStep
=
1
;
#ifdef __APPLE__
this
->
BlockTimer
.
setInterval
(
1000
);
...
...
@@ -149,7 +149,7 @@ void pqEventDispatcher::awake()
//-----------------------------------------------------------------------------
void
pqEventDispatcher
::
setTimeStep
(
int
value
)
{
this
->
TimeStep
=
value
;
EventPlaybackDelay
=
value
;
}
//-----------------------------------------------------------------------------
...
...
pqEventDispatcher.h
View file @
4d42969a
...
...
@@ -140,7 +140,6 @@ protected:
bool
PlayBackOneStep
;
bool
PlayBackStoped
;
static
bool
DeferMenuTimeouts
;
int
TimeStep
;
pqEventSource
*
ActiveSource
;
pqEventPlayer
*
ActivePlayer
;
...
...
pqEventPlayer.cxx
View file @
4d42969a
...
...
@@ -135,8 +135,7 @@ void pqEventPlayer::playEvent(const QString& Object,
{
emit
this
->
eventAboutToBePlayed
(
Object
,
Command
,
Arguments
);
// If we can't find an object with the right name, we're done ...
QString
messageError
;
QObject
*
const
object
=
pqObjectNaming
::
GetObject
(
Object
,
messageError
);
QObject
*
const
object
=
pqObjectNaming
::
GetObject
(
Object
);
if
(
!
object
&&
Object
.
contains
(
QString
(
"QScrollBar"
)))
{
...
...
@@ -147,7 +146,8 @@ void pqEventPlayer::playEvent(const QString& Object,
if
(
!
object
&&
Command
!=
"comment"
)
{
emit
this
->
errorMessage
(
messageError
);
qCritical
()
<<
pqObjectNaming
::
lastErrorMessage
();
emit
this
->
errorMessage
(
pqObjectNaming
::
lastErrorMessage
());
Error
=
true
;
return
;
}
...
...
@@ -167,7 +167,9 @@ void pqEventPlayer::playEvent(const QString& Object,
// The event wasn't handled at all ...
if
(
!
accepted
)
{
messageError
=
QString
(
"Unhandled event %1 object %2
\n
"
).
arg
(
Command
,
object
->
objectName
());
QString
messageError
=
QString
(
"Unhandled event %1 object %2
\n
"
)
.
arg
(
Command
,
object
->
objectName
());
qCritical
()
<<
messageError
;
emit
this
->
errorMessage
(
messageError
);
Error
=
true
;
...
...
@@ -177,7 +179,9 @@ void pqEventPlayer::playEvent(const QString& Object,
// The event was handled, but there was a problem ...
if
(
accepted
&&
error
)
{
messageError
=
QString
(
"Event error %1 object %2
\n
"
).
arg
(
Command
,
object
->
objectName
());
QString
messageError
=
QString
(
"Event error %1 object %2
\n
"
)
.
arg
(
Command
,
object
->
objectName
());
qCritical
()
<<
messageError
;
emit
this
->
errorMessage
(
messageError
);
Error
=
true
;
...
...
pqEventSource.h
View file @
4d42969a
...
...
@@ -58,7 +58,7 @@ public:
/** Set the filename for contents.
Returns true for valid file, false for invalid file */
virtual
bool
setContent
(
const
QString
&
filename
)
=
0
;
virtual
void
setContent
(
const
QString
&
filename
)
=
0
;
/** tell the source to stop feeding in events */
virtual
void
stop
()
{}
...
...
pqObjectNaming.cxx
View file @
4d42969a
...
...
@@ -55,8 +55,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QToolButton>
#include <QtDebug>
/** Returns the name of an object as if it was unnamed.
*/
namespace
{
QString
ErrorMessage
;
}
/** Returns the name of an object as if it was unnamed.*/
static
const
QString
InternalGetNameAsUnnamed
(
QObject
&
Object
)
{
QString
result
;
...
...
@@ -178,7 +183,7 @@ const QString pqObjectNaming::GetName(QObject& Object)
return
name
;
}
QObject
*
pqObjectNaming
::
GetObject
(
const
QString
&
Name
,
QString
&
messageError
)
QObject
*
pqObjectNaming
::
GetObject
(
const
QString
&
Name
)
{
QObject
*
result
=
0
;
QObject
*
lastObject
=
0
;
...
...
@@ -241,10 +246,10 @@ QObject* pqObjectNaming::GetObject(const QString& Name, QString& messageError)
if
(
result
)
return
result
;
messageError
=
QString
(
"Couldn't find object %1
\n
"
).
arg
(
Name
);
if
(
lastObject
)
ErrorMessage
=
QString
(
"Couldn't find object %1
\n
"
).
arg
(
Name
);
{
m
essage
Error
+=
QString
(
"Found up to %1
\n
"
).
arg
(
ErrorM
essage
+=
QString
(
"Found up to %1
\n
"
).
arg
(
pqObjectNaming
::
GetName
(
*
lastObject
));
}
if
(
lastObject
)
...
...
@@ -253,10 +258,11 @@ QObject* pqObjectNaming::GetObject(const QString& Name, QString& messageError)
lastObject
->
findChildren
<
QObject
*>
(
names
[
names
.
size
()
-
1
]);
foreach
(
QObject
*
o
,
matches
)
{
m
essage
Error
+=
QString
(
"
\t
Possible match: %1
\n
"
).
arg
(
pqObjectNaming
::
GetName
(
*
o
));
ErrorM
essage
+=
QString
(
"
\t
Possible match: %1
\n
"
).
arg
(
pqObjectNaming
::
GetName
(
*
o
));
}
}
qCritical
()
<<
messageError
;
qCritical
()
<<
ErrorMessage
;
return
0
;
}
...
...
@@ -279,3 +285,9 @@ void pqObjectNaming::DumpHierarchy(QObject& object, QStringList& results)
DumpHierarchy
(
*
children
[
i
],
results
);
}
}
QString
pqObjectNaming
::
lastErrorMessage
()
{
return
ErrorMessage
;
}
pqObjectNaming.h
View file @
4d42969a
...
...
@@ -33,10 +33,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _pqObjectNaming_h
#define _pqObjectNaming_h
#include <QString>
#include "QtTestingExport.h"
class
QObject
;
class
QString
;
class
QStringList
;
/// Provides functionality to ensuring that Qt objects can be uniquely identified for recording and playback of regression tests
...
...
@@ -46,12 +47,15 @@ public:
/// Returns a unique identifier for the given object that can be serialized for later regression test playback
static
const
QString
GetName
(
QObject
&
Object
);
/// Given a unique identifier returned by GetName(), returns the corresponding object, or NULL
static
QObject
*
GetObject
(
const
QString
&
Name
,
QString
&
Message
);
static
QObject
*
GetObject
(
const
QString
&
Name
);
/** Dumps the widget hierarchy to a string */
static
void
DumpHierarchy
(
QStringList
&
results
);
/** Dumps a subtree of the widget hierarchy to a string */
static
void
DumpHierarchy
(
QObject
&
Object
,
QStringList
&
results
);
/// Recover the last error message
static
QString
lastErrorMessage
();
};
#endif // !_pqObjectNaming_h
pqTestUtility.cxx
View file @
4d42969a
...
...
@@ -140,11 +140,11 @@ void pqTestUtility::stopTests()
}
//-----------------------------------------------------------------------------
void
pqTestUtility
::
playTests
(
const
QString
&
filename
)
bool
pqTestUtility
::
playTests
(
const
QString
&
filename
)
{
QStringList
files
;
files
<<
filename
;
this
->
playTests
(
files
);
return
this
->
playTests
(
files
);
}
//-----------------------------------------------------------------------------
...
...
@@ -174,10 +174,8 @@ bool pqTestUtility::playTests(const QStringList& filenames)
iter
=
this
->
EventSources
.
find
(
suffix
);
if
(
info
.
isReadable
()
&&
iter
!=
this
->
EventSources
.
end
())
{
if
(
!
iter
.
value
()
->
setContent
(
filename
))
{
return
false
;
}
iter
.
value
()
->
setContent
(
filename
);
// QEventLoop loop;
// QTimer::singleShot(100, &loop, SLOT(quit()));
// loop.exec();
...
...
pqTestUtility.h
View file @
4d42969a
...
...
@@ -107,7 +107,7 @@ public:
QString
convertFromDataDirectory
(
const
QString
&
file
);
public
slots
:
void
playTests
(
const
QString
&
filename
);
bool
playTests
(
const
QString
&
filename
);
void
openPlayerDialog
();
void
stopTests
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment