diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-31 08:28:28 +0300 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-08-01 12:55:07 +0000 |
commit | 4726f47b41e507a967c8995609e11947dde4c250 (patch) | |
tree | cb975c2e5c2309306c6522f18bd5beb5176c39ad /tests/auto/widgets/widgets | |
parent | f23f9ba041a790566ca1553d4dc138af3c49db80 (diff) |
Port users of get{Contents,Text}Margins() missed first time around
Done-with: Sona Kurazyan <sona.kurazyan@qt.io>
Change-Id: I5b584cbe468429c53c2d661a0d7957d74e7ad691
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r-- | tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 8 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 14 |
2 files changed, 14 insertions, 8 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index f1bc3e8dd4..1c68a5f752 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3530,6 +3530,13 @@ void tst_QLineEdit::textMargin() centerOnScreen(&tlw); tlw.show(); + const QMargins margins = testWidget.textMargins(); + QCOMPARE(left, margins.left()); + QCOMPARE(top, margins.top()); + QCOMPARE(right, margins.right()); + QCOMPARE(bottom, margins.bottom()); + +#if QT_DEPRECATED_SINCE(5, 14) int l; int t; int r; @@ -3539,6 +3546,7 @@ void tst_QLineEdit::textMargin() QCOMPARE(top, t); QCOMPARE(right, r); QCOMPARE(bottom, b); +#endif QTest::mouseClick(&testWidget, Qt::LeftButton, 0, mousePressPos); QTRY_COMPARE(testWidget.cursorPosition(), cursorPosition); diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 4f5a2ce1a6..9c40c0bd57 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -951,8 +951,7 @@ void tst_QMenu::menuSizeHint() for (auto str : {"trer", "ezrfgtgvqd", "sdgzgzerzerzer", "eerzertz", "er"}) menu.addAction(str); - int left, top, right, bottom; - menu.getContentsMargins(&left, &top, &right, &bottom); + const QMargins cm = menu.contentsMargins(); const int panelWidth = menu.style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, &menu); const int hmargin = menu.style()->pixelMetric(QStyle::PM_MenuHMargin, 0, &menu), vmargin = menu.style()->pixelMetric(QStyle::PM_MenuVMargin, 0, &menu); @@ -962,15 +961,15 @@ void tst_QMenu::menuSizeHint() for (QAction *action : menu.actions()) { maxWidth = qMax(maxWidth, menu.actionGeometry(action).width()); result |= menu.actionGeometry(action); - QCOMPARE(result.x(), left + hmargin + panelWidth); - QCOMPARE(result.y(), top + vmargin + panelWidth); + QCOMPARE(result.x(), cm.left() + hmargin + panelWidth); + QCOMPARE(result.y(), cm.top() + vmargin + panelWidth); } QStyleOption opt(0); opt.rect = menu.rect(); opt.state = QStyle::State_None; - QSize resSize = QSize(result.x(), result.y()) + result.size() + QSize(hmargin + right + panelWidth, vmargin + top + panelWidth); + QSize resSize = QSize(result.x(), result.y()) + result.size() + QSize(hmargin + cm.right() + panelWidth, vmargin + cm.top() + panelWidth); resSize = menu.style()->sizeFromContents(QStyle::CT_Menu, &opt, resSize.expandedTo(QApplication::globalStrut()), &menu); @@ -1571,8 +1570,7 @@ void tst_QMenu::menuSize_Scrolling() int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin, nullptr, this); int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, this); - int leftMargin, topMargin, rightMargin, bottomMargin; - getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); + const QMargins cm = contentsMargins(); QRect lastItem = actionGeometry(actions().at(actions().length() - 1)); QSize s = size(); #ifdef Q_OS_WINRT @@ -1585,7 +1583,7 @@ void tst_QMenu::menuSize_Scrolling() return; } - QCOMPARE( s.width(), lastItem.right() + fw + hmargin + rightMargin + 1); + QCOMPARE( s.width(), lastItem.right() + fw + hmargin + cm.right() + 1); QMenu::showEvent(e); } |