diff options
Diffstat (limited to 'tests/auto/qwidget/tst_qwidget.cpp')
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 135 |
1 files changed, 123 insertions, 12 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 34971a9..33722c7 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -67,6 +67,14 @@ #include <qcalendarwidget.h> #include <qmainwindow.h> #include <QtGui/qpaintengine.h> +#include <private/qbackingstore_p.h> + +#ifdef Q_WS_S60 +#include <avkon.hrh> // EEikStatusPaneUidTitle +#include <akntitle.h> // CAknTitlePane +#include <akncontext.h> // CAknContextPane +#include <eikspane.h> // CEikStatusPane +#endif #ifdef Q_WS_QWS # include <qscreen_qws.h> @@ -356,6 +364,8 @@ private slots: void focusWidget_task254563(); void rectOutsideCoordinatesLimit_task144779(); + void destroyBackingStore(); + private: bool ensureScreenSize(int width, int height); QWidget *testWidget; @@ -1079,6 +1089,9 @@ void tst_QWidget::enabledPropagation() void tst_QWidget::acceptDropsPropagation() { +#ifdef QT_NO_DRAGANDDROP + QSKIP("Drag'n drop disabled in this build", SkipAll); +#else QWidget *childWidget = new QWidget(testWidget); childWidget->show(); QVERIFY(!testWidget->acceptDrops()); @@ -1122,6 +1135,7 @@ void tst_QWidget::acceptDropsPropagation() QVERIFY(childWidget->acceptDrops()); QVERIFY(!grandChildWidget->acceptDrops()); QVERIFY(grandChildWidget->testAttribute(Qt::WA_DropSiteRegistered)); +#endif } void tst_QWidget::isEnabledTo() @@ -1409,7 +1423,7 @@ void tst_QWidget::mapFromAndTo() subWindow2->setGeometry(75, 75, 100, 100); subSubWindow->setGeometry(10, 10, 10, 10); -#ifndef Q_OS_WINCE //still no proper minimizing +#if !defined (Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) //still no proper minimizing //update visibility if (windowMinimized) { if (!windowHidden) { @@ -1814,6 +1828,9 @@ void tst_QWidget::windowState() pos = QPoint(10,10); size = QSize(100,100); } +#elif defined(Q_WS_S60) + QPoint pos = QPoint(10,10); + QSize size = QSize(100,100); #else const QPoint pos(500, 500); const QSize size(200, 200); @@ -1928,7 +1945,7 @@ void tst_QWidget::showMaximized() layouted.showNormal(); QVERIFY(!(layouted.windowState() & Qt::WindowMaximized)); -#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) && !defined(Q_WS_S60) //embedded may choose a different size to fit on the screen. QCOMPARE(layouted.size(), layouted.sizeHint()); #endif @@ -1969,6 +1986,13 @@ void tst_QWidget::showMaximized() QVERIFY(widget.isMaximized()); } + { + QWidget widget; + widget.setGeometry(0, 0, 10, 10); + widget.showMaximized(); + QVERIFY(widget.size().width() > 20 && widget.size().height() > 20); + } + #ifdef QT3_SUPPORT #if !defined(Q_WS_QWS) //embedded respects max/min sizes by design -- maybe wrong design, but that's the way it is now. @@ -2020,7 +2044,7 @@ void tst_QWidget::showFullScreen() layouted.showNormal(); QVERIFY(!(layouted.windowState() & Qt::WindowFullScreen)); -#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) && !defined (Q_WS_S60) //embedded may choose a different size to fit on the screen. QCOMPARE(layouted.size(), layouted.sizeHint()); #endif @@ -2451,6 +2475,9 @@ void tst_QWidget::hideWhenFocusWidgetIsChild() actualFocusWidget.sprintf("%p %s %s", qApp->focusWidget(), qApp->focusWidget()->objectName().toLatin1().constData(), qApp->focusWidget()->metaObject()->className()); expectedFocusWidget.sprintf("%p %s %s", edit2, edit2->objectName().toLatin1().constData(), edit2->metaObject()->className()); QCOMPARE(actualFocusWidget, expectedFocusWidget); + + delete edit2; + delete parentWidget; } void tst_QWidget::normalGeometry() @@ -3354,6 +3381,9 @@ void tst_QWidget::widgetAt() #if defined(Q_OS_WINCE) QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191 #endif +#if defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("", "Symbian/S60 does only support rectangular regions", Continue); //See also task 147191 +#endif QCOMPARE(QApplication::widgetAt(100,100)->objectName(), w1->objectName()); QCOMPARE(QApplication::widgetAt(101,101)->objectName(), w2->objectName()); @@ -3369,6 +3399,9 @@ void tst_QWidget::widgetAt() #if defined(Q_OS_WINCE) QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191 #endif +#if defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("", "Symbian/S60 does only support rectangular regions", Continue); //See also task 147191 +#endif QVERIFY(QApplication::widgetAt(100,100) == w1); QVERIFY(QApplication::widgetAt(101,101) == w2); @@ -3428,6 +3461,34 @@ QString textPropertyToString(Display *display, XTextProperty& text_prop) #endif +#if defined(Q_WS_S60) +// Returns the application's status pane control, if not present returns NULL. +static CCoeControl* GetStatusPaneControl( TInt aPaneId ) +{ + const TUid paneUid = { aPaneId }; + + CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); + if (statusPane && statusPane->PaneCapabilities(paneUid).IsPresent()){ + CCoeControl* control = NULL; + // ControlL shouldn't leave because the pane is present + TRAPD(err, control = statusPane->ControlL(paneUid)); + return err != KErrNone ? NULL : control; + } + return NULL; +} +// Returns the application's title pane, if not present returns NULL. +static CAknTitlePane* TitlePane() +{ + return static_cast<CAknTitlePane*>(GetStatusPaneControl(EEikStatusPaneUidTitle)); +} + +// Returns the application's title pane, if not present returns NULL. +static CAknContextPane* ContextPane() +{ + return static_cast<CAknContextPane*>(GetStatusPaneControl(EEikStatusPaneUidContext)); +} +#endif + static QString visibleWindowTitle(QWidget *window, Qt::WindowState state = Qt::WindowNoState) { QString vTitle; @@ -3490,6 +3551,13 @@ static QString visibleWindowTitle(QWidget *window, Qt::WindowState state = Qt::W if (win) vTitle = win->caption(); } +#elif defined (Q_WS_S60) + CAknTitlePane* titlePane = TitlePane(); + if(titlePane) + { + const TDesC* nTitle = titlePane->Text(); + vTitle = QString::fromUtf16(nTitle->Ptr(), nTitle->Length()); + } #endif return vTitle; @@ -3520,6 +3588,9 @@ void tst_QWidget::windowTitle() void tst_QWidget::windowIconText() { +#ifdef Q_OS_SYMBIAN + QSKIP("Symbian/S60 windows don't have window icon text", SkipAll); +#endif QWidget widget(0); widget.setWindowTitle("Application Name"); @@ -5312,7 +5383,7 @@ void tst_QWidget::moveChild() QCOMPARE(pos, child.pos()); QCOMPARE(parent.r, QRegion(oldGeometry) - child.geometry()); -#ifndef Q_WS_MAC +#if !defined(Q_WS_MAC) // should be scrolled in backingstore QCOMPARE(child.r, QRegion()); #endif @@ -6108,7 +6179,10 @@ void tst_QWidget::compatibilityChildInsertedEvents() EventRecorder::EventList() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) +#ifdef Q_OS_SYMBIAN + << qMakePair(&widget, QEvent::SymbianDeferredFocusChanged) +#endif +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) << qMakePair(&widget, QEvent::UpdateRequest) #endif ; @@ -6203,7 +6277,10 @@ void tst_QWidget::compatibilityChildInsertedEvents() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) +#ifdef Q_OS_SYMBIAN + << qMakePair(&widget, QEvent::SymbianDeferredFocusChanged) +#endif +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) << qMakePair(&widget, QEvent::UpdateRequest) #endif ; @@ -6298,7 +6375,10 @@ void tst_QWidget::compatibilityChildInsertedEvents() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) +#ifdef Q_OS_SYMBIAN + << qMakePair(&widget, QEvent::SymbianDeferredFocusChanged) +#endif +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) << qMakePair(&widget, QEvent::UpdateRequest) #endif ; @@ -7352,7 +7432,7 @@ void tst_QWidget::repaintWhenChildDeleted() } #endif ColorWidget w(0, Qt::red); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_WS_S60) QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); startPoint.rx() += 50; startPoint.ry() += 50; @@ -7386,7 +7466,7 @@ void tst_QWidget::repaintWhenChildDeleted() void tst_QWidget::hideOpaqueChildWhileHidden() { ColorWidget w(0, Qt::red); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_WS_S60) QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); startPoint.rx() += 50; startPoint.ry() += 50; @@ -8261,7 +8341,12 @@ void tst_QWidget::customDpi() custom->logicalDpiX(); QCOMPARE(custom->metricCallCount, 1); child->logicalDpiX(); +#ifdef Q_WS_S60 + // QWidget::metric is not recursive on Symbian + QCOMPARE(custom->metricCallCount, 1); +#else QCOMPARE(custom->metricCallCount, 2); +#endif delete topLevel; } @@ -9102,8 +9187,8 @@ void tst_QWidget::toplevelLineEditFocus() #endif QTest::qWait(200); - QCOMPARE(QApplication::activeWindow(), &w); - QCOMPARE(QApplication::focusWidget(), &w); + QCOMPARE(QApplication::activeWindow(), (QWidget*)&w); + QCOMPARE(QApplication::focusWidget(), (QWidget*)&w); } void tst_QWidget::focusWidget_task254563() @@ -9121,6 +9206,32 @@ void tst_QWidget::focusWidget_task254563() QVERIFY(top.focusWidget() != widget); //dangling pointer } +void tst_QWidget::destroyBackingStore() +{ + UpdateWidget w; + w.show(); + +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&w); +#endif + QApplication::processEvents(); + + w.reset(); + w.update(); + delete qt_widget_private(&w)->topData()->backingStore; + qt_widget_private(&w)->topData()->backingStore = 0; + qt_widget_private(&w)->topData()->backingStore = new QWidgetBackingStore(&w); + + w.update(); + QApplication::processEvents(); + QCOMPARE(w.numPaintEvents, 1); + + // Check one more time, because the second time around does more caching. + w.update(); + QApplication::processEvents(); + QCOMPARE(w.numPaintEvents, 2); +} + void tst_QWidget::rectOutsideCoordinatesLimit_task144779() { QWidget main; @@ -9163,7 +9274,7 @@ void tst_QWidget::inputFocus_task257832() QSKIP("No input context", SkipSingle); widget->setFocus(); context->setFocusWidget(widget); - QCOMPARE(context->focusWidget(), widget); + QCOMPARE(context->focusWidget(), static_cast<QWidget*>(widget)); widget->setReadOnly(true); QVERIFY(!context->focusWidget()); delete widget; |