13.19e: 70318de verified; the Smear's allocation guards starved in WarpFailureTests; the commit's thinning and the bar's deferred finish pinned
This commit is contained in:
1 parent
3757eb8910
commit
1de10e711c
7 files changed
+142
-7
No files matched your search
@@ -8,6 +8,7 @@ class MoveBarPressTests : public QObject {
|
||||
private slots:
|
||||
void aTypedValueThenAPressDragsTheActiveLayer();
|
||||
void ctrlKeepsAFolderAsAutoSelectPicksElsewhere();
|
||||
void aValueLeftByMouseForAnotherFieldApplies();
|
||||
};
|
||||
|
||||
// Swift picks before focus moves: the active layer drags.
|
||||
@@ -69,5 +70,33 @@ void MoveBarPressTests::ctrlKeepsAFolderAsAutoSelectPicksElsewhere()
|
||||
QCOMPARE(session.activeLayerID(), std::optional(blue));
|
||||
}
|
||||
|
||||
// No canvas press: the deferred finish alone applies the value.
|
||||
void MoveBarPressTests::aValueLeftByMouseForAnotherFieldApplies()
|
||||
{
|
||||
Canvas shown;
|
||||
EditorSession &session = shown.session;
|
||||
// Wide enough that Y shows beside X.
|
||||
shown.window.resize(1000, 350);
|
||||
TransformInspector bar(session, &shown.window);
|
||||
bar.setGeometry(0, 300, 1000, 42);
|
||||
bar.show();
|
||||
QLineEdit *x = bar.findChild<QLineEdit *>(QStringLiteral("transformX"));
|
||||
QLineEdit *y = bar.findChild<QLineEdit *>(QStringLiteral("transformY"));
|
||||
QVERIFY(x && y);
|
||||
x->setFocus();
|
||||
QTRY_VERIFY(x->hasFocus());
|
||||
x->selectAll();
|
||||
QTest::keyClicks(x, "12");
|
||||
QVERIFY(session.transformEdit().value().fromFields);
|
||||
const int steps = session.history.undoCount();
|
||||
QWindow *window = shown.window.windowHandle();
|
||||
const QPoint inY = y->mapTo(&shown.window, y->rect().center());
|
||||
QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, inY);
|
||||
QTRY_VERIFY(y->hasFocus());
|
||||
QTRY_VERIFY(!session.transformEdit().has_value());
|
||||
QCOMPARE(shown.origin(), QPointF(12, 100));
|
||||
QCOMPARE(session.history.undoCount(), steps + 1);
|
||||
}
|
||||
|
||||
QTEST_MAIN(MoveBarPressTests)
|
||||
#include "MoveBarPressTests.moc"
|
||||
@@ -42,6 +42,7 @@ compositor_test(CloneStampTests)
|
||||
compositor_test(CloneStampCanvasTests)
|
||||
compositor_test(SmudgeLiquifyTests)
|
||||
compositor_test(WarpStrokeTests)
|
||||
compositor_test(WarpFailureTests)
|
||||
compositor_test(LargeCanvasBrushTests)
|
||||
compositor_test(BlurBrushTests)
|
||||
compositor_test(BlurToolTests)
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#include "AddressSpaceLimit.h"
|
||||
#include "BrushFixtures.h"
|
||||
#include "Document/SmudgeLiquify.h"
|
||||
#include "IO/ImageExporter.h"
|
||||
#include <QtTest>
|
||||
#include <malloc.h>
|
||||
|
||||
// The Smear's buffers, starved of memory mid-stroke.
|
||||
namespace {
|
||||
WarpStroke warp(const QImage &image, BlurToolMode mode, const BrushSettings &settings)
|
||||
{
|
||||
const ImageLayer layer(ImportedImage(image, image, QStringLiteral("Picture")), QPointF(0, 0));
|
||||
return WarpStroke(layer, image, layer.transform, QSizeF(image.size()), mode, settings);
|
||||
}
|
||||
|
||||
QImage stripes(int side)
|
||||
{
|
||||
QImage image = BrushRaster::context(side, side, false);
|
||||
for (int x = 0; x < side; ++x)
|
||||
QPainter(&image).fillRect(x, 0, 1, side, x % 2 ? Qt::red : Qt::blue);
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
class WarpFailureTests : public QObject {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
// Large asks map memory, so the address limit counts them.
|
||||
void initTestCase() { mallopt(M_MMAP_THRESHOLD, 64 * 1024); }
|
||||
void aLiquifyDabWithoutScratchIsSkipped();
|
||||
void smudgeWithoutRoomToCarryIsARenderError();
|
||||
void liquifyWithoutItsOffsetsIsARenderError();
|
||||
};
|
||||
|
||||
void WarpFailureTests::aLiquifyDabWithoutScratchIsSkipped()
|
||||
{
|
||||
const QImage image = stripes(2400);
|
||||
WarpStroke stroke = warp(image, BlurToolMode::liquify, brush(2000, 0.5, 0, 0, 0, 1));
|
||||
stroke.append(QPointF(1200, 1200));
|
||||
{
|
||||
// The dab's scratch, about 33 MB, cannot be had.
|
||||
const AddressSpaceLimit limit(8ll * 1024 * 1024);
|
||||
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("a Liquify dab finds no memory"));
|
||||
stroke.append(QPointF(1250, 1200));
|
||||
}
|
||||
QCOMPARE(stroke.image(), image);
|
||||
// With memory back the next dab pushes.
|
||||
stroke.append(QPointF(1300, 1200));
|
||||
QVERIFY(stroke.image() != image);
|
||||
}
|
||||
|
||||
void WarpFailureTests::smudgeWithoutRoomToCarryIsARenderError()
|
||||
{
|
||||
const QImage image = stripes(2400);
|
||||
WarpStroke stroke = warp(image, BlurToolMode::smudge, brush(2000, 0.5, 0, 0, 0, 1));
|
||||
{
|
||||
// The carried colour, about 64 MB, cannot be had.
|
||||
const AddressSpaceLimit limit(8ll * 1024 * 1024);
|
||||
try {
|
||||
stroke.append(QPointF(1200, 1200));
|
||||
QFAIL("the carried colour was had");
|
||||
} catch (const ExportError &error) {
|
||||
QCOMPARE(error.kind, ExportError::Kind::render);
|
||||
}
|
||||
}
|
||||
QCOMPARE(stroke.image(), image);
|
||||
}
|
||||
|
||||
void WarpFailureTests::liquifyWithoutItsOffsetsIsARenderError()
|
||||
{
|
||||
// Room for two 36 MB copies, not the offsets.
|
||||
const QImage image = stripes(3000);
|
||||
{
|
||||
const AddressSpaceLimit limit(90ll * 1024 * 1024);
|
||||
try {
|
||||
warp(image, BlurToolMode::liquify, brush(100, 0.5, 0, 0, 0, 1));
|
||||
QFAIL("the offsets were had");
|
||||
} catch (const ExportError &error) {
|
||||
QCOMPARE(error.kind, ExportError::Kind::render);
|
||||
}
|
||||
}
|
||||
// Smudge needs neither.
|
||||
{
|
||||
const AddressSpaceLimit limit(52ll * 1024 * 1024);
|
||||
QCOMPARE(warp(image, BlurToolMode::smudge, brush(100, 0.5, 0, 0, 0, 1)).image(), image);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(WarpFailureTests)
|
||||
#include "WarpFailureTests.moc"
|
||||
@@ -111,6 +111,18 @@ void WarpStrokeTests::aCommitKeepsATwentiethAndTheLastPoint()
|
||||
QCOMPARE(kept[6], stroke.points()[18]);
|
||||
// Two and a half from the previous, kept as last.
|
||||
QCOMPARE(kept.back(), QPointF(51, 10));
|
||||
// Exactly the spacing apart is kept: a 40 brush.
|
||||
WarpStroke even = warp(image, BlurToolMode::liquify, brush(40, 0.5, 0, 0, 0, 1));
|
||||
even.append(QPointF(0, 10));
|
||||
even.append(QPointF(10, 10));
|
||||
QCOMPARE(even.committedPoints(), (std::vector<QPointF>{{1, 10}, {3, 10}, {5, 10}, {7, 10}, {9, 10}, {10, 10}}));
|
||||
// A small brush still keeps points a pixel apart.
|
||||
WarpStroke small = warp(image, BlurToolMode::liquify, brush(10, 0.5, 0, 0, 0, 1));
|
||||
small.append(QPointF(0, 10));
|
||||
small.append(QPointF(1.5, 10));
|
||||
small.append(QPointF(3, 10));
|
||||
QCOMPARE(small.points().size(), size_t(4));
|
||||
QCOMPARE(small.committedPoints(), (std::vector<QPointF>{{0.75, 10}, {2.25, 10}, {3, 10}}));
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(WarpStrokeTests)
|
||||
|
||||
Reference in new issue
Block a user