tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
changeset 37 758a864f9613
parent 30 5dc02b23752f
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   786     QGraphicsScene scene;
   786     QGraphicsScene scene;
   787     QGraphicsView view(&scene);
   787     QGraphicsView view(&scene);
   788     view.show();
   788     view.show();
   789     QApplication::setActiveWindow(&view);
   789     QApplication::setActiveWindow(&view);
   790     QTest::qWaitForWindowShown(&view);
   790     QTest::qWaitForWindowShown(&view);
   791     QTRY_COMPARE(QApplication::activeWindow(), &view);
   791     QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
   792     if (hasScene) {
   792     if (hasScene) {
   793         scene.addItem(proxy);
   793         scene.addItem(proxy);
   794         proxy->show();
   794         proxy->show();
   795 
   795 
   796         // widget should take precedence over scene so make scene.focusNextPrevChild return false
   796         // widget should take precedence over scene so make scene.focusNextPrevChild return false
   835     QApplication::setActiveWindow(&view);
   835     QApplication::setActiveWindow(&view);
   836     view.activateWindow();
   836     view.activateWindow();
   837     view.setFocus();
   837     view.setFocus();
   838     QTest::qWaitForWindowShown(&view);
   838     QTest::qWaitForWindowShown(&view);
   839     QTRY_VERIFY(view.isVisible());
   839     QTRY_VERIFY(view.isVisible());
   840     QTRY_COMPARE(QApplication::activeWindow(), &view);
   840     QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
   841 
   841 
   842     QWidget *widget = new QWidget;
   842     QWidget *widget = new QWidget;
   843     widget->setFocusPolicy(Qt::WheelFocus);
   843     widget->setFocusPolicy(Qt::WheelFocus);
   844     if (hasWidget)
   844     if (hasWidget)
   845         proxy->setWidget(widget);
   845         proxy->setWidget(widget);
  1091     QGraphicsView view(&scene);
  1091     QGraphicsView view(&scene);
  1092     view.show();
  1092     view.show();
  1093     view.viewport()->setFocus();
  1093     view.viewport()->setFocus();
  1094     QApplication::setActiveWindow(&view);
  1094     QApplication::setActiveWindow(&view);
  1095     QTest::qWaitForWindowShown(&view);
  1095     QTest::qWaitForWindowShown(&view);
  1096     QTRY_COMPARE(QApplication::activeWindow(), &view);
  1096     QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
  1097 
  1097 
  1098     SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
  1098     SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
  1099     proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
  1099     proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
  1100 
  1100 
  1101     QLineEdit *widget = new QLineEdit;
  1101     QLineEdit *widget = new QLineEdit;
  1132     QGraphicsScene scene;
  1132     QGraphicsScene scene;
  1133     QGraphicsView view(&scene);
  1133     QGraphicsView view(&scene);
  1134     view.show();
  1134     view.show();
  1135     QApplication::setActiveWindow(&view);
  1135     QApplication::setActiveWindow(&view);
  1136     QTest::qWaitForWindowShown(&view);
  1136     QTest::qWaitForWindowShown(&view);
  1137     QTRY_COMPARE(QApplication::activeWindow(), &view);
  1137     QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
  1138 
  1138 
  1139 
  1139 
  1140     SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
  1140     SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
  1141     proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
  1141     proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
  1142     QPushButton *widget = new QPushButton;
  1142     QPushButton *widget = new QPushButton;
  1176     QGraphicsView view(&scene);
  1176     QGraphicsView view(&scene);
  1177     view.show();
  1177     view.show();
  1178 
  1178 
  1179     QApplication::setActiveWindow(&view);
  1179     QApplication::setActiveWindow(&view);
  1180     QTest::qWaitForWindowShown(&view);
  1180     QTest::qWaitForWindowShown(&view);
  1181     QTRY_COMPARE(QApplication::activeWindow(), &view);
  1181     QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
  1182 
  1182 
  1183     SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
  1183     SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
  1184     proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
  1184     proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
  1185     QLineEdit *widget = new QLineEdit;
  1185     QLineEdit *widget = new QLineEdit;
  1186     widget->setText("foo");
  1186     widget->setText("foo");
  3470         view.show();
  3470         view.show();
  3471 #ifdef Q_WS_X11
  3471 #ifdef Q_WS_X11
  3472         qt_x11_wait_for_window_manager(&view);
  3472         qt_x11_wait_for_window_manager(&view);
  3473 #endif
  3473 #endif
  3474         QApplication::setActiveWindow(&view);
  3474         QApplication::setActiveWindow(&view);
  3475         QTRY_COMPARE(QApplication::activeWindow(), &view);
  3475         QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
  3476 
  3476 
  3477         QVERIFY(!proxy->hasFocus());
  3477         QVERIFY(!proxy->hasFocus());
  3478         QVERIFY(!proxy->widget()->hasFocus());
  3478         QVERIFY(!proxy->widget()->hasFocus());
  3479 
  3479 
  3480         QCOMPARE(proxySpy.counts[QEvent::FocusIn], 0);
  3480         QCOMPARE(proxySpy.counts[QEvent::FocusIn], 0);