1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2017 The Qt Company Ltd. |
4 | ** Contact: http://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at http://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or later as published by the Free |
28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
29 | ** the packaging of this file. Please review the following information to |
30 | ** ensure the GNU General Public License version 2.0 requirements will be |
31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
32 | ** |
33 | ** $QT_END_LICENSE$ |
34 | ** |
35 | ****************************************************************************/ |
36 | |
37 | #include <QtQml> |
38 | #include <QtTest> |
39 | |
40 | #include "../../auto/shared/visualtestutil.h" |
41 | |
42 | using namespace QQuickVisualTestUtil; |
43 | |
44 | class tst_CreationTime : public QObject |
45 | { |
46 | Q_OBJECT |
47 | |
48 | private slots: |
49 | void init(); |
50 | |
51 | void controls(); |
52 | void controls_data(); |
53 | |
54 | void fusion(); |
55 | void fusion_data(); |
56 | |
57 | void imagine(); |
58 | void imagine_data(); |
59 | |
60 | void material(); |
61 | void material_data(); |
62 | |
63 | void universal(); |
64 | void universal_data(); |
65 | |
66 | void calendar(); |
67 | void calendar_data(); |
68 | |
69 | private: |
70 | QQmlEngine engine; |
71 | }; |
72 | |
73 | void tst_CreationTime::init() |
74 | { |
75 | engine.clearComponentCache(); |
76 | } |
77 | |
78 | static void doBenchmark(QQmlEngine *engine, const QUrl &url) |
79 | { |
80 | QQmlComponent component(engine); |
81 | component.loadUrl(url); |
82 | |
83 | QObjectList objects; |
84 | objects.reserve(size: 4096); |
85 | QBENCHMARK { |
86 | QObject *object = component.create(); |
87 | QVERIFY2(object, qPrintable(component.errorString())); |
88 | objects += object; |
89 | } |
90 | qDeleteAll(c: objects); |
91 | } |
92 | |
93 | void tst_CreationTime::controls() |
94 | { |
95 | QFETCH(QUrl, url); |
96 | doBenchmark(engine: &engine, url); |
97 | } |
98 | |
99 | void tst_CreationTime::controls_data() |
100 | { |
101 | QTest::addColumn<QUrl>(name: "url" ); |
102 | addTestRowForEachControl(engine: &engine, sourcePath: "controls" , targetPath: "QtQuick/Controls.2" , skiplist: QStringList() << "ApplicationWindow" ); |
103 | } |
104 | |
105 | void tst_CreationTime::fusion() |
106 | { |
107 | QFETCH(QUrl, url); |
108 | doBenchmark(engine: &engine, url); |
109 | } |
110 | |
111 | void tst_CreationTime::fusion_data() |
112 | { |
113 | QTest::addColumn<QUrl>(name: "url" ); |
114 | addTestRowForEachControl(engine: &engine, sourcePath: "controls/fusion" , targetPath: "QtQuick/Controls.2/Fusion" , skiplist: QStringList() << "ApplicationWindow" << "ButtonPanel" << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator" ); |
115 | } |
116 | |
117 | void tst_CreationTime::imagine() |
118 | { |
119 | QFETCH(QUrl, url); |
120 | doBenchmark(engine: &engine, url); |
121 | } |
122 | |
123 | void tst_CreationTime::imagine_data() |
124 | { |
125 | QTest::addColumn<QUrl>(name: "url" ); |
126 | addTestRowForEachControl(engine: &engine, sourcePath: "controls/imagine" , targetPath: "QtQuick/Controls.2/Imagine" , skiplist: QStringList() << "ApplicationWindow" ); |
127 | } |
128 | |
129 | void tst_CreationTime::material() |
130 | { |
131 | QFETCH(QUrl, url); |
132 | doBenchmark(engine: &engine, url); |
133 | } |
134 | |
135 | void tst_CreationTime::material_data() |
136 | { |
137 | QTest::addColumn<QUrl>(name: "url" ); |
138 | addTestRowForEachControl(engine: &engine, sourcePath: "controls/material" , targetPath: "QtQuick/Controls.2/Material" , skiplist: QStringList() << "ApplicationWindow" << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate" ); |
139 | } |
140 | |
141 | void tst_CreationTime::universal() |
142 | { |
143 | QFETCH(QUrl, url); |
144 | doBenchmark(engine: &engine, url); |
145 | } |
146 | |
147 | void tst_CreationTime::universal_data() |
148 | { |
149 | QTest::addColumn<QUrl>(name: "url" ); |
150 | addTestRowForEachControl(engine: &engine, sourcePath: "controls/universal" , targetPath: "QtQuick/Controls.2/Universal" , skiplist: QStringList() << "ApplicationWindow" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" ); |
151 | } |
152 | |
153 | void tst_CreationTime::calendar() |
154 | { |
155 | QFETCH(QUrl, url); |
156 | doBenchmark(engine: &engine, url); |
157 | } |
158 | |
159 | void tst_CreationTime::calendar_data() |
160 | { |
161 | QTest::addColumn<QUrl>(name: "url" ); |
162 | addTestRowForEachControl(engine: &engine, sourcePath: "calendar" , targetPath: "Qt/labs/calendar" ); |
163 | } |
164 | |
165 | QTEST_MAIN(tst_CreationTime) |
166 | |
167 | #include "tst_creationtime.moc" |
168 | |