Check crop preview rendering and interrupted drags
This commit is contained in:
1 parent
0a69864d10
commit
b95d3628bf
1 file changed
+19
@@ -6,6 +6,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QTemporaryDir>
|
||||
#include <QWheelEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <functional>
|
||||
#include <cmath>
|
||||
extern "C" {
|
||||
@@ -83,6 +84,8 @@ private slots:
|
||||
QVERIFY(image.save(path)); QRectF crop;
|
||||
QVERIFY(edit(path, crop, nullptr, [&](QDialog*, QWidget* view, QPushButton* upload) {
|
||||
for (int i = 0; i < zoomSteps; i++) wheel(view, QPoint(0, 120));
|
||||
const QImage rendered = view->grab().toImage();
|
||||
QCOMPARE(rendered.pixelColor(rendered.width()/2, rendered.height()/2), QColor(Qt::green));
|
||||
upload->click();
|
||||
}));
|
||||
QVERIFY(std::isfinite(crop.x()) && std::isfinite(crop.y()) && std::isfinite(crop.width()) && std::isfinite(crop.height()));
|
||||
@@ -102,6 +105,22 @@ private slots:
|
||||
QCOMPARE(crop, before);
|
||||
}
|
||||
|
||||
void lostLeftButtonStopsDrag() {
|
||||
QTemporaryDir directory; QVERIFY(directory.isValid());
|
||||
const QString path = directory.filePath("source.png"); QImage image(800, 400, QImage::Format_RGB32); image.fill(Qt::blue);
|
||||
QVERIFY(image.save(path)); QRectF crop;
|
||||
QVERIFY(edit(path, crop, nullptr, [](QDialog*, QWidget* view, QPushButton* upload) {
|
||||
const QPoint center = view->rect().center(); QTest::mousePress(view, Qt::LeftButton, Qt::NoModifier, center);
|
||||
for (Qt::MouseButtons buttons : {Qt::MouseButtons(), Qt::MouseButtons(Qt::LeftButton)}) {
|
||||
const QPoint point = center + QPoint(240, 0);
|
||||
QMouseEvent move(QEvent::MouseMove, point, view->mapToGlobal(point), Qt::NoButton, buttons, Qt::NoModifier);
|
||||
QApplication::sendEvent(view, &move);
|
||||
}
|
||||
QTest::mouseRelease(view, Qt::LeftButton, Qt::NoModifier, center + QPoint(240, 0)); upload->click();
|
||||
}));
|
||||
QVERIFY(qAbs(crop.x() - .25) < 1e-8);
|
||||
}
|
||||
|
||||
void parentCanDisappearDuringLoad() {
|
||||
QPointer<QWidget> parent = new QWidget;
|
||||
const QRectF before(.1, .2, .3, .4); QRectF crop = before;
|
||||
|
||||
Reference in new issue
Block a user