summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptenginedebugger
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-11-02 16:27:20 +0100
committerKent Hansen <kent.hansen@nokia.com>2010-11-08 15:44:45 +0100
commit7b79a508bb16fd104ddf7d9a485d566ee2e051ba (patch)
tree47b31c1433705b3c5258942996f593d02df801a5 /tests/auto/qscriptenginedebugger
parent596ddb0f82e54cd828c6d2b6248a1686924671f9 (diff)
Improve autotest coverage of QScriptEngineDebugger
The internal coverage is still poor, but at least the public API has 100% coverage now.
Diffstat (limited to 'tests/auto/qscriptenginedebugger')
-rw-r--r--tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp107
1 files changed, 93 insertions, 14 deletions
diff --git a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp
index c5e4954679..591e2e48e3 100644
--- a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp
+++ b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp
@@ -50,24 +50,11 @@
#include <qmenu.h>
#include <qplaintextedit.h>
#include <qtoolbar.h>
+#include "../../shared/util.h"
//TESTED_CLASS=
//TESTED_FILES=
-// Will try to wait for the condition while allowing event processing
-#define QTRY_COMPARE(__expr, __expected) \
- do { \
- const int __step = 50; \
- const int __timeout = 5000; \
- if ((__expr) != (__expected)) { \
- QTest::qWait(0); \
- } \
- for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \
- QTest::qWait(__step); \
- } \
- QCOMPARE(__expr, __expected); \
- } while(0)
-
// Can't use QTest::qWait() because it causes event loop to hang on some platforms
static void qsWait(int ms)
{
@@ -89,6 +76,9 @@ public:
tst_QScriptEngineDebugger();
virtual ~tst_QScriptEngineDebugger();
+protected slots:
+ void recordDebuggerStateAndContinue();
+
private slots:
void attachAndDetach();
void action();
@@ -97,6 +87,12 @@ private slots:
void debuggerSignals();
void consoleCommands();
void multithreadedDebugging();
+ void autoShowStandardWindow();
+ void standardWindowOwnership();
+ void runningState();
+
+private:
+ QScriptEngineDebugger::DebuggerState m_recordedDebuggerState;
};
tst_QScriptEngineDebugger::tst_QScriptEngineDebugger()
@@ -107,6 +103,14 @@ tst_QScriptEngineDebugger::~tst_QScriptEngineDebugger()
{
}
+void tst_QScriptEngineDebugger::recordDebuggerStateAndContinue()
+{
+ QScriptEngineDebugger *debugger = qobject_cast<QScriptEngineDebugger*>(sender());
+ Q_ASSERT(debugger != 0);
+ m_recordedDebuggerState = debugger->state();
+ debugger->action(QScriptEngineDebugger::ContinueAction)->trigger();
+}
+
void tst_QScriptEngineDebugger::attachAndDetach()
{
#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600
@@ -784,5 +788,80 @@ void tst_QScriptEngineDebugger::multithreadedDebugging()
QTRY_COMPARE(threadFinishedSpy.count(), 1);
}
+void tst_QScriptEngineDebugger::autoShowStandardWindow()
+{
+ {
+ QScriptEngine engine;
+ QScriptEngineDebugger debugger;
+ QCOMPARE(debugger.autoShowStandardWindow(), true);
+ debugger.attachTo(&engine);
+ QObject::connect(&debugger, SIGNAL(evaluationSuspended()),
+ debugger.action(QScriptEngineDebugger::ContinueAction),
+ SLOT(trigger()));
+ engine.evaluate("debugger");
+ QTRY_VERIFY(debugger.standardWindow()->isVisible());
+
+ debugger.setAutoShowStandardWindow(true);
+ QCOMPARE(debugger.autoShowStandardWindow(), true);
+
+ debugger.setAutoShowStandardWindow(false);
+ QCOMPARE(debugger.autoShowStandardWindow(), false);
+
+ debugger.setAutoShowStandardWindow(true);
+ QCOMPARE(debugger.autoShowStandardWindow(), true);
+
+ debugger.standardWindow()->hide();
+
+ engine.evaluate("debugger");
+ QTRY_VERIFY(debugger.standardWindow()->isVisible());
+ }
+
+ {
+ QScriptEngine engine;
+ QScriptEngineDebugger debugger;
+ debugger.setAutoShowStandardWindow(false);
+ debugger.attachTo(&engine);
+ QObject::connect(&debugger, SIGNAL(evaluationSuspended()),
+ debugger.action(QScriptEngineDebugger::ContinueAction),
+ SLOT(trigger()));
+ QSignalSpy evaluationResumedSpy(&debugger, SIGNAL(evaluationResumed()));
+ engine.evaluate("debugger");
+ QTRY_COMPARE(evaluationResumedSpy.count(), 1);
+ QVERIFY(!debugger.standardWindow()->isVisible());
+ }
+}
+
+void tst_QScriptEngineDebugger::standardWindowOwnership()
+{
+ QScriptEngine engine;
+ QPointer<QMainWindow> win;
+ {
+ QScriptEngineDebugger debugger;
+ win = debugger.standardWindow();
+ }
+ QVERIFY(win == 0);
+
+ // Reparent the window.
+ QWidget widget;
+ {
+ QScriptEngineDebugger debugger;
+ win = debugger.standardWindow();
+ win->setParent(&widget);
+ }
+ QVERIFY(win != 0);
+}
+
+void tst_QScriptEngineDebugger::runningState()
+{
+ QScriptEngine engine;
+ QScriptEngineDebugger debugger;
+ debugger.attachTo(&engine);
+ QObject::connect(&debugger, SIGNAL(evaluationSuspended()),
+ this, SLOT(recordDebuggerStateAndContinue()));
+ m_recordedDebuggerState = QScriptEngineDebugger::SuspendedState;
+ engine.evaluate("debugger");
+ QTRY_COMPARE(m_recordedDebuggerState, QScriptEngineDebugger::RunningState);
+}
+
QTEST_MAIN(tst_QScriptEngineDebugger)
#include "tst_qscriptenginedebugger.moc"