Files
keepassxreboot-keepassxc/tests/gui/attachments/TestTextAttachmentsPreviewWidget.cpp
Sami Vänttinen 7c7ca4575e WIP: Qt6 transition (#11651)
Update KeePassXC to use Qt 6.
2026-05-04 15:16:51 +03:00

39 lines
1.2 KiB
C++

#include "TestTextAttachmentsPreviewWidget.h"
#include <attachments/TextAttachmentsPreviewWidget.h>
#include <QComboBox>
#include <QTest>
void TestTextAttachmentsPreviewWidget::initTestCase()
{
m_widget.reset(new TextAttachmentsPreviewWidget());
}
void TestTextAttachmentsPreviewWidget::testDetectMimeByFile()
{
const auto combobox = m_widget->findChild<QComboBox*>("typeComboBox");
QVERIFY(combobox);
const attachments::Attachment Text{.name = "test.txt", .data = {}};
m_widget->openAttachment(Text, attachments::OpenMode::ReadOnly);
QCoreApplication::processEvents();
QCOMPARE(combobox->currentData().toInt(), TextAttachmentsPreviewWidget::PlainText);
const attachments::Attachment Html{.name = "test.html", .data = {}};
m_widget->openAttachment(Html, attachments::OpenMode::ReadOnly);
QCoreApplication::processEvents();
QCOMPARE(combobox->currentData().toInt(), TextAttachmentsPreviewWidget::Html);
const attachments::Attachment Markdown{.name = "test.md", .data = {}};
m_widget->openAttachment(Markdown, attachments::OpenMode::ReadOnly);
QCoreApplication::processEvents();
QCOMPARE(combobox->currentData().toInt(), TextAttachmentsPreviewWidget::Markdown);
}