1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the test suite of the Qt Toolkit. |
7 ** This file is part of the test suite of the Qt Toolkit. |
8 ** |
8 ** |
482 void defineMacroViaCmdline(); |
482 void defineMacroViaCmdline(); |
483 void invokable(); |
483 void invokable(); |
484 void singleFunctionKeywordSignalAndSlot(); |
484 void singleFunctionKeywordSignalAndSlot(); |
485 void templateGtGt(); |
485 void templateGtGt(); |
486 void qprivateslots(); |
486 void qprivateslots(); |
|
487 void qprivateproperties(); |
487 void inlineSlotsWithThrowDeclaration(); |
488 void inlineSlotsWithThrowDeclaration(); |
488 void warnOnPropertyWithoutREAD(); |
489 void warnOnPropertyWithoutREAD(); |
489 void constructors(); |
490 void constructors(); |
490 void typenameWithUnsigned(); |
491 void typenameWithUnsigned(); |
491 void warnOnVirtualSignal(); |
492 void warnOnVirtualSignal(); |
1067 { |
1068 { |
1068 TestQPrivateSlots tst; |
1069 TestQPrivateSlots tst; |
1069 const QMetaObject *mobj = tst.metaObject(); |
1070 const QMetaObject *mobj = tst.metaObject(); |
1070 QVERIFY(mobj->indexOfSlot("_q_privateslot()") != -1); |
1071 QVERIFY(mobj->indexOfSlot("_q_privateslot()") != -1); |
1071 QVERIFY(mobj->indexOfMethod("method1()") != -1); //tast204730 |
1072 QVERIFY(mobj->indexOfMethod("method1()") != -1); //tast204730 |
|
1073 } |
|
1074 |
|
1075 class PrivatePropertyTest : public QObject |
|
1076 { |
|
1077 Q_OBJECT |
|
1078 Q_PROPERTY(int foo READ foo WRITE setFoo); |
|
1079 Q_PRIVATE_PROPERTY(d, int bar READ bar WRITE setBar); |
|
1080 Q_PRIVATE_PROPERTY(PrivatePropertyTest::d, int plop READ plop WRITE setPlop); |
|
1081 Q_PRIVATE_PROPERTY(PrivatePropertyTest::d_func(), int baz READ baz WRITE setBaz); |
|
1082 class MyDPointer { |
|
1083 public: |
|
1084 MyDPointer() : mBar(0), mPlop(0) {} |
|
1085 int bar() { return mBar ; } |
|
1086 void setBar(int value) { mBar = value; } |
|
1087 int plop() { return mPlop ; } |
|
1088 void setPlop(int value) { mPlop = value; } |
|
1089 int baz() { return mBaz ; } |
|
1090 void setBaz(int value) { mBaz = value; } |
|
1091 private: |
|
1092 int mBar; |
|
1093 int mPlop; |
|
1094 int mBaz; |
|
1095 }; |
|
1096 public: |
|
1097 PrivatePropertyTest() : mFoo(0), d (new MyDPointer) {} |
|
1098 int foo() { return mFoo ; } |
|
1099 void setFoo(int value) { mFoo = value; } |
|
1100 MyDPointer *d_func() {return d;} |
|
1101 private: |
|
1102 int mFoo; |
|
1103 MyDPointer *d; |
|
1104 }; |
|
1105 |
|
1106 |
|
1107 void tst_Moc::qprivateproperties() |
|
1108 { |
|
1109 PrivatePropertyTest test; |
|
1110 |
|
1111 test.setProperty("foo", 1); |
|
1112 QCOMPARE(test.property("foo"), qVariantFromValue(1)); |
|
1113 |
|
1114 test.setProperty("bar", 2); |
|
1115 QCOMPARE(test.property("bar"), qVariantFromValue(2)); |
|
1116 |
|
1117 test.setProperty("plop", 3); |
|
1118 QCOMPARE(test.property("plop"), qVariantFromValue(3)); |
|
1119 |
|
1120 test.setProperty("baz", 4); |
|
1121 QCOMPARE(test.property("baz"), qVariantFromValue(4)); |
|
1122 |
1072 } |
1123 } |
1073 |
1124 |
1074 #include "task189996.h" |
1125 #include "task189996.h" |
1075 |
1126 |
1076 void InlineSlotsWithThrowDeclaration::c() throw() {} |
1127 void InlineSlotsWithThrowDeclaration::c() throw() {} |