aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2016-05-18 15:17:37 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2016-05-18 15:17:37 +0200
commit5861dc4869e2bb313a0ea20d39b3c7a198664acf (patch)
tree24538a98ddd31e11dce2bc25b7744c59a8792fed /tests
parent709f6370884b110def2e4665df8fa7bbf5fae734 (diff)
parentb9e4a4df577959579b2322fb6077bde82d9ffce3 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: src/qml/qml/v8/qqmlbuiltinfunctions_p.h tests/auto/qml/qqmlqt/tst_qqmlqt.cpp Change-Id: I9dd93732f4b19513576ca1dd89ae18c69de0203b
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlqt/data/qtObjectContents.qml10
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp46
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp6
3 files changed, 60 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmlqt/data/qtObjectContents.qml b/tests/auto/qml/qqmlqt/data/qtObjectContents.qml
new file mode 100644
index 0000000000..c85e7986e9
--- /dev/null
+++ b/tests/auto/qml/qqmlqt/data/qtObjectContents.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+
+QtObject {
+ property var values: Object()
+ Component.onCompleted: {
+ for (var key in Qt) {
+ values[key] = Qt[key]
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
index 413feb0eb4..8150241e4a 100644
--- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -90,6 +90,7 @@ private slots:
void resolvedUrl();
void later_data();
void later();
+ void qtObjectContents();
private:
QQmlEngine engine;
@@ -1093,6 +1094,51 @@ void tst_qqmlqt::later()
delete root;
}
+void tst_qqmlqt::qtObjectContents()
+{
+ struct StaticQtMetaObject : public QObject
+ {
+ static const QMetaObject *get()
+ { return &staticQtMetaObject; }
+ };
+
+ QQmlComponent component(&engine, testFileUrl("qtObjectContents.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("values").canConvert<QJSValue>());
+ QVariantMap values = object->property("values").value<QJSValue>().toVariant().toMap();
+
+ QSet<const char *> keys;
+ int uniqueKeys = 0;
+ const QMetaObject *qtMetaObject = StaticQtMetaObject::get();
+ for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) {
+ QMetaEnum enumerator = qtMetaObject->enumerator(ii);
+ for (int jj = 0; jj < enumerator.keyCount(); ++jj) {
+ auto key = enumerator.key(jj);
+// qDebug() << "key:" << key;
+ if (!keys.contains(key)) {
+ ++uniqueKeys;
+ keys.insert(key);
+ }
+ QVERIFY(values.contains(key));
+ QVariant value = values.value(key);
+ QVERIFY(value.canConvert<int>());
+ QCOMPARE(value.toInt(), enumerator.value(jj));
+ }
+ }
+ QVERIFY(values.contains("Asynchronous"));
+ QCOMPARE(values.value("Asynchronous").toInt(), 0);
+ ++uniqueKeys;
+ QVERIFY(values.contains("Synchronous"));
+ QCOMPARE(values.value("Synchronous").toInt(), 1);
+ ++uniqueKeys;
+ QCOMPARE(values.count(), uniqueKeys);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qqmlqt)
#include "tst_qqmlqt.moc"
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 79d4adbb3d..8b7d8c0711 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -915,8 +915,10 @@ void tst_qquicktext::hAlignImplicitWidth()
// Try to check whether alignment works by checking the number of black
// pixels in the thirds of the grabbed image.
- const int windowWidth = 220;
- const int textWidth = qCeil(text->implicitWidth());
+ // QQuickWindow::grabWindow() scales the returned image by the devicePixelRatio of the screen.
+ const qreal devicePixelRatio = view.screen()->devicePixelRatio();
+ const int windowWidth = 220 * devicePixelRatio;
+ const int textWidth = qCeil(text->implicitWidth()) * devicePixelRatio;
QVERIFY2(textWidth < windowWidth, "System font too large.");
const int sectionWidth = textWidth / 3;
const int centeredSection1 = (windowWidth - textWidth) / 2;