From 081d6a9dd5d39df7a0d16727b2547285e95b7e80 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 4 Nov 2015 12:11:53 +0100 Subject: tst_creationtime: use components This makes it easier to add different styles to the test. Change-Id: I6be66d09d58317d454fbf219cdbbb43c6000d3cd Reviewed-by: Liang Qi --- tests/benchmarks/creationtime/tst_creationtime.cpp | 26 ++++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'tests/benchmarks/creationtime/tst_creationtime.cpp') diff --git a/tests/benchmarks/creationtime/tst_creationtime.cpp b/tests/benchmarks/creationtime/tst_creationtime.cpp index 20fcfbbe..3eccc654 100644 --- a/tests/benchmarks/creationtime/tst_creationtime.cpp +++ b/tests/benchmarks/creationtime/tst_creationtime.cpp @@ -59,19 +59,11 @@ void tst_CreationTime::init() engine.clearComponentCache(); } -static QStringList listControls(const QString &path) -{ - QStringList controls; - foreach (const QFileInfo &entry, QDir(path).entryInfoList(QStringList("*.qml"), QDir::Files)) - controls += entry.baseName(); - return controls; -} - static void addTestRows(const QString &path) { - QStringList controls = listControls(path); - foreach (const QString &control, controls) - QTest::newRow(qPrintable(control)) << control.toUtf8(); + QFileInfoList entries = QDir(path).entryInfoList(QStringList("*.qml"), QDir::Files); + foreach (const QFileInfo &entry, entries) + QTest::newRow(qPrintable(entry.baseName())) << QUrl::fromLocalFile(entry.absoluteFilePath()); } static void doBenchmark(QQmlComponent *component) @@ -89,29 +81,29 @@ static void doBenchmark(QQmlComponent *component) void tst_CreationTime::controls() { - QFETCH(QByteArray, control); + QFETCH(QUrl, url); QQmlComponent component(&engine); - component.setData("import Qt.labs.controls 1.0;" + control + "{}", QUrl()); + component.loadUrl(url); doBenchmark(&component); } void tst_CreationTime::controls_data() { - QTest::addColumn("control"); + QTest::addColumn("url"); addTestRows(QQC2_IMPORT_PATH "/controls"); } void tst_CreationTime::calendar() { - QFETCH(QByteArray, control); + QFETCH(QUrl, url); QQmlComponent component(&engine); - component.setData("import Qt.labs.calendar 1.0;" + control + "{}", QUrl()); + component.loadUrl(url); doBenchmark(&component); } void tst_CreationTime::calendar_data() { - QTest::addColumn("control"); + QTest::addColumn("url"); addTestRows(QQC2_IMPORT_PATH "/calendar"); } -- cgit v1.2.3