Commit 8dbfddff authored by Michael Brasser's avatar Michael Brasser Committed by Qt by Nokia

Test unregistered local enums in QML methods and signal handlers.

Also make sure valueC and valueD are initialized.

Change-Id: I8ee78b7b779c37ca792300c7771ae9975f43d8bb
Reviewed-by: 's avatarChris Adams <christopher.adams@nokia.com>
parent 1312f4d1
......@@ -27,10 +27,20 @@ Item {
dValue = newValue;
}
onValueEChanged: {
eValue = newValue;
}
onValueE2Changed: {
e2Value = newValue;
}
property int aValue: 0
property int bValue: 0
property int cValue: 0
property int dValue: 0
property int eValue: 0
property int e2Value: 0
}
function setEnumValues() {
......@@ -39,5 +49,7 @@ Item {
enumDerivedClass.setValueB(MyEnum2Class.B_37);
enumDerivedClass.setValueC(Qt.RichText);
enumDerivedClass.setValueD(Qt.ElideMiddle);
enumDerivedClass.setValueE(MyEnum2Class.E_14);
enumDerivedClass.setValueE2(MyEnum2Class.E_76);
}
}
......@@ -839,9 +839,11 @@ class MyEnum2Class : public QObject
{
Q_OBJECT
Q_ENUMS(EnumB)
Q_ENUMS(EnumE)
public:
MyEnum2Class() : valueA(MyEnum1Class::A_Invalid), valueB(B_Invalid) {}
MyEnum2Class() : valueA(MyEnum1Class::A_Invalid), valueB(B_Invalid), valueC(Qt::PlainText),
valueD(Qt::ElideLeft), valueE(E_Invalid), valueE2(E_Invalid) {}
enum EnumB
{
......@@ -852,27 +854,43 @@ public:
B_37 = 37
};
enum EnumE
{
E_Invalid = -1,
E_14 = 14,
E_76 = 76
};
MyEnum1Class::EnumA getValueA() { return valueA; }
EnumB getValueB() { return valueB; }
Qt::TextFormat getValueC() { return valueC; }
Qt::TextElideMode getValueD() { return valueD; }
EnumE getValueE() { return valueE; }
EnumE getValueE2() { return valueE2; }
Q_INVOKABLE void setValueA(MyEnum1Class::EnumA v) { valueA = v; emit valueAChanged(v); }
Q_INVOKABLE void setValueB(EnumB v) { valueB = v; emit valueBChanged(v); }
Q_INVOKABLE void setValueC(Qt::TextFormat v) { valueC = v; emit valueCChanged(v); } //registered
Q_INVOKABLE void setValueD(Qt::TextElideMode v) { valueD = v; emit valueDChanged(v); } //unregistered
Q_INVOKABLE void setValueE(EnumE v) { valueE = v; emit valueEChanged(v); }
Q_INVOKABLE void setValueE2(MyEnum2Class::EnumE v) { valueE2 = v; emit valueE2Changed(v); }
signals:
void valueAChanged(MyEnum1Class::EnumA newValue);
void valueBChanged(MyEnum2Class::EnumB newValue);
void valueCChanged(Qt::TextFormat newValue);
void valueDChanged(Qt::TextElideMode newValue);
void valueEChanged(EnumE newValue);
void valueE2Changed(MyEnum2Class::EnumE newValue);
private:
MyEnum1Class::EnumA valueA;
EnumB valueB;
Qt::TextFormat valueC;
Qt::TextElideMode valueD;
EnumE valueE;
EnumE valueE2;
};
class MyEnumDerivedClass : public MyEnum2Class
......
......@@ -2308,11 +2308,17 @@ void tst_qqmllanguage::globalEnums()
QVERIFY(enum2Class != 0);
QVERIFY(enum2Class->getValueA() == -1);
QVERIFY(enum2Class->getValueB() == -1);
QVERIFY(enum2Class->getValueC() == 0);
QVERIFY(enum2Class->getValueD() == 0);
QVERIFY(enum2Class->getValueE() == -1);
QVERIFY(enum2Class->getValueE2() == -1);
QVERIFY(enum2Class->property("aValue") == 0);
QVERIFY(enum2Class->property("bValue") == 0);
QVERIFY(enum2Class->property("cValue") == 0);
QVERIFY(enum2Class->property("dValue") == 0);
QVERIFY(enum2Class->property("eValue") == 0);
QVERIFY(enum2Class->property("e2Value") == 0);
QSignalSpy signalA(enum2Class, SIGNAL(valueAChanged(MyEnum1Class::EnumA)));
QSignalSpy signalB(enum2Class, SIGNAL(valueBChanged(MyEnum2Class::EnumB)));
......@@ -2324,6 +2330,8 @@ void tst_qqmllanguage::globalEnums()
QVERIFY(enum2Class->getValueB() == MyEnum2Class::B_37);
QVERIFY(enum2Class->getValueC() == Qt::RichText);
QVERIFY(enum2Class->getValueD() == Qt::ElideMiddle);
QVERIFY(enum2Class->getValueE() == MyEnum2Class::E_14);
QVERIFY(enum2Class->getValueE2() == MyEnum2Class::E_76);
QVERIFY(signalA.count() == 1);
QVERIFY(signalB.count() == 1);
......@@ -2332,6 +2340,8 @@ void tst_qqmllanguage::globalEnums()
QVERIFY(enum2Class->property("bValue") == 37);
QVERIFY(enum2Class->property("cValue") == 1);
QVERIFY(enum2Class->property("dValue") == 2);
QVERIFY(enum2Class->property("eValue") == 14);
QVERIFY(enum2Class->property("e2Value") == 76);
delete o;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment