D15907: Compare float values in DecorationButton contains check
Vlad Zagorodniy
noreply at phabricator.kde.org
Fri Feb 22 10:07:03 GMT 2019
zzag added a comment.
void DecorationButtonTest::testContains_data()
{
QTest::addColumn<QRectF>("geometry");
QTest::addColumn<QPointF>("pos");
QTest::addColumn<bool>("contains");
QTest::newRow("left edge (integer)") << QRectF(0, 0, 10, 10) << QPointF(0, 5) << true;
QTest::newRow("top edge (integer)") << QRectF(0, 0, 10, 10) << QPointF(5, 0) << true;
QTest::newRow("right edge (integer)") << QRectF(0, 0, 10, 10) << QPointF(9, 5) << true;
QTest::newRow("bottom edge (integer)") << QRectF(0, 0, 10, 10) << QPointF(5, 9) << true;
QTest::newRow("inside (integer)") << QRectF(0, 0, 10, 10) << QPointF(5, 5) << true;
QTest::newRow("outside 1 (integer)") << QRectF(0, 0, 10, 10) << QPointF(-1, 5) << false;
QTest::newRow("outside 2 (integer)") << QRectF(0, 0, 10, 10) << QPointF(5, -1) << false;
QTest::newRow("outside 3 (integer)") << QRectF(0, 0, 10, 10) << QPointF(10, 5) << false;
QTest::newRow("outside 4 (integer)") << QRectF(0, 0, 10, 10) << QPointF(5, 10) << false;
const qreal eps = 1e-3;
QTest::newRow("left edge (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(0.1, 5.1) << true;
QTest::newRow("top edge (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(5.1, 0.1) << true;
QTest::newRow("right edge (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(10.1 - eps, 5.1) << true;
QTest::newRow("bottom edge (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(5.1, 10.1 - eps) << true;
QTest::newRow("inside (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(5.0, 5.0) << true;
QTest::newRow("outside 1 (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(0.1 - eps, 5.1) << false;
QTest::newRow("outside 2 (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(5.1, 0.1 - eps) << false;
QTest::newRow("outside 3 (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(10.1, 5.1) << false;
QTest::newRow("outside 4 (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(5.1, 10.1) << false;
QTest::newRow("outside 5 (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(10.1 + eps, 5.1) << false;
QTest::newRow("outside 6 (float)") << QRectF(0.1, 0.1, 10.0, 10.0) << QPointF(5.1, 10.1 + eps) << false;
}
void DecorationButtonTest::testContains()
{
MockBridge bridge;
MockDecoration mockDecoration(&bridge);
QFETCH(QRectF, geometry);
MockButton button(KDecoration2::DecorationButtonType::Custom, &mockDecoration);
button.setGeometry(geometry);
button.setEnabled(true);
button.setVisible(true);
QFETCH(QPointF, pos);
QTEST(button.contains(pos), "contains");
}
REPOSITORY
R129 Window Decoration Library
REVISION DETAIL
https://phabricator.kde.org/D15907
To: romangg, #kwin, zzag, davidedmundson
Cc: plasma-devel, jraleigh, GB_2, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20190222/0b22edee/attachment-0001.html>
More information about the Plasma-devel
mailing list