summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2010-04-09 12:48:41 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2010-04-12 06:31:40 (GMT)
commitd22c8c60ffd986cc46d1f1cab878d60b03b5d4ea (patch)
tree179467591fcda27b0fd53b65ab22039ad3d4788c /tests
parentef3b0420bfa9ef810267d174922ff2477f983c8d (diff)
downloadQt-d22c8c60ffd986cc46d1f1cab878d60b03b5d4ea.zip
Qt-d22c8c60ffd986cc46d1f1cab878d60b03b5d4ea.tar.gz
Qt-d22c8c60ffd986cc46d1f1cab878d60b03b5d4ea.tar.bz2
Implement heightForWidth support for QTabWidget and QStackedLayout.
In order to add the support we also had to add hasHeightForWidth to QWidget that calls the new virtual hasHeightForWidth() in QWidgetPrivate Task-number: QTBUG-7792 Reviewed-by: Paul
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtabwidget/tst_qtabwidget.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp
index 4491fb3..204c27a 100644
--- a/tests/auto/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp
@@ -45,6 +45,7 @@
#include <qdebug.h>
#include <qapplication.h>
#include <qlabel.h>
+#include <qboxlayout.h>
//TESTED_CLASS=
//TESTED_FILES=
@@ -120,6 +121,8 @@ class tst_QTabWidget:public QObject {
void clear();
void keyboardNavigation();
void paintEventCount();
+ void heightForWidth();
+ void heightForWidth_data();
private:
int addPage();
@@ -621,6 +624,50 @@ void tst_QTabWidget::paintEventCount()
QCOMPARE(tab2->count, 1);
}
+void tst_QTabWidget::heightForWidth_data()
+{
+ QTest::addColumn<int>("tabPosition");
+ QTest::newRow("West") << int(QTabWidget::West);
+ QTest::newRow("North") << int(QTabWidget::North);
+ QTest::newRow("East") << int(QTabWidget::East);
+ QTest::newRow("South") << int(QTabWidget::South);
+}
+
+void tst_QTabWidget::heightForWidth()
+{
+ QFETCH(int, tabPosition);
+
+ QWidget *window = new QWidget;
+ QVBoxLayout *lay = new QVBoxLayout(window);
+ lay->setMargin(0);
+ lay->setSpacing(0);
+ QTabWidget *tabWid = new QTabWidget(window);
+ QWidget *w = new QWidget;
+ tabWid->addTab(w, QLatin1String("HFW page"));
+ tabWid->setTabPosition(QTabWidget::TabPosition(tabPosition));
+ QVBoxLayout *lay2 = new QVBoxLayout(w);
+ QLabel *label = new QLabel("Label with wordwrap turned on makes it trade height for width."
+ " Make it a really long text so that it spans on several lines"
+ " when the label is on its narrowest."
+ " I don't like to repeat myself."
+ " I don't like to repeat myself."
+ " I don't like to repeat myself."
+ " I don't like to repeat myself."
+ );
+ label->setWordWrap(true);
+ lay2->addWidget(label);
+ lay2->setMargin(0);
+
+ lay->addWidget(tabWid);
+ int h = window->heightForWidth(160);
+ window->resize(160, h);
+ window->show();
+
+ QTest::qWaitForWindowShown(window);
+ QVERIFY(label->height() >= label->heightForWidth(label->width()));
+
+ delete window;
+}
QTEST_MAIN(tst_QTabWidget)
#include "tst_qtabwidget.moc"