summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-10-04 19:05:53 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-10-04 19:05:53 (GMT)
commit488c4fd1137c5702d2a52e9c00053561b69bcdb5 (patch)
tree940873cc78bc9505285da91f18d9c7068d6bd610 /tests
parenta7bf1cfb1a75c35e837c01f4a5b0697fc8961148 (diff)
parent0ee5619ac77285935317a2a068c90f8c999b3f0d (diff)
downloadQt-488c4fd1137c5702d2a52e9c00053561b69bcdb5.zip
Qt-488c4fd1137c5702d2a52e9c00053561b69bcdb5.tar.gz
Qt-488c4fd1137c5702d2a52e9c00053561b69bcdb5.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (21 commits) Update japanese translations. Ensure that the underline is only drawn when expected for an accel Small improvement in the textedit demo My changes for 4.7.1 QWorkspace: fix hardcoded min size overwriting the real min size Doc: Fixing link titles and error color in search results Doc: Implementing features to the search feature. Setting the _NET_WM_STATE Atom only when its not already set Fix focus appearance of tabwidget tabs with QGtkStyle Incorrect selection background for unfocused widgets with GTK Make the OpenSSL library search also hit /lib. Update change log. Doc: Implementing new doc search dialog. Doc: fixing slim fit style - search box. Doc: add style to new search results Doc: fixing bugs in slim-fit style Doc: Added lisence header to snippet Fix a link that no longer exists in documentation. Remove obsolete reference to qregexp.tex. Reference to QStringList::find() is incorrect, should be QStringList::filter(). ...
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qstyle/tst_qstyle.cpp51
-rw-r--r--tests/auto/qworkspace/tst_qworkspace.cpp10
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));