Browse Source

Verify five centered previews while navigating six avatar originals

master
evgeny 6 days ago
parent
commit
7d69404532
  1. 33
      tools/chatgui/tests/test_avatars.cpp

33
tools/chatgui/tests/test_avatars.cpp

@ -131,7 +131,8 @@ private slots:
if (!view || !upload || !upload->isEnabled()) return;
const QPoint center=view->rect().center();
QTest::mousePress(view,Qt::LeftButton,Qt::NoModifier,center);
QTest::mouseMove(view,center+QPoint(1000,0)); QTest::mouseRelease(view,Qt::LeftButton,Qt::NoModifier,center+QPoint(1000,0));
const QPoint edge=center+QPoint(view->width()/2-5,0);
QTest::mouseMove(view,edge); QTest::mouseRelease(view,Qt::LeftButton,Qt::NoModifier,edge);
QTest::mouseClick(upload,Qt::LeftButton);
});
automate.start(); QRectF crop; QVERIFY(selectAvatarCrop(source,crop,nullptr)); automate.stop();
@ -262,6 +263,36 @@ private slots:
QVERIFY(next); QTest::mouseClick(next,Qt::LeftButton);
QTRY_VERIFY_WITH_TIMEOUT(viewer->grab().toImage().pixelColor(viewer->rect().center()).blue()>240,5000);
gallery->close(); QTRY_VERIFY_WITH_TIMEOUT(manager.gallery().isEmpty(),5000);
QHash<QString,QString> previous;
auto reference=[&](const QString& channel) {
uint8_t wire[CHAT_MEMBER_DISPLAY_SIZE]; chat_member_display member{};
if (chat_core_get_single_member(testInstance,channel.toLatin1().constData(),testInstance->node_id,wire)<0) return QString();
chat_core_deserialize_member(wire,&member); return QString::fromLatin1(member.avatar_file);
};
for (const auto& channel : channels) previous[channel.channelId]=reference(channel.channelId);
for (int i=0;i<4;i++) {
image.fill(QColor::fromHsv(60+i*40,255,230)); const QString path=directory.path()+QString("/extra-%1.png").arg(i);
QVERIFY(image.save(path)); manager.uploadDefault(path,testInstance->node_id);
auto published=[&] {
for (const auto& channel : channels) if (reference(channel.channelId)==previous[channel.channelId]) return false;
return true;
};
QTRY_VERIFY_WITH_TIMEOUT(published(),10000);
for (const auto& channel : channels) previous[channel.channelId]=reference(channel.channelId);
}
showAvatarGallery(channels[0].channelId,testInstance->node_id); gallery=nullptr;
for (auto* widget : QApplication::topLevelWidgets()) if (widget->windowTitle()=="Avatars") gallery=qobject_cast<QDialog*>(widget);
QVERIFY(gallery); QTRY_COMPARE_WITH_TIMEOUT(manager.gallery().size(),6,5000);
const auto album=manager.gallery(); int cursor=album.indexOf(manager.galleryCurrent());
while (cursor!=2) {
auto* button=gallery->findChild<QPushButton*>(cursor<2 ? "avatarNext" : "avatarPrevious"); QVERIFY(button);
QTest::mouseClick(button,Qt::LeftButton); cursor+=cursor<2 ? 1 : -1;
}
for (int i=0;i<5;i++) QVERIFY(gallery->findChild<QPushButton*>(QString("avatarPreview%1").arg(i))->isEnabled());
QTRY_VERIFY_WITH_TIMEOUT(!manager.galleryImage(album[2],true).isNull(),5000);
const QColor expected=manager.galleryImage(album[2],true).pixelColor(0,0); viewer=gallery->findChild<ImageViewerWindow*>();
QTRY_COMPARE_WITH_TIMEOUT(viewer->grab().toImage().pixelColor(viewer->rect().center()),expected,5000);
gallery->close(); QTRY_VERIFY_WITH_TIMEOUT(manager.gallery().isEmpty(),5000);
manager.clearDefault();
for (const auto& channel : channels) {
uint8_t wire[CHAT_MEMBER_DISPLAY_SIZE];

Loading…
Cancel
Save