Check the exact scroll threshold and only notify successful sends
This commit is contained in:
1 parent
804a684ef7
commit
f29554f92b
1 file changed
+7
-4
@@ -133,7 +133,7 @@ class GroupEditTest : public QObject {
|
||||
private slots:
|
||||
void newMessageScroll_data() {
|
||||
QTest::addColumn<bool>("dm"); QTest::addColumn<QString>("scenario");
|
||||
for (bool dm : {false, true}) for (const QString& scenario : {"bottom", "near", "boundary", "far", "own", "unchanged"})
|
||||
for (bool dm : {false, true}) for (const QString& scenario : {"bottom", "near", "boundary", "outside", "far", "own", "unchanged"})
|
||||
QTest::newRow(qPrintable(QString("%1-%2").arg(dm ? "pm" : "group", scenario))) << dm << scenario;
|
||||
}
|
||||
void newMessageScroll() {
|
||||
@@ -178,7 +178,7 @@ private slots:
|
||||
delegate->replyRequested(model->index(0, 0).data(MsgMessageKeyRole).toString());
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
const int distance = scenario == "bottom" ? 0 : scenario == "boundary" ? 10 * line :
|
||||
const int distance = scenario == "bottom" ? 0 : scenario == "boundary" ? 10 * line : scenario == "outside" ? 10 * line + 1 :
|
||||
scenario == "far" || scenario == "own" ? 30 * line : 5 * line;
|
||||
scrollbar->setValue(scrollbar->maximum() - distance); const int previous = scrollbar->value();
|
||||
const QString text = "```cpp\n" + QString("int value = 1;\n").repeated(30) + "```";
|
||||
@@ -190,7 +190,7 @@ private slots:
|
||||
}
|
||||
if (dm) snapshot(); else history->refresh();
|
||||
QCoreApplication::processEvents(); view->doItemsLayout();
|
||||
const bool follow = scenario != "far" && scenario != "unchanged";
|
||||
const bool follow = scenario != "outside" && scenario != "far" && scenario != "unchanged";
|
||||
if (follow) QCOMPARE(scrollbar->value(), scrollbar->maximum());
|
||||
else QCOMPARE(scrollbar->value(), previous);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_CHAT, "scroll verified: dm=%d scenario=%s previous=%d current=%d maximum=%d", dm, qPrintable(scenario), previous,
|
||||
@@ -279,7 +279,8 @@ private slots:
|
||||
QFETCH(bool, reply); QFETCH(QString, failure); const auto baseline = u_get_allocated_count();
|
||||
{
|
||||
SendCore core; QVERIFY(core.start(reply)); QSignalSpy errors(core.input(), &InputBar::attachmentRejected);
|
||||
QSignalSpy sends(core.input(), &InputBar::sendMessage); const auto before = u_get_allocated_count();
|
||||
QSignalSpy sends(core.input(), &InputBar::sendMessage), accepted(core.input(), &InputBar::messageAccepted);
|
||||
const auto before = u_get_allocated_count();
|
||||
if (failure == "unavailable") gui_bridge_set_inst(nullptr);
|
||||
if (failure == "stopped") uasync_mark_stopped(core.ua);
|
||||
QByteArray table = core.db.msgTableName(core.channel).toUtf8();
|
||||
@@ -302,6 +303,7 @@ private slots:
|
||||
gui_bridge_set_inst(nullptr); QCOMPARE(u_get_allocated_count(), before); QCoreApplication::processEvents();
|
||||
} else if (failure != "unavailable" && failure != "stopped") core.pump();
|
||||
const bool success = failure == "none";
|
||||
QCOMPARE(accepted.size(), success ? 1 : 0);
|
||||
QCOMPARE(errors.size(), success ? 0 : 1);
|
||||
QCOMPARE(core.editor()->toPlainText(), success ? QString() : text);
|
||||
QCOMPARE(core.db.getMessages(core.channel, 200).size(), int(reply) + int(success));
|
||||
@@ -312,6 +314,7 @@ private slots:
|
||||
#endif
|
||||
core.attach(); QVERIFY(core.send()); QCOMPARE(sends.size(), 2);
|
||||
QVERIFY(sends[0][2] != sends[1][2]); core.pump(); QVERIFY(core.editor()->toPlainText().isEmpty());
|
||||
QCOMPARE(accepted.size(), 1);
|
||||
QCOMPARE(core.db.getMessages(core.channel, 200).size(), int(reply) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user