summaryrefslogtreecommitdiffstats
path: root/tests/auto/moc
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2010-03-17 00:29:17 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2010-03-19 05:01:45 (GMT)
commit78e1a866ba5d594233db80f7aab88331db237d3a (patch)
tree8e9a05b5fa6db273a7de2528e7c1b611a4372cda /tests/auto/moc
parent4537b52520e0829ba89666c114d8da14d74b768e (diff)
downloadQt-78e1a866ba5d594233db80f7aab88331db237d3a.zip
Qt-78e1a866ba5d594233db80f7aab88331db237d3a.tar.gz
Qt-78e1a866ba5d594233db80f7aab88331db237d3a.tar.bz2
Implement Q_PRIVATE_PROPERTY that allows you to declare properties
where the read/write are in the d pointer. Works like Q_PRIVATE_SLOT. Reviewed-by:olivier Reviewed-by:akennedy Reviewed-by:warwick allison
Diffstat (limited to 'tests/auto/moc')
-rw-r--r--tests/auto/moc/tst_moc.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index fad4845..30c2721 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -484,6 +484,7 @@ private slots:
void singleFunctionKeywordSignalAndSlot();
void templateGtGt();
void qprivateslots();
+ void qprivateproperties();
void inlineSlotsWithThrowDeclaration();
void warnOnPropertyWithoutREAD();
void constructors();
@@ -1071,6 +1072,56 @@ void tst_Moc::qprivateslots()
QVERIFY(mobj->indexOfMethod("method1()") != -1); //tast204730
}
+class PrivatePropertyTest : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo WRITE setFoo);
+ Q_PRIVATE_PROPERTY(d, int bar READ bar WRITE setBar);
+ Q_PRIVATE_PROPERTY(PrivatePropertyTest::d, int plop READ plop WRITE setPlop);
+ Q_PRIVATE_PROPERTY(PrivatePropertyTest::d_func(), int baz READ baz WRITE setBaz);
+ class MyDPointer {
+ public:
+ MyDPointer() : mBar(0), mPlop(0) {}
+ int bar() { return mBar ; }
+ void setBar(int value) { mBar = value; }
+ int plop() { return mPlop ; }
+ void setPlop(int value) { mPlop = value; }
+ int baz() { return mBaz ; }
+ void setBaz(int value) { mBaz = value; }
+ private:
+ int mBar;
+ int mPlop;
+ int mBaz;
+ };
+public:
+ PrivatePropertyTest() : mFoo(0), d (new MyDPointer) {}
+ int foo() { return mFoo ; }
+ void setFoo(int value) { mFoo = value; }
+ MyDPointer *d_func() {return d;}
+private:
+ int mFoo;
+ MyDPointer *d;
+};
+
+
+void tst_Moc::qprivateproperties()
+{
+ PrivatePropertyTest test;
+
+ test.setProperty("foo", 1);
+ QCOMPARE(test.property("foo"), qVariantFromValue(1));
+
+ test.setProperty("bar", 2);
+ QCOMPARE(test.property("bar"), qVariantFromValue(2));
+
+ test.setProperty("plop", 3);
+ QCOMPARE(test.property("plop"), qVariantFromValue(3));
+
+ test.setProperty("baz", 4);
+ QCOMPARE(test.property("baz"), qVariantFromValue(4));
+
+}
+
#include "task189996.h"
void InlineSlotsWithThrowDeclaration::c() throw() {}