| 2543 | |
| 2544 | template<typename UrlProvider> |
| 2545 | QUrl DebuggerTestBase::urlForFileKind(FileKind fileKind, UrlProvider validUrlCallback) const |
| 2546 | { |
| 2547 | switch (fileKind) { |
| 2548 | case FileKind::Valid: |
| 2549 | return validUrlCallback(); |
| 2550 | case FileKind::EmptyName: |
| 2551 | return QUrl{}; |
| 2552 | case FileKind::Nonexistent: |
| 2553 | return QUrl::fromLocalFile("/this/path/should/not/exist"); |
| 2554 | case FileKind::Directory: |
| 2555 | return debugeeUrl().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); |
| 2556 | case FileKind::NotReadable: { |
| 2557 | if (m_notReadableFile.fileName().isEmpty()) { |
| 2558 | QVERIFY_RETURN(m_notReadableFile.open(), QUrl{}); |
| 2559 | m_notReadableFile.close(); |
| 2560 | QCOMPARE_RETURN(m_notReadableFile.error(), QFileDevice::NoError, QUrl{}); |
| 2561 | QVERIFY_RETURN(m_notReadableFile.setPermissions({}), QUrl{}); |
| 2562 | } |
| 2563 | const auto fileName = m_notReadableFile.fileName(); |
| 2564 | QVERIFY_RETURN(!fileName.isEmpty(), QUrl{}); |
| 2565 | QVERIFY_RETURN(!QFileInfo{fileName}.isReadable(), QUrl{}); |
| 2566 | return QUrl::fromLocalFile(fileName); |
| 2567 | } |
| 2568 | case FileKind::Invalid: |
| 2569 | return debugeeUrl(); // a C++ source file is neither an executable nor a core dump file |
| 2570 | } |
| 2571 | Q_UNREACHABLE_RETURN(QUrl{}); |
| 2572 | } |
| 2573 | |
| 2574 | #include "moc_debuggertestbase.cpp" |