diff options
author | Milla Pohjanheimo <milla.pohjanheimo@theqtcompany.com> | 2016-03-15 07:44:09 +0200 |
---|---|---|
committer | Milla Pohjanheimo <milla.pohjanheimo@theqtcompany.com> | 2016-03-16 07:39:22 +0000 |
commit | e3638174983849c355f9d336759439f78497a3ee (patch) | |
tree | 86e3a028fcbd3b1bacc8df6c99738e7048f8dc02 /tests | |
parent | 5393ba970b0d25280a048ef31c3ffd2e5efe0320 (diff) |
tst_qtabbar sizeHints fix
tst_qtabbar uses fixed values to check the minimumSizeHint and it fails
with screens that have a higher resolution. The test still uses the
default values, but now in the beginning it creates enough tabs so that
it goes over the default.
Change-Id: I3f891d2661288d7fad50ad522d73f634b3e91958
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp index ced2253a74..3f1badeda1 100644 --- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp @@ -279,36 +279,30 @@ void tst_QTabBar::sizeHints() { QTabBar tabBar; tabBar.setFont(QFont("Arial", 10)); - tabBar.addTab("tab 01"); - tabBar.addTab("tab 02"); - tabBar.addTab("tab 03"); - tabBar.addTab("tab 04"); - tabBar.addTab("tab 05"); - tabBar.addTab("tab 06"); - tabBar.addTab("This is tab7"); - tabBar.addTab("This is tab8"); - tabBar.addTab("This is tab9 with a very long title"); // No eliding and no scrolling -> tabbar becomes very wide tabBar.setUsesScrollButtons(false); tabBar.setElideMode(Qt::ElideNone); -// qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-27230", Abort); -#endif + tabBar.addTab("tab 01"); + + // Fetch the minimum size hint width and make sure that we create enough + // tabs. + int minimumSizeHintWidth = tabBar.minimumSizeHint().width(); + for (int i = 0; i <= 700 / minimumSizeHintWidth; ++i) + tabBar.addTab(QString("tab 0%1").arg(i+2)); + + //qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); QVERIFY(tabBar.minimumSizeHint().width() > 700); QVERIFY(tabBar.sizeHint().width() > 700); // Scrolling enabled -> no reason to become very wide tabBar.setUsesScrollButtons(true); - // qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); QVERIFY(tabBar.minimumSizeHint().width() < 200); QVERIFY(tabBar.sizeHint().width() > 700); // unchanged // Eliding enabled -> no reason to become very wide tabBar.setUsesScrollButtons(false); tabBar.setElideMode(Qt::ElideRight); -// qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); // The sizeHint is very much dependent on the screen DPI value // so we can not really predict it. @@ -317,7 +311,7 @@ void tst_QTabBar::sizeHints() QVERIFY(tabBarMinSizeHintWidth < tabBarSizeHintWidth); QVERIFY(tabBarSizeHintWidth > 700); // unchanged - tabBar.addTab("This is tab10 with a very long title"); + tabBar.addTab("This is tab with a very long title"); QVERIFY(tabBar.minimumSizeHint().width() > tabBarMinSizeHintWidth); QVERIFY(tabBar.sizeHint().width() > tabBarSizeHintWidth); } |