From 4b4015f960ee94a7e244a7ca49297c68446984b0 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 19 Aug 2009 11:42:54 +1000 Subject: Update Positioner Tests Note that it still doesn't pass tests, due at least partially to an error in the test code. This change also slips in a change to the QLayoutItem example less of a bad example of how to integrate QGraphicsLayouts. --- examples/declarative/layouts/layouts.qml | 40 ++--- .../auto/declarative/layouts/data/grid-margin.qml | 40 ----- .../layouts/data/grid-spacing-margin.qml | 41 ------ .../auto/declarative/layouts/data/grid-spacing.qml | 2 +- tests/auto/declarative/layouts/data/grid.qml | 2 +- .../declarative/layouts/data/horizontal-margin.qml | 27 ---- .../layouts/data/horizontal-spacing-margin.qml | 28 ---- .../layouts/data/horizontal-spacing.qml | 2 +- tests/auto/declarative/layouts/data/horizontal.qml | 2 +- .../declarative/layouts/data/vertical-margin.qml | 27 ---- .../layouts/data/vertical-spacing-margin.qml | 28 ---- .../declarative/layouts/data/vertical-spacing.qml | 2 +- tests/auto/declarative/layouts/data/vertical.qml | 2 +- tests/auto/declarative/layouts/tst_layouts.cpp | 163 --------------------- 14 files changed, 26 insertions(+), 380 deletions(-) delete mode 100644 tests/auto/declarative/layouts/data/grid-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/grid-spacing-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/horizontal-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/vertical-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/vertical-spacing-margin.qml diff --git a/examples/declarative/layouts/layouts.qml b/examples/declarative/layouts/layouts.qml index d049e0a..1f6b956 100644 --- a/examples/declarative/layouts/layouts.qml +++ b/examples/declarative/layouts/layouts.qml @@ -1,25 +1,25 @@ import Qt 4.6 -QGraphicsView{ -QGraphicsScene{ -QGraphicsWidget{ - visible: true - opacity: 1 - geometry: "0,0,400x400" - layout: QGraphicsLinearLayout{ - LayoutItem{ - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rect { color: "yellow"; anchors.fill: parent } - } - LayoutItem{ - minimumSize: "100x100" - maximumSize: "400x400" - preferredSize: "200x200" - Rect { color: "green"; anchors.fill: parent } +Item { id: resizable + width:400; height:400; + GraphicsObjectContainer{ + anchors.fill:parent + QGraphicsWidget{ + geometry:{ "0,0," + parent.width.toString() + "x" + parent.height.toString(); } + layout: QGraphicsLinearLayout{ + LayoutItem{ + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rect { color: "yellow"; anchors.fill: parent } + } + LayoutItem{ + minimumSize: "100x100" + maximumSize: "400x400" + preferredSize: "200x200" + Rect { color: "green"; anchors.fill: parent } + } + } } } } -} -} diff --git a/tests/auto/declarative/layouts/data/grid-margin.qml b/tests/auto/declarative/layouts/data/grid-margin.qml deleted file mode 100644 index a49dc85..0000000 --- a/tests/auto/declarative/layouts/data/grid-margin.qml +++ /dev/null @@ -1,40 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - GridLayout { - columns: 3 - margin: 8 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "green" - width: 20 - height: 50 - } - Rect { - id: three - color: "blue" - width: 50 - height: 20 - } - Rect { - id: four - color: "cyan" - width: 50 - height: 50 - } - Rect { - id: five - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/declarative/layouts/data/grid-spacing-margin.qml b/tests/auto/declarative/layouts/data/grid-spacing-margin.qml deleted file mode 100644 index d2fe4f6..0000000 --- a/tests/auto/declarative/layouts/data/grid-spacing-margin.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - GridLayout { - columns: 3 - spacing: 4 - margin: 8 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "green" - width: 20 - height: 50 - } - Rect { - id: three - color: "blue" - width: 50 - height: 20 - } - Rect { - id: four - color: "cyan" - width: 50 - height: 50 - } - Rect { - id: five - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/declarative/layouts/data/grid-spacing.qml b/tests/auto/declarative/layouts/data/grid-spacing.qml index 704e3f2..f8b5620 100644 --- a/tests/auto/declarative/layouts/data/grid-spacing.qml +++ b/tests/auto/declarative/layouts/data/grid-spacing.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - GridLayout { + GridPositioner { columns: 3 spacing: 4 Rect { diff --git a/tests/auto/declarative/layouts/data/grid.qml b/tests/auto/declarative/layouts/data/grid.qml index 2f60f16..2fbc37c 100644 --- a/tests/auto/declarative/layouts/data/grid.qml +++ b/tests/auto/declarative/layouts/data/grid.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - GridLayout { + GridPositioner { columns: 3 Rect { id: one diff --git a/tests/auto/declarative/layouts/data/horizontal-margin.qml b/tests/auto/declarative/layouts/data/horizontal-margin.qml deleted file mode 100644 index a96db02..0000000 --- a/tests/auto/declarative/layouts/data/horizontal-margin.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - HorizontalLayout { - margin: 10 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "red" - width: 20 - height: 10 - } - Rect { - id: three - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml b/tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml deleted file mode 100644 index 82957be..0000000 --- a/tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml +++ /dev/null @@ -1,28 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - HorizontalLayout { - spacing: 5 - margin: 10 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "red" - width: 20 - height: 10 - } - Rect { - id: three - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing.qml b/tests/auto/declarative/layouts/data/horizontal-spacing.qml index 8c55ae9..25dad8a 100644 --- a/tests/auto/declarative/layouts/data/horizontal-spacing.qml +++ b/tests/auto/declarative/layouts/data/horizontal-spacing.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - HorizontalLayout { + HorizontalPositioner { spacing: 10 Rect { id: one diff --git a/tests/auto/declarative/layouts/data/horizontal.qml b/tests/auto/declarative/layouts/data/horizontal.qml index 286b90b..4bce504 100644 --- a/tests/auto/declarative/layouts/data/horizontal.qml +++ b/tests/auto/declarative/layouts/data/horizontal.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - HorizontalLayout { + HorizontalPositioner { Rect { id: one color: "red" diff --git a/tests/auto/declarative/layouts/data/vertical-margin.qml b/tests/auto/declarative/layouts/data/vertical-margin.qml deleted file mode 100644 index a7e10ea..0000000 --- a/tests/auto/declarative/layouts/data/vertical-margin.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - VerticalLayout { - margin: 10 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "red" - width: 20 - height: 10 - } - Rect { - id: three - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/declarative/layouts/data/vertical-spacing-margin.qml b/tests/auto/declarative/layouts/data/vertical-spacing-margin.qml deleted file mode 100644 index 828ae61..0000000 --- a/tests/auto/declarative/layouts/data/vertical-spacing-margin.qml +++ /dev/null @@ -1,28 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - VerticalLayout { - spacing: 5 - margin: 10 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "red" - width: 20 - height: 10 - } - Rect { - id: three - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/declarative/layouts/data/vertical-spacing.qml b/tests/auto/declarative/layouts/data/vertical-spacing.qml index 8d3e86f..aa704be 100644 --- a/tests/auto/declarative/layouts/data/vertical-spacing.qml +++ b/tests/auto/declarative/layouts/data/vertical-spacing.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - VerticalLayout { + VerticalPositioner { spacing: 10 Rect { id: one diff --git a/tests/auto/declarative/layouts/data/vertical.qml b/tests/auto/declarative/layouts/data/vertical.qml index 960f10a..0a52126 100644 --- a/tests/auto/declarative/layouts/data/vertical.qml +++ b/tests/auto/declarative/layouts/data/vertical.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - VerticalLayout { + VerticalPositioner { Rect { id: one color: "red" diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp index 732551c..466a7de 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/layouts/tst_layouts.cpp @@ -13,16 +13,10 @@ public: private slots: void test_horizontal(); void test_horizontal_spacing(); - void test_horizontal_margin(); - void test_horizontal_spacing_margin(); void test_vertical(); void test_vertical_spacing(); - void test_vertical_margin(); - void test_vertical_spacing_margin(); void test_grid(); void test_grid_spacing(); - void test_grid_margin(); - void test_grid_spacing_margin(); private: QFxView *createView(const QString &filename); @@ -82,54 +76,6 @@ void tst_QFxLayouts::test_horizontal_spacing() QCOMPARE(three->y(), 0.0); } -void tst_QFxLayouts::test_horizontal_margin() -{ - QFxView *canvas = createView(SRCDIR "/data/horizontal-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 10.0); - QCOMPARE(one->y(), 10.0); - QCOMPARE(two->x(), 60.0); - QCOMPARE(two->y(), 10.0); - QCOMPARE(three->x(), 80.0); - QCOMPARE(three->y(), 10.0); -} - -void tst_QFxLayouts::test_horizontal_spacing_margin() -{ - QFxView *canvas = createView(SRCDIR "/data/horizontal-spacing-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 10.0); - QCOMPARE(one->y(), 10.0); - QCOMPARE(two->x(), 65.0); - QCOMPARE(two->y(), 10.0); - QCOMPARE(three->x(), 90.0); - QCOMPARE(three->y(), 10.0); -} - void tst_QFxLayouts::test_vertical() { QFxView *canvas = createView(SRCDIR "/data/vertical.qml"); @@ -178,54 +124,6 @@ void tst_QFxLayouts::test_vertical_spacing() QCOMPARE(three->y(), 80.0); } -void tst_QFxLayouts::test_vertical_margin() -{ - QFxView *canvas = createView(SRCDIR "/data/vertical-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 10.0); - QCOMPARE(one->y(), 10.0); - QCOMPARE(two->x(), 10.0); - QCOMPARE(two->y(), 60.0); - QCOMPARE(three->x(), 10.0); - QCOMPARE(three->y(), 70.0); -} - -void tst_QFxLayouts::test_vertical_spacing_margin() -{ - QFxView *canvas = createView(SRCDIR "/data/vertical-spacing-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 10.0); - QCOMPARE(one->y(), 10.0); - QCOMPARE(two->x(), 10.0); - QCOMPARE(two->y(), 65.0); - QCOMPARE(three->x(), 10.0); - QCOMPARE(three->y(), 80.0); -} - void tst_QFxLayouts::test_grid() { QFxView *canvas = createView("data/grid.qml"); @@ -286,67 +184,6 @@ void tst_QFxLayouts::test_grid_spacing() QCOMPARE(five->y(), 54.0); } -void tst_QFxLayouts::test_grid_margin() -{ - QFxView *canvas = createView("data/grid-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - QFxRect *four = findItem(canvas->root(), "four"); - QVERIFY(four != 0); - QFxRect *five = findItem(canvas->root(), "five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 8.0); - QCOMPARE(one->y(), 8.0); - QCOMPARE(two->x(), 58.0); - QCOMPARE(two->y(), 8.0); - QCOMPARE(three->x(), 78.0); - QCOMPARE(three->y(), 8.0); - QCOMPARE(four->x(), 8.0); - QCOMPARE(four->y(), 58.0); - QCOMPARE(five->x(), 58.0); - QCOMPARE(five->y(), 58.0); -} - - -void tst_QFxLayouts::test_grid_spacing_margin() -{ - QFxView *canvas = createView("data/grid-spacing-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - QFxRect *four = findItem(canvas->root(), "four"); - QVERIFY(four != 0); - QFxRect *five = findItem(canvas->root(), "five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 8.0); - QCOMPARE(one->y(), 8.0); - QCOMPARE(two->x(), 62.0); - QCOMPARE(two->y(), 8.0); - QCOMPARE(three->x(), 86.0); - QCOMPARE(three->y(), 8.0); - QCOMPARE(four->x(), 8.0); - QCOMPARE(four->y(), 62.0); - QCOMPARE(five->x(), 62.0); - QCOMPARE(five->y(), 62.0); -} - QFxView *tst_QFxLayouts::createView(const QString &filename) { QFxView *canvas = new QFxView(0); -- cgit v0.12