diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2012-12-10 12:00:53 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-07 16:11:19 +0100 |
commit | 6ecc3e76e822b1545bcbfa78f5caf94156a026d2 (patch) | |
tree | bf846c3cb7a790e2cdff4b832866604437e1f3fe /tests/auto/corelib/tools/qrect | |
parent | 41ec7c32ace8ba89605e7923fe699de1998afbd6 (diff) |
Add API dealing with QMargins to QRect.
- Addition of a QMargin to a QRect.
- Removal of a QMargin from a QRect.
- Remove implementation from Windows platform plugin.
Change-Id: Iae54bc13e94a7ece48853b1d3f3de2bfc154d2dd
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qrect')
-rw-r--r-- | tests/auto/corelib/tools/qrect/tst_qrect.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qrect/tst_qrect.cpp b/tests/auto/corelib/tools/qrect/tst_qrect.cpp index 3bd6d1dd75..f832b97f84 100644 --- a/tests/auto/corelib/tools/qrect/tst_qrect.cpp +++ b/tests/auto/corelib/tools/qrect/tst_qrect.cpp @@ -41,6 +41,7 @@ #include <QtTest/QtTest> #include <qrect.h> +#include <qmargins.h> #include <limits.h> #include <qdebug.h> @@ -137,6 +138,7 @@ private slots: void newMoveTopLeft(); void newMoveBottomRight_data(); void newMoveBottomRight(); + void margins(); void translate_data(); void translate(); @@ -3488,6 +3490,25 @@ void tst_QRect::newMoveBottomRight() QCOMPARE(r,nr); } +void tst_QRect::margins() +{ + const QRect rectangle = QRect(QPoint(10, 10), QSize(50 ,50)); + const QMargins margins = QMargins(2, 3, 4, 5); + + const QRect added = rectangle + margins; + QCOMPARE(added, QRect(QPoint(8, 7), QSize(56, 58))); + QCOMPARE(added, margins + rectangle); + QCOMPARE(added, rectangle.marginsAdded(margins)); + + QRect a = rectangle; + a += margins; + QCOMPARE(added, a); + + a = rectangle; + a -= margins; + QCOMPARE(a, QRect(QPoint(12, 13), QSize(44, 42))); + QCOMPARE(a, rectangle.marginsRemoved(margins)); +} void tst_QRect::translate_data() { |