|
|
|
|
@ -264,7 +264,7 @@ private slots:
|
|
|
|
|
|
|
|
|
|
void recursiveDeletion_data() { |
|
|
|
|
QTest::addColumn<QString>("scenario"); |
|
|
|
|
for (const auto* scenario : {"complete", "cancel-scan", "cancel-remove", "changed-file", "new-child", "changed-page"}) |
|
|
|
|
for (const auto* scenario : {"complete", "cancel-scan", "cancel-remove", "changed-file", "new-child", "changed-page", "server-busy"}) |
|
|
|
|
QTest::newRow(scenario) << QString::fromLatin1(scenario); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -277,7 +277,7 @@ private slots:
|
|
|
|
|
QFile file(user + '/' + path); QVERIFY(file.open(QIODevice::WriteOnly)); QCOMPARE(file.write(contents), qint64(contents.size())); |
|
|
|
|
}; |
|
|
|
|
// Длинные имена вынуждают настоящий storage выдавать несколько страниц LIST.
|
|
|
|
|
for (int i = 0; i < 40; i++) write("folder/" + QString::number(i) + QString(220, 'x'), "payload"); |
|
|
|
|
for (int i = 0; i < (scenario == "server-busy" ? 70 : 40); i++) write("folder/" + QString::number(i) + QString(220, 'x'), "payload"); |
|
|
|
|
write("folder/nested/file.txt", "nested"); write("loose.txt", "selected"); write("keep.txt", "unselected"); |
|
|
|
|
auto* storage = mf_storage_create(root.path().toUtf8().constData(), 1000000, 200000); |
|
|
|
|
QVERIFY(storage); auto destroy = qScopeGuard([&] { mf_storage_destroy(storage); }); |
|
|
|
|
@ -309,7 +309,9 @@ private slots:
|
|
|
|
|
} |
|
|
|
|
if (q.command == MF_REMOVE_PATH) { |
|
|
|
|
QVERIFY(pages >= 4); // folder: две страницы, nested и empty: по одной.
|
|
|
|
|
if (scenario == "changed-file" && !injected) { changed = path; write(path, "changed contents"); injected = true; } |
|
|
|
|
if (scenario == "changed-file" && !injected) { |
|
|
|
|
changed = "folder/nested/file.txt"; write(changed, "changed contents"); injected = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
mf_message response{}; mf_storage_execute(storage, request.group, request.message.owner, &q, &response); |
|
|
|
|
if (q.command == MF_REMOVE_PATH && !response.status) { |
|
|
|
|
@ -331,7 +333,7 @@ private slots:
|
|
|
|
|
QVERIFY(!QFileInfo::exists(user + "/loose.txt")); QVERIFY(summary.contains("Completed: 46")); |
|
|
|
|
} else { |
|
|
|
|
QVERIFY(!success); QVERIFY(QFileInfo::exists(user + "/folder")); |
|
|
|
|
if (scenario == "cancel-scan" || scenario == "changed-page" || scenario == "changed-file") QCOMPARE(removed, 0); |
|
|
|
|
if (scenario == "cancel-scan" || scenario == "changed-page") QCOMPARE(removed, 0); |
|
|
|
|
if (scenario == "cancel-remove") { QCOMPARE(removed, 1); QVERIFY(summary.contains("Completed: 1")); } |
|
|
|
|
if (scenario.startsWith("cancel-")) QVERIFY(summary.contains("Deletion cancelled")); |
|
|
|
|
if (scenario == "changed-file") { QVERIFY(injected); QVERIFY(QFileInfo::exists(user + '/' + changed)); } |
|
|
|
|
@ -340,6 +342,7 @@ private slots:
|
|
|
|
|
QVERIFY(summary.contains(QString::fromUtf8(mf_status_text(MF_DIRECTORY_NOT_EMPTY)))); |
|
|
|
|
} |
|
|
|
|
if (scenario == "changed-page") QVERIFY(summary.contains(QString::fromUtf8(mf_status_text(MF_STALE)))); |
|
|
|
|
if (scenario == "server-busy") { QCOMPARE(removed, 64); QVERIFY(summary.contains(QString::fromUtf8(mf_status_text(MF_BUSY)))); } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -388,6 +391,15 @@ private slots:
|
|
|
|
|
for (auto key : {Qt::Key_Return, Qt::Key_Enter}) { |
|
|
|
|
item = new QTreeWidgetItem(tree, {"folder"}); item->setData(0, Qt::UserRole, "folder"); |
|
|
|
|
item->setData(0, Qt::UserRole + 1, MF_DIRECTORY); tree->setCurrentItem(item); |
|
|
|
|
if (key == Qt::Key_Return) { |
|
|
|
|
previous = captured.message.request_id; |
|
|
|
|
QTimer::singleShot(0, [] { |
|
|
|
|
auto* box = qobject_cast<QMessageBox*>(QApplication::activeModalWidget()); QVERIFY(box); |
|
|
|
|
bool recursive = box->text().contains("all its contents"); box->button(QMessageBox::No)->click(); QVERIFY(recursive); |
|
|
|
|
}); |
|
|
|
|
QTest::keyClick(tree, Qt::Key_Delete); QCOMPARE(captured.message.request_id, previous); |
|
|
|
|
browser.activateWindow(); QTRY_VERIFY(browser.isActiveWindow()); QTRY_VERIFY(tree->hasFocus()); |
|
|
|
|
} |
|
|
|
|
QTest::keyClick(tree, key); |
|
|
|
|
QCOMPARE(captured.message.command, uint8_t(MF_LIST)); QCOMPARE(QString::fromUtf8(captured.message.path), QString("folder")); |
|
|
|
|
up->setFocus(); QTest::mouseClick(up, Qt::LeftButton); |
|
|
|
|
|