|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the test suite of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 #include <QtCore> |
|
42 #include <QtGui> |
|
43 #include <qtest.h> |
|
44 |
|
45 class tst_qmetaobject: public QObject |
|
46 { |
|
47 Q_OBJECT |
|
48 private slots: |
|
49 void initTestCase(); |
|
50 void cleanupTestCase(); |
|
51 |
|
52 void indexOfProperty_data(); |
|
53 void indexOfProperty(); |
|
54 void indexOfMethod_data(); |
|
55 void indexOfMethod(); |
|
56 void indexOfSignal_data(); |
|
57 void indexOfSignal(); |
|
58 void indexOfSlot_data(); |
|
59 void indexOfSlot(); |
|
60 }; |
|
61 |
|
62 void tst_qmetaobject::initTestCase() |
|
63 { |
|
64 } |
|
65 |
|
66 void tst_qmetaobject::cleanupTestCase() |
|
67 { |
|
68 } |
|
69 |
|
70 void tst_qmetaobject::indexOfProperty_data() |
|
71 { |
|
72 QTest::addColumn<QByteArray>("name"); |
|
73 const QMetaObject *mo = &QTreeView::staticMetaObject; |
|
74 for (int i = 0; i < mo->propertyCount(); ++i) { |
|
75 QMetaProperty prop = mo->property(i); |
|
76 QTest::newRow(prop.name()) << QByteArray(prop.name()); |
|
77 } |
|
78 } |
|
79 |
|
80 void tst_qmetaobject::indexOfProperty() |
|
81 { |
|
82 QFETCH(QByteArray, name); |
|
83 const char *p = name.constData(); |
|
84 const QMetaObject *mo = &QTreeView::staticMetaObject; |
|
85 QBENCHMARK { |
|
86 (void)mo->indexOfProperty(p); |
|
87 } |
|
88 } |
|
89 |
|
90 void tst_qmetaobject::indexOfMethod_data() |
|
91 { |
|
92 QTest::addColumn<QByteArray>("method"); |
|
93 const QMetaObject *mo = &QTreeView::staticMetaObject; |
|
94 for (int i = 0; i < mo->methodCount(); ++i) { |
|
95 QMetaMethod method = mo->method(i); |
|
96 QByteArray sig = method.signature(); |
|
97 QTest::newRow(sig) << sig; |
|
98 } |
|
99 } |
|
100 |
|
101 void tst_qmetaobject::indexOfMethod() |
|
102 { |
|
103 QFETCH(QByteArray, method); |
|
104 const char *p = method.constData(); |
|
105 const QMetaObject *mo = &QTreeView::staticMetaObject; |
|
106 QBENCHMARK { |
|
107 (void)mo->indexOfMethod(p); |
|
108 } |
|
109 } |
|
110 |
|
111 void tst_qmetaobject::indexOfSignal_data() |
|
112 { |
|
113 QTest::addColumn<QByteArray>("signal"); |
|
114 const QMetaObject *mo = &QTreeView::staticMetaObject; |
|
115 for (int i = 0; i < mo->methodCount(); ++i) { |
|
116 QMetaMethod method = mo->method(i); |
|
117 if (method.methodType() != QMetaMethod::Signal) |
|
118 continue; |
|
119 QByteArray sig = method.signature(); |
|
120 QTest::newRow(sig) << sig; |
|
121 } |
|
122 } |
|
123 |
|
124 void tst_qmetaobject::indexOfSignal() |
|
125 { |
|
126 QFETCH(QByteArray, signal); |
|
127 const char *p = signal.constData(); |
|
128 const QMetaObject *mo = &QTreeView::staticMetaObject; |
|
129 QBENCHMARK { |
|
130 (void)mo->indexOfSignal(p); |
|
131 } |
|
132 } |
|
133 |
|
134 void tst_qmetaobject::indexOfSlot_data() |
|
135 { |
|
136 QTest::addColumn<QByteArray>("slot"); |
|
137 const QMetaObject *mo = &QTreeView::staticMetaObject; |
|
138 for (int i = 0; i < mo->methodCount(); ++i) { |
|
139 QMetaMethod method = mo->method(i); |
|
140 if (method.methodType() != QMetaMethod::Slot) |
|
141 continue; |
|
142 QByteArray sig = method.signature(); |
|
143 QTest::newRow(sig) << sig; |
|
144 } |
|
145 } |
|
146 |
|
147 void tst_qmetaobject::indexOfSlot() |
|
148 { |
|
149 QFETCH(QByteArray, slot); |
|
150 const char *p = slot.constData(); |
|
151 const QMetaObject *mo = &QTreeView::staticMetaObject; |
|
152 QBENCHMARK { |
|
153 (void)mo->indexOfSlot(p); |
|
154 } |
|
155 } |
|
156 |
|
157 QTEST_MAIN(tst_qmetaobject) |
|
158 |
|
159 #include "main.moc" |