summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp')
-rw-r--r--tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp64
1 files changed, 34 insertions, 30 deletions
diff --git a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
index 8e4e2a0ea4..c3b53addcc 100644
--- a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
+++ b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -36,6 +11,8 @@
#include <qwhatsthis.h>
#include <qscreen.h>
+#include <QtWidgets/private/qapplication_p.h>
+
class tst_QToolTip : public QObject
{
Q_OBJECT
@@ -49,6 +26,7 @@ private slots:
void setPalette();
void qtbug64550_stylesheet();
void dontCrashOutsideScreenGeometry();
+ void marginSetWithStyleSheet();
};
void tst_QToolTip::init()
@@ -120,7 +98,7 @@ void tst_QToolTip::keyEvent()
widget.setWindowTitle(QLatin1String(QTest::currentTestFunction())
+ QLatin1Char(' ') + QLatin1String(QTest::currentDataTag()));
widget.show();
- QApplication::setActiveWindow(&widget);
+ QApplicationPrivate::setActiveWindow(&widget);
QVERIFY(QTest::qWaitForWindowActive(&widget));
widget.showDelayedToolTip(100);
@@ -140,7 +118,8 @@ void tst_QToolTip::keyEvent()
static QWidget *findWhatsThat()
{
- foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ const auto widgets = QApplication::topLevelWidgets();
+ for (QWidget *widget : widgets) {
if (widget->inherits("QWhatsThat"))
return widget;
}
@@ -214,7 +193,7 @@ void tst_QToolTip::qtbug64550_stylesheet()
Widget widget;
widget.setStyleSheet(QStringLiteral("* { font-size: 48pt; }\n"));
widget.show();
- QApplication::setActiveWindow(&widget);
+ QApplicationPrivate::setActiveWindow(&widget);
QVERIFY(QTest::qWaitForWindowActive(&widget));
widget.showDelayedToolTip(100);
@@ -236,5 +215,30 @@ void tst_QToolTip::dontCrashOutsideScreenGeometry() {
QToolTip::hideText();
}
+void tst_QToolTip::marginSetWithStyleSheet()
+{
+ const char *toolTipText = "Test Tool Tip";
+
+ qApp->setStyleSheet("QToolTip {font-size: 8px; margin: 5px;}");
+ QToolTip::showText(QGuiApplication::primaryScreen()->availableGeometry().topLeft(), toolTipText);
+ QTRY_VERIFY(QToolTip::isVisible());
+ QWidget *toolTip = findToolTip();
+ QVERIFY(toolTip);
+ QTRY_VERIFY(toolTip->isVisible());
+ int toolTipHeight = toolTip->size().height();
+ qApp->setStyleSheet(QString());
+ QToolTip::hideText();
+
+ qApp->setStyleSheet("QToolTip {font-size: 8px; margin: 10px;}");
+ QToolTip::showText(QGuiApplication::primaryScreen()->availableGeometry().topLeft(), toolTipText);
+ QTRY_VERIFY(QToolTip::isVisible());
+ toolTip = findToolTip();
+ QVERIFY(toolTip);
+ QTRY_VERIFY(toolTip->isVisible());
+ QCOMPARE_LE(toolTip->size().height(), toolTipHeight + 10);
+ qApp->setStyleSheet(QString());
+ QToolTip::hideText();
+}
+
QTEST_MAIN(tst_QToolTip)
#include "tst_qtooltip.moc"