diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2010-12-09 13:10:57 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2011-01-17 13:35:51 (GMT) |
commit | 72aa2eb43b0cf5a6eef940da05ac58f605794ffb (patch) | |
tree | e71eca54cfa309286b5203601c7ed2f3461a26ad /tests/auto/qwidget | |
parent | 09656c9b57af5bb383d029c62396b536899b28e7 (diff) | |
download | Qt-72aa2eb43b0cf5a6eef940da05ac58f605794ffb.zip Qt-72aa2eb43b0cf5a6eef940da05ac58f605794ffb.tar.gz Qt-72aa2eb43b0cf5a6eef940da05ac58f605794ffb.tar.bz2 |
Alien implementation for the Cocoa port
Give Alien on Cocoa a warm welcome.
Diffstat (limited to 'tests/auto/qwidget')
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 39 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget_mac_helpers.h | 13 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget_mac_helpers.mm | 44 |
3 files changed, 59 insertions, 37 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index d230f2c..a518470 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -3852,29 +3852,6 @@ void tst_QWidget::testDeletionInEventHandlers() #ifdef Q_WS_MAC -bool testAndRelease(const HIViewRef view) -{ -// qDebug() << CFGetRetainCount(view); - if (CFGetRetainCount(view) != 2) - return false; - CFRelease(view); - CFRelease(view); - return true; -} - -typedef QPair<QWidget *, HIViewRef> WidgetViewPair; - -WidgetViewPair createAndRetain(QWidget * const parent = 0) -{ - QWidget * const widget = new QWidget(parent); - const HIViewRef view = (HIViewRef)widget->winId(); - // Retain twice so we can safely call CFGetRetaintCount even if the retain count - // is off by one because of a double release. - CFRetain(view); - CFRetain(view); - return qMakePair(widget, view); -} - /* Test that retaining and releasing the HIView returned by QWidget::winId() works even if the widget itself is deleted. @@ -4751,9 +4728,6 @@ void tst_QWidget::update() QRegion expectedVisible = QRegion(w.rect()) - child.visibleRegion().translated(childOffset); QCOMPARE(w.visibleRegion(), expectedVisible); -#ifdef QT_MAC_USE_COCOA - QEXPECT_FAIL(0, "Cocoa compositor paints the content view", Continue); -#endif QCOMPARE(w.paintedRegion, expectedVisible); #ifdef QT_MAC_USE_COCOA QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue); @@ -4803,14 +4777,8 @@ void tst_QWidget::update() & sibling.visibleRegion().translated(siblingOffset)); QCOMPARE(w.numPaintEvents, 1); -#ifdef QT_MAC_USE_COCOA - QEXPECT_FAIL(0, "Cocoa compositor paints the content view", Continue); -#endif QCOMPARE(w.paintedRegion, w.visibleRegion() & sibling.visibleRegion().translated(siblingOffset)); -#ifdef QT_MAC_USE_COCOA - QEXPECT_FAIL(0, "Cocoa compositor paints the content view", Continue); -#endif QCOMPARE(w.paintedRegion, (w.visibleRegion() - child.visibleRegion().translated(childOffset)) & sibling.visibleRegion().translated(siblingOffset)); @@ -4833,7 +4801,8 @@ void tst_QWidget::update() QCOMPARE(sibling.paintedRegion, sibling.visibleRegion()); #ifdef QT_MAC_USE_COCOA - QEXPECT_FAIL(0, "Cocoa compositor paints child and sibling", Continue); + if (child.internalWinId()) // child is native + QEXPECT_FAIL(0, "Cocoa compositor paints child and sibling", Continue); #endif QCOMPARE(child.numPaintEvents, 0); QCOMPARE(child.visibleRegion(), @@ -5464,6 +5433,7 @@ public: rect.width(), rect.height()); \ QCOMPARE(pixmap.size(), rect.size()); \ QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ + expectedPixmap.detach(); \ expectedPixmap.fill(color); \ QImage image = pixmap.toImage(); \ uint alphaCorrection = image.format() == QImage::Format_RGB32 ? 0xff000000 : 0; \ @@ -5510,9 +5480,6 @@ void tst_QWidget::moveChild() QTest::qWait(30); const QPoint tlwOffset = parent.geometry().topLeft(); -#ifdef QT_MAC_USE_COCOA - QEXPECT_FAIL(0, "Cocoa compositor paints the entire content view, even when opaque", Continue); -#endif QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); QTRY_COMPARE(child.r, QRegion(child.rect())); VERIFY_COLOR(child.geometry().translated(tlwOffset), diff --git a/tests/auto/qwidget/tst_qwidget_mac_helpers.h b/tests/auto/qwidget/tst_qwidget_mac_helpers.h index f310aef..b341971 100644 --- a/tests/auto/qwidget/tst_qwidget_mac_helpers.h +++ b/tests/auto/qwidget/tst_qwidget_mac_helpers.h @@ -39,9 +39,20 @@ ** ****************************************************************************/ #include <QtCore/QString> -class QWidget; +#include <QtCore/QPair> +#include <QtGui/QWidget> #pragma once // Yeah, it's deprecated in general, but it's standard practive for Mac OS X. QString nativeWindowTitle(QWidget *widget, Qt::WindowState state); bool nativeWindowModified(QWidget *widget); + +#ifndef QT_MAC_USE_COCOA +typedef QPair<QWidget *, HIViewRef> WidgetViewPair; +bool testAndRelease(const HIViewRef view); +WidgetViewPair createAndRetain(QWidget * const parent = 0); +#else +typedef QPair<QWidget *, WId> WidgetViewPair; +bool testAndRelease(const WId); +WidgetViewPair createAndRetain(QWidget * const parent = 0); +#endif diff --git a/tests/auto/qwidget/tst_qwidget_mac_helpers.mm b/tests/auto/qwidget/tst_qwidget_mac_helpers.mm index 0572a4c..e1f23b0 100644 --- a/tests/auto/qwidget/tst_qwidget_mac_helpers.mm +++ b/tests/auto/qwidget/tst_qwidget_mac_helpers.mm @@ -72,3 +72,47 @@ bool nativeWindowModified(QWidget *widget) return [qt_mac_window_for(widget) isDocumentEdited]; #endif } + +#ifndef QT_MAC_USE_COCOA +bool testAndRelease(const HIViewRef view) +{ +// qDebug() << CFGetRetainCount(view); + if (CFGetRetainCount(view) != 2) + return false; + CFRelease(view); + CFRelease(view); + return true; +} + +WidgetViewPair createAndRetain(QWidget * const parent) +{ + QWidget * const widget = new QWidget(parent); + const HIViewRef view = (HIViewRef)widget->winId(); + // Retain twice so we can safely call CFGetRetaintCount even if the retain count + // is off by one because of a double release. + CFRetain(view); + CFRetain(view); + return qMakePair(widget, view); +} +#else +bool testAndRelease(const WId view) +{ + if ([id(view) retainCount] != 2) + return false; + [id(view) release]; + [id(view) release]; + return true; +} + +WidgetViewPair createAndRetain(QWidget * const parent) +{ + QWidget * const widget = new QWidget(parent); + const WId view = widget->winId(); + // Retain twice so we can safely call retainCount even if the retain count + // is off by one because of a double release. + [id(view) retain]; + [id(view) retain]; + return qMakePair(widget, view); +} +#endif + |