aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickview
diff options
context:
space:
mode:
authorAlexandr Akulich <akulichalexander@gmail.com>2016-06-02 23:59:04 +0500
committerShawn Rutledge <shawn.rutledge@qt.io>2016-07-12 11:15:57 +0000
commit2418a36d0a83c22a12654caa5138a0bc4f84e9f3 (patch)
tree230b1e729aad4e54c678a3e60093e826f2f53434 /tests/auto/quick/qquickview
parent5f4eb78ccb0639ec77b45ae1a94c137a77e74d8c (diff)
Set width and height simultaneously on SizeRootObjectToView
On QQuickView/QQuickWidget size update we used set width (with the notify signal emission) and then height (with signal emission again). This way code, relying on width and height would be triggered twice and at the first time with there would be outdated height value. The new code takes care on proper value for both width and height. Change-Id: I6525911c40af0ca6a26ab3e7dac16d32a96d9a27 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickview')
-rw-r--r--tests/auto/quick/qquickview/tst_qquickview.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp
index 05922ae20f..200f769a65 100644
--- a/tests/auto/quick/qquickview/tst_qquickview.cpp
+++ b/tests/auto/quick/qquickview/tst_qquickview.cpp
@@ -36,6 +36,30 @@
#include <QtCore/QDebug>
#include <QtQml/qqmlengine.h>
+class SizeChangesListener : public QObject, public QVector<QSize>
+{
+ Q_OBJECT
+public:
+ explicit SizeChangesListener(QQuickItem *item);
+private slots:
+ void onSizeChanged();
+private:
+ QQuickItem *item;
+
+};
+
+SizeChangesListener::SizeChangesListener(QQuickItem *item) :
+ item(item)
+{
+ connect(item, &QQuickItem::widthChanged, this, &SizeChangesListener::onSizeChanged);
+ connect(item, &QQuickItem::heightChanged, this, &SizeChangesListener::onSizeChanged);
+}
+
+void SizeChangesListener::onSizeChanged()
+{
+ append(QSize(item->width(), item->height()));
+}
+
class tst_QQuickView : public QQmlDataTest
{
Q_OBJECT
@@ -139,8 +163,15 @@ void tst_QQuickView::resizemodeitem()
QCOMPARE(QSize(item->width(), item->height()), view->sizeHint());
// size update from view
+ SizeChangesListener sizeListener(item);
view->resize(QSize(200,300));
QTRY_COMPARE(item->width(), 200.0);
+
+ for (int i = 0; i < sizeListener.count(); ++i) {
+ // Check that we have the correct geometry on all signals
+ QCOMPARE(sizeListener.at(i), view->size());
+ }
+
QCOMPARE(item->height(), 300.0);
QCOMPARE(view->size(), QSize(200, 300));
QCOMPARE(view->size(), view->sizeHint());