diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-04-20 08:02:05 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-04-20 13:53:57 (GMT) |
commit | c520a4c75d16948417f6c1a3f42508510be0b5f4 (patch) | |
tree | 8b4854c1077d645f523a4928f2f5aafde4191ba1 /tests | |
parent | 9f668a352df15404234ea30bc9bb0c1ef774c1b0 (diff) | |
download | Qt-c520a4c75d16948417f6c1a3f42508510be0b5f4.zip Qt-c520a4c75d16948417f6c1a3f42508510be0b5f4.tar.gz Qt-c520a4c75d16948417f6c1a3f42508510be0b5f4.tar.bz2 |
Working on QGraphicsProxyWidget's handling of widget flags.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 64 | ||||
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 79 |
2 files changed, 143 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index b99f111..9d82ffd 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -175,6 +175,9 @@ private slots: void bypassGraphicsProxyWidget_data(); void bypassGraphicsProxyWidget(); void dragDrop(); + void windowFlags_data(); + void windowFlags(); + void comboboxWindowFlags(); }; // Subclass that exposes the protected functions. @@ -3153,6 +3156,67 @@ void tst_QGraphicsProxyWidget::dragDrop() QCOMPARE(edit->text(), QString("hei")); } +void tst_QGraphicsProxyWidget::windowFlags_data() +{ + QTest::addColumn<int>("proxyFlags"); + QTest::addColumn<int>("widgetFlags"); + QTest::addColumn<int>("resultingProxyFlags"); + QTest::addColumn<int>("resultingWidgetFlags"); + + QTest::newRow("proxy(0) widget(0)") << 0 << 0 << 0 << int(Qt::Window); + QTest::newRow("proxy(window)") << int(Qt::Window) << 0 << int(Qt::Window) << int(Qt::Window); + QTest::newRow("proxy(window) widget(window)") << int(Qt::Window) << int(Qt::Window) << int(Qt::Window) << int(Qt::Window); + QTest::newRow("proxy(0) widget(window)") << int(0) << int(Qt::Window) << int(0) << int(Qt::Window); +} + +void tst_QGraphicsProxyWidget::windowFlags() +{ + QFETCH(int, proxyFlags); + QFETCH(int, widgetFlags); + QFETCH(int, resultingProxyFlags); + QFETCH(int, resultingWidgetFlags); + Qt::WindowFlags proxyWFlags = Qt::WindowFlags(proxyFlags); + Qt::WindowFlags widgetWFlags = Qt::WindowFlags(widgetFlags); + Qt::WindowFlags resultingProxyWFlags = Qt::WindowFlags(resultingProxyFlags); + Qt::WindowFlags resultingWidgetWFlags = Qt::WindowFlags(resultingWidgetFlags); + + QGraphicsProxyWidget proxy(0, proxyWFlags); + QVERIFY((proxy.windowFlags() & proxyWFlags) == proxyWFlags); + + QWidget *widget = new QWidget(0, widgetWFlags); + QVERIFY((widget->windowFlags() & widgetWFlags) == widgetWFlags); + + proxy.setWidget(widget); + + if (resultingProxyFlags == 0) + QVERIFY(!proxy.windowFlags()); + else + QVERIFY((proxy.windowFlags() & resultingProxyWFlags) == resultingProxyWFlags); + QVERIFY((widget->windowFlags() & resultingWidgetWFlags) == resultingWidgetWFlags); +} + +void tst_QGraphicsProxyWidget::comboboxWindowFlags() +{ + QComboBox *comboBox = new QComboBox; + comboBox->addItem("Item 1"); + comboBox->addItem("Item 2"); + comboBox->addItem("Item 3"); + QWidget *embedWidget = comboBox; + + QGraphicsScene scene; + QGraphicsProxyWidget *proxy = scene.addWidget(embedWidget); + proxy->setWindowFlags(Qt::Window); + QVERIFY(embedWidget->isWindow()); + QVERIFY(proxy->isWindow()); + + comboBox->showPopup(); + + QCOMPARE(proxy->childItems().size(), 1); + QGraphicsItem *popupProxy = proxy->childItems().first(); + QVERIFY(popupProxy->isWindow()); + QVERIFY((static_cast<QGraphicsWidget *>(popupProxy)->windowFlags() & Qt::Popup) == Qt::Popup); +} + QTEST_MAIN(tst_QGraphicsProxyWidget) #include "tst_qgraphicsproxywidget.moc" diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index a737a37..56737c3 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -149,6 +149,8 @@ private slots: void explicitMouseGrabber(); void implicitMouseGrabber(); void popupMouseGrabber(); + void windowFlags_data(); + void windowFlags(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2086,6 +2088,83 @@ void tst_QGraphicsWidget::popupMouseGrabber() QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)widget3); } +void tst_QGraphicsWidget::windowFlags_data() +{ + QTest::addColumn<int>("inputFlags"); + QTest::addColumn<int>("outputFlags"); + + QTest::newRow("nil") << 0 << 0; + + // Window types + QTest::newRow("Qt::Window") << int(Qt::Window) + << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint + | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); + QTest::newRow("Qt::SubWindow") << int(Qt::SubWindow) + << int(Qt::SubWindow | Qt::WindowTitleHint | Qt::WindowSystemMenuHint + | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); + QTest::newRow("Qt::Dialog") << int(Qt::Dialog) + << int(Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint + | Qt::WindowContextHelpButtonHint); + QTest::newRow("Qt::Sheet") << int(Qt::Sheet) + << int(Qt::Sheet | Qt::WindowTitleHint | Qt::WindowSystemMenuHint + | Qt::WindowContextHelpButtonHint); + QTest::newRow("Qt::Tool") << int(Qt::Tool) + << int(Qt::Tool | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); + + // Custom window flags + QTest::newRow("Qt::FramelessWindowHint") << int(Qt::FramelessWindowHint) + << int(Qt::FramelessWindowHint); + QTest::newRow("Qt::CustomizeWindowHint") << int(Qt::CustomizeWindowHint) + << int(Qt::CustomizeWindowHint); +} + +void tst_QGraphicsWidget::windowFlags() +{ + QFETCH(int, inputFlags); + QFETCH(int, outputFlags); + + // Construct with flags set already + QGraphicsWidget widget(0, Qt::WindowFlags(inputFlags)); + QCOMPARE(widget.windowFlags(), Qt::WindowFlags(outputFlags)); + + // Set flags after construction + QGraphicsWidget widget2; + widget2.setWindowFlags(Qt::WindowFlags(inputFlags)); + QCOMPARE(widget2.windowFlags(), Qt::WindowFlags(outputFlags)); + + // Reset flags + widget2.setWindowFlags(0); + QVERIFY(!widget2.windowFlags()); + + // Set flags back again + widget2.setWindowFlags(Qt::WindowFlags(inputFlags)); + QCOMPARE(widget2.windowFlags(), Qt::WindowFlags(outputFlags)); + + // Construct with custom flags set already + QGraphicsWidget widget3(0, Qt::WindowFlags(inputFlags | Qt::FramelessWindowHint)); + QCOMPARE(widget3.windowFlags(), Qt::WindowFlags(inputFlags | Qt::FramelessWindowHint)); + + // Set custom flags after construction + QGraphicsWidget widget4; + widget4.setWindowFlags(Qt::WindowFlags(inputFlags | Qt::FramelessWindowHint)); + QCOMPARE(widget4.windowFlags(), Qt::WindowFlags(inputFlags | Qt::FramelessWindowHint)); + + // Reset flags + widget4.setWindowFlags(0); + QVERIFY(!widget4.windowFlags()); + + // Set custom flags back again + widget4.setWindowFlags(Qt::WindowFlags(inputFlags | Qt::FramelessWindowHint)); + QCOMPARE(widget4.windowFlags(), Qt::WindowFlags(inputFlags | Qt::FramelessWindowHint)); + + QGraphicsWidget *widget5 = new QGraphicsWidget; + widget5->setWindowFlags(Qt::WindowFlags(inputFlags)); + QCOMPARE(widget5->windowFlags(), Qt::WindowFlags(outputFlags)); + QGraphicsWidget window(0, Qt::Window); + widget5->setParentItem(&window); + QCOMPARE(widget5->windowFlags(), Qt::WindowFlags(outputFlags)); +} + class ProxyStyle : public QCommonStyle { public: |