| 745 | } |
| 746 | |
| 747 | void TestCodeCompletion::testOverrideExecute() |
| 748 | { |
| 749 | QFETCH(QString, code); |
| 750 | QFETCH(CompletionItems, expectedItems); |
| 751 | QFETCH(QString, itemToExecute); |
| 752 | QFETCH(QString, cppStandard); |
| 753 | QFETCH(QString, expectedCode); |
| 754 | |
| 755 | QTemporaryDir directory; |
| 756 | TestProject testProject {Path{directory.path()}}; |
| 757 | auto t = testProject.path().toLocalFile(); |
| 758 | auto configGroup = testProject.projectConfiguration()->group(definesAndIncludesConfigName).group("ProjectPath0"); |
| 759 | configGroup.writeEntry("Path", "."); |
| 760 | configGroup.writeEntry("parserArguments", cppStandard); |
| 761 | configGroup.sync(); |
| 762 | m_projectController->addProject(&testProject); |
| 763 | |
| 764 | TestFile file(code, QStringLiteral("cpp"), &testProject, directory.path()); |
| 765 | QVERIFY(file.parseAndWait(TopDUContext::AllDeclarationsContextsUsesAndAST)); |
| 766 | |
| 767 | auto executeItem = [=] (const ClangCodeCompletionItemTester& tester) { |
| 768 | auto item = tester.findItem(itemToExecute); |
| 769 | QVERIFY(item); |
| 770 | auto view = createView(tester.completionContext->duContext()->url().toUrl()); |
| 771 | DUChainReadLocker lock; |
| 772 | item->execute(view.get(), view->document()->wordRangeAt(expectedItems.position)); |
| 773 | QCOMPARE(view->document()->text(), expectedCode); |
| 774 | }; |
| 775 | executeCompletionTest(file.topContext(), expectedItems, NoMacroOrBuiltin, executeItem); |
| 776 | m_projectController->closeProject(&testProject); |
| 777 | } |
| 778 | |
| 779 | void TestCodeCompletion::testOverrideExecute_data() |
| 780 | { |
nothing calls this directly
no test coverage detected