diff options
author | Eirik Aavitsland <eirik.aavitsland@theqtcompany.com> | 2015-04-14 13:30:36 +0200 |
---|---|---|
committer | aavit <eirik.aavitsland@theqtcompany.com> | 2015-04-23 07:31:51 +0000 |
commit | 346abd22118c81e8434ff5a2a7694bd81fe17be1 (patch) | |
tree | ced56df7d337935adc9503ffd28e1728c5e0e504 /tests/manual | |
parent | a6fa9189b0698091fd70674aeafb853d4405da5c (diff) |
Make the scenegraph_lancelot test work on Mac
Grabbing the window after every frame is needlessly expensive and
would overload a less powerful Mac. Rewrote the grabber to just do the
necessary grabs.
Make the hostinfo script not output the unneeded '[undefined]' value
for unset environment variables, as the braces would upset the paths
in the html report.
Change-Id: I76104235c15eafd5e7f92f2ec01c84f5b11b55a6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/scenegraph_lancelot/hostinfo.sh | 5 | ||||
-rw-r--r-- | tests/manual/scenegraph_lancelot/scenegrabber/main.cpp | 49 |
2 files changed, 33 insertions, 21 deletions
diff --git a/tests/manual/scenegraph_lancelot/hostinfo.sh b/tests/manual/scenegraph_lancelot/hostinfo.sh index ac22ce8d22..7f486efb76 100644 --- a/tests/manual/scenegraph_lancelot/hostinfo.sh +++ b/tests/manual/scenegraph_lancelot/hostinfo.sh @@ -45,15 +45,14 @@ printProperty () # printEnvVar(): prints a key-value pair from given environment variable name. # key is printed as "Env_<varname>". -# If the variable is undefined, value is printed as UNDEFINED. +# If the variable is undefined, nothing is printed. # Arguments: $1: varname printEnvVar () { key=Env_$1 val=`eval 'echo $'$1` - [ -z "$val" ] && val='[undefined]' - echo $key: $val + [ -n "$val" ] && echo $key: $val } diff --git a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp index 35328b44f3..d8eedd5afb 100644 --- a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp +++ b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp @@ -43,12 +43,11 @@ // Timeout values: // A valid screen grab requires the scene to not change -// for SCENE_STABLE_TIME ms (default 500) -#define SCENE_STABLE_TIME 500 +// for SCENE_STABLE_TIME ms +#define SCENE_STABLE_TIME 200 // Give up after SCENE_TIMEOUT ms -#define SCENE_TIMEOUT 16000 - +#define SCENE_TIMEOUT 6000 //#define GRABBERDEBUG @@ -58,30 +57,44 @@ class GrabbingView : public QQuickView public: GrabbingView(const QString &outputFile) - : ofile(outputFile), frames(0), isGrabbing(false) + : ofile(outputFile), grabNo(0), isGrabbing(false), initDone(false) { - connect(this, SIGNAL(afterRendering()), SLOT(renderingDone())); + grabTimer = new QTimer(this); + grabTimer->setSingleShot(true); + grabTimer->setInterval(SCENE_STABLE_TIME); + connect(grabTimer, SIGNAL(timeout()), SLOT(grab())); + + connect(this, SIGNAL(afterRendering()), SLOT(startGrabbing())); + QTimer::singleShot(SCENE_TIMEOUT, this, SLOT(timedOut())); - stableSceneTimer.setSingleShot(true); - connect(&stableSceneTimer, SIGNAL(timeout()), SLOT(sceneStabilized())); } private slots: - void renderingDone() + void startGrabbing() + { + if (!initDone) { + initDone = true; + grabTimer->start(); + } + } + + void grab() { if (isGrabbing) return; isGrabbing = true; - frames++; + grabNo++; #ifdef GRABBERDEBUG - printf("...frame %i\n", frames); + printf("grab no. %i\n", grabNo); #endif QImage img = grabWindow(); - //qDebug() << "Rendering done, grab is" << !img.isNull() << "timer valid:" << stableSceneTimer.isActive() << "same as last:" << (img == lastGrab); - if (!img.isNull() && img != lastGrab) { + if (!img.isNull() && img == lastGrab) { + sceneStabilized(); + } else { lastGrab = img; - stableSceneTimer.start(SCENE_STABLE_TIME); + grabTimer->start(); } + isGrabbing = false; } @@ -104,7 +117,6 @@ private slots: return; } } - QGuiApplication::exit(0); #ifdef GRABBERDEBUG printf("...sceneStabilized OUT\n"); @@ -113,16 +125,17 @@ private slots: void timedOut() { - qWarning() << "Error: timed out waiting for scene to stabilize." << frames << "frame(s) received. Last grab was" << (lastGrab.isNull() ? "invalid." : "valid."); + qWarning() << "Error: timed out waiting for scene to stabilize." << grabNo << "grab(s) done. Last grab was" << (lastGrab.isNull() ? "invalid." : "valid."); QGuiApplication::exit(3); } private: QImage lastGrab; - QTimer stableSceneTimer; + QTimer *grabTimer; QString ofile; - int frames; + int grabNo; bool isGrabbing; + bool initDone; }; |