diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-07-26 13:48:45 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-26 08:00:31 +0200 |
commit | e06211e4c67c0c7470fdac86c3fa6d50792516c5 (patch) | |
tree | fc672331a442d93f714c962efc47cbeb6b23dd3c /tests/auto/qtquick1 | |
parent | e5be1482c81fb3a502e2e5f8e56f11f182c2adab (diff) |
qmlviewer resizes the root object multiple times.
In SizeRootObjectToView mode on initial load the view was set to
root object size, then the sceneResized() slot would resize back,
then we would finally reset back to the correct value in
statusChanged(true). Now react directly to the initial size being
set.
Change-Id: Ib6977cf7bad3fe79b9ac80bb6d916fb0f57c5f5e
Fixes: QTBUG-16499
Reviewed-on: http://codereview.qt.nokia.com/2148
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/qtquick1')
-rw-r--r-- | tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 6ef2a114d7..f4fc4f0d46 100644 --- a/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -62,6 +62,20 @@ # define MENUBAR_HEIGHT(mw) (mw->menuBar()->height()) #endif + +class QDeclarativeViewerTest : public QDeclarativeViewer +{ +public: + QDeclarativeViewerTest() : QDeclarativeViewer(), resizeCount(0) {} + + void resizeEvent (QResizeEvent *event) { + QDeclarativeViewer::resizeEvent(event); + ++resizeCount; + } + + int resizeCount; +}; + class tst_QDeclarativeViewer : public QObject { @@ -288,7 +302,7 @@ void tst_QDeclarativeViewer::fileBrowser() void tst_QDeclarativeViewer::resizing() { - QDeclarativeViewer *viewer = new QDeclarativeViewer(); + QDeclarativeViewerTest *viewer = new QDeclarativeViewerTest(); QVERIFY(viewer); viewer->open(SRCDIR "/data/orientation.qml"); QVERIFY(viewer->view()); @@ -303,6 +317,8 @@ void tst_QDeclarativeViewer::resizing() TEST_INITIAL_SIZES(viewer); + QCOMPARE(viewer->resizeCount, 1); + viewer->setSizeToView(false); // size view to root object @@ -317,6 +333,8 @@ void tst_QDeclarativeViewer::resizing() QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200)); QCOMPARE(viewer->size(), QSize(150, 200 + MENUBAR_HEIGHT(viewer))); + QCOMPARE(viewer->resizeCount, 2); + // do not size root object to view viewer->resize(QSize(180,250)); QCOMPARE(rootItem->width(), 150.0); @@ -336,10 +354,14 @@ void tst_QDeclarativeViewer::resizing() QCOMPARE(viewer->size(), QSize(250, 350)); // do not size view to root object + viewer->resizeCount = 0; + rootItem->setWidth(150); rootItem->setHeight(200); QTRY_COMPARE(viewer->size(), QSize(250, 350)); + QCOMPARE(viewer->resizeCount, 0); + delete viewer; } |