mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-02 11:36:18 -04:00

* 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
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#include "TestTextAttachmentsEditWidget.h"
|
|
|
|
#include <attachments/TextAttachmentsEditWidget.h>
|
|
|
|
#include <QComboBox>
|
|
#include <QMouseEvent>
|
|
#include <QPushButton>
|
|
#include <QSignalSpy>
|
|
#include <QTest>
|
|
#include <QTestMouseEvent>
|
|
#include <QTextEdit>
|
|
|
|
void TestTextAttachmentsEditWidget::initTestCase()
|
|
{
|
|
m_widget.reset(new TextAttachmentsEditWidget());
|
|
}
|
|
|
|
void TestTextAttachmentsEditWidget::testEmitTextChanged()
|
|
{
|
|
QSignalSpy textChangedSignal(m_widget.data(), &TextAttachmentsEditWidget::textChanged);
|
|
|
|
m_widget->openAttachment({.name = "test.txt", .data = {}}, attachments::OpenMode::ReadWrite);
|
|
|
|
QCoreApplication::processEvents();
|
|
|
|
auto textEdit = m_widget->findChild<QTextEdit*>("attachmentsTextEdit");
|
|
QVERIFY(textEdit);
|
|
|
|
const QByteArray NewText = "New test text";
|
|
textEdit->setText(NewText);
|
|
|
|
QVERIFY(textChangedSignal.count() > 0);
|
|
}
|
|
|
|
void TestTextAttachmentsEditWidget::testEmitPreviewButtonClicked()
|
|
{
|
|
QSignalSpy previwButtonClickedSignal(m_widget.data(), &TextAttachmentsEditWidget::previewButtonClicked);
|
|
|
|
m_widget->openAttachment({.name = "test.txt", .data = {}}, attachments::OpenMode::ReadWrite);
|
|
|
|
QCoreApplication::processEvents();
|
|
|
|
auto previewButton = m_widget->findChild<QPushButton*>("previewPushButton");
|
|
QVERIFY(previewButton);
|
|
|
|
QTest::mouseClick(previewButton, Qt::LeftButton);
|
|
|
|
QCOMPARE(previwButtonClickedSignal.count(), 1);
|
|
}
|