diff options
author | Tobias Hunger <tobias.hunger@nokia.com> | 2010-09-03 15:50:30 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@nokia.com> | 2010-09-03 16:45:42 +0200 |
commit | 979998f4cff672329dfb50e399e1b8c8d6feec79 (patch) | |
tree | 4ff0de4b38e46246f72a57fe01479b16ec4fe5e9 | |
parent | b65103f5632aa5a8fbd737967813281d7edcd8e3 (diff) | |
download | qt-creator-979998f4cff672329dfb50e399e1b8c8d6feec79.tar.gz |
Fix unit tests of the gnumake parser
-rw-r--r-- | src/plugins/projectexplorer/gnumakeparser.cpp | 17 | ||||
-rw-r--r-- | src/plugins/projectexplorer/gnumakeparser.h | 16 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/plugins/projectexplorer/gnumakeparser.cpp b/src/plugins/projectexplorer/gnumakeparser.cpp index c9f85c3214..f2693d8e07 100644 --- a/src/plugins/projectexplorer/gnumakeparser.cpp +++ b/src/plugins/projectexplorer/gnumakeparser.cpp @@ -170,6 +170,16 @@ QStringList GnuMakeParser::searchDirectories() const # include "metatypedeclarations.h" +GnuMakeParserTester::GnuMakeParserTester(GnuMakeParser *p, QObject *parent) : + QObject(parent), + parser(p) +{ } + +void GnuMakeParserTester::parserIsAboutToBeDeleted() +{ + directories = parser->searchDirectories(); +} + void ProjectExplorerPlugin::testGnuMakeParserParsing_data() { QTest::addColumn<QStringList>("extraSearchDirs"); @@ -304,6 +314,10 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing() { OutputParserTester testbench; GnuMakeParser *childParser = new GnuMakeParser; + GnuMakeParserTester *tester = new GnuMakeParserTester(childParser); + connect(&testbench, SIGNAL(aboutToDeleteParser()), + tester, SLOT(parserIsAboutToBeDeleted())); + testbench.appendOutputParser(childParser); QFETCH(QStringList, extraSearchDirs); QFETCH(QString, input); @@ -325,7 +339,7 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing() outputLines); // make sure we still have all the original dirs - QStringList newSearchDirs = childParser->searchDirectories(); + QStringList newSearchDirs = tester->directories; foreach (const QString &dir, searchDirs) { QVERIFY(newSearchDirs.contains(dir)); newSearchDirs.removeOne(dir); @@ -338,6 +352,7 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing() } // make sure we have no extra cruft: QVERIFY(newSearchDirs.isEmpty()); + delete tester; } void ProjectExplorerPlugin::testGnuMakeParserTaskMangling_data() diff --git a/src/plugins/projectexplorer/gnumakeparser.h b/src/plugins/projectexplorer/gnumakeparser.h index f5c693e519..ae24798f09 100644 --- a/src/plugins/projectexplorer/gnumakeparser.h +++ b/src/plugins/projectexplorer/gnumakeparser.h @@ -72,6 +72,22 @@ private: int m_fatalErrorCount; }; +#if defined WITH_TESTS +class GnuMakeParserTester : public QObject +{ + Q_OBJECT + +public: + GnuMakeParserTester(GnuMakeParser *parser, QObject *parent = 0); + + QStringList directories; + GnuMakeParser *parser; + +public slots: + void parserIsAboutToBeDeleted(); +}; +#endif + } // namespace ProjectExplorer #endif // GNUMAKEPARSER_H |