Exercise settings retries and deletion changes during confirmation
This commit is contained in:
1 parent
cba3f4f75a
commit
ddb373d445
1 file changed
+66
@@ -122,6 +122,25 @@ private slots:
|
||||
gui_bridge_set_inst(nullptr); QCOMPARE(u_get_allocated_count(), baseline);
|
||||
auto* status = dialog.findChild<QLabel*>("channelSettingsStatus"); QVERIFY(status && !status->text().isEmpty());
|
||||
}
|
||||
|
||||
void retryAfterPartialQueueAcceptance() {
|
||||
SettingsCore core; QVERIFY(core.start());
|
||||
ChannelSettingsDialog dialog(core.channel, &core.db);
|
||||
const auto checks = dialog.findChildren<QCheckBox*>(); QCOMPARE(checks.size(), 2);
|
||||
checks[0]->setChecked(true); checks[1]->setChecked(false);
|
||||
QSignalSpy accepted(&dialog, &QDialog::accepted);
|
||||
allocationFile = "gui_bridge_impl.cpp"; failAllocation = 2;
|
||||
auto reset = qScopeGuard([] { failAllocation = 0; allocationFile = nullptr; });
|
||||
QVERIFY(QMetaObject::invokeMethod(&dialog, "onSave", Qt::DirectConnection));
|
||||
QCOMPARE(failAllocation, 0); QVERIFY(accepted.isEmpty());
|
||||
uasync_poll(core.ua, 0);
|
||||
QCOMPARE(core.db.getUiStateInt("ch_" + core.channel + "_auto_play_voice", -1), 1);
|
||||
QCOMPARE(chat_core_get_sound_on_message(core.inst, qPrintable(core.channel)), 1);
|
||||
QVERIFY(QMetaObject::invokeMethod(&dialog, "onSave", Qt::DirectConnection));
|
||||
QCOMPARE(accepted.count(), 1); uasync_poll(core.ua, 0);
|
||||
QCOMPARE(core.db.getUiStateInt("ch_" + core.channel + "_auto_play_voice", -1), 1);
|
||||
QCOMPARE(chat_core_get_sound_on_message(core.inst, qPrintable(core.channel)), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void invalidChannel_data() {
|
||||
@@ -159,6 +178,42 @@ private slots:
|
||||
QVERIFY(!dialog); QCOMPARE(core.db.getChannels().size(), 1);
|
||||
}
|
||||
|
||||
void confirmationOutcome_data() {
|
||||
QTest::addColumn<int>("change");
|
||||
QTest::newRow("confirm-owned-request") << 0;
|
||||
QTest::newRow("cancel") << 1;
|
||||
QTest::newRow("removed-during-confirmation") << 2;
|
||||
QTest::newRow("core-stopped") << 3;
|
||||
#ifdef UTUN_TEST_SETTINGS_ALLOC_FAILURES
|
||||
QTest::newRow("queue-rejected") << 4;
|
||||
#endif
|
||||
}
|
||||
void confirmationOutcome() {
|
||||
QFETCH(int, change);
|
||||
SettingsCore core; QVERIFY(core.start());
|
||||
ChannelSettingsDialog dialog(core.channel, &core.db); dialog.show();
|
||||
QSignalSpy accepted(&dialog, &QDialog::accepted);
|
||||
const auto baseline = u_get_allocated_count();
|
||||
#ifdef UTUN_TEST_SETTINGS_ALLOC_FAILURES
|
||||
auto reset = qScopeGuard([] { failAllocation = 0; allocationFile = nullptr; });
|
||||
#endif
|
||||
QTimer::singleShot(0, &dialog, [&] {
|
||||
auto* box = qobject_cast<QMessageBox*>(QApplication::activeModalWidget()); QVERIFY(box);
|
||||
if (change == 1) { box->button(QMessageBox::Cancel)->click(); return; }
|
||||
if (change == 2) chat_core_delete_channel(core.inst, qPrintable(core.channel));
|
||||
if (change == 3) gui_bridge_set_inst(nullptr);
|
||||
#ifdef UTUN_TEST_SETTINGS_ALLOC_FAILURES
|
||||
if (change == 4) { allocationFile = "gui_bridge_impl.cpp"; failAllocation = 1; }
|
||||
#endif
|
||||
auto* button = box->findChild<QPushButton*>("confirmDeleteChannel"); QVERIFY(button); button->click();
|
||||
});
|
||||
QVERIFY(QMetaObject::invokeMethod(&dialog, "onDelete", Qt::DirectConnection));
|
||||
QCOMPARE(accepted.count(), int(change == 0));
|
||||
gui_bridge_set_inst(nullptr);
|
||||
if (change != 2) QCOMPARE(u_get_allocated_count(), baseline);
|
||||
QCOMPARE(core.db.getChannels().size(), change == 2 ? 0 : 1);
|
||||
}
|
||||
|
||||
void avatarChooserSurvivesOwnerDeletion() {
|
||||
SettingsCore core; QVERIFY(core.start()); GroupAvatarManager avatars(&core.db);
|
||||
QPointer<ChannelSettingsDialog> dialog = new ChannelSettingsDialog(core.channel, &core.db);
|
||||
@@ -166,6 +221,17 @@ private slots:
|
||||
QTimer::singleShot(0, [&] { QVERIFY(qobject_cast<QFileDialog*>(QApplication::activeModalWidget())); delete dialog.data(); });
|
||||
upload->click(); QVERIFY(!dialog);
|
||||
}
|
||||
|
||||
void avatarManagerDisappearsDuringChoice() {
|
||||
SettingsCore core; QVERIFY(core.start());
|
||||
QPointer<GroupAvatarManager> avatars = new GroupAvatarManager(&core.db);
|
||||
auto release = qScopeGuard([&] { delete avatars.data(); });
|
||||
ChannelSettingsDialog dialog(core.channel, &core.db); dialog.show();
|
||||
auto* upload = dialog.findChild<QPushButton*>("uploadGroupAvatar"); QVERIFY(upload && upload->isEnabled());
|
||||
QTimer::singleShot(0, [&] { QVERIFY(qobject_cast<QFileDialog*>(QApplication::activeModalWidget())); delete avatars.data(); });
|
||||
upload->click(); QVERIFY(!avatars); QVERIFY(!upload->isEnabled());
|
||||
QVERIFY(!dialog.findChild<QPushButton*>("removeGroupAvatar")->isEnabled());
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(ChannelSettingsTest)
|
||||
|
||||
Reference in new issue
Block a user