summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMartin Smith <msmith@trolltech.com>2010-04-07 09:55:11 (GMT)
committerMartin Smith <msmith@trolltech.com>2010-04-07 09:55:11 (GMT)
commit757e9af177544eaf6b66641ea724716ccd4b2701 (patch)
tree84aab0e4c7141b7a25db40838b9cf27829ff9fe8 /tests/auto
parenteeccdc0cec9a616e740e3b59a6f011bfe703ce09 (diff)
parent6947390e5d331ae653e91acecad70108915328e7 (diff)
downloadQt-757e9af177544eaf6b66641ea724716ccd4b2701.zip
Qt-757e9af177544eaf6b66641ea724716ccd4b2701.tar.gz
Qt-757e9af177544eaf6b66641ea724716ccd4b2701.tar.bz2
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index e10d7ee..4be6fdd 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -106,6 +106,8 @@ private slots:
void pushButtonPopulateOnAboutToShow();
void QTBUG7907_submenus_autoselect();
void QTBUG7411_submenus_activate();
+ void menuGeometry_data();
+ void menuGeometry();
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -967,6 +969,60 @@ void tst_QMenu::QTBUG7411_submenus_activate()
QTRY_VERIFY(sub1.isVisible());
}
+void tst_QMenu::menuGeometry_data()
+{
+ QTest::addColumn<QRect>("screen");
+ QTest::addColumn<QPoint>("pos");
+ QTest::addColumn<QPoint>("expectedPos");
+
+ QMenu menu("Test Menu");
+ for (int i = 0; i < 3; ++i)
+ menu.addAction("Hello World!");
+
+ menu.adjustSize();
+
+ const int screenCount = QApplication::desktop()->screenCount();
+ const int desktopFrame = menu.style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, &menu);
+
+ for (int i = 0; i < screenCount; ++i) {
+ const QRect screen = QApplication::desktop()->screenGeometry(i);
+
+ if (screen.width() < menu.width() || screen.height() < menu.height())
+ continue;
+
+ QTest::newRow("topLeft") << screen << screen.topLeft()
+ << QPoint(screen.left() + desktopFrame, screen.top() + desktopFrame);
+
+ QTest::newRow("topRight") << screen << screen.topRight()
+ << QPoint(screen.right() - desktopFrame - menu.width() + 1, screen.top() + desktopFrame);
+
+ QTest::newRow("bottomLeft") << screen << screen.bottomLeft()
+ << QPoint(screen.left() + desktopFrame, screen.bottom() - desktopFrame - menu.height() + 1);
+
+ QTest::newRow("bottomRight") << screen << screen.bottomRight()
+ << QPoint(screen.right() - desktopFrame - menu.width() + 1, screen.bottom() - desktopFrame - menu.height() + 1);
+
+ const QPoint pos = QPoint(screen.right() - qMax(desktopFrame, 20), screen.bottom() - qMax(desktopFrame, 20));
+ QTest::newRow("position") << screen << pos
+ << QPoint(screen.right() - menu.width() + 1, pos.y() - menu.height() + 1);
+ }
+}
+
+void tst_QMenu::menuGeometry()
+{
+ QFETCH(QRect, screen);
+ QFETCH(QPoint, pos);
+ QFETCH(QPoint, expectedPos);
+
+ QMenu menu("Test Menu");
+ for (int i = 0; i < 3; ++i)
+ menu.addAction("Hello World!");
+
+ menu.popup(pos);
+ QTest::qWaitForWindowShown(&menu);
+ QVERIFY(screen.contains(menu.geometry()));
+ QCOMPARE(menu.pos(), expectedPos);
+}
QTEST_MAIN(tst_QMenu)