diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-07-13 15:28:09 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-07-13 15:28:09 (GMT) |
commit | 650353f402d725688821b83904fe6319c8afa4da (patch) | |
tree | 943c251676fe006e723e991bd126c002bcbb7bbd /tests/auto/qmenu/tst_qmenu.cpp | |
parent | 4a82d7cc185bd98ec8183fb0ccadefd3196b3ee2 (diff) | |
parent | 754d9c2f1d0dce16017b99f766c1fa3e47b0afde (diff) | |
download | Qt-650353f402d725688821b83904fe6319c8afa4da.zip Qt-650353f402d725688821b83904fe6319c8afa4da.tar.gz Qt-650353f402d725688821b83904fe6319c8afa4da.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt into qtwebkit-4.6-staging
Conflicts:
util/webkit/mkdist-webkit
Diffstat (limited to 'tests/auto/qmenu/tst_qmenu.cpp')
-rw-r--r-- | tests/auto/qmenu/tst_qmenu.cpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 2fb9b8b..1d19ffa 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -92,7 +92,9 @@ private slots: void activeSubMenuPosition(); void task242454_sizeHint(); void task176201_clear(); - void task250673_activeMutliColumnSubMenuPosition(); + void task250673_activeMultiColumnSubMenuPosition(); + void task256918_setFont(); + void menuSizeHint(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -679,7 +681,7 @@ void tst_QMenu::task176201_clear() QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center()); } -void tst_QMenu::task250673_activeMutliColumnSubMenuPosition() +void tst_QMenu::task250673_activeMultiColumnSubMenuPosition() { class MyMenu : public QMenu { @@ -713,5 +715,53 @@ void tst_QMenu::task250673_activeMutliColumnSubMenuPosition() const int subMenuOffset = main.style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, &main); QVERIFY((sub.geometry().left() - subMenuOffset + 5) < main.geometry().right()); } + + +void tst_QMenu::task256918_setFont() +{ + QMenu menu; + QAction *action = menu.addAction("foo"); + QFont f; + f.setPointSize(30); + action->setFont(f); + menu.show(); //ensures that the actiongeometry are calculated + QVERIFY(menu.actionGeometry(action).height() > f.pointSize()); +} + +void tst_QMenu::menuSizeHint() +{ + QMenu menu; + //this is a list of arbitrary strings so that we check the geometry + QStringList list = QStringList() << "trer" << "ezrfgtgvqd" << "sdgzgzerzerzer" << "eerzertz" << "er"; + foreach(QString str, list) + menu.addAction(str); + + int left, top, right, bottom; + menu.getContentsMargins(&left, &top, &right, &bottom); + 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); + + int maxWidth =0; + QRect result; + foreach(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); + } + + 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); + + resSize = menu.style()->sizeFromContents(QStyle::CT_Menu, &opt, + resSize.expandedTo(QApplication::globalStrut()), &menu); + + QCOMPARE(resSize, menu.sizeHint()); +} + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" |