keepassxc/tests/gui/attachments/TestTextAttachmentsPreviewWidget.cpp
Kuznetsov Oleg f2a4cc7e66
Refactor attachment handling system with enhanced UI (#12085)
* Renamed NewEntryAttachmentsDialog to EditEntryAttachmentsDialog for clarity.
* Introduced EditEntryAttachmentsDialog class to manage editing of existing attachments.
* Added functionality to preview attachments while editing them.
* Enhanced EntryAttachmentsModel with rowByKey method for better key management.
* Add image attachment support with zoom functionality.
* Add html and markdown detection.
* Improve button layout on the attachment section when editing an entry
2025-06-19 13:27:23 -04:00

40 lines
1.3 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);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
const attachments::Attachment Markdown{.name = "test.md", .data = {}};
m_widget->openAttachment(Markdown, attachments::OpenMode::ReadOnly);
QCoreApplication::processEvents();
QCOMPARE(combobox->currentData().toInt(), TextAttachmentsPreviewWidget::Markdown);
#endif
}