| 804 | } |
| 805 | |
| 806 | void TestAssistants::testHeaderGuardAssistant() |
| 807 | { |
| 808 | CodeRepresentation::setDiskChangesForbidden(false); |
| 809 | |
| 810 | QFETCH(QString, filename); |
| 811 | QFETCH(QString, code); |
| 812 | QFETCH(QString, pragmaExpected); |
| 813 | QFETCH(QString, macroExpected); |
| 814 | |
| 815 | TestFile pragmaFile(code, QStringLiteral("h")); |
| 816 | TestFile macroFile(code, QStringLiteral("h"), filename); |
| 817 | TestFile impl("#include \"" + pragmaFile.url().str() + "\"\n" |
| 818 | "#include \"" + macroFile.url().str() + "\"\n", QStringLiteral("cpp")); |
| 819 | |
| 820 | QExplicitlySharedDataPointer<IAssistant> pragmaAssistant; |
| 821 | QExplicitlySharedDataPointer<IAssistant> macroAssistant; |
| 822 | |
| 823 | QVERIFY(impl.parseAndWait(TopDUContext::Empty)); |
| 824 | |
| 825 | DUChainReadLocker lock; |
| 826 | QVERIFY(impl.topContext()); |
| 827 | |
| 828 | const auto pragmaTopContext = DUChain::self()->chainForDocument(pragmaFile.url()); |
| 829 | const auto macroTopContext = DUChain::self()->chainForDocument(macroFile.url()); |
| 830 | QVERIFY(pragmaTopContext); |
| 831 | QVERIFY(macroTopContext); |
| 832 | |
| 833 | const auto pragmaProblem = findStaticAssistantProblem(DUChainUtils::allProblemsForContext(pragmaTopContext)); |
| 834 | const auto macroProblem = findStaticAssistantProblem(DUChainUtils::allProblemsForContext(macroTopContext)); |
| 835 | QVERIFY(pragmaProblem && macroProblem); |
| 836 | pragmaAssistant = pragmaProblem->solutionAssistant(); |
| 837 | macroAssistant = macroProblem->solutionAssistant(); |
| 838 | QVERIFY(pragmaAssistant && macroAssistant); |
| 839 | |
| 840 | pragmaAssistant->actions()[0]->execute(); |
| 841 | macroAssistant->actions()[1]->execute(); |
| 842 | |
| 843 | QCOMPARE(pragmaFile.fileContents(), pragmaExpected); |
| 844 | QCOMPARE(macroFile.fileContents(), macroExpected); |
| 845 | |
| 846 | CodeRepresentation::setDiskChangesForbidden(true); |
| 847 | } |
| 848 | |
| 849 | void TestAssistants::testHeaderGuardAssistant_data() |
| 850 | { |
nothing calls this directly
no test coverage detected