aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickanchors
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-03-05 11:39:24 +1000
committerMatthew Vogt <matthew.vogt@nokia.com>2012-03-05 11:39:54 +1000
commit0284817d6cd7e17afa8da26ee6e9199100754446 (patch)
treec351d55d5a606c81c72e481f846b9b9e2603c883 /tests/auto/quick/qquickanchors
parent377eb94eb19dafeca20d12bc6b624f1779fae514 (diff)
parent36bd7f616f37f5f60e59bce1f0d8970248d627de (diff)
Merge master <-> api_changes
Diffstat (limited to 'tests/auto/quick/qquickanchors')
-rw-r--r--tests/auto/quick/qquickanchors/data/stretch.qml39
-rw-r--r--tests/auto/quick/qquickanchors/tst_qquickanchors.cpp41
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickanchors/data/stretch.qml b/tests/auto/quick/qquickanchors/data/stretch.qml
new file mode 100644
index 0000000000..64e23e30b5
--- /dev/null
+++ b/tests/auto/quick/qquickanchors/data/stretch.qml
@@ -0,0 +1,39 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400; height: 400
+
+ Rectangle {
+ id: rect1
+ x: 20; y: 20;
+ height: 360; width: 360;
+
+ Rectangle {
+ id: rect2; objectName: "stretcher"
+ anchors.verticalCenter: rect1.verticalCenter
+ anchors.bottom: rect3.top
+ anchors.horizontalCenter: rect1.horizontalCenter
+ anchors.left: rect3.left
+ }
+
+ Rectangle {
+ id: rect3
+ x: 160; y: 230
+ width: 10
+ height: 10
+ }
+
+ Rectangle {
+ id: rect4; objectName: "stretcher2"
+ anchors.verticalCenter: rect1.verticalCenter
+ anchors.top: rect5.top
+ }
+
+ Rectangle {
+ id: rect5
+ x: 160; y: 130
+ width: 10
+ height: 10
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
index 749b11f919..dd1f9f77ae 100644
--- a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
+++ b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
@@ -83,6 +83,7 @@ private slots:
void fillRTL();
void margins();
void marginsRTL();
+ void stretch();
};
void tst_qquickanchors::basicAnchors()
@@ -472,6 +473,10 @@ void tst_qquickanchors::fill()
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 30.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 40.0);
QCOMPARE(rect->x(), 0.0 + 10.0);
QCOMPARE(rect->y(), 0.0 + 30.0);
QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
@@ -481,6 +486,10 @@ void tst_qquickanchors::fill()
rectPrivate->anchors()->setRightMargin(0.0);
rectPrivate->anchors()->setBottomMargin(0.0);
rectPrivate->anchors()->setTopMargin(10.0);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 20.0);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 0.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 0.0);
QCOMPARE(rect->x(), 0.0 + 20.0);
QCOMPARE(rect->y(), 0.0 + 10.0);
QCOMPARE(rect->width(), 200.0 - 20.0);
@@ -523,11 +532,15 @@ void tst_qquickanchors::centerIn()
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), 30.0);
QCOMPARE(rect->x(), 75.0 + 10);
QCOMPARE(rect->y(), 75.0 + 30);
//Alter Offsets (tests QTBUG-6631)
rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
+ QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), -20.0);
+ QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), -10.0);
QCOMPARE(rect->x(), 75.0 - 20.0);
QCOMPARE(rect->y(), 75.0 - 10.0);
@@ -623,6 +636,11 @@ void tst_qquickanchors::margins()
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rectPrivate->anchors()->margins(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 6.0);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 10.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 10.0);
QCOMPARE(rect->x(), 5.0);
QCOMPARE(rect->y(), 6.0);
QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
@@ -631,6 +649,12 @@ void tst_qquickanchors::margins()
rectPrivate->anchors()->setTopMargin(0.0);
rectPrivate->anchors()->setMargins(20.0);
+ QCOMPARE(rectPrivate->anchors()->margins(), 20.0);
+ QEXPECT_FAIL("","QTBUG-24515", Continue);
+ QCOMPARE(rectPrivate->anchors()->topMargin(), 0.0);
+ QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0);
+ QCOMPARE(rectPrivate->anchors()->bottomMargin(), 20.0);
+ QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0);
QCOMPARE(rect->x(), 5.0);
QCOMPARE(rect->y(), 20.0);
QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
@@ -663,6 +687,23 @@ void tst_qquickanchors::marginsRTL()
delete view;
}
+void tst_qquickanchors::stretch()
+{
+ QQuickView *view = new QQuickView(testFileUrl("stretch.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("stretcher"));
+ QCOMPARE(rect->x(), 160.0);
+ QCOMPARE(rect->y(), 130.0);
+ QCOMPARE(rect->width(), 40.0);
+ QCOMPARE(rect->height(), 100.0);
+
+ QQuickRectangle* rect2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("stretcher2"));
+ QCOMPARE(rect2->y(), 130.0);
+ QCOMPARE(rect2->height(), 100.0);
+
+ delete view;
+}
QTEST_MAIN(tst_qquickanchors)