|
|
|
|
@ -459,6 +459,30 @@ private slots:
|
|
|
|
|
if (!preview.isEmpty()) QVERIFY(view.grab().save(preview)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void phoneButtonReflectsBusyFreeUnknownAndOffline() { |
|
|
|
|
QStandardItemModel model; |
|
|
|
|
auto* peer = new QStandardItem("peer"); model.appendRow(peer); |
|
|
|
|
peer->setData(false, Qt::UserRole + 2); peer->setData(true, MemberListModel::OnlineRole); |
|
|
|
|
AccountDelegate delegate; |
|
|
|
|
QStyleOptionViewItem option; option.rect = QRect(0, 0, 280, 52); |
|
|
|
|
auto pixels = [&](int flags, bool online, const QColor& color) { |
|
|
|
|
peer->setData(flags, Qt::UserRole + 3); peer->setData(online, MemberListModel::OnlineRole); |
|
|
|
|
QImage image(option.rect.size(), QImage::Format_RGB32); image.fill(Qt::white); |
|
|
|
|
QPainter painter(&image); delegate.paint(&painter, option, model.index(0, 0)); painter.end(); |
|
|
|
|
int count = 0; |
|
|
|
|
for (int y = 0; y < image.height(); ++y) |
|
|
|
|
for (int x = image.width() - 31; x < image.width(); ++x) count += image.pixelColor(x, y) == color; |
|
|
|
|
return count; |
|
|
|
|
}; |
|
|
|
|
const int known = CHAT_MEMBER_FLAG_PHONE_KNOWN, busy = CHAT_MEMBER_FLAG_PHONE_BUSY; |
|
|
|
|
QVERIFY(pixels(known | busy, true, QColor("#E53935")) > 0); |
|
|
|
|
QVERIFY(pixels(known, true, QColor("#4CAF50")) > 0); |
|
|
|
|
QCOMPARE(pixels(0, true, QColor("#4CAF50")), 0); |
|
|
|
|
QCOMPARE(pixels(busy, true, QColor("#E53935")), 0); |
|
|
|
|
QCOMPARE(pixels(known | busy, false, QColor("#E53935")), 0); |
|
|
|
|
QCOMPARE(pixels(known | busy, true, QColor("#4CAF50")), 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void radioMuteButtonTargetsMemberAndChangesColor() { |
|
|
|
|
QStandardItemModel model; |
|
|
|
|
auto* other = new QStandardItem("other"); other->setData(false, Qt::UserRole + 2); model.appendRow(other); |
|
|
|
|
|