MCPcopy Create free account
hub / github.com/KDE/kdevelop / testIncludePathCompletion

Method testIncludePathCompletion

plugins/clang/tests/test_codecompletion.cpp:1167–1205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1165}
1166
1167void TestCodeCompletion::testIncludePathCompletion()
1168{
1169 QFETCH(QString, code);
1170 QFETCH(KTextEditor::Cursor, cursor);
1171 QFETCH(QString, itemId);
1172 QFETCH(QString, result);
1173
1174 QTemporaryDir tempDir;
1175 QDir dir(tempDir.path());
1176 QVERIFY(dir.mkpath("foo/bar/asdf"));
1177 TestFile file(code, QStringLiteral("cpp"), nullptr, tempDir.path());
1178 {
1179 QFile otherFile(tempDir.path() + "/dash-file.h");
1180 QVERIFY(otherFile.open(QIODevice::WriteOnly));
1181 }
1182 IncludeTester tester(executeIncludePathCompletion(&file, cursor));
1183 QVERIFY(tester.completionContext);
1184 QVERIFY(tester.completionContext->isValid());
1185
1186 auto item = tester.findItem(itemId);
1187 QVERIFY(item);
1188
1189 auto view = createView(file.url().toUrl());
1190 QVERIFY(view.get());
1191 auto doc = view->document();
1192 item->execute(view.get(), KTextEditor::Range(cursor, cursor));
1193 QCOMPARE(doc->text(), result);
1194
1195 const auto newCursor = view->cursorPosition();
1196 QCOMPARE(newCursor.line(), cursor.line());
1197 if (!itemId.endsWith('/')) {
1198 // file inserted, cursor should be at end of line
1199 QCOMPARE(newCursor.column(), doc->lineLength(cursor.line()));
1200 } else {
1201 // directory inserted, cursor should be before the " or >
1202 const auto cursorChar = doc->characterAt(newCursor);
1203 QVERIFY(cursorChar == '"' || cursorChar == '>');
1204 }
1205}
1206
1207void TestCodeCompletion::testIncludePathCompletionLocal()
1208{

Callers

nothing calls this directly

Calls 15

endsWithMethod · 0.80
RangeClass · 0.50
pathMethod · 0.45
openMethod · 0.45
isValidMethod · 0.45
findItemMethod · 0.45
toUrlMethod · 0.45
urlMethod · 0.45
getMethod · 0.45
documentMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected