diff options
Diffstat (limited to 'tests/benchmarks/widgets/graphicsview/qgraphicsitem')
-rw-r--r-- | tests/benchmarks/widgets/graphicsview/qgraphicsitem/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 21 |
2 files changed, 23 insertions, 6 deletions
diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsitem/CMakeLists.txt b/tests/benchmarks/widgets/graphicsview/qgraphicsitem/CMakeLists.txt index e5d19ceb24..0ab35585fb 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsitem/CMakeLists.txt +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsitem/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qgraphicsitem.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qgraphicsitem Binary: @@ -7,11 +8,8 @@ qt_internal_add_benchmark(tst_bench_qgraphicsitem SOURCES tst_qgraphicsitem.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::Test Qt::Widgets ) - -#### Keys ignored in scope 1:.:.:qgraphicsitem.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index fd74a7b3b9..7556864ded 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -1,10 +1,11 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <qtest.h> #include <QGraphicsItem> #include <QGraphicsScene> #include <QGraphicsView> +#include <QTextDocument> class tst_QGraphicsItem : public QObject { @@ -33,6 +34,7 @@ private slots: void shear(); void translate(); void createTextItem(); + void createTextItemNoLayouting(); }; tst_QGraphicsItem::tst_QGraphicsItem() @@ -216,5 +218,22 @@ void tst_QGraphicsItem::createTextItem() } } +void tst_QGraphicsItem::createTextItemNoLayouting() +{ + // Ensure QFontDatabase loaded the font beforehand + QFontInfo(qApp->font()).family(); + const QString text = "This is some text"; + QBENCHMARK { + QGraphicsTextItem item; + item.document()->setLayoutEnabled(false); + // Prepare everything + item.setPlainText(text); + QTextOption option = item.document()->defaultTextOption(); + option.setAlignment(Qt::AlignHCenter); + item.document()->setDefaultTextOption(option); + // And (in a real app) enable layouting here + } +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" |