diff options
Diffstat (limited to 'tests/benchmarks/widgets/graphicsview/qgraphicsitem')
3 files changed, 36 insertions, 39 deletions
diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsitem/CMakeLists.txt b/tests/benchmarks/widgets/graphicsview/qgraphicsitem/CMakeLists.txt index e32fd82819..0ab35585fb 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsitem/CMakeLists.txt +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsitem/CMakeLists.txt @@ -1,17 +1,15 @@ -# Generated from qgraphicsitem.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qgraphicsitem Binary: ##################################################################### -qt_add_benchmark(tst_bench_qgraphicsitem +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/qgraphicsitem.pro b/tests/benchmarks/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro deleted file mode 100644 index 461ec13263..0000000000 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro +++ /dev/null @@ -1,6 +0,0 @@ -QT += widgets testlib - -TEMPLATE = app -TARGET = tst_bench_qgraphicsitem - -SOURCES += tst_qgraphicsitem.cpp diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 56b34fff2a..7556864ded 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -1,35 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// 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 { @@ -57,6 +33,8 @@ private slots: void scale(); void shear(); void translate(); + void createTextItem(); + void createTextItemNoLayouting(); }; tst_QGraphicsItem::tst_QGraphicsItem() @@ -230,5 +208,32 @@ void tst_QGraphicsItem::translate() } } +void tst_QGraphicsItem::createTextItem() +{ + // Ensure QFontDatabase loaded the font beforehand + QFontInfo(qApp->font()).family(); + const QString text = "This is some text"; + QBENCHMARK { + QGraphicsTextItem item(text); + } +} + +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" |