Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
**
|
|
|
|
** This file is part of the test suite 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$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <qbaselinetest.h>
|
2021-11-19 11:25:00 +00:00
|
|
|
#include <qwidgetbaselinetest.h>
|
Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
#include <QtWidgets>
|
2022-01-14 11:56:55 +00:00
|
|
|
#include <QStyleOptionSlider>
|
Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
|
2021-11-19 11:25:00 +00:00
|
|
|
class tst_Widgets : public QWidgetBaselineTest
|
Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-11-19 11:25:00 +00:00
|
|
|
tst_Widgets() = default;
|
Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void tst_QSlider_data();
|
|
|
|
void tst_QSlider();
|
|
|
|
|
|
|
|
void tst_QPushButton_data();
|
|
|
|
void tst_QPushButton();
|
2022-01-11 10:57:49 +00:00
|
|
|
|
|
|
|
void tst_QProgressBar_data();
|
|
|
|
void tst_QProgressBar();
|
2022-01-07 12:55:50 +00:00
|
|
|
|
|
|
|
void tst_QSpinBox_data();
|
|
|
|
void tst_QSpinBox();
|
2022-01-12 09:59:32 +00:00
|
|
|
|
2022-02-03 12:26:59 +00:00
|
|
|
void tst_QDoubleSpinBox_data();
|
|
|
|
void tst_QDoubleSpinBox();
|
|
|
|
|
|
|
|
void tst_QDateTimeEdit_data();
|
|
|
|
void tst_QDateTimeEdit();
|
|
|
|
|
|
|
|
void tst_QTimeEdit_data();
|
|
|
|
void tst_QTimeEdit();
|
|
|
|
|
|
|
|
void tst_QDateEdit_data();
|
|
|
|
void tst_QDateEdit();
|
|
|
|
|
2022-01-12 09:59:32 +00:00
|
|
|
void tst_QDial_data();
|
|
|
|
void tst_QDial();
|
2022-01-12 13:03:13 +00:00
|
|
|
|
|
|
|
void tst_QCheckbox_data();
|
|
|
|
void tst_QCheckbox();
|
2022-01-12 13:45:28 +00:00
|
|
|
|
|
|
|
void tst_QRadioButton_data();
|
|
|
|
void tst_QRadioButton();
|
2022-01-14 11:56:55 +00:00
|
|
|
|
|
|
|
void tst_QScrollBar_data();
|
|
|
|
void tst_QScrollBar();
|
2022-01-14 12:07:36 +00:00
|
|
|
|
|
|
|
void tst_QTabBar_data();
|
|
|
|
void tst_QTabBar();
|
2022-01-31 13:18:55 +00:00
|
|
|
|
|
|
|
void tst_QTabWidget_data();
|
|
|
|
void tst_QTabWidget();
|
2022-02-03 12:26:59 +00:00
|
|
|
|
2022-02-03 12:34:09 +00:00
|
|
|
void tst_QListView_data();
|
|
|
|
void tst_QListView();
|
|
|
|
|
|
|
|
void tst_QTableView_data();
|
|
|
|
void tst_QTableView();
|
|
|
|
|
|
|
|
void tst_QTreeView_data();
|
|
|
|
void tst_QTreeView();
|
|
|
|
|
|
|
|
void tst_QLineEdit_data();
|
|
|
|
void tst_QLineEdit();
|
|
|
|
|
2022-02-03 12:26:59 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
// Abstract SpinBox test for QSpinBox, QDoubleSpinBox, QDateTimeEdit, QDateEdit, QTimeEdit
|
|
|
|
void tst_SpinBox_data();
|
|
|
|
void tst_SpinBox(QAbstractSpinBox* spinBox);
|
2022-02-03 12:34:09 +00:00
|
|
|
|
|
|
|
// 78 standard icons from 6.3
|
|
|
|
const int numberStandardIcons = 78;
|
|
|
|
|
|
|
|
// recursive methods for QTreeView population
|
|
|
|
void tst_QTreeView_populateTree(QStandardItem* node, int height, int itemsPerNode, bool hasIcon);
|
|
|
|
QStandardItem* tst_QTreeView_populateItem(int height, int number, bool hasIcon);
|
Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QSlider_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<Qt::Orientation>("orientation");
|
|
|
|
QTest::addColumn<QSlider::TickPosition>("tickPosition");
|
|
|
|
|
|
|
|
QBaselineTest::newRow("horizontal") << Qt::Horizontal << QSlider::NoTicks;
|
|
|
|
QBaselineTest::newRow("horizontal ticks above") << Qt::Horizontal << QSlider::TicksAbove;
|
|
|
|
QBaselineTest::newRow("horizontal ticks below") << Qt::Horizontal << QSlider::TicksBelow;
|
|
|
|
QBaselineTest::newRow("horizontal ticks both") << Qt::Horizontal << QSlider::TicksBothSides;
|
|
|
|
QBaselineTest::newRow("vertical") << Qt::Vertical << QSlider::NoTicks;
|
|
|
|
QBaselineTest::newRow("vertical ticks left") << Qt::Vertical << QSlider::TicksLeft;
|
|
|
|
QBaselineTest::newRow("vertical ticks right") << Qt::Vertical << QSlider::TicksRight;
|
|
|
|
QBaselineTest::newRow("vertical ticks both") << Qt::Vertical << QSlider::TicksBothSides;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QSlider()
|
|
|
|
{
|
|
|
|
struct PublicSlider : QSlider { friend tst_Widgets; };
|
|
|
|
QFETCH(Qt::Orientation, orientation);
|
|
|
|
QFETCH(QSlider::TickPosition, tickPosition);
|
|
|
|
|
|
|
|
QBoxLayout *box = new QBoxLayout(orientation == Qt::Horizontal ? QBoxLayout::TopToBottom
|
|
|
|
: QBoxLayout::LeftToRight);
|
|
|
|
QList<QSlider*> _sliders;
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
QSlider *slider = new QSlider;
|
|
|
|
slider->setOrientation(orientation);
|
|
|
|
slider->setTickPosition(tickPosition);
|
|
|
|
_sliders << slider;
|
|
|
|
box->addWidget(slider);
|
|
|
|
}
|
|
|
|
const auto sliders = _sliders;
|
|
|
|
|
2021-11-19 11:25:00 +00:00
|
|
|
testWindow()->setLayout(box);
|
Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
|
|
|
|
// we want to see sliders with different values
|
|
|
|
int value = 0;
|
|
|
|
for (const auto &slider : sliders)
|
|
|
|
slider->setValue(value += 33);
|
|
|
|
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
PublicSlider *slider = static_cast<PublicSlider*>(sliders.first());
|
|
|
|
QStyleOptionSlider sliderOptions;
|
|
|
|
slider->initStyleOption(&sliderOptions);
|
|
|
|
const QRect handleRect = slider->style()->subControlRect(QStyle::CC_Slider, &sliderOptions,
|
|
|
|
QStyle::SubControl::SC_SliderHandle, slider);
|
|
|
|
QTest::mousePress(slider, Qt::LeftButton, {}, handleRect.center());
|
|
|
|
QBASELINE_CHECK(takeSnapshot(), "pressed");
|
|
|
|
QTest::mouseRelease(slider, Qt::LeftButton, {}, handleRect.center());
|
|
|
|
QBASELINE_CHECK(takeSnapshot(), "released");
|
|
|
|
|
|
|
|
slider->setSliderDown(true);
|
|
|
|
QBASELINE_CHECK(takeSnapshot(), "down");
|
|
|
|
|
|
|
|
sliders.first()->setSliderDown(false);
|
|
|
|
QBASELINE_CHECK(takeSnapshot(), "notdown");
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QPushButton_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("isFlat");
|
|
|
|
|
|
|
|
QBaselineTest::newRow("normal") << false;
|
|
|
|
QBaselineTest::newRow("flat") << true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QPushButton()
|
|
|
|
{
|
|
|
|
QFETCH(bool, isFlat);
|
|
|
|
|
|
|
|
QVBoxLayout *vbox = new QVBoxLayout;
|
|
|
|
QPushButton *testButton = new QPushButton("Ok");
|
|
|
|
testButton->setFlat(isFlat);
|
|
|
|
vbox->addWidget(testButton);
|
|
|
|
|
|
|
|
testWindow()->setLayout(vbox);
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
testButton->setDown(true);
|
|
|
|
QBASELINE_CHECK(takeSnapshot(), "down");
|
|
|
|
testButton->setDown(false);
|
|
|
|
QBASELINE_CHECK(takeSnapshot(), "up");
|
2021-11-23 13:13:26 +00:00
|
|
|
|
|
|
|
testButton->setDefault(true);
|
|
|
|
QBASELINE_CHECK(takeSnapshot(), "default_up");
|
|
|
|
testButton->setDown(true);
|
|
|
|
QBASELINE_CHECK(takeSnapshot(), "default_down");
|
|
|
|
testButton->setDown(false);
|
Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 10:57:49 +00:00
|
|
|
void tst_Widgets::tst_QProgressBar_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<Qt::Orientation>("orientation");
|
|
|
|
QTest::addColumn<bool>("invertedAppearance");
|
|
|
|
QTest::addColumn<bool>("textVisible");
|
|
|
|
|
|
|
|
QTest::newRow("vertical_normalAppearance_textVisible") << Qt::Vertical << false << true;
|
|
|
|
QTest::newRow("vertical_invertedAppearance_textVisible") << Qt::Vertical << true << true;
|
|
|
|
QTest::newRow("horizontal_normalAppearance_textVisible") << Qt::Horizontal << false << true;
|
|
|
|
QTest::newRow("horizontal_invertedAppearance_textVisible") << Qt::Horizontal << true << true;
|
|
|
|
QTest::newRow("vertical_normalAppearance_textNotVisible") << Qt::Vertical << false << false;
|
|
|
|
QTest::newRow("vertical_invertedAppearance_textNotVisible") << Qt::Vertical << true << false;
|
|
|
|
QTest::newRow("horizontal_normalAppearance_textNotVisible") << Qt::Horizontal << false << false;
|
|
|
|
QTest::newRow("horizontal_invertedAppearance_textNotVisible") << Qt::Horizontal << true << false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QProgressBar()
|
|
|
|
{
|
|
|
|
QFETCH(Qt::Orientation, orientation);
|
|
|
|
QFETCH(bool, invertedAppearance);
|
|
|
|
QFETCH(bool, textVisible);
|
|
|
|
|
|
|
|
QBoxLayout box((orientation == Qt::Vertical) ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom);
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
QProgressBar *bar = new QProgressBar(testWindow());
|
|
|
|
bar->setOrientation(orientation);
|
|
|
|
bar->setInvertedAppearance(invertedAppearance);
|
|
|
|
bar->setTextVisible(textVisible);
|
|
|
|
bar->setValue(i * 33);
|
|
|
|
box.addWidget(bar);
|
|
|
|
}
|
|
|
|
|
|
|
|
testWindow()->setLayout(&box);
|
|
|
|
takeStandardSnapshots();
|
|
|
|
}
|
Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
|
2022-02-03 12:26:59 +00:00
|
|
|
void tst_Widgets::tst_SpinBox_data()
|
2022-01-07 12:55:50 +00:00
|
|
|
{
|
|
|
|
QTest::addColumn<QAbstractSpinBox::ButtonSymbols>("buttons");
|
|
|
|
|
2022-02-03 12:26:59 +00:00
|
|
|
QTest::addRow("NoButtons") << QAbstractSpinBox::NoButtons;
|
|
|
|
QTest::addRow("UpDownArrows") << QAbstractSpinBox::UpDownArrows;
|
|
|
|
QTest::addRow("PlusMinus") << QAbstractSpinBox::PlusMinus;
|
2022-01-07 12:55:50 +00:00
|
|
|
}
|
|
|
|
|
2022-02-03 12:26:59 +00:00
|
|
|
void tst_Widgets::tst_SpinBox(QAbstractSpinBox *spinBox)
|
2022-01-07 12:55:50 +00:00
|
|
|
{
|
2022-02-03 12:26:59 +00:00
|
|
|
QFETCH(const QAbstractSpinBox::ButtonSymbols, buttons);
|
2022-01-07 12:55:50 +00:00
|
|
|
|
|
|
|
spinBox->setButtonSymbols(buttons);
|
|
|
|
spinBox->setMinimumWidth(200);
|
|
|
|
|
2022-02-03 12:26:59 +00:00
|
|
|
QVBoxLayout layout;
|
|
|
|
layout.addWidget(spinBox);
|
|
|
|
testWindow()->setLayout(&layout);
|
2022-01-07 12:55:50 +00:00
|
|
|
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
spinBox->setAlignment(Qt::AlignHCenter);
|
2022-02-03 12:26:59 +00:00
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "alignCenter");
|
2022-01-07 12:55:50 +00:00
|
|
|
|
|
|
|
spinBox->setAlignment(Qt::AlignRight);
|
2022-02-03 12:26:59 +00:00
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "alignRight");
|
|
|
|
|
|
|
|
// Press / release up button
|
|
|
|
QStyleOptionSpinBox styleOption;
|
|
|
|
styleOption.initFrom(spinBox);
|
|
|
|
QPoint clickTarget = spinBox->style()->subControlRect(QStyle::CC_SpinBox,&styleOption,
|
|
|
|
QStyle::SC_SpinBoxUp,spinBox).center();
|
|
|
|
|
|
|
|
QTest::mousePress(spinBox, Qt::LeftButton, Qt::KeyboardModifiers(), clickTarget);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "upPressed");
|
|
|
|
QTest::mouseRelease(spinBox, Qt::LeftButton, Qt::KeyboardModifiers(), clickTarget);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "upReleased");
|
|
|
|
|
|
|
|
// Press / release down button
|
|
|
|
clickTarget = spinBox->style()->subControlRect(QStyle::CC_SpinBox,&styleOption,
|
|
|
|
QStyle::SC_SpinBoxDown,spinBox).center();
|
|
|
|
|
|
|
|
QTest::mousePress(spinBox, Qt::LeftButton, Qt::KeyboardModifiers(), clickTarget);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "downPressed");
|
|
|
|
QTest::mouseRelease(spinBox, Qt::LeftButton, Qt::KeyboardModifiers(), clickTarget);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "downReleased");
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QSpinBox_data()
|
|
|
|
{
|
|
|
|
tst_SpinBox_data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QSpinBox()
|
|
|
|
{
|
|
|
|
QSpinBox spinBox;
|
|
|
|
tst_SpinBox(&spinBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QDoubleSpinBox_data()
|
|
|
|
{
|
|
|
|
tst_SpinBox_data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QDoubleSpinBox()
|
|
|
|
{
|
|
|
|
QDoubleSpinBox spinBox;
|
|
|
|
tst_SpinBox(&spinBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QDateTimeEdit_data()
|
|
|
|
{
|
|
|
|
tst_SpinBox_data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QDateTimeEdit()
|
|
|
|
{
|
|
|
|
QDateTimeEdit edit;
|
|
|
|
tst_SpinBox(&edit);
|
|
|
|
|
|
|
|
// show calendar popup
|
|
|
|
QStyleOptionSpinBox styleOption;
|
|
|
|
styleOption.initFrom(&edit);
|
|
|
|
const QRect buttonUp = edit.style()->subControlRect(QStyle::CC_SpinBox,&styleOption,
|
|
|
|
QStyle::SC_SpinBoxUp,&edit);
|
|
|
|
|
|
|
|
// no rect for popup button => use bottom center of up-button
|
|
|
|
QPoint clickTarget = buttonUp.center();
|
|
|
|
clickTarget.setY(buttonUp.bottomLeft().y());
|
|
|
|
edit.setCalendarPopup(true);
|
|
|
|
QTest::mouseClick(&edit, Qt::LeftButton, Qt::KeyboardModifiers(), clickTarget);
|
|
|
|
QCalendarWidget* calendar = edit.calendarWidget();
|
|
|
|
QVERIFY(calendar);
|
|
|
|
QVBoxLayout layout;
|
|
|
|
layout.addWidget(calendar);
|
|
|
|
testWindow()->setLayout(&layout);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "showCalendar");
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QTimeEdit_data()
|
|
|
|
{
|
|
|
|
tst_SpinBox_data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QTimeEdit()
|
|
|
|
{
|
|
|
|
QTimeEdit edit;
|
|
|
|
tst_SpinBox(&edit);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QDateEdit_data()
|
|
|
|
{
|
|
|
|
tst_SpinBox_data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QDateEdit()
|
|
|
|
{
|
|
|
|
QDateEdit edit;
|
|
|
|
tst_SpinBox(&edit);
|
2022-01-07 12:55:50 +00:00
|
|
|
}
|
|
|
|
|
2022-01-12 09:59:32 +00:00
|
|
|
void tst_Widgets::tst_QDial_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<int>("minimum");
|
|
|
|
QTest::addColumn<int>("maximum");
|
|
|
|
QTest::addColumn<bool>("notchesVisible");
|
|
|
|
QTest::addColumn<qreal>("notchTarget");
|
|
|
|
|
|
|
|
QTest::newRow("0..99_notches") << 0 << 99 << true << 3.7;
|
|
|
|
QTest::newRow("0..99_noNotches") << 0 << 99 << false << 3.7;
|
|
|
|
QTest::newRow("1..100_notches") << 1 << 100 << true << 5.7;
|
|
|
|
QTest::newRow("1..100_noNotches") << 1 << 100 << false << 3.7;
|
|
|
|
QTest::newRow("1..5_notches") << 1 << 5 << true << 8.7;
|
|
|
|
QTest::newRow("1..5_noNotches") << 1 << 5 << false << 3.7;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QDial()
|
|
|
|
{
|
|
|
|
QFETCH(int, minimum);
|
|
|
|
QFETCH(int, maximum);
|
|
|
|
QFETCH(bool, notchesVisible);
|
|
|
|
QFETCH(qreal, notchTarget);
|
|
|
|
|
|
|
|
QVERIFY(maximum > minimum);
|
|
|
|
const int steps = maximum - minimum;
|
|
|
|
|
|
|
|
QDial dial(testWindow());
|
|
|
|
dial.setMinimum(minimum);
|
|
|
|
dial.setMaximum(maximum);
|
|
|
|
dial.setNotchTarget(notchTarget);
|
|
|
|
dial.setSliderPosition(minimum + (steps / 2));
|
|
|
|
dial.setNotchesVisible(notchesVisible);
|
|
|
|
|
|
|
|
QBoxLayout box(QBoxLayout::LeftToRight);
|
|
|
|
box.addWidget(&dial);
|
|
|
|
testWindow()->setLayout(&box);
|
|
|
|
takeStandardSnapshots();
|
|
|
|
}
|
|
|
|
|
2022-01-12 13:03:13 +00:00
|
|
|
void tst_Widgets::tst_QCheckbox_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QString>("text");
|
|
|
|
QTest::addColumn<bool>("hasIcon");
|
|
|
|
QTest::addColumn<bool>("isTriState");
|
|
|
|
|
|
|
|
QTest::newRow("SimpleCheckbox") << "" << false << false;
|
|
|
|
QTest::newRow("SimpleCheckboxWithIcon") << "" << true << false;
|
|
|
|
QTest::newRow("SimpleCheckboxWithText") << "checkBox" << false << false;
|
|
|
|
QTest::newRow("SimpleCheckboxWithTextAndIcon") << "checkBox with icon" << true << false;
|
|
|
|
QTest::newRow("SimpleTristate") << "" << false << true;
|
|
|
|
QTest::newRow("SimpleTristateWithText") << "tristateBox" << false << true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QCheckbox()
|
|
|
|
{
|
|
|
|
QFETCH(QString, text);
|
|
|
|
QFETCH(bool, hasIcon);
|
|
|
|
QFETCH(bool, isTriState);
|
|
|
|
|
|
|
|
QBoxLayout layout(QBoxLayout::TopToBottom);
|
|
|
|
QCheckBox box;
|
|
|
|
box.setTristate(isTriState);
|
|
|
|
|
|
|
|
if (!text.isEmpty())
|
|
|
|
box.setText(text);
|
|
|
|
|
|
|
|
if (hasIcon)
|
|
|
|
box.setIcon(QApplication::style()->standardIcon(QStyle::SP_ComputerIcon));
|
|
|
|
|
|
|
|
layout.addWidget(&box);
|
|
|
|
testWindow()->setLayout(&layout);
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const Qt::CheckState checkState = box.checkState();
|
|
|
|
const QPoint clickTarget = box.rect().center();
|
|
|
|
|
|
|
|
const std::array titles = {"unChecked", "partiallyChecked", "checked"};
|
|
|
|
const QString snapShotTitle = titles[checkState];
|
|
|
|
|
|
|
|
QTest::mousePress(&box,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(box.isDown());
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), (snapShotTitle + "_pressed").toLocal8Bit().constData());
|
|
|
|
|
|
|
|
QTest::mouseRelease(&box,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(!box.isDown());
|
|
|
|
QVERIFY(checkState != box.checkState());
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), (snapShotTitle + "_released").toLocal8Bit().constData());
|
|
|
|
|
|
|
|
} while (box.checkState() != Qt::Unchecked);
|
|
|
|
}
|
|
|
|
|
2022-01-12 13:45:28 +00:00
|
|
|
void tst_Widgets::tst_QRadioButton_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QString>("text");
|
|
|
|
QTest::addColumn<bool>("hasIcon");
|
|
|
|
|
|
|
|
QTest::newRow("SimpleRadioButton") << "" << false;
|
|
|
|
QTest::newRow("RadioButtonWithText") << "RadioButton" << false;
|
|
|
|
QTest::newRow("SimpleRadioButtonWithIcon") << "" << true;
|
|
|
|
QTest::newRow("RadioButtonWithTextAndIcon") << "RadioButton" << true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QRadioButton()
|
|
|
|
{
|
|
|
|
QFETCH(QString,text);
|
|
|
|
QFETCH(bool,hasIcon);
|
|
|
|
|
|
|
|
QRadioButton button1(testWindow());
|
|
|
|
|
|
|
|
if (!text.isEmpty())
|
|
|
|
button1.setText(text);
|
|
|
|
|
|
|
|
if (hasIcon)
|
|
|
|
button1.setIcon(QApplication::style()->standardIcon(QStyle::SP_ComputerIcon));
|
|
|
|
|
|
|
|
button1.setChecked(false);
|
|
|
|
|
|
|
|
QRadioButton button2(testWindow());
|
|
|
|
|
|
|
|
if (!text.isEmpty())
|
|
|
|
button2.setText(text);
|
|
|
|
|
|
|
|
if (hasIcon)
|
|
|
|
button2.setIcon(QApplication::style()->standardIcon(QStyle::SP_ComputerIcon));
|
|
|
|
|
|
|
|
// button2 has to start checked for the following tests to work
|
|
|
|
button2.setChecked(true);
|
|
|
|
|
|
|
|
QBoxLayout box(QBoxLayout::TopToBottom);
|
|
|
|
box.addWidget(&button1);
|
|
|
|
box.addWidget(&button2);
|
2022-01-21 15:26:06 +00:00
|
|
|
testWindow()->setLayout(&box);
|
2022-01-12 13:45:28 +00:00
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
const QPoint clickTarget = button1.rect().center();
|
|
|
|
QTest::mousePress(&button1,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(button1.isDown());
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressUnchecked");
|
|
|
|
QTest::mouseRelease(&button1,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(!button1.isDown());
|
|
|
|
|
|
|
|
// button1 has grabbed the check from button2
|
|
|
|
QVERIFY(button1.isChecked());
|
|
|
|
QVERIFY(!button2.isChecked());
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "releaseUnchecked");
|
|
|
|
|
|
|
|
// press and release checked button1 again
|
|
|
|
QTest::mousePress(&button1,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(button1.isDown());
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressChecked");
|
|
|
|
QTest::mouseRelease(&button1,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(!button1.isDown());
|
|
|
|
|
|
|
|
// checkstate not supposed to change
|
|
|
|
QVERIFY(button1.isChecked());
|
|
|
|
QVERIFY(!button2.isChecked());
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "releaseChecked");
|
|
|
|
}
|
|
|
|
|
2022-01-14 11:56:55 +00:00
|
|
|
void tst_Widgets::tst_QScrollBar_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<Qt::Orientation>("orientation");
|
|
|
|
|
|
|
|
QTest::newRow("Horizontal") << Qt::Horizontal;
|
|
|
|
QTest::newRow("Vertical") << Qt::Vertical;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QScrollBar()
|
|
|
|
{
|
|
|
|
QFETCH(Qt::Orientation, orientation);
|
|
|
|
|
|
|
|
QBoxLayout box((orientation == Qt::Vertical) ? QBoxLayout::LeftToRight
|
|
|
|
: QBoxLayout::TopToBottom);
|
|
|
|
QList<QScrollBar*> bars;
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
|
|
|
|
QScrollBar *bar = new QScrollBar(testWindow());
|
|
|
|
(orientation == Qt::Vertical) ? bar->setFixedHeight(100)
|
|
|
|
: bar->setFixedWidth(100);
|
|
|
|
|
|
|
|
bar->setOrientation(orientation);
|
|
|
|
bar->setValue(i * 33);
|
|
|
|
box.addWidget(bar);
|
|
|
|
bars.append(bar);
|
|
|
|
}
|
|
|
|
|
|
|
|
testWindow()->setLayout(&box);
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
// press left/up of first bar
|
|
|
|
QScrollBar *bar = bars.at(0);
|
|
|
|
QStyleOptionSlider styleOption = qt_qscrollbarStyleOption(bar);
|
|
|
|
QPoint clickTarget = bar->style()->subControlRect(QStyle::CC_ScrollBar, &styleOption,
|
|
|
|
QStyle::SC_ScrollBarSubLine, bar).center();
|
|
|
|
QTest::mousePress(bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressLeftUp");
|
|
|
|
QTest::mouseRelease(bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
|
|
|
|
// press slider of first bar
|
|
|
|
styleOption = qt_qscrollbarStyleOption(bar);
|
|
|
|
clickTarget = bar->style()->subControlRect(QStyle::CC_ScrollBar, &styleOption,
|
|
|
|
QStyle::SC_ScrollBarSlider, bar).center();
|
|
|
|
QTest::mousePress(bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(bar->isSliderDown());
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressSlider");
|
|
|
|
QTest::mouseRelease(bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
|
|
|
|
// Press AddPage up on first bar
|
|
|
|
clickTarget = bar->style()->subControlRect(QStyle::CC_ScrollBar, &styleOption,
|
|
|
|
QStyle::SC_ScrollBarAddPage, bar).center();
|
|
|
|
QTest::mousePress(bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressAddPage");
|
|
|
|
QTest::mouseRelease(bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
|
|
|
|
// press SubPage of last bar
|
|
|
|
bar = bars.at(3);
|
|
|
|
styleOption = qt_qscrollbarStyleOption(bar);
|
|
|
|
clickTarget = bar->style()->subControlRect(QStyle::CC_ScrollBar, &styleOption,
|
|
|
|
QStyle::SC_ScrollBarAddLine, bar).center();
|
|
|
|
QTest::mousePress(bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressRightDown");
|
|
|
|
QTest::mouseRelease(bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
}
|
|
|
|
|
2022-01-14 12:07:36 +00:00
|
|
|
void tst_Widgets::tst_QTabBar_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QTabBar::Shape>("shape");
|
|
|
|
QTest::addColumn<int>("numberTabs");
|
|
|
|
QTest::addColumn<int>("fixedWidth");
|
2022-01-31 10:02:52 +00:00
|
|
|
QTest::addColumn<bool>("isClosable");
|
2022-01-14 12:07:36 +00:00
|
|
|
|
|
|
|
// fixedWidth <0 will be interpreted as variable width
|
2022-01-31 10:02:52 +00:00
|
|
|
QTest::newRow("RoundedNorth_3_variableWidth") << QTabBar::RoundedNorth << 3 << -1 << false;
|
|
|
|
QTest::newRow("RoundedEast_3_variableWidth") << QTabBar::RoundedEast << 3 << -1 << false;
|
|
|
|
QTest::newRow("RoundedWest_3_variableWidth") << QTabBar::RoundedWest << 3 << -1 << false;
|
|
|
|
QTest::newRow("RoundedSouth_3_variableWidth") << QTabBar::RoundedSouth << 3 << -1 << false;
|
|
|
|
QTest::newRow("RoundedNorth_20_fixedWidth") << QTabBar::RoundedNorth << 20 << 250 << true;
|
2022-01-14 12:07:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QTabBar()
|
|
|
|
{
|
|
|
|
QFETCH(QTabBar::Shape, shape);
|
|
|
|
QFETCH(int, numberTabs);
|
|
|
|
QFETCH(int, fixedWidth);
|
2022-01-31 10:02:52 +00:00
|
|
|
QFETCH(bool, isClosable);
|
2022-01-14 12:07:36 +00:00
|
|
|
|
|
|
|
QTabBar bar (testWindow());
|
|
|
|
bar.setShape(shape);
|
2022-01-31 10:02:52 +00:00
|
|
|
bar.setTabsClosable(isClosable);
|
2022-01-14 12:07:36 +00:00
|
|
|
if (fixedWidth > 0)
|
|
|
|
bar.setFixedWidth(fixedWidth);
|
|
|
|
|
|
|
|
for (int i = 0; i < numberTabs; ++i) {
|
|
|
|
bar.insertTab(i,"Tab_" + QString::number(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
QBoxLayout box(QBoxLayout::LeftToRight, testWindow());
|
|
|
|
box.addWidget(&bar);
|
|
|
|
testWindow()->setLayout(&box);
|
|
|
|
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
// press/release first tab
|
|
|
|
bar.setCurrentIndex(0);
|
|
|
|
QPoint clickTarget = bar.tabRect(0).center();
|
|
|
|
QTest::mousePress(&bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressFirstTab");
|
|
|
|
QTest::mouseRelease(&bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(bar.currentIndex() == 0);
|
|
|
|
|
|
|
|
// press/release second tab if it exists
|
|
|
|
if (bar.count() > 1) {
|
|
|
|
clickTarget = bar.tabRect(1).center();
|
|
|
|
QTest::mousePress(&bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressSecondTab");
|
|
|
|
QTest::mouseRelease(&bar,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(bar.currentIndex() == 1);
|
|
|
|
}
|
2022-01-31 10:02:52 +00:00
|
|
|
|
|
|
|
// test press/release on close button
|
|
|
|
if (isClosable) {
|
|
|
|
|
|
|
|
// CloseButton is either left or right
|
|
|
|
QWidget *leftButton = bar.tabButton(bar.currentIndex(),QTabBar::ButtonPosition::LeftSide);
|
|
|
|
QWidget *rightButton = bar.tabButton(bar.currentIndex(),QTabBar::ButtonPosition::RightSide);
|
|
|
|
QAbstractButton *button = qobject_cast<QAbstractButton*>(leftButton);
|
|
|
|
if (button == nullptr)
|
|
|
|
button = qobject_cast<QAbstractButton*>(rightButton);
|
|
|
|
|
|
|
|
if (button != nullptr) {
|
|
|
|
clickTarget = button->rect().center();
|
|
|
|
QTest::mousePress(button,Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressCloseFirstTab");
|
|
|
|
QTest::mouseRelease(button,Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "releaseCloseFirstTab");
|
|
|
|
}
|
|
|
|
}
|
2022-01-14 12:07:36 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 13:18:55 +00:00
|
|
|
void tst_Widgets::tst_QTabWidget_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QTabWidget::TabPosition>("tabPosition");
|
|
|
|
QTest::addColumn<int>("numberTabs");
|
|
|
|
QTest::addColumn<QString>("tabText");
|
|
|
|
QTest::addColumn<int>("fixedWidth");
|
|
|
|
QTest::addColumn<bool>("isClosable");
|
|
|
|
QTest::addColumn<bool>("isDocumentMode");
|
|
|
|
|
|
|
|
// fixedWidth <0 will be interpreted as variable width
|
|
|
|
QTest::newRow("North_3_variableWidthDocMode") << QTabWidget::North << 3 << "This is a tab text" << -1 << false << true;
|
|
|
|
QTest::newRow("East_3_variableWidth") << QTabWidget::East << 3 << "This is a tab text" << -1 << false << false;
|
|
|
|
QTest::newRow("West_3_variableWidthDocMode") << QTabWidget::West << 3 << "This is a tab text" << -1 << false << true;
|
|
|
|
QTest::newRow("South_3_variableWidth") << QTabWidget::South << 3 << "This is a tab text" << -1 << true << false;
|
|
|
|
QTest::newRow("North_20_fixedWidthDocMode") << QTabWidget::North << 20
|
|
|
|
<< "This is a very long text to actually force wrapping!" << 100 << true << true;
|
|
|
|
QTest::newRow("South_20_variableWidth") << QTabWidget::South << 20
|
|
|
|
<< "This is a very long text to actually force wrapping!" << -1 << false << false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QTabWidget()
|
|
|
|
{
|
|
|
|
QFETCH(QTabWidget::TabPosition, tabPosition);
|
|
|
|
QFETCH(int, numberTabs);
|
|
|
|
QFETCH(QString, tabText);
|
|
|
|
QFETCH(int, fixedWidth);
|
|
|
|
QFETCH(bool, isClosable);
|
|
|
|
QFETCH(bool, isDocumentMode);
|
|
|
|
|
|
|
|
QTabWidget tabWidget (testWindow());
|
|
|
|
if (fixedWidth > 0)
|
|
|
|
tabWidget.setFixedWidth(fixedWidth);
|
|
|
|
tabWidget.setTabPosition(tabPosition);
|
|
|
|
tabWidget.setTabsClosable(isClosable);
|
|
|
|
tabWidget.setDocumentMode(isDocumentMode);
|
|
|
|
|
|
|
|
for (int i = 0; i < numberTabs; ++i) {
|
|
|
|
QLabel *tabLabel = new QLabel("Tab number " + QString::number(i) + "\n" + tabText, &tabWidget);
|
|
|
|
QBoxLayout *tabBox = new QBoxLayout(QBoxLayout::TopToBottom,&tabWidget);
|
|
|
|
tabBox->addWidget(tabLabel);
|
|
|
|
tabWidget.insertTab(i,tabLabel,"Tab_" + QString::number(i));
|
|
|
|
tabWidget.setCurrentIndex(i);
|
|
|
|
tabWidget.currentWidget()->setLayout(tabBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
tabWidget.setCurrentIndex(0);
|
|
|
|
QBoxLayout box(QBoxLayout::LeftToRight, testWindow());
|
|
|
|
box.addWidget(&tabWidget);
|
|
|
|
testWindow()->setLayout(&box);
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
// press/release on second tab if it exists
|
|
|
|
if (numberTabs > 1) {
|
|
|
|
const QPoint clickTarget = tabWidget.tabBar()->tabRect(1).center();
|
|
|
|
QTest::mousePress(tabWidget.tabBar(),Qt::MouseButton::LeftButton,Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressSecondTab");
|
|
|
|
QTest::mouseRelease(tabWidget.tabBar(),Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QVERIFY(tabWidget.currentIndex() == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// test press/release on close button
|
|
|
|
if (isClosable) {
|
|
|
|
|
|
|
|
// CloseButton is either left or right
|
|
|
|
QWidget *leftButton = tabWidget.tabBar()->tabButton(tabWidget.currentIndex(),QTabBar::ButtonPosition::LeftSide);
|
|
|
|
QWidget *rightButton = tabWidget.tabBar()->tabButton(tabWidget.currentIndex(),QTabBar::ButtonPosition::RightSide);
|
|
|
|
QAbstractButton *button = qobject_cast<QAbstractButton*>(leftButton);
|
|
|
|
if (button == nullptr)
|
|
|
|
button = qobject_cast<QAbstractButton*>(rightButton);
|
|
|
|
|
|
|
|
if (button != nullptr) {
|
|
|
|
const QPoint clickTarget = button->rect().center();
|
|
|
|
QTest::mousePress(button,Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "pressCloseTab");
|
|
|
|
QTest::mouseRelease(button,Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "releaseCloseTab");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-03 12:34:09 +00:00
|
|
|
void tst_Widgets::tst_QListView_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QListView::ViewMode>("viewMode");
|
|
|
|
QTest::addColumn<bool>("isWrapping");
|
|
|
|
QTest::addColumn<bool>("hasWordWrap");
|
|
|
|
QTest::addColumn<int>("numberItems");
|
|
|
|
QTest::addColumn<QSize>("fixedSize");
|
|
|
|
|
|
|
|
|
|
|
|
// QSize() will be interpreted as variable size
|
|
|
|
QTest::newRow("ListModeWrappingNoWordWrapFixed_10") <<
|
|
|
|
QListView::ListMode << true << false << 10 << QSize(100, 500);
|
|
|
|
QTest::newRow("ListModeNoWrappingNoWordWrapVariable_20") <<
|
|
|
|
QListView::ListMode << false << true << 20 << QSize();
|
|
|
|
QTest::newRow("ListModeNoWrappingWordWrapVariable_30") <<
|
|
|
|
QListView::ListMode << false << true << 30 << QSize();
|
|
|
|
QTest::newRow("IconModeNoWrappingNoWordWrapFixed_10") <<
|
|
|
|
QListView::IconMode << false << false << 10 << QSize(100, 500);
|
|
|
|
QTest::newRow("IconModeWrappingNoWordWrapVariable_20") <<
|
|
|
|
QListView::IconMode << true << false << 20 << QSize();
|
|
|
|
QTest::newRow("IconModeWrappingWordWrapVariable_30") <<
|
|
|
|
QListView::IconMode << true << true << 30 << QSize(100, 500);
|
|
|
|
}
|
|
|
|
void tst_Widgets::tst_QListView()
|
|
|
|
{
|
|
|
|
QFETCH(QListView::ViewMode,viewMode);
|
|
|
|
QFETCH(bool,isWrapping);
|
|
|
|
QFETCH(bool,hasWordWrap);
|
|
|
|
QFETCH(int,numberItems);
|
|
|
|
QFETCH(QSize,fixedSize);
|
|
|
|
|
|
|
|
QListView listView;
|
|
|
|
listView.setViewMode(viewMode);
|
|
|
|
listView.setWrapping(isWrapping);
|
|
|
|
listView.setWordWrap(hasWordWrap);
|
|
|
|
if (fixedSize.isValid())
|
|
|
|
listView.setFixedSize(fixedSize);
|
|
|
|
|
|
|
|
QStandardItemModel model(0,1,testWindow());
|
|
|
|
|
|
|
|
// Populate model, add standard icons if required
|
|
|
|
const QString itemText = hasWordWrap ? "This is a long text for word wrapping Item_"
|
|
|
|
: "ListItem_";
|
|
|
|
int icon = 0;
|
|
|
|
for (int i = 0; i < numberItems; ++i) {
|
|
|
|
QStandardItem *item;
|
|
|
|
if (viewMode == QListView::IconMode) {
|
|
|
|
item = new QStandardItem(QApplication::style()->standardIcon
|
|
|
|
(static_cast<QStyle::StandardPixmap>(icon)), itemText + QString::number(i));
|
|
|
|
icon = (icon + 1) % numberStandardIcons;
|
|
|
|
} else {
|
|
|
|
item = new QStandardItem(itemText + QString::number(i));
|
|
|
|
}
|
|
|
|
model.appendRow(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
listView.setModel(&model);
|
|
|
|
QBoxLayout layout(QBoxLayout::LeftToRight, testWindow());
|
|
|
|
layout.addWidget(&listView);
|
|
|
|
testWindow()->setLayout(&layout);
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
// click on first item
|
|
|
|
QPoint clickTarget = listView.visualRect(model.index(0,0)).center();
|
|
|
|
QTest::mouseClick(listView.viewport(),Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "clickFirstItem");
|
|
|
|
|
|
|
|
// click on scond item
|
|
|
|
if (numberItems > 1) {
|
|
|
|
clickTarget = listView.visualRect(model.index(1,0)).center();
|
|
|
|
QTest::mouseClick(listView.viewport(),Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "clickSecondItem");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hide first row
|
|
|
|
listView.setRowHidden(0,true);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "hideFirstItem");
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QTableView_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("hasHeader");
|
|
|
|
QTest::addColumn<bool>("hasRowNumbers");
|
|
|
|
QTest::addColumn<bool>("hasWordWrap");
|
|
|
|
QTest::addColumn<int>("numberRows");
|
|
|
|
QTest::addColumn<int>("numberColumns");
|
|
|
|
QTest::addColumn<int>("iconColumn");
|
|
|
|
QTest::addColumn<QSize>("fixedSize");
|
|
|
|
|
|
|
|
// QSize() => variable size; iconColumn -1 => no icon
|
|
|
|
QTest::newRow("HeaderRowNumWordWrapFixed_10") << true << true << true << 10 << 3 << -1 << QSize(500, 100);
|
|
|
|
QTest::newRow("HeaderVariable_20") << true << false << false << 20 << 4 << 1 << QSize();
|
|
|
|
QTest::newRow("HeaderFixed_20") << true << false << false << 20 << 4 << 1 << QSize(500, 700);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QTableView()
|
|
|
|
{
|
|
|
|
QFETCH(bool, hasHeader);
|
|
|
|
QFETCH(bool, hasRowNumbers);
|
|
|
|
QFETCH(bool, hasWordWrap);
|
|
|
|
QFETCH(int, numberRows);
|
|
|
|
QFETCH(int, numberColumns);
|
|
|
|
QFETCH(int, iconColumn);
|
|
|
|
QFETCH(QSize, fixedSize);
|
|
|
|
|
|
|
|
// Populate model
|
|
|
|
int icon = 0;
|
|
|
|
QStandardItemModel model(numberRows, numberColumns, testWindow());
|
|
|
|
|
|
|
|
if (hasHeader) {
|
|
|
|
for (int i = 0; i < numberColumns; ++i)
|
|
|
|
model.setHorizontalHeaderItem(i, new QStandardItem("Header_" + QString::number(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString wrap = hasWordWrap ? "\n long text to wrap words" : "" ;
|
|
|
|
for (int row = 0; row < numberRows; ++row) {
|
|
|
|
for (int column = 0; column < numberColumns; ++column) {
|
|
|
|
QStandardItem *item;
|
|
|
|
const QString itemText = QString::number(row) + "/" + QString::number(column) + wrap;
|
|
|
|
if (iconColumn == column) {
|
|
|
|
item = new QStandardItem(QApplication::style()->standardIcon
|
|
|
|
(static_cast<QStyle::StandardPixmap>(icon)),itemText);
|
|
|
|
|
|
|
|
icon = (icon + 1) % numberStandardIcons;
|
|
|
|
} else {
|
|
|
|
item = new QStandardItem(itemText);
|
|
|
|
}
|
|
|
|
model.setItem(row,column,item);
|
|
|
|
}
|
|
|
|
if (hasRowNumbers)
|
|
|
|
model.setVerticalHeaderItem(row, new QStandardItem(QString::number(row)));
|
|
|
|
}
|
|
|
|
|
|
|
|
QTableView tableView(testWindow());
|
|
|
|
tableView.setWordWrap(hasWordWrap);
|
|
|
|
if (fixedSize.isValid())
|
|
|
|
tableView.setFixedSize(fixedSize);
|
|
|
|
|
|
|
|
QBoxLayout layout(QBoxLayout::LeftToRight, testWindow());
|
|
|
|
tableView.setModel(&model);
|
|
|
|
layout.addWidget(&tableView);
|
|
|
|
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
// Hide grid
|
|
|
|
tableView.setShowGrid(false);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "hideGrid");
|
|
|
|
tableView.setShowGrid(true);
|
|
|
|
|
|
|
|
// click item 0,0
|
|
|
|
QPoint clickTarget = tableView.visualRect(model.index(0,0)).center();
|
|
|
|
QTest::mouseClick(tableView.viewport(),Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "clickFirstItem");
|
|
|
|
|
|
|
|
// click item 0,1 if it exists
|
|
|
|
if (numberColumns > 1) {
|
|
|
|
clickTarget = tableView.visualRect(model.index(0,1)).center();
|
|
|
|
QTest::mouseClick(tableView.viewport(),Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget,0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "clickSecondItem");
|
|
|
|
}
|
|
|
|
|
|
|
|
tableView.clearSelection();
|
|
|
|
|
|
|
|
// Hide first row and column
|
|
|
|
tableView.setRowHidden(0, true);
|
|
|
|
tableView.setColumnHidden(0, true);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "hideFirstRowColumn");
|
|
|
|
tableView.setRowHidden(0, false);
|
|
|
|
tableView.setColumnHidden(0, false);
|
|
|
|
|
|
|
|
// Select first row
|
|
|
|
tableView.selectRow(0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "selectFirstRow");
|
|
|
|
|
|
|
|
// Select first column
|
|
|
|
tableView.selectColumn(0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "selectFirstColumn");
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QTreeView_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("showHeader");
|
|
|
|
QTest::addColumn<bool>("hasIcons");
|
|
|
|
QTest::addColumn<QSize>("fixedSize");
|
|
|
|
QTest::addColumn<int>("treeHeight");
|
|
|
|
QTest::addColumn<int>("itemsPerNode");
|
|
|
|
|
|
|
|
// QSize() => variable size
|
|
|
|
QTest::newRow("HeaderIcons_4_3") << true << true << QSize() << 3 << 2;
|
|
|
|
QTest::newRow("NoHeaderNoIcons_4_4") << false << false << QSize(100, 350) << 3 << 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QTreeView()
|
|
|
|
{
|
|
|
|
QFETCH(bool, showHeader);
|
|
|
|
QFETCH(bool, hasIcons);
|
|
|
|
QFETCH(QSize, fixedSize);
|
|
|
|
QFETCH(int, treeHeight);
|
|
|
|
QFETCH(int, itemsPerNode);
|
|
|
|
QVERIFY(treeHeight > 0 && itemsPerNode > 0);
|
|
|
|
|
|
|
|
QTreeView treeView(testWindow());
|
|
|
|
fixedSize.isValid() ? treeView.setFixedSize(fixedSize)
|
|
|
|
: treeView.setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
|
|
|
|
|
|
|
QStandardItemModel model(&treeView);
|
|
|
|
showHeader ? model.setHorizontalHeaderItem(0, new QStandardItem("TreeHeader"))
|
|
|
|
: treeView.setHeaderHidden(true);
|
|
|
|
|
|
|
|
// Populate tree model
|
|
|
|
for (int i = 0; i < itemsPerNode; ++i) {
|
|
|
|
QStandardItem* root = tst_QTreeView_populateItem(treeHeight, i, hasIcons);
|
|
|
|
tst_QTreeView_populateTree(root,treeHeight - 1,itemsPerNode, hasIcons);
|
|
|
|
model.appendRow(root);
|
|
|
|
}
|
|
|
|
|
|
|
|
treeView.setModel(&model);
|
|
|
|
QBoxLayout layout(QBoxLayout::LeftToRight, testWindow());
|
|
|
|
layout.addWidget(&treeView);
|
|
|
|
testWindow()->setLayout(&layout);
|
|
|
|
|
|
|
|
treeView.expandAll();
|
|
|
|
treeView.resizeColumnToContents(0);
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
// Partly expand if possible
|
|
|
|
if (treeHeight > 1) {
|
|
|
|
treeView.expandToDepth(1);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "partlyExpanded");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Click on first node
|
|
|
|
QPoint clickTarget = treeView.visualRect(model.index(0, 0)).center();
|
|
|
|
QTest::mouseClick(treeView.viewport(),Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget, 0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "clickFirstNode");
|
|
|
|
|
|
|
|
// Hide first row
|
|
|
|
treeView.setRowHidden(0, model.index(0, 0), true);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "hideFirstRow");
|
|
|
|
treeView.setRowHidden(0, model.index(0, 0), false);
|
|
|
|
|
|
|
|
// Click on second row if it exists
|
|
|
|
if (itemsPerNode > 1) {
|
|
|
|
clickTarget = treeView.visualRect(model.index(1, 0)).center();
|
|
|
|
QTest::mouseClick(treeView.viewport(), Qt::MouseButton::LeftButton,
|
|
|
|
Qt::KeyboardModifiers(), clickTarget, 0);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "clickSecondNode");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QTreeView_populateTree(QStandardItem* node, int height, int itemsPerNode, bool hasIcon)
|
|
|
|
{
|
|
|
|
QList<QStandardItem*> items;
|
|
|
|
for (int i = 0; i < itemsPerNode; ++i) {
|
|
|
|
if (height == 0) {
|
|
|
|
items.append(tst_QTreeView_populateItem(height, i, hasIcon));
|
|
|
|
} else {
|
|
|
|
QStandardItem* item = tst_QTreeView_populateItem(height, i, hasIcon);
|
|
|
|
tst_QTreeView_populateTree(item, height - 1, itemsPerNode, hasIcon);
|
|
|
|
items.append(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return node->appendColumn(items);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStandardItem* tst_Widgets::tst_QTreeView_populateItem(int height, int number, bool hasIcon)
|
|
|
|
{
|
|
|
|
static int icon = 0;
|
|
|
|
static int itemCount = 0;
|
|
|
|
|
|
|
|
QStandardItem* item;
|
|
|
|
const QString itemText = QString("%1/%2/%3").arg(height).arg(number).arg(itemCount);
|
|
|
|
++itemCount;
|
|
|
|
|
|
|
|
if (hasIcon) {
|
|
|
|
item = new QStandardItem(QApplication::style()->standardIcon
|
|
|
|
(static_cast<QStyle::StandardPixmap>(icon)), itemText);
|
|
|
|
|
|
|
|
icon = (icon + 1) % numberStandardIcons;
|
|
|
|
} else {
|
|
|
|
item = new QStandardItem(itemText);
|
|
|
|
}
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QLineEdit_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("hasFrame");
|
|
|
|
QTest::addColumn<QLineEdit::EchoMode>("echoMode");
|
|
|
|
QTest::addColumn<QString>("placeHolderText");
|
|
|
|
QTest::addColumn<QString>("text");
|
|
|
|
|
|
|
|
QTest::newRow("framePassword") << true << QLineEdit::Password << "password" << "secret";
|
|
|
|
QTest::newRow("noFrameCleartext") << false << QLineEdit::Normal << "text" << "this is a text";
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_Widgets::tst_QLineEdit()
|
|
|
|
{
|
|
|
|
QFETCH(const bool, hasFrame);
|
|
|
|
QFETCH(const QLineEdit::EchoMode, echoMode);
|
|
|
|
QFETCH(const QString, placeHolderText);
|
|
|
|
QFETCH(const QString, text);
|
|
|
|
|
|
|
|
QLineEdit lineEdit(testWindow());
|
|
|
|
lineEdit.setFrame(hasFrame);
|
|
|
|
lineEdit.setEchoMode(echoMode);
|
|
|
|
lineEdit.setPlaceholderText(placeHolderText);
|
|
|
|
|
|
|
|
QHBoxLayout layout;
|
|
|
|
layout.addWidget(&lineEdit);
|
|
|
|
testWindow()->setLayout(&layout);
|
|
|
|
takeStandardSnapshots();
|
|
|
|
|
|
|
|
lineEdit.setText(text);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "setText");
|
|
|
|
|
|
|
|
lineEdit.setAlignment(Qt::AlignRight);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "alignedRight");
|
|
|
|
|
|
|
|
lineEdit.setAlignment(Qt::AlignCenter);
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "alignedCenter");
|
|
|
|
|
|
|
|
lineEdit.setSelection(0,text.length());
|
|
|
|
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "textSelected");
|
|
|
|
}
|
|
|
|
|
Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.
Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.
The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).
Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.
Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 19:29:22 +00:00
|
|
|
#define main _realmain
|
|
|
|
QTEST_MAIN(tst_Widgets)
|
|
|
|
#undef main
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
qSetGlobalQHashSeed(0); // Avoid rendering variations caused by QHash randomization
|
|
|
|
|
|
|
|
QBaselineTest::handleCmdLineArgs(&argc, &argv);
|
|
|
|
return _realmain(argc, argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "tst_baseline_widgets.moc"
|