From b2f9f3f2157629eae2544cf6fa2215b26e4e5a84 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 6 Nov 2009 13:49:08 +1000 Subject: Test more anchors. --- tests/auto/declarative/anchors/data/anchors.qml | 27 +++++++++++++++++++++++++ tests/auto/declarative/anchors/tst_anchors.cpp | 16 +++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/tests/auto/declarative/anchors/data/anchors.qml b/tests/auto/declarative/anchors/data/anchors.qml index 377dd2d..765e5b6 100644 --- a/tests/auto/declarative/anchors/data/anchors.qml +++ b/tests/auto/declarative/anchors/data/anchors.qml @@ -114,4 +114,31 @@ Rectangle { y: 70; width: 10; height: 10 anchors.horizontalCenter: parent.left } + Rectangle { + id: Rect22; objectName: "Rect22" + width: 10; height: 10 + anchors.centerIn: MasterRect + } + Rectangle { + id: Rect23; objectName: "Rect23" + anchors.left: MasterRect.left + anchors.leftMargin: 5 + anchors.right: MasterRect.right + anchors.rightMargin: 5 + anchors.top: MasterRect.top + anchors.topMargin: 5 + anchors.bottom: MasterRect.bottom + anchors.bottomMargin: 5 + } + Text { + id: text1; objectName: "text1" + y: 200; + text: "Hello" + } + Text { + id: text2; objectName: "text2" + anchors.baseline: text1.baseline + anchors.left: text1.right + text: "World" + } } diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index 8abf04f..c3a857c 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -131,6 +132,21 @@ void tst_anchors::basicAnchors() QCOMPARE(findItem(view->root(), QLatin1String("Rect20"))->x(), 235.0); QCOMPARE(findItem(view->root(), QLatin1String("Rect21"))->x(), -5.0); + //centerIn + QCOMPARE(findItem(view->root(), QLatin1String("Rect22"))->x(), 69.0); + QCOMPARE(findItem(view->root(), QLatin1String("Rect22"))->y(), 5.0); + + //margins + QCOMPARE(findItem(view->root(), QLatin1String("Rect23"))->x(), 31.0); + QCOMPARE(findItem(view->root(), QLatin1String("Rect23"))->y(), 5.0); + QCOMPARE(findItem(view->root(), QLatin1String("Rect23"))->width(), 86.0); + QCOMPARE(findItem(view->root(), QLatin1String("Rect23"))->height(), 10.0); + + //baseline + QmlGraphicsText *text1 = findItem(view->root(), QLatin1String("text1")); + QmlGraphicsText *text2 = findItem(view->root(), QLatin1String("text2")); + QCOMPARE(text1->y(), text2->y()); + delete view; } -- cgit v0.12