~timo-jyrinki/ubuntu/saucy/qtcreator/add_workaround_back

« back to all changes in this revision

Viewing changes to tests/auto/cplusplus/codegen/tst_codegen.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2011-11-18 16:18:49 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20111118161849-5t8jugl6egvs4iev
Tags: 2.4.0~rc-0ubuntu1
* New upstream release candidate.
* Drop 04_fix_ftbfs_arm_qreal.diff, merged upstream.
* Refresh 01_fix_installation_paths.diff.
* Compress binary packages with xz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
**
5
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6
6
**
7
 
** Contact: Nokia Corporation (info@qt.nokia.com)
 
7
** Contact: Nokia Corporation (qt-info@nokia.com)
8
8
**
9
9
**
10
10
** GNU Lesser General Public License Usage
26
26
** conditions contained in a signed written agreement between you and Nokia.
27
27
**
28
28
** If you have questions regarding the use of this file, please contact
29
 
** Nokia at info@qt.nokia.com.
 
29
** Nokia at qt-info@nokia.com.
30
30
**
31
31
**************************************************************************/
32
32
 
48
48
#include <QtTest>
49
49
#include <QtDebug>
50
50
#include <QTextDocument>
 
51
#include <QDir>
51
52
 
52
53
//TESTED_COMPONENT=src/libs/cplusplus
53
54
 
79
80
 
80
81
private:
81
82
    ExtensionSystem::PluginManager *pluginManager;
 
83
    QString tempPath;
82
84
};
83
85
 
84
86
void tst_Codegen::initTestCase()
90
92
    pluginManager->setFileExtension(QLatin1String("pluginspec"));
91
93
    pluginManager->setPluginPaths(QStringList() << QLatin1String(Q_PLUGIN_PATH));
92
94
    pluginManager->loadPlugins();
 
95
 
 
96
    tempPath = QDir::tempPath();
93
97
}
94
98
 
95
99
void tst_Codegen::cleanupTestCase()
414
418
            "int x;\n"  // line 1
415
419
            "\n";
416
420
 
417
 
    Document::Ptr src = Document::create(QLatin1String("/tmp/file.h"));
 
421
    Document::Ptr src = Document::create(tempPath + QLatin1String("/file.h"));
418
422
    Utils::FileSaver srcSaver(src->fileName());
419
423
    srcSaver.write(srcText);
420
424
    srcSaver.finalize();
424
428
    QCOMPARE(src->diagnosticMessages().size(), 0);
425
429
    QCOMPARE(src->globalSymbolCount(), 1U);
426
430
 
427
 
    Document::Ptr dst = Document::create(QLatin1String("/tmp/file.cpp"));
 
431
    Document::Ptr dst = Document::create(tempPath + QLatin1String("/file.cpp"));
428
432
    Utils::FileSaver dstSaver(dst->fileName());
429
433
    dstSaver.write(dstText);
430
434
    dstSaver.finalize();
453
457
    QList<InsertionLocation> locList = find.methodDefinition(decl);
454
458
    QVERIFY(locList.size() == 1);
455
459
    InsertionLocation loc = locList.first();
456
 
    QCOMPARE(loc.fileName(), QLatin1String("/tmp/file.cpp"));
 
460
    QCOMPARE(loc.fileName(), dst->fileName());
457
461
    QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
458
462
    QCOMPARE(loc.suffix(), QString());
459
463
    QCOMPARE(loc.line(), 1U);
470
474
            "};\n"
471
475
            "\n";
472
476
 
473
 
    const QByteArray dstText = "\n"
474
 
            "#include \"/tmp/file.h\"\n" // line 1
475
 
            "int x;\n"
476
 
            "\n"
477
 
            "void Foo::bar()\n" // line 4
478
 
            "{\n"
479
 
            "\n"
480
 
            "}\n"
481
 
            "\n"
482
 
            "int y;\n";
 
477
    const QByteArray dstText = QString(
 
478
                "\n"
 
479
                "#include \"%1/file.h\"\n" // line 1
 
480
                "int x;\n"
 
481
                "\n"
 
482
                "void Foo::bar()\n" // line 4
 
483
                "{\n"
 
484
                "\n"
 
485
                "}\n"
 
486
                "\n"
 
487
                "int y;\n").arg(tempPath).toLatin1();
483
488
 
484
 
    Document::Ptr src = Document::create(QLatin1String("/tmp/file.h"));
 
489
    Document::Ptr src = Document::create(tempPath + QLatin1String("/file.h"));
485
490
    Utils::FileSaver srcSaver(src->fileName());
486
491
    srcSaver.write(srcText);
487
492
    srcSaver.finalize();
491
496
    QCOMPARE(src->diagnosticMessages().size(), 0);
492
497
    QCOMPARE(src->globalSymbolCount(), 1U);
493
498
 
494
 
    Document::Ptr dst = Document::create(QLatin1String("/tmp/file.cpp"));
495
 
    dst->addIncludeFile("/tmp/file.h", 1);
 
499
    Document::Ptr dst = Document::create(tempPath + QLatin1String("/file.cpp"));
 
500
    dst->addIncludeFile(src->fileName(), 1);
496
501
    Utils::FileSaver dstSaver(dst->fileName());
497
502
    dstSaver.write(dstText);
498
503
    dstSaver.finalize();
521
526
    QList<InsertionLocation> locList = find.methodDefinition(decl);
522
527
    QVERIFY(locList.size() == 1);
523
528
    InsertionLocation loc = locList.first();
