From 4b37d772cd5c1098d38944a125b48751f4bb1280 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 3 Jun 2009 21:25:38 +0300 Subject: Fix to tst_QDateTimeEdit::mousePress test case. Checked datetimedit spinbox up location from style, instead of trying to guess the difference offsets. --- tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp index b975405..624d193 100644 --- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp @@ -2213,21 +2213,16 @@ void tst_QDateTimeEdit::mousePress() testWidget->setDate(QDate(2004, 6, 23)); testWidget->setCurrentSection(QDateTimeEdit::YearSection); QCOMPARE(testWidget->currentSection(), QDateTimeEdit::YearSection); - int offset = 10; -#if defined(Q_OS_WINCE) - offset = 20; - if (qt_wince_is_pocket_pc()) { - // depending on wether the display is double-pixeld, we need - // to click at a different position - bool doubledSize = false; - int dpi = GetDeviceCaps(GetDC(0), LOGPIXELSX); - if ((dpi < 1000) && (dpi > 0)) - doubledSize = true; - offset = doubledSize ? 50 : 25; // On CE buttons are aligned horizontal - } -#endif - QTest::mouseClick(testWidget, Qt::LeftButton, 0, QPoint(testWidget->width() - offset, 5)); - QCOMPARE(testWidget->date().year(), 2005); + + // Ask the SC_SpinBoxUp button location from style + QStyleOptionSpinBox so; + so.rect = testWidget->rect(); + QRect rectUp = testWidget->style()->subControlRect(QStyle::CC_SpinBox, &so, QStyle::SC_SpinBoxUp, testWidget); + + // Send mouseClick to center of SC_SpinBoxUp + QTest::mouseClick(testWidget, Qt::LeftButton, 0, rectUp.center()); + QCOMPARE(testWidget->date().year(), 2005); + } void tst_QDateTimeEdit::stepHourAMPM_data() -- cgit v0.12