diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qstyle/tst_qstyle.cpp | 51 | ||||
-rw-r--r-- | tests/auto/qworkspace/tst_qworkspace.cpp | 10 |
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp index a76c82d..ba24225 100644 --- a/tests/auto/qstyle/tst_qstyle.cpp +++ b/tests/auto/qstyle/tst_qstyle.cpp @@ -53,6 +53,7 @@ #include <qscrollbar.h> #include <qprogressbar.h> #include <qtoolbutton.h> +#include <qtoolbar.h> #include <qplastiquestyle.h> #include <qwindowsstyle.h> @@ -146,6 +147,7 @@ private slots: void pixelMetric(); void progressBarChangeStyle(); void defaultFont(); + void testDrawingShortcuts(); private: void lineUpLayoutTest(QStyle *); QWidget *testWidget; @@ -781,5 +783,54 @@ void tst_QStyle::defaultFont() qApp->setFont(defaultFont); } +class DrawTextStyle : public QProxyStyle +{ + Q_OBJECT +public: + DrawTextStyle(QStyle *base = 0) : QProxyStyle(), alignment(0) { setBaseStyle(base); } + void drawItemText(QPainter *painter, const QRect &rect, + int flags, const QPalette &pal, bool enabled, + const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const + { + DrawTextStyle *that = (DrawTextStyle *)this; + that->alignment = flags; + QProxyStyle::drawItemText(painter, rect, flags, pal, enabled, text, textRole); + } + int alignment; +}; + +void tst_QStyle::testDrawingShortcuts() +{ + { + QWidget w; + QToolButton *tb = new QToolButton(&w); + tb->setText("&abc"); + DrawTextStyle *dts = new DrawTextStyle; + w.show(); + tb->setStyle(dts); + QPixmap::grabWidget(tb); + QStyleOptionToolButton sotb; + sotb.initFrom(tb); + bool showMnemonic = dts->styleHint(QStyle::SH_UnderlineShortcut, &sotb, tb); + QVERIFY(dts->alignment & (showMnemonic ? Qt::TextShowMnemonic : Qt::TextHideMnemonic)); + delete dts; + } + { + QToolBar w; + QToolButton *tb = new QToolButton(&w); + tb->setText("&abc"); + DrawTextStyle *dts = new DrawTextStyle; + w.addWidget(tb); + w.show(); + tb->setStyle(dts); + QPixmap::grabWidget(tb); + QStyleOptionToolButton sotb; + sotb.initFrom(tb); + bool showMnemonic = dts->styleHint(QStyle::SH_UnderlineShortcut, &sotb, tb); + QVERIFY(dts->alignment & (showMnemonic ? Qt::TextShowMnemonic : Qt::TextHideMnemonic)); + delete dts; + } +} + QTEST_MAIN(tst_QStyle) #include "tst_qstyle.moc" diff --git a/tests/auto/qworkspace/tst_qworkspace.cpp b/tests/auto/qworkspace/tst_qworkspace.cpp index 4cf76b5..9039eb3 100644 --- a/tests/auto/qworkspace/tst_qworkspace.cpp +++ b/tests/auto/qworkspace/tst_qworkspace.cpp @@ -44,6 +44,7 @@ #include <qapplication.h> #include <qmainwindow.h> #include <qmenubar.h> +#include <qlayout.h> #include <qworkspace.h> #if defined(QT3_SUPPORT) #include <q3popupmenu.h> @@ -591,16 +592,25 @@ void tst_QWorkspace::childSize() MyChild *child = new MyChild(&ws); child->show(); + ws.addWindow(child); QCOMPARE(child->size(), child->sizeHint()); delete child; child = new MyChild(&ws); child->setFixedSize(200, 200); child->show(); + ws.addWindow(child); QCOMPARE(child->size(), child->minimumSize()); + QCOMPARE(child->parentWidget()->metaObject()->className(), "QWorkspaceChild"); + QVERIFY(child->parentWidget()->width() >= 200); + // check that the minimum size is respected, using closestAcceptableSize + // like QSizeGrip does. + const QSize newSize = QLayout::closestAcceptableSize(child->parentWidget(), QSize(100, 100)); + QVERIFY(newSize.width() >= 200); delete child; child = new MyChild(&ws); + ws.addWindow(child); child->resize(150, 150); child->show(); QCOMPARE(child->size(), QSize(150,150)); |