524
 
    QCOMPARE(loc.fileName(), QLatin1String("/tmp/file.cpp"));
 
529
    QCOMPARE(loc.fileName(), dst->fileName());
525
530
    QCOMPARE(loc.line(), 4U);
526
531
    QCOMPARE(loc.column(), 1U);
527
532
    QCOMPARE(loc.suffix(), QLatin1String("\n\n"));
538
543
            "};\n"
539
544
            "\n";
540
545
 
541
 
    const QByteArray dstText = "\n"
542
 
            "#include \"/tmp/file.h\"\n" // line 1
543
 
            "int x;\n"
544
 
            "\n"
545
 
            "void Foo::foo()\n" // line 4
546
 
            "{\n"
547
 
            "\n"
548
 
            "}\n" // line 7
549
 
            "\n"
550
 
            "int y;\n";
 
546
    const QByteArray dstText = QString(
 
547
                "\n"
 
548
                "#include \"%1/file.h\"\n" // line 1
 
549
                "int x;\n"
 
550
                "\n"
 
551
                "void Foo::foo()\n" // line 4
 
552
                "{\n"
 
553
                "\n"
 
554
                "}\n" // line 7
 
555
                "\n"
 
556
                "int y;\n").arg(tempPath).toLatin1();
551
557
 
552
 
    Document::Ptr src = Document::create(QLatin1String("/tmp/file.h"));
 
558
    Document::Ptr src = Document::create(tempPath + QLatin1String("/file.h"));
553
559
    Utils::FileSaver srcSaver(src->fileName());
554
560
    srcSaver.write(srcText);
555
561
    srcSaver.finalize();
559
565
    QCOMPARE(src->diagnosticMessages().size(), 0);
560
566
    QCOMPARE(src->globalSymbolCount(), 1U);
561
567
 
562
 
    Document::Ptr dst = Document::create(QLatin1String("/tmp/file.cpp"));
563
 
    dst->addIncludeFile("/tmp/file.h", 1);
 
568
    Document::Ptr dst = Document::create(tempPath + QLatin1String("/file.cpp"));
 
569
    dst->addIncludeFile(src->fileName(), 1);
564
570
    Utils::FileSaver dstSaver(dst->fileName());
565
571
    dstSaver.write(dstText);
566
572
    dstSaver.finalize();
589
595
    QList<InsertionLocation> locList = find.methodDefinition(decl);
590
596
    QVERIFY(locList.size() == 1);
591
597
    InsertionLocation loc = locList.first();
592
 
    QCOMPARE(loc.fileName(), QLatin1String("/tmp/file.cpp"));
 
598
    QCOMPARE(loc.fileName(), dst->fileName());
593
599
    QCOMPARE(loc.line(), 7U);
594
600
    QCOMPARE(loc.column(), 2U);
595
601
    QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
607
613
            "};\n"
608
614
            "\n";
609
615
 
610
 
    const QByteArray dstText = "\n"
611
 
            "#include \"/tmp/file.h\"\n" // line 1
612
 
            "int x;\n"
613
 
            "\n"
614
 
            "void Foo::foo()\n" // line 4
615
 
            "{\n"
616
 
            "\n"
617
 
            "}\n" // line 7
618
 
            "\n"
619
 
            "void Foo::car()\n" // line 9
620
 
            "{\n"
621
 
            "\n"
622
 
            "}\n"
623
 
            "\n"
624
 
            "int y;\n";
 
616
    const QByteArray dstText = QString(
 
617
                "\n"
 
618
                "#include \"%1/file.h\"\n" // line 1
 
619
                "int x;\n"
 
620
                "\n"
 
621
                "void Foo::foo()\n" // line 4
 
622
                "{\n"
 
623
                "\n"
 
624
                "}\n" // line 7
 
625
                "\n"
 
626
                "void Foo::car()\n" // line 9
 
627
                "{\n"
 
628
                "\n"
 
629
                "}\n"
 
630
                "\n"
 
631
                "int y;\n").arg(tempPath).toLatin1();
625
632
 
626
 
    Document::Ptr src = Document::create(QLatin1String("/tmp/file.h"));
 
633
    Document::Ptr src = Document::create(tempPath + QLatin1String("/file.h"));
627
634
    Utils::FileSaver srcSaver(src->fileName());
628
635
    srcSaver.write(srcText);
629
636
    srcSaver.finalize();
633
640
    QCOMPARE(src->diagnosticMessages().size(), 0);
634
641
    QCOMPARE(src->globalSymbolCount(), 1U);
635
642
 
636
 
    Document::Ptr dst = Document::create(QLatin1String("/tmp/file.cpp"));
637
 
    dst->addIncludeFile("/tmp/file.h", 1);
 
643
    Document::Ptr dst = Document::create(tempPath + QLatin1String("/file.cpp"));
 
644
    dst->addIncludeFile(src->fileName(), 1);
638
645
    Utils::FileSaver dstSaver(dst->fileName());
639
646
    dstSaver.write(dstText);
640
647
    dstSaver.finalize();
663
670
    QList<InsertionLocation> locList = find.methodDefinition(decl);
664
671
    QVERIFY(locList.size() == 1);
665
672
    InsertionLocation loc = locList.first();
666
 
    QCOMPARE(loc.fileName(), QLatin1String("/tmp/file.cpp"));
 
673
    QCOMPARE(loc.fileName(), dst->fileName());
667
674
    QCOMPARE(loc.line(), 7U);
668
675
    QCOMPARE(loc.column(), 2U);
669
676
    QCOMPARE(loc.prefix(), QLatin1String("\n\n"));