diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2009-06-29 07:00:09 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2009-06-29 07:00:09 (GMT) |
commit | 74b3de38bce01b06954e7ff836693f80dc9e66ee (patch) | |
tree | 62d1e8c3e921327bed678859636a92f56285dbba /tests | |
parent | 81efb149c9cea095ef62ceb11a963a0fb0fad73e (diff) | |
parent | a8cd5dc1294f2bbaa12c88d7f59b61a1011f5d18 (diff) | |
download | Qt-74b3de38bce01b06954e7ff836693f80dc9e66ee.zip Qt-74b3de38bce01b06954e7ff836693f80dc9e66ee.tar.gz Qt-74b3de38bce01b06954e7ff836693f80dc9e66ee.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qpushbutton/tst_qpushbutton.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp index cf79ffc..7a81dbf 100644 --- a/tests/auto/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp @@ -51,6 +51,8 @@ #include <qtimer.h> #include <QDialog> #include <QGridLayout> +#include <QStyleFactory> +#include <QTabWidget> Q_DECLARE_METATYPE(QPushButton*) @@ -90,6 +92,8 @@ private slots: void toggled(); void isEnabled(); void defaultAndAutoDefault(); + void sizeHint_data(); + void sizeHint(); /* void state(); void group(); @@ -590,5 +594,77 @@ void tst_QPushButton::defaultAndAutoDefault() } } +void tst_QPushButton::sizeHint_data() +{ + QTest::addColumn<QString>("stylename"); + QTest::newRow("motif") << QString::fromAscii("motif"); + QTest::newRow("cde") << QString::fromAscii("cde"); + QTest::newRow("windows") << QString::fromAscii("windows"); + QTest::newRow("cleanlooks") << QString::fromAscii("cleanlooks"); + QTest::newRow("gtk") << QString::fromAscii("gtk"); + QTest::newRow("mac") << QString::fromAscii("mac"); + QTest::newRow("plastique") << QString::fromAscii("plastique"); + QTest::newRow("windowsxp") << QString::fromAscii("windowsxp"); + QTest::newRow("windowsvista") << QString::fromAscii("windowsvista"); +} + +void tst_QPushButton::sizeHint() +{ + QFETCH(QString, stylename); + + QStyle *style = QStyleFactory::create(stylename); + if (!style) + QSKIP(qPrintable(QString::fromLatin1("Qt has been compiled without style: %1") + .arg(stylename)), SkipSingle); + QApplication::setStyle(style); + +// Test 1 + { + QPushButton *button = new QPushButton("123"); + QSize initSizeHint = button->sizeHint(); + + QDialog *dialog = new QDialog; + QWidget *widget = new QWidget(dialog); + button->setParent(widget); + button->sizeHint(); + + widget->setParent(0); + delete dialog; + button->setDefault(false); + QCOMPARE(button->sizeHint(), initSizeHint); + delete button; + } + +// Test 2 + { + QWidget *tab1 = new QWidget; + QHBoxLayout *layout1 = new QHBoxLayout(tab1); + QPushButton *button1_1 = new QPushButton("123"); + QPushButton *button1_2 = new QPushButton("123"); + layout1->addWidget(button1_1); + layout1->addWidget(button1_2); + + QWidget *tab2 = new QWidget; + QHBoxLayout *layout2 = new QHBoxLayout(tab2); + QPushButton *button2_1 = new QPushButton("123"); + QPushButton *button2_2 = new QPushButton("123"); + layout2->addWidget(button2_1); + layout2->addWidget(button2_2); + + QDialog *dialog = new QDialog; + QTabWidget *tabWidget = new QTabWidget; + tabWidget->addTab(tab1, "1"); + tabWidget->addTab(tab2, "2"); + QVBoxLayout *mainLayout = new QVBoxLayout(dialog); + mainLayout->addWidget(tabWidget); + dialog->show(); + tabWidget->setCurrentWidget(tab2); + tabWidget->setCurrentWidget(tab1); + QTest::qWait(100); + + QCOMPARE(button1_2->size(), button2_2->size()); + } +} + QTEST_MAIN(tst_QPushButton) #include "tst_qpushbutton.moc" |