|
|
|
|
@ -102,6 +102,48 @@ private slots:
|
|
|
|
|
} |
|
|
|
|
void init() { transfers.clear(); cancelled.clear(); ready = true; transferStarted = {}; } |
|
|
|
|
|
|
|
|
|
void deleteAndParentShortcuts() { |
|
|
|
|
sqlite3* sql = nullptr; QCOMPARE(sqlite3_open(":memory:", &sql), SQLITE_OK); |
|
|
|
|
QCOMPARE(sqlite3_exec(sql, "CREATE TABLE accounts(node_id INTEGER,display_name TEXT);" |
|
|
|
|
"INSERT INTO accounts VALUES(11,'Other'),(22,'Me'),(33,'Server');" |
|
|
|
|
"CREATE TABLE peers_42(node_id INTEGER,adm_tags TEXT,adm_tags_sig BLOB,deleted INTEGER,source INTEGER);" |
|
|
|
|
"INSERT INTO peers_42 VALUES(11,'{}',NULL,0,0),(22,'{}',NULL,0,0)," |
|
|
|
|
"(33,'{\"storage\":\"yes\"}',zeroblob(64),0,0);", nullptr, nullptr, nullptr), SQLITE_OK); |
|
|
|
|
DbManager db; db.setDb(sql); db.setMyNodeId(22); |
|
|
|
|
{ |
|
|
|
|
MemberFileBrowser browser(&db); browser.setChannel("42", 22); browser.show(); browser.activateWindow(); |
|
|
|
|
auto* tree = browser.findChild<QTreeWidget*>(); auto* location = browser.findChild<QLineEdit*>(); |
|
|
|
|
location->setText("documents/nested"); QTest::keyClick(location, Qt::Key_Return); |
|
|
|
|
auto* item = new QTreeWidgetItem(tree, {"remote.txt"}); |
|
|
|
|
item->setData(0, Qt::UserRole, "remote.txt"); item->setData(0, Qt::UserRole + 1, MF_FILE); |
|
|
|
|
item->setData(0, Qt::UserRole + 2, QByteArray(16, '\7')); tree->setCurrentItem(item); |
|
|
|
|
tree->setFocus(); QTRY_VERIFY(tree->hasFocus()); |
|
|
|
|
auto previous = captured.message.request_id; |
|
|
|
|
answerDialog(QMessageBox::No); QTest::keyClick(tree, Qt::Key_Delete); |
|
|
|
|
QCOMPARE(captured.message.request_id, previous); |
|
|
|
|
answerDialog(QMessageBox::Yes); QTest::keyClick(tree, Qt::Key_Delete); |
|
|
|
|
QCOMPARE(captured.message.command, uint8_t(MF_REMOVE_PATH)); QCOMPARE(captured.message.owner, 22ULL); |
|
|
|
|
QCOMPARE(QString::fromUtf8(captured.message.path), QString("documents/nested/remote.txt")); |
|
|
|
|
QCOMPARE(QByteArray((const char*)captured.message.version, 16), QByteArray(16, '\7')); |
|
|
|
|
location->setFocus(); location->setText("abc"); location->setCursorPosition(1); |
|
|
|
|
previous = captured.message.request_id; |
|
|
|
|
QTest::keyClick(location, Qt::Key_Delete); QCOMPARE(location->text(), QString("ac")); |
|
|
|
|
QTest::keyClick(location, Qt::Key_Backspace); QCOMPARE(location->text(), QString("c")); |
|
|
|
|
QCOMPARE(captured.message.request_id, previous); |
|
|
|
|
tree->setFocus(); QTest::keyClick(tree, Qt::Key_Backspace); |
|
|
|
|
QCOMPARE(captured.message.command, uint8_t(MF_LIST)); QCOMPARE(QString::fromUtf8(captured.message.path), QString("documents")); |
|
|
|
|
QTest::keyClick(tree, Qt::Key_Backspace); QCOMPARE(QString::fromUtf8(captured.message.path), QString()); |
|
|
|
|
QTest::keyClick(tree, Qt::Key_Backspace); QCOMPARE(captured.message.owner, 0ULL); |
|
|
|
|
browser.setChannel("42", 11); |
|
|
|
|
item = new QTreeWidgetItem(tree, {"foreign.txt"}); item->setData(0, Qt::UserRole, "foreign.txt"); |
|
|
|
|
item->setData(0, Qt::UserRole + 1, MF_FILE); tree->setCurrentItem(item); |
|
|
|
|
previous = captured.message.request_id; |
|
|
|
|
QTest::keyClick(tree, Qt::Key_Delete); QCOMPARE(captured.message.request_id, previous); |
|
|
|
|
QVERIFY(!QApplication::activeModalWidget()); |
|
|
|
|
} |
|
|
|
|
db.setDb(nullptr); QCOMPARE(sqlite3_close(sql), SQLITE_OK); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void exportToSystemClipboardAndSingleDrag_data() { |
|
|
|
|
QTest::addColumn<int>("dragStatus"); |
|
|
|
|
QTest::newRow("success") << int(MF_OK); |
|
|
|
|
|