diff --git a/share/qtcreator/gdbmacros/gdbmacros_p.h b/share/qtcreator/gdbmacros/gdbmacros_p.h index ce7cf4ccc60..0aed16d3781 100644 --- a/share/qtcreator/gdbmacros/gdbmacros_p.h +++ b/share/qtcreator/gdbmacros/gdbmacros_p.h @@ -43,6 +43,7 @@ #define GDBMACROS_P_H #include +#include #ifndef QT_BOOTSTRAPPED diff --git a/tests/auto/debugger/debugger.pro b/tests/auto/debugger/debugger.pro index da74874c8a1..c4cadd3715f 100644 --- a/tests/auto/debugger/debugger.pro +++ b/tests/auto/debugger/debugger.pro @@ -1,17 +1,5 @@ -QT = core testlib gui +TEMPLATE = subdirs -DEBUGGERDIR = ../../../src/plugins/debugger -UTILSDIR = ../../../src/libs -MACROSDIR = ../../../share/qtcreator/gdbmacros - -SOURCES += \ - $$DEBUGGERDIR/gdb/gdbmi.cpp \ - $$DEBUGGERDIR/tcf/json.cpp \ - $$MACROSDIR/gdbmacros.cpp \ - main.cpp \ - -DEFINES += MACROSDEBUG - -INCLUDEPATH += $$DEBUGGERDIR $$UTILSDIR $$MACROSDIR +SUBDIRS = dumpers.pro plugin.pro diff --git a/tests/auto/debugger/dumpers.pro b/tests/auto/debugger/dumpers.pro new file mode 100644 index 00000000000..ca5338af380 --- /dev/null +++ b/tests/auto/debugger/dumpers.pro @@ -0,0 +1,16 @@ +QT += testlib + +DEBUGGERDIR = ../../../src/plugins/debugger +UTILSDIR = ../../../src/libs +MACROSDIR = ../../../share/qtcreator/gdbmacros + +SOURCES += \ + $$DEBUGGERDIR/gdb/gdbmi.cpp \ + $$DEBUGGERDIR/tcf/json.cpp \ + $$MACROSDIR/gdbmacros.cpp \ + tst_dumpers.cpp \ + +DEFINES += MACROSDEBUG + +INCLUDEPATH += $$DEBUGGERDIR $$UTILSDIR $$MACROSDIR + diff --git a/tests/auto/debugger/plugin.pro b/tests/auto/debugger/plugin.pro new file mode 100644 index 00000000000..fae675b38f8 --- /dev/null +++ b/tests/auto/debugger/plugin.pro @@ -0,0 +1,14 @@ +QT += testlib + + +DEBUGGERDIR = ../../../src/plugins/debugger +UTILSDIR = ../../../src/libs +MACROSDIR = ../../../share/qtcreator/gdbmacros + +SOURCES += \ + tst_plugin.cpp \ + +DEFINES += MACROSDEBUG + +INCLUDEPATH += $$DEBUGGERDIR $$UTILSDIR $$MACROSDIR + diff --git a/tests/auto/debugger/main.cpp b/tests/auto/debugger/tst_dumpers.cpp similarity index 97% rename from tests/auto/debugger/main.cpp rename to tests/auto/debugger/tst_dumpers.cpp index 55d25220672..60ae50b2f54 100644 --- a/tests/auto/debugger/main.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -1,33 +1,16 @@ -#include - -#include -#include -#include -#include -#include -#include -#if QT_VERSION >= 0x040500 -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#include - -#include - #include "gdb/gdbmi.h" #include "tcf/json.h" #include "gdbmacros.h" #include "gdbmacros_p.h" +#include + +#include +#include + +#include +//#include + #undef NS #ifdef QT_NAMESPACE # define STRINGIFY0(s) #s @@ -178,16 +161,7 @@ private slots: void dumpQWeakPointer(); void initTestCase(); -public slots: - void runQtc(); - -public slots: - void readStandardOutput(); - void readStandardError(); - private: - QProcess m_proc; // the Qt Creator process - void dumpQAbstractItemHelper(QModelIndex &index); void dumpQAbstractItemModelHelper(QAbstractItemModel &m); void dumpQByteArrayHelper(QByteArray &ba); @@ -220,17 +194,6 @@ private: void dumpQTextCodecHelper(QTextCodec *codec); }; -static QByteArray stripped(QByteArray ba) -{ - for (int i = ba.size(); --i >= 0; ) { - if (ba.at(i) == '\n' || ba.at(i) == ' ') - ba.chop(1); - else - break; - } - return ba; -} - void tst_Debugger::infoBreak() { // This tests the regular expression used in GdbEngine::extractDataFromInfoBreak @@ -1765,7 +1728,12 @@ class Cheater : public QObject public: static const QObjectPrivate *getPrivate(const QObject &o) { - return dynamic_cast(static_cast(o).d_ptr); + const Cheater &cheater = static_cast(o); +#if QT_VERSION >= 0x040600 + return dynamic_cast(cheater.d_ptr.data()); +#else + return dynamic_cast(cheater.d_ptr); +#endif } }; @@ -2408,54 +2376,13 @@ void tst_Debugger::initTestCase() #endif } -void tst_Debugger::readStandardOutput() -{ - qDebug() << "qtcreator-out: " << stripped(m_proc.readAllStandardOutput()); -} - -void tst_Debugger::readStandardError() -{ - qDebug() << "qtcreator-err: " << stripped(m_proc.readAllStandardError()); -} - -void tst_Debugger::runQtc() -{ - QString test = QFileInfo(qApp->arguments().at(0)).absoluteFilePath(); - QString qtc = QFileInfo(test).absolutePath() + "/../../../bin/qtcreator.bin"; - qtc = QFileInfo(qtc).absoluteFilePath(); - QStringList env = QProcess::systemEnvironment(); - env.append("QTC_DEBUGGER_TEST=" + test); - m_proc.setEnvironment(env); - connect(&m_proc, SIGNAL(readyReadStandardOutput()), - this, SLOT(readStandardOutput())); - connect(&m_proc, SIGNAL(readyReadStandardError()), - this, SLOT(readStandardError())); - m_proc.start(qtc); - m_proc.waitForStarted(); - QCOMPARE(m_proc.state(), QProcess::Running); - m_proc.waitForFinished(); - QCOMPARE(m_proc.state(), QProcess::NotRunning); -} - -void runDebuggee() -{ - qDebug() << "RUNNING DEBUGGEE"; -} int main(int argc, char *argv[]) { - QCoreApplication app(argc, argv); - QStringList args = app.arguments(); - - if (args.size() == 2 && args.at(1) == "--run-debuggee") { - runDebuggee(); - app.exec(); - return 0; - } - + QApplication app(argc, argv); tst_Debugger test; return QTest::qExec(&test, argc, argv); } -#include "main.moc" +#include "tst_dumpers.moc" diff --git a/tests/auto/debugger/tst_plugin.cpp b/tests/auto/debugger/tst_plugin.cpp new file mode 100644 index 00000000000..5d26a6ac121 --- /dev/null +++ b/tests/auto/debugger/tst_plugin.cpp @@ -0,0 +1,125 @@ +#include + +#include +#include +#include +#include +#include +#include +#if QT_VERSION >= 0x040500 +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include + +#include + +#include "gdb/gdbmi.h" +#include "tcf/json.h" +#include "gdbmacros.h" +#include "gdbmacros_p.h" + +#undef NS +#ifdef QT_NAMESPACE +# define STRINGIFY0(s) #s +# define STRINGIFY1(s) STRINGIFY0(s) +# define NS STRINGIFY1(QT_NAMESPACE) "::" +#else +# define NS "" +#endif + +using namespace Debugger; +using namespace Debugger::Internal; + + +static QByteArray stripped(QByteArray ba) +{ + for (int i = ba.size(); --i >= 0; ) { + if (ba.at(i) == '\n' || ba.at(i) == ' ') + ba.chop(1); + else + break; + } + return ba; +} + + +class tst_Plugin : public QObject +{ + Q_OBJECT + +public: + tst_Plugin() {} + + +public slots: + void runQtc(); + +public slots: + void readStandardOutput(); + void readStandardError(); + +private: + QProcess m_proc; // the Qt Creator process +}; + +void tst_Plugin::readStandardOutput() +{ + qDebug() << "qtcreator-out: " << stripped(m_proc.readAllStandardOutput()); +} + +void tst_Plugin::readStandardError() +{ + qDebug() << "qtcreator-err: " << stripped(m_proc.readAllStandardError()); +} + +void tst_Plugin::runQtc() +{ + QString test = QFileInfo(qApp->arguments().at(0)).absoluteFilePath(); + QString qtc = QFileInfo(test).absolutePath() + "/../../../bin/qtcreator.bin"; + qtc = QFileInfo(qtc).absoluteFilePath(); + QStringList env = QProcess::systemEnvironment(); + env.append("QTC_DEBUGGER_TEST=" + test); + m_proc.setEnvironment(env); + connect(&m_proc, SIGNAL(readyReadStandardOutput()), + this, SLOT(readStandardOutput())); + connect(&m_proc, SIGNAL(readyReadStandardError()), + this, SLOT(readStandardError())); + m_proc.start(qtc); + m_proc.waitForStarted(); + QCOMPARE(m_proc.state(), QProcess::Running); + m_proc.waitForFinished(); + QCOMPARE(m_proc.state(), QProcess::NotRunning); +} + +void runDebuggee() +{ + qDebug() << "RUNNING DEBUGGEE"; +} + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + QStringList args = app.arguments(); + + if (args.size() == 2 && args.at(1) == "--run-debuggee") { + runDebuggee(); + app.exec(); + return 0; + } + + tst_Plugin test; + return QTest::qExec(&test, argc, argv); +} + +#include "tst_plugin.moc" +