diff options
| author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-10-20 11:40:58 +0200 |
|---|---|---|
| committer | Bill King <bill.king@nokia.com> | 2011-10-20 11:44:15 +0200 |
| commit | 65ef5f7a354acef5843c14546a4d8d231419b514 (patch) | |
| tree | 7150bc69b60a458ab894da31474d15cab2bbb6a0 /tests/auto/cplusplus/codegen/tst_codegen.cpp | |
| parent | 934c77c2c42becbb85bc5db8c900f7ed3fa00776 (diff) | |
| download | qt-creator-65ef5f7a354acef5843c14546a4d8d231419b514.tar.gz | |
Fix tests/auto/cplusplus/codegen on windows.
Change-Id: I765baa58c6b39d98949c0c8530623baf112f42bb
Reviewed-by: Bill King <bill.king@nokia.com>
Diffstat (limited to 'tests/auto/cplusplus/codegen/tst_codegen.cpp')
| -rw-r--r-- | tests/auto/cplusplus/codegen/tst_codegen.cpp | 113 |
1 files changed, 60 insertions, 53 deletions
diff --git a/tests/auto/cplusplus/codegen/tst_codegen.cpp b/tests/auto/cplusplus/codegen/tst_codegen.cpp index 9d71984dcf..1044843ed3 100644 --- a/tests/auto/cplusplus/codegen/tst_codegen.cpp +++ b/tests/auto/cplusplus/codegen/tst_codegen.cpp @@ -48,6 +48,7 @@ #include <QtTest> #include <QtDebug> #include <QTextDocument> +#include <QDir> //TESTED_COMPONENT=src/libs/cplusplus @@ -79,6 +80,7 @@ private slots: private: ExtensionSystem::PluginManager *pluginManager; + QString tempPath; }; void tst_Codegen::initTestCase() @@ -90,6 +92,8 @@ void tst_Codegen::initTestCase() pluginManager->setFileExtension(QLatin1String("pluginspec")); pluginManager->setPluginPaths(QStringList() << QLatin1String(Q_PLUGIN_PATH)); pluginManager->loadPlugins(); + + tempPath = QDir::tempPath(); } void tst_Codegen::cleanupTestCase() @@ -414,7 +418,7 @@ void tst_Codegen::definition_empty_class() "int x;\n" // line 1 "\n"; - Document::Ptr src = Document::create(QLatin1String("/tmp/file.h")); + Document::Ptr src = Document::create(tempPath + QLatin1String("/file.h")); Utils::FileSaver srcSaver(src->fileName()); srcSaver.write(srcText); srcSaver.finalize(); @@ -424,7 +428,7 @@ void tst_Codegen::definition_empty_class() QCOMPARE(src->diagnosticMessages().size(), 0); QCOMPARE(src->globalSymbolCount(), 1U); - Document::Ptr dst = Document::create(QLatin1String("/tmp/file.cpp")); + Document::Ptr dst = Document::create(tempPath + QLatin1String("/file.cpp")); Utils::FileSaver dstSaver(dst->fileName()); dstSaver.write(dstText); dstSaver.finalize(); @@ -453,7 +457,7 @@ void tst_Codegen::definition_empty_class() QList<InsertionLocation> locList = find.methodDefinition(decl); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), QLatin1String("/tmp/file.cpp")); + QCOMPARE(loc.fileName(), dst->fileName()); QCOMPARE(loc.prefix(), QLatin1String("\n\n")); QCOMPARE(loc.suffix(), QString()); QCOMPARE(loc.line(), 1U); @@ -470,18 +474,19 @@ void tst_Codegen::definition_first_member() "};\n" "\n"; - const QByteArray dstText = "\n" - "#include \"/tmp/file.h\"\n" // line 1 - "int x;\n" - "\n" - "void Foo::bar()\n" // line 4 - "{\n" - "\n" - "}\n" - "\n" - "int y;\n"; - - Document::Ptr src = Document::create(QLatin1String("/tmp/file.h")); + const QByteArray dstText = QString( + "\n" + "#include \"%1/file.h\"\n" // line 1 + "int x;\n" + "\n" + "void Foo::bar()\n" // line 4 + "{\n" + "\n" + "}\n" + "\n" + "int y;\n").arg(tempPath).toLatin1(); + + Document::Ptr src = Document::create(tempPath + QLatin1String("/file.h")); Utils::FileSaver srcSaver(src->fileName()); srcSaver.write(srcText); srcSaver.finalize(); @@ -491,8 +496,8 @@ void tst_Codegen::definition_first_member() QCOMPARE(src->diagnosticMessages().size(), 0); QCOMPARE(src->globalSymbolCount(), 1U); - Document::Ptr dst = Document::create(QLatin1String("/tmp/file.cpp")); - dst->addIncludeFile("/tmp/file.h", 1); + Document::Ptr dst = Document::create(tempPath + QLatin1String("/file.cpp")); + dst->addIncludeFile(src->fileName(), 1); Utils::FileSaver dstSaver(dst->fileName()); dstSaver.write(dstText); dstSaver.finalize(); @@ -521,7 +526,7 @@ void tst_Codegen::definition_first_member() QList<InsertionLocation> locList = find.methodDefinition(decl); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), QLatin1String("/tmp/file.cpp")); + QCOMPARE(loc.fileName(), dst->fileName()); QCOMPARE(loc.line(), 4U); QCOMPARE(loc.column(), 1U); QCOMPARE(loc.suffix(), QLatin1String("\n\n")); @@ -538,18 +543,19 @@ void tst_Codegen::definition_last_member() "};\n" "\n"; - const QByteArray dstText = "\n" - "#include \"/tmp/file.h\"\n" // line 1 - "int x;\n" - "\n" - "void Foo::foo()\n" // line 4 - "{\n" - "\n" - "}\n" // line 7 - "\n" - "int y;\n"; - - Document::Ptr src = Document::create(QLatin1String("/tmp/file.h")); + const QByteArray dstText = QString( + "\n" + "#include \"%1/file.h\"\n" // line 1 + "int x;\n" + "\n" + "void Foo::foo()\n" // line 4 + "{\n" + "\n" + "}\n" // line 7 + "\n" + "int y;\n").arg(tempPath).toLatin1(); + + Document::Ptr src = Document::create(tempPath + QLatin1String("/file.h")); Utils::FileSaver srcSaver(src->fileName()); srcSaver.write(srcText); srcSaver.finalize(); @@ -559,8 +565,8 @@ void tst_Codegen::definition_last_member() QCOMPARE(src->diagnosticMessages().size(), 0); QCOMPARE(src->globalSymbolCount(), 1U); - Document::Ptr dst = Document::create(QLatin1String("/tmp/file.cpp")); - dst->addIncludeFile("/tmp/file.h", 1); + Document::Ptr dst = Document::create(tempPath + QLatin1String("/file.cpp")); + dst->addIncludeFile(src->fileName(), 1); Utils::FileSaver dstSaver(dst->fileName()); dstSaver.write(dstText); dstSaver.finalize(); @@ -589,7 +595,7 @@ void tst_Codegen::definition_last_member() QList<InsertionLocation> locList = find.methodDefinition(decl); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), QLatin1String("/tmp/file.cpp")); + QCOMPARE(loc.fileName(), dst->fileName()); QCOMPARE(loc.line(), 7U); QCOMPARE(loc.column(), 2U); QCOMPARE(loc.prefix(), QLatin1String("\n\n")); @@ -607,23 +613,24 @@ void tst_Codegen::definition_middle_member() "};\n" "\n"; - const QByteArray dstText = "\n" - "#include \"/tmp/file.h\"\n" // line 1 - "int x;\n" - "\n" - "void Foo::foo()\n" // line 4 - "{\n" - "\n" - "}\n" // line 7 - "\n" - "void Foo::car()\n" // line 9 - "{\n" - "\n" - "}\n" - "\n" - "int y;\n"; - - Document::Ptr src = Document::create(QLatin1String("/tmp/file.h")); + const QByteArray dstText = QString( + "\n" + "#include \"%1/file.h\"\n" // line 1 + "int x;\n" + "\n" + "void Foo::foo()\n" // line 4 + "{\n" + "\n" + "}\n" // line 7 + "\n" + "void Foo::car()\n" // line 9 + "{\n" + "\n" + "}\n" + "\n" + "int y;\n").arg(tempPath).toLatin1(); + + Document::Ptr src = Document::create(tempPath + QLatin1String("/file.h")); Utils::FileSaver srcSaver(src->fileName()); srcSaver.write(srcText); srcSaver.finalize(); @@ -633,8 +640,8 @@ void tst_Codegen::definition_middle_member() QCOMPARE(src->diagnosticMessages().size(), 0); QCOMPARE(src->globalSymbolCount(), 1U); - Document::Ptr dst = Document::create(QLatin1String("/tmp/file.cpp")); - dst->addIncludeFile("/tmp/file.h", 1); + Document::Ptr dst = Document::create(tempPath + QLatin1String("/file.cpp")); + dst->addIncludeFile(src->fileName(), 1); Utils::FileSaver dstSaver(dst->fileName()); dstSaver.write(dstText); dstSaver.finalize(); @@ -663,7 +670,7 @@ void tst_Codegen::definition_middle_member() QList<InsertionLocation> locList = find.methodDefinition(decl); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), QLatin1String("/tmp/file.cpp")); + QCOMPARE(loc.fileName(), dst->fileName()); QCOMPARE(loc.line(), 7U); QCOMPARE(loc.column(), 2U); QCOMPARE(loc.prefix(), QLatin1String("\n\n")); |
