summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-07-23 15:26:19 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2019-08-01 17:04:13 +0000
commit376715f1a57209cbb19502954a37939e2d6d88c6 (patch)
tree83786e4d39be7ce6f6ce3897d8fad8aab899b9f6 /tests/auto/widgets/widgets
parentbd2c8353b44a1e63b84852ec9adeed78dbfab312 (diff)
Remove usages of deprecated APIs of qtbase/widgets
- Replace the usages of deprecated APIs by corresponding alternatives in the library code and documentation. - Build docs for deprecated APIs conditionally, based on deprecation version. Remove the docs of methods deprecated since 5.0.0, these methods are not compiled anymore. - Modify the tests to make them build when deprecated APIs disabled: * Make the the parts of the tests testing the deprecated APIs to be compiled conditionally, only when the corresponding methods are enabled. * If the test-case tests only the deprecated API, but not the corresponding replacement, add tests for the replacement Task-number: QTBUG-76491 Task-number: QTBUG-76540 Task-number: QTBUG-76541 Change-Id: I6aaf0a1369c479fb880369a38f2b8e1e86b46934 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp19
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp7
-rw-r--r--tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp2
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp4
6 files changed, 28 insertions, 8 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 8a46211714..4e16edaca8 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -254,12 +254,22 @@ void tst_QComboBox::getSetCheck()
obj1.setMaxCount(INT_MAX);
QCOMPARE(INT_MAX, obj1.maxCount());
+ // QCompleter *QComboBox::completer()
+ // void QComboBox::setCompleter(QCompleter *)
+ obj1.setCompleter(nullptr);
+ QCOMPARE(nullptr, obj1.completer());
+ QCompleter completer;
+ obj1.setCompleter(&completer);
+ QVERIFY(obj1.completer() == nullptr); // no QLineEdit is set
+
+#if QT_DEPRECATED_SINCE(5, 13)
// bool QComboBox::autoCompletion()
// void QComboBox::setAutoCompletion(bool)
obj1.setAutoCompletion(false);
QCOMPARE(false, obj1.autoCompletion());
obj1.setAutoCompletion(true);
QCOMPARE(true, obj1.autoCompletion());
+#endif
// bool QComboBox::duplicatesEnabled()
// void QComboBox::setDuplicatesEnabled(bool)
@@ -317,6 +327,9 @@ void tst_QComboBox::getSetCheck()
QCOMPARE(var8, obj1.lineEdit());
// delete var8; // No delete, since QComboBox takes ownership
+ // After setting a line edit, completer() should not return nullptr anymore
+ QVERIFY(obj1.completer() != nullptr);
+
// const QValidator * QComboBox::validator()
// void QComboBox::setValidator(const QValidator *)
QIntValidator *var9 = new QIntValidator(0);
@@ -777,7 +790,9 @@ void tst_QComboBox::virtualAutocompletion()
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
QComboBox *testWidget = topLevel.comboBox();
testWidget->clear();
+#if QT_DEPRECATED_SINCE(5, 13)
testWidget->setAutoCompletion(true);
+#endif
testWidget->addItem("Foo");
testWidget->addItem("Bar");
testWidget->addItem("Boat");
@@ -837,7 +852,9 @@ void tst_QComboBox::autoCompletionCaseSensitivity()
QCOMPARE(qApp->focusWidget(), (QWidget *)testWidget);
testWidget->clear();
+#if QT_DEPRECATED_SINCE(5, 13)
testWidget->setAutoCompletion(true);
+#endif
testWidget->addItem("Cow");
testWidget->addItem("irrelevant1");
testWidget->addItem("aww");
@@ -3054,7 +3071,9 @@ void tst_QComboBox::task_QTBUG_31146_popupCompletion()
{
QComboBox comboBox;
comboBox.setEditable(true);
+#if QT_DEPRECATED_SINCE(5, 13)
comboBox.setAutoCompletion(true);
+#endif
comboBox.setInsertPolicy(QComboBox::NoInsert);
comboBox.completer()->setCaseSensitivity(Qt::CaseInsensitive);
comboBox.completer()->setCompletionMode(QCompleter::PopupCompletion);
diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
index 34862f6810..f599ac73c6 100644
--- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -461,7 +461,7 @@ void tst_QLabel::unicodeText()
QVBoxLayout *layout = new QVBoxLayout();
QLabel *label = new QLabel(text, &frame);
layout->addWidget(label);
- layout->setMargin(8);
+ layout->setContentsMargins(8, 8, 8, 8);
frame.setLayout(layout);
frame.show();
QVERIFY(QTest::qWaitForWindowExposed(&frame));
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index 046899ce05..b8abd78657 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -880,7 +880,7 @@ void tst_QMdiArea::minimumSizeHint()
{
QMdiArea workspace;
workspace.show();
- QSize expectedSize(workspace.style()->pixelMetric(QStyle::PM_MDIMinimizedWidth),
+ QSize expectedSize(workspace.style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth),
workspace.style()->pixelMetric(QStyle::PM_TitleBarHeight));
qApp->processEvents();
QAbstractScrollArea dummyScrollArea;
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index 2b59a227b3..b8891fab95 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -613,7 +613,7 @@ void tst_QMdiSubWindow::showShaded()
// Calculate mouse position for bottom right corner and simulate a
// vertical resize with the mouse.
- int offset = window->style()->pixelMetric(QStyle::PM_MDIFrameWidth) / 2;
+ int offset = window->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth) / 2;
QPoint mousePosition(window->width() - qMax(offset, 2), window->height() - qMax(offset, 2));
QWidget *mouseReceiver = nullptr;
#ifdef Q_OS_MAC
@@ -759,7 +759,7 @@ void tst_QMdiSubWindow::setOpaqueResizeAndMove()
QTRY_COMPARE(priv->resizeTimerId, -1);
// Enter resize mode.
- int offset = window->style()->pixelMetric(QStyle::PM_MDIFrameWidth) / 2;
+ int offset = window->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth) / 2;
QPoint mousePosition(mouseReceiver->width() - qMax(offset, 2), mouseReceiver->height() - qMax(offset, 2));
sendMouseMove(mouseReceiver, mousePosition, Qt::NoButton);
sendMousePress(mouseReceiver, mousePosition);
@@ -1762,7 +1762,8 @@ void tst_QMdiSubWindow::fixedMinMaxSize()
int minimizedHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
if (!subWindow->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, subWindow))
minimizedHeight += 8;
- int minimizedWidth = subWindow->style()->pixelMetric(QStyle::PM_MDIMinimizedWidth, &options);
+ int minimizedWidth = subWindow->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth,
+ &options);
const QSize minimizedSize = QSize(minimizedWidth, minimizedHeight);
// Even though the sub window has a minimum size set, it should be possible
diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
index 8b45ac20b7..cbeb77a25e 100644
--- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
@@ -599,7 +599,7 @@ void tst_QSplitter::testShowHide()
QWidget widget(&topLevel);
widget.resize(400 + split->handleWidth(), 200);
QVBoxLayout *lay=new QVBoxLayout(&widget);
- lay->setMargin(0);
+ lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(0);
split->addWidget(new QWidget);
split->addWidget(new QWidget);
diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
index cbf5196bb9..feade7d443 100644
--- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
@@ -620,7 +620,7 @@ void tst_QTabWidget::heightForWidth()
QWidget *window = new QWidget;
QVBoxLayout *lay = new QVBoxLayout(window);
- lay->setMargin(0);
+ lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(0);
QTabWidget *tabWid = new QTabWidget(window);
QWidget *w = new QWidget;
@@ -637,7 +637,7 @@ void tst_QTabWidget::heightForWidth()
);
label->setWordWrap(true);
lay2->addWidget(label);
- lay2->setMargin(0);
+ lay2->setContentsMargins(0, 0, 0, 0);
lay->addWidget(tabWid);
int h = window->heightForWidth(160);