Remove the tst_QWidget::retainHIView() test
Qt is Cocoa only now, and does not use HIView anymore, making this test is meaningless. The testAndRelease() and createAndRetain() helper functions are also no longer needed. Change-Id: I26180a4670c8e7445741d3aab510c4da7b65388c Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
parent
1e29040c17
commit
e87813bfa2
@ -225,7 +225,6 @@ private slots:
|
||||
|
||||
void widgetAt();
|
||||
#ifdef Q_WS_MAC
|
||||
void retainHIView();
|
||||
void sheetOpacity();
|
||||
void setMask();
|
||||
#endif
|
||||
@ -3464,98 +3463,6 @@ void tst_QWidget::testDeletionInEventHandlers()
|
||||
}
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
|
||||
/*
|
||||
Test that retaining and releasing the HIView returned by QWidget::winId()
|
||||
works even if the widget itself is deleted.
|
||||
*/
|
||||
void tst_QWidget::retainHIView()
|
||||
{
|
||||
// Single window
|
||||
{
|
||||
const WidgetViewPair window = createAndRetain();
|
||||
delete window.first;
|
||||
QVERIFY(testAndRelease(window.second));
|
||||
}
|
||||
|
||||
// Child widget
|
||||
{
|
||||
const WidgetViewPair parent = createAndRetain();
|
||||
const WidgetViewPair child = createAndRetain(parent.first);
|
||||
|
||||
delete parent.first;
|
||||
QVERIFY(testAndRelease(parent.second));
|
||||
QVERIFY(testAndRelease(child.second));
|
||||
}
|
||||
|
||||
// Multiple children
|
||||
{
|
||||
const WidgetViewPair parent = createAndRetain();
|
||||
const WidgetViewPair child1 = createAndRetain(parent.first);
|
||||
const WidgetViewPair child2 = createAndRetain(parent.first);
|
||||
|
||||
delete parent.first;
|
||||
QVERIFY(testAndRelease(parent.second));
|
||||
QVERIFY(testAndRelease(child1.second));
|
||||
QVERIFY(testAndRelease(child2.second));
|
||||
}
|
||||
|
||||
// Grandchild widget
|
||||
{
|
||||
const WidgetViewPair parent = createAndRetain();
|
||||
const WidgetViewPair child = createAndRetain(parent.first);
|
||||
const WidgetViewPair grandchild = createAndRetain(child.first);
|
||||
|
||||
delete parent.first;
|
||||
QVERIFY(testAndRelease(parent.second));
|
||||
QVERIFY(testAndRelease(child.second));
|
||||
QVERIFY(testAndRelease(grandchild.second));
|
||||
}
|
||||
|
||||
// Reparent child widget
|
||||
{
|
||||
const WidgetViewPair parent1 = createAndRetain();
|
||||
const WidgetViewPair parent2 = createAndRetain();
|
||||
const WidgetViewPair child = createAndRetain(parent1.first);
|
||||
|
||||
child.first->setParent(parent2.first);
|
||||
|
||||
delete parent1.first;
|
||||
QVERIFY(testAndRelease(parent1.second));
|
||||
delete parent2.first;
|
||||
QVERIFY(testAndRelease(parent2.second));
|
||||
QVERIFY(testAndRelease(child.second));
|
||||
}
|
||||
|
||||
// Reparent window
|
||||
{
|
||||
const WidgetViewPair window1 = createAndRetain();
|
||||
const WidgetViewPair window2 = createAndRetain();
|
||||
const WidgetViewPair child1 = createAndRetain(window1.first);
|
||||
const WidgetViewPair child2 = createAndRetain(window2.first);
|
||||
|
||||
window2.first->setParent(window1.first);
|
||||
|
||||
delete window2.first;
|
||||
QVERIFY(testAndRelease(window2.second));
|
||||
QVERIFY(testAndRelease(child2.second));
|
||||
delete window1.first;
|
||||
QVERIFY(testAndRelease(window1.second));
|
||||
QVERIFY(testAndRelease(child1.second));
|
||||
}
|
||||
|
||||
// Delete child widget
|
||||
{
|
||||
const WidgetViewPair parent = createAndRetain();
|
||||
const WidgetViewPair child = createAndRetain(parent.first);
|
||||
|
||||
delete child.first;
|
||||
QVERIFY(testAndRelease(child.second));
|
||||
delete parent.first;
|
||||
QVERIFY(testAndRelease(parent.second));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QWidget::sheetOpacity()
|
||||
{
|
||||
QWidget tmpWindow;
|
||||
|
@ -46,7 +46,3 @@
|
||||
|
||||
QString nativeWindowTitle(QWidget *widget, Qt::WindowState state);
|
||||
bool nativeWindowModified(QWidget *widget);
|
||||
|
||||
typedef QPair<QWidget *, WId> WidgetViewPair;
|
||||
bool testAndRelease(const WId);
|
||||
WidgetViewPair createAndRetain(QWidget * const parent = 0);
|
||||
|
@ -60,24 +60,3 @@ bool nativeWindowModified(QWidget *widget)
|
||||
{
|
||||
return [qt_mac_window_for(widget) isDocumentEdited];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user