summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-02-17 09:23:29 +0100
committerDavid Faure <david.faure@kdab.com>2015-02-26 09:49:10 +0000
commit05e0dfa0060aab80afc696161226b2ab0cddfbf9 (patch)
treec848d937af71a450f940d4226cb867429ad976a5 /tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp
parent081afb2a16eb9a85458d32b2365b301115fd2119 (diff)
Reverse iteration in QMetaEnum::valueToKeys().
Otherwise, values that are composed of others are not handled correctly. For example, Qt::Dialog|Qt::FramelessWindowHint (Qt::Dialog=0x2|Qt::Window) is currently output as "Window|FramelessWindowHint" since Qt::Window matches first and its bits are removed from the flag value so that Qt::Dialog in the next iteration no longer matches. Change-Id: I67db5c977c75f887392aa8f345c5e6e9d82c5c26 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp')
-rw-r--r--tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp b/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp
index e81e105bfb..17b00ebf63 100644
--- a/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp
+++ b/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp
@@ -46,6 +46,8 @@ public:
private slots:
void fromType();
+ void valuesToKeys_data();
+ void valuesToKeys();
};
void tst_QMetaEnum::fromType()
@@ -57,5 +59,37 @@ void tst_QMetaEnum::fromType()
QCOMPARE(meta.keyCount(), 2);
}
+Q_DECLARE_METATYPE(Qt::WindowFlags)
+
+void tst_QMetaEnum::valuesToKeys_data()
+{
+ QTest::addColumn<Qt::WindowFlags>("windowFlags");
+ QTest::addColumn<QByteArray>("expected");
+
+ QTest::newRow("Window")
+ << Qt::WindowFlags(Qt::Window)
+ << QByteArrayLiteral("Window");
+
+ // Verify that Qt::Dialog does not cause 'Window' to appear in the output.
+ QTest::newRow("Frameless_Dialog")
+ << (Qt::Dialog | Qt::FramelessWindowHint)
+ << QByteArrayLiteral("Dialog|FramelessWindowHint");
+
+ // Similarly, Qt::WindowMinMaxButtonsHint should not show up as
+ // WindowMinimizeButtonHint|WindowMaximizeButtonHint
+ QTest::newRow("Tool_MinMax_StaysOnTop")
+ << (Qt::Tool | Qt::WindowMinMaxButtonsHint | Qt::WindowStaysOnTopHint)
+ << QByteArrayLiteral("Tool|WindowMinMaxButtonsHint|WindowStaysOnTopHint");
+}
+
+void tst_QMetaEnum::valuesToKeys()
+{
+ QFETCH(Qt::WindowFlags, windowFlags);
+ QFETCH(QByteArray, expected);
+
+ QMetaEnum me = QMetaEnum::fromType<Qt::WindowFlags>();
+ QCOMPARE(me.valueToKeys(windowFlags), expected);
+}
+
QTEST_MAIN(tst_QMetaEnum)
#include "tst_qmetaenum.moc"