476 EventSpy focusInSpy(widget, QEvent::FocusIn); |
478 EventSpy focusInSpy(widget, QEvent::FocusIn); |
477 EventSpy focusOutSpy(widget, QEvent::FocusOut); |
479 EventSpy focusOutSpy(widget, QEvent::FocusOut); |
478 |
480 |
479 scene.addItem(widget); |
481 scene.addItem(widget); |
480 |
482 |
481 QVERIFY(!widget->hasFocus()); |
483 QTRY_VERIFY(!widget->hasFocus()); |
482 widget->setFocusPolicy(Qt::StrongFocus); |
484 widget->setFocusPolicy(Qt::StrongFocus); |
483 QVERIFY(!widget->hasFocus()); |
485 QTRY_VERIFY(!widget->hasFocus()); |
484 |
486 |
485 QGraphicsWidget *subWidget = new QGraphicsWidget(widget); |
487 QGraphicsWidget *subWidget = new QGraphicsWidget(widget); |
486 QVERIFY(!subWidget->hasFocus()); |
488 QTRY_VERIFY(!subWidget->hasFocus()); |
487 |
489 |
488 scene.setFocus(); |
490 scene.setFocus(); |
489 |
491 |
490 QVERIFY(!widget->hasFocus()); |
492 QTRY_VERIFY(!widget->hasFocus()); |
491 QVERIFY(!subWidget->hasFocus()); |
493 QTRY_VERIFY(!subWidget->hasFocus()); |
492 |
494 |
493 widget->setFocus(); |
495 widget->setFocus(); |
494 |
496 |
495 QVERIFY(widget->hasFocus()); |
497 QTRY_VERIFY(widget->hasFocus()); |
496 QCOMPARE(focusInSpy.count(), 1); |
498 QTRY_COMPARE(focusInSpy.count(), 1); |
497 QVERIFY(!subWidget->hasFocus()); |
499 QTRY_VERIFY(!subWidget->hasFocus()); |
498 |
500 |
499 QGraphicsWidget *otherSubWidget = new QGraphicsWidget; |
501 QGraphicsWidget *otherSubWidget = new QGraphicsWidget; |
500 EventSpy otherFocusInSpy(otherSubWidget, QEvent::FocusIn); |
502 EventSpy otherFocusInSpy(otherSubWidget, QEvent::FocusIn); |
501 EventSpy otherFocusOutSpy(otherSubWidget, QEvent::FocusOut); |
503 EventSpy otherFocusOutSpy(otherSubWidget, QEvent::FocusOut); |
502 |
504 |
503 otherSubWidget->setFocusPolicy(Qt::StrongFocus); |
505 otherSubWidget->setFocusPolicy(Qt::StrongFocus); |
504 otherSubWidget->setParentItem(widget); |
506 otherSubWidget->setParentItem(widget); |
505 |
507 |
506 QVERIFY(widget->hasFocus()); |
508 QTRY_VERIFY(widget->hasFocus()); |
507 QCOMPARE(scene.focusItem(), (QGraphicsItem *)widget); |
509 QCOMPARE(scene.focusItem(), (QGraphicsItem *)widget); |
508 QVERIFY(!subWidget->hasFocus()); |
510 QTRY_VERIFY(!subWidget->hasFocus()); |
509 QVERIFY(!otherSubWidget->hasFocus()); |
511 QTRY_VERIFY(!otherSubWidget->hasFocus()); |
510 |
512 |
511 widget->hide(); |
513 widget->hide(); |
512 QVERIFY(!widget->hasFocus()); // lose but still has subfocus |
514 QTRY_VERIFY(!widget->hasFocus()); // lose but still has subfocus |
513 QCOMPARE(focusInSpy.count(), 1); |
515 QCOMPARE(focusInSpy.count(), 1); |
514 QCOMPARE(focusOutSpy.count(), 1); |
516 QCOMPARE(focusOutSpy.count(), 1); |
515 |
517 |
516 widget->show(); |
518 widget->show(); |
517 QVERIFY(!widget->hasFocus()); // no regain |
519 QTRY_VERIFY(!widget->hasFocus()); // no regain |
518 QCOMPARE(focusInSpy.count(), 1); |
520 QCOMPARE(focusInSpy.count(), 1); |
519 QCOMPARE(focusOutSpy.count(), 1); |
521 QCOMPARE(focusOutSpy.count(), 1); |
520 |
522 |
521 widget->hide(); |
523 widget->hide(); |
522 |
524 |
523 // try to setup subFocus on item that can't take focus |
525 // try to setup subFocus on item that can't take focus |
524 subWidget->setFocus(); |
526 subWidget->setFocus(); |
525 QVERIFY(!subWidget->hasFocus()); |
527 QTRY_VERIFY(!subWidget->hasFocus()); |
526 QVERIFY(!scene.focusItem()); // but isn't the scene's focus item |
528 QVERIFY(!scene.focusItem()); // but isn't the scene's focus item |
527 |
529 |
528 // try to setup subFocus on item that can take focus |
530 // try to setup subFocus on item that can take focus |
529 otherSubWidget->setFocus(); |
531 otherSubWidget->setFocus(); |
530 QVERIFY(!otherSubWidget->hasFocus()); |
532 QTRY_VERIFY(!otherSubWidget->hasFocus()); |
531 QCOMPARE(widget->focusWidget(), otherSubWidget); |
533 QCOMPARE(widget->focusWidget(), otherSubWidget); |
532 QVERIFY(!scene.focusItem()); // but isn't the scene's focus item |
534 QVERIFY(!scene.focusItem()); // but isn't the scene's focus item |
533 |
535 |
534 widget->show(); |
536 widget->show(); |
535 |
537 |
536 QCOMPARE(scene.focusItem(), (QGraphicsItem *)otherSubWidget); // but isn't the scene's focus item |
538 QTRY_COMPARE(scene.focusItem(), (QGraphicsItem *)otherSubWidget); // but isn't the scene's focus item |
537 QCOMPARE(otherFocusInSpy.count(), 1); |
539 QCOMPARE(otherFocusInSpy.count(), 1); |
538 QCOMPARE(otherFocusOutSpy.count(), 0); |
540 QCOMPARE(otherFocusOutSpy.count(), 0); |
539 |
541 |
540 delete otherSubWidget; |
542 delete otherSubWidget; |
541 |
543 |
542 QCOMPARE(otherFocusOutSpy.count(), 1); |
544 QTRY_COMPARE(otherFocusOutSpy.count(), 1); |
543 QVERIFY(!scene.focusItem()); |
545 QVERIFY(!scene.focusItem()); |
544 QVERIFY(!widget->focusWidget()); |
546 QVERIFY(!widget->focusWidget()); |
545 } |
547 } |
546 |
548 |
547 Q_DECLARE_METATYPE(Qt::FocusPolicy) |
549 Q_DECLARE_METATYPE(Qt::FocusPolicy) |
576 QEvent windowActivate(QEvent::WindowActivate); |
578 QEvent windowActivate(QEvent::WindowActivate); |
577 qApp->sendEvent(&scene, &windowActivate); |
579 qApp->sendEvent(&scene, &windowActivate); |
578 |
580 |
579 SubQGraphicsWidget *widget = new SubQGraphicsWidget; |
581 SubQGraphicsWidget *widget = new SubQGraphicsWidget; |
580 scene.addItem(widget); |
582 scene.addItem(widget); |
581 QCOMPARE(Qt::NoFocus, widget->focusPolicy()); |
583 QTRY_COMPARE(Qt::NoFocus, widget->focusPolicy()); |
582 |
584 |
583 QFETCH(Qt::FocusPolicy, focusPolicy1); |
585 QFETCH(Qt::FocusPolicy, focusPolicy1); |
584 widget->setFocusPolicy(focusPolicy1); |
586 widget->setFocusPolicy(focusPolicy1); |
585 QCOMPARE(widget->focusPolicy(), focusPolicy1); |
587 QTRY_COMPARE(widget->focusPolicy(), focusPolicy1); |
586 bool isFocusable = widget->flags() & QGraphicsItem::ItemIsFocusable; |
588 bool isFocusable = widget->flags() & QGraphicsItem::ItemIsFocusable; |
587 bool wasFocusable = isFocusable; |
589 bool wasFocusable = isFocusable; |
588 QVERIFY(isFocusable == (focusPolicy1 != Qt::NoFocus)); |
590 QTRY_VERIFY(isFocusable == (focusPolicy1 != Qt::NoFocus)); |
589 widget->setFocus(); |
591 widget->setFocus(); |
590 QCOMPARE(widget->hasFocus(), isFocusable); |
592 QTRY_COMPARE(widget->hasFocus(), isFocusable); |
591 |
593 |
592 QFETCH(Qt::FocusPolicy, focusPolicy2); |
594 QFETCH(Qt::FocusPolicy, focusPolicy2); |
593 widget->setFocusPolicy(focusPolicy2); |
595 widget->setFocusPolicy(focusPolicy2); |
594 QCOMPARE(widget->focusPolicy(), focusPolicy2); |
596 QCOMPARE(widget->focusPolicy(), focusPolicy2); |
595 isFocusable = widget->flags() & QGraphicsItem::ItemIsFocusable; |
597 isFocusable = widget->flags() & QGraphicsItem::ItemIsFocusable; |
688 QCOMPARE(scene.font(), appFont); |
690 QCOMPARE(scene.font(), appFont); |
689 QCOMPARE(root->font(), appFont); |
691 QCOMPARE(root->font(), appFont); |
690 |
692 |
691 EventSpy rootSpyFont(root, QEvent::FontChange); |
693 EventSpy rootSpyFont(root, QEvent::FontChange); |
692 EventSpy rootSpyPolish(root, QEvent::Polish); |
694 EventSpy rootSpyPolish(root, QEvent::Polish); |
693 QCOMPARE(rootSpyFont.count(), 0); |
695 QTRY_COMPARE(rootSpyFont.count(), 0); |
694 QApplication::processEvents(); //The polish event is sent |
696 QTRY_COMPARE(rootSpyPolish.count(), 1); |
695 QCOMPARE(rootSpyPolish.count(), 1); |
|
696 QApplication::processEvents(); //Process events to see if we get the font change event |
|
697 //The font is still the same so no fontChangeEvent |
697 //The font is still the same so no fontChangeEvent |
698 QCOMPARE(rootSpyFont.count(), 0); |
698 QTRY_COMPARE(rootSpyFont.count(), 0); |
699 |
699 |
700 QFont font; |
700 QFont font; |
701 font.setPointSize(43); |
701 font.setPointSize(43); |
702 root->setFont(font); |
702 root->setFont(font); |
703 QApplication::processEvents(); //Process events to get the font change event |
|
704 //The font changed |
703 //The font changed |
705 QCOMPARE(rootSpyFont.count(), 1); |
704 QTRY_COMPARE(rootSpyFont.count(), 1); |
706 |
705 |
707 //then roll back to the default one. |
706 //then roll back to the default one. |
708 root->setFont(appFont); |
707 root->setFont(appFont); |
709 QApplication::processEvents(); //Process events to get the font change event |
|
710 //The font changed |
708 //The font changed |
711 QCOMPARE(rootSpyFont.count(), 2); |
709 QTRY_COMPARE(rootSpyFont.count(), 2); |
712 } |
710 } |
713 |
711 |
714 void tst_QGraphicsWidget::fontPropagationWidgetItemWidget() |
712 void tst_QGraphicsWidget::fontPropagationWidgetItemWidget() |
715 { |
713 { |
716 QGraphicsWidget *widget = new QGraphicsWidget; |
714 QGraphicsWidget *widget = new QGraphicsWidget; |
767 // QRectF geometry() const public |
765 // QRectF geometry() const public |
768 void tst_QGraphicsWidget::geometry() |
766 void tst_QGraphicsWidget::geometry() |
769 { |
767 { |
770 SubQGraphicsWidget widget; |
768 SubQGraphicsWidget widget; |
771 QCOMPARE(widget.geometry(), QRectF(widget.pos(), widget.size())); |
769 QCOMPARE(widget.geometry(), QRectF(widget.pos(), widget.size())); |
772 |
770 QSignalSpy spy(&widget, SIGNAL(geometryChanged())); |
773 QFETCH(QPointF, pos); |
771 QFETCH(QPointF, pos); |
774 QFETCH(QSizeF, size); |
772 QFETCH(QSizeF, size); |
775 widget.setPos(pos); |
773 widget.setPos(pos); |
776 widget.resize(size); |
774 widget.resize(size); |
|
775 if (!size.isNull()) |
|
776 QCOMPARE(spy.count(), 1); |
777 QCOMPARE(widget.geometry(), QRectF(pos, size)); |
777 QCOMPARE(widget.geometry(), QRectF(pos, size)); |
|
778 } |
|
779 |
|
780 void tst_QGraphicsWidget::width() |
|
781 { |
|
782 QGraphicsWidget w; |
|
783 QCOMPARE(w.property("width").toReal(), qreal(0)); |
|
784 QSignalSpy spy(&w, SIGNAL(widthChanged())); |
|
785 w.setProperty("width", qreal(50)); |
|
786 QCOMPARE(w.property("width").toReal(), qreal(50)); |
|
787 QCOMPARE(spy.count(), 1); |
|
788 //calling old school setGeometry should work too |
|
789 w.setGeometry(0, 0, 200, 200); |
|
790 QCOMPARE(spy.count(), 2); |
|
791 } |
|
792 |
|
793 void tst_QGraphicsWidget::height() |
|
794 { |
|
795 QGraphicsWidget w; |
|
796 QCOMPARE(w.property("height").toReal(), qreal(0)); |
|
797 QSignalSpy spy(&w, SIGNAL(heightChanged())); |
|
798 w.setProperty("height", qreal(50)); |
|
799 QCOMPARE(w.property("height").toReal(), qreal(50)); |
|
800 QCOMPARE(spy.count(), 1); |
|
801 //calling old school setGeometry should work too |
|
802 w.setGeometry(0, 0, 200, 200); |
|
803 QCOMPARE(spy.count(), 2); |
778 } |
804 } |
779 |
805 |
780 void tst_QGraphicsWidget::getContentsMargins_data() |
806 void tst_QGraphicsWidget::getContentsMargins_data() |
781 { |
807 { |
782 QTest::addColumn<qreal>("left"); |
808 QTest::addColumn<qreal>("left"); |
1458 window->show(); |
1477 window->show(); |
1459 QApplication::setActiveWindow(window); |
1478 QApplication::setActiveWindow(window); |
1460 QTest::qWaitForWindowShown(window); |
1479 QTest::qWaitForWindowShown(window); |
1461 |
1480 |
1462 lineEdit->setFocus(); |
1481 lineEdit->setFocus(); |
1463 QTest::qWait(25); |
|
1464 QTRY_VERIFY(lineEdit->hasFocus()); |
1482 QTRY_VERIFY(lineEdit->hasFocus()); |
1465 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1483 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1466 QTest::qWait(25); |
|
1467 QTRY_VERIFY(w1_1->hasFocus()); |
1484 QTRY_VERIFY(w1_1->hasFocus()); |
1468 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1485 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1469 QTest::qWait(25); |
|
1470 QTRY_VERIFY(w1_2->hasFocus()); |
1486 QTRY_VERIFY(w1_2->hasFocus()); |
1471 |
1487 |
1472 // remove the tabFocusFirst and insert new item |
1488 // remove the tabFocusFirst and insert new item |
1473 delete w1_1; // calls _q_removeItemLater |
1489 delete w1_1; // calls _q_removeItemLater |
1474 QTest::qWait(25); |
|
1475 SubQGraphicsWidget *w1_3 = new SubQGraphicsWidget; |
1490 SubQGraphicsWidget *w1_3 = new SubQGraphicsWidget; |
1476 w1_3->setFocusPolicy(Qt::StrongFocus); |
1491 w1_3->setFocusPolicy(Qt::StrongFocus); |
1477 w1_3->setData(0, "w1_3"); |
1492 w1_3->setData(0, "w1_3"); |
1478 w1_3->setGeometry(50,0,25, 25); |
1493 w1_3->setGeometry(50,0,25, 25); |
1479 scene.addItem(w1_3); |
1494 scene.addItem(w1_3); |
1480 QTRY_VERIFY(w1_2->hasFocus()); |
1495 QTRY_VERIFY(w1_2->hasFocus()); |
1481 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); |
1496 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); |
1482 QTest::qWait(25); |
|
1483 QTRY_VERIFY(lineEdit->hasFocus()); |
1497 QTRY_VERIFY(lineEdit->hasFocus()); |
1484 // tabFocusFirst should now point to w1_2 |
1498 // tabFocusFirst should now point to w1_2 |
1485 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1499 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1486 QTest::qWait(25); |
|
1487 QTRY_VERIFY(w1_2->hasFocus()); |
1500 QTRY_VERIFY(w1_2->hasFocus()); |
1488 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1501 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1489 QTest::qWait(25); |
|
1490 QTRY_VERIFY(w1_3->hasFocus()); |
1502 QTRY_VERIFY(w1_3->hasFocus()); |
1491 scene.removeItem(w1_2); // does not call _q_removeItemLater |
1503 scene.removeItem(w1_2); // does not call _q_removeItemLater |
1492 delete w1_2; // calls _q_removeItemLater |
1504 delete w1_2; // calls _q_removeItemLater |
1493 |
1505 |
1494 SubQGraphicsWidget *w1_4 = new SubQGraphicsWidget; |
1506 SubQGraphicsWidget *w1_4 = new SubQGraphicsWidget; |
1495 w1_4->setFocusPolicy(Qt::StrongFocus); |
1507 w1_4->setFocusPolicy(Qt::StrongFocus); |
1496 w1_4->setData(0, "w1_4"); |
1508 w1_4->setData(0, "w1_4"); |
1497 w1_4->setGeometry(75,0,25, 25); |
1509 w1_4->setGeometry(75,0,25, 25); |
1498 scene.addItem(w1_4); |
1510 scene.addItem(w1_4); |
1499 QTRY_VERIFY(w1_3->hasFocus()); |
1511 QTRY_VERIFY(w1_3->hasFocus()); |
1500 QTest::qWait(25); |
|
1501 QTRY_VERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); |
1512 QTRY_VERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); |
1502 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); |
1513 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); |
1503 QTest::qWait(25); |
|
1504 QTRY_VERIFY(lineEdit->hasFocus()); |
1514 QTRY_VERIFY(lineEdit->hasFocus()); |
1505 // tabFocusFirst should now point to w1_3 |
1515 // tabFocusFirst should now point to w1_3 |
1506 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1516 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); |
1507 QTest::qWait(25); |
|
1508 QTRY_VERIFY(w1_3->hasFocus()); |
1517 QTRY_VERIFY(w1_3->hasFocus()); |
1509 QTest::qWait(25); |
|
1510 QTRY_VERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); |
1518 QTRY_VERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); |
1511 delete window; |
1519 delete window; |
1512 } |
1520 } |
1513 } |
1521 } |
1514 |
1522 |
1753 |
1760 |
1754 widget->setMinimumSize(min); |
1761 widget->setMinimumSize(min); |
1755 widget->setPreferredSize(pref); |
1762 widget->setPreferredSize(pref); |
1756 widget->setMaximumSize(max); |
1763 widget->setMaximumSize(max); |
1757 |
1764 |
1758 QApplication::processEvents(); |
|
1759 |
|
1760 for (i = 0; i < compareInstructions.count(); ++i) { |
1765 for (i = 0; i < compareInstructions.count(); ++i) { |
1761 Inst input = compareInstructions.at(i); |
1766 Inst input = compareInstructions.at(i); |
1762 switch (input.first) { |
1767 switch (input.first) { |
1763 case MinimumSize: |
1768 case MinimumSize: |
1764 QCOMPARE(widget->minimumSize(), input.second.toSizeF()); |
1769 QTRY_COMPARE(widget->minimumSize(), input.second.toSizeF()); |
1765 break; |
1770 break; |
1766 case PreferredSize: |
1771 case PreferredSize: |
1767 QCOMPARE(widget->preferredSize(), input.second.toSizeF()); |
1772 QTRY_COMPARE(widget->preferredSize(), input.second.toSizeF()); |
1768 break; |
1773 break; |
1769 case MaximumSize: |
1774 case MaximumSize: |
1770 QCOMPARE(widget->maximumSize(), input.second.toSizeF()); |
1775 QTRY_COMPARE(widget->maximumSize(), input.second.toSizeF()); |
1771 break; |
1776 break; |
1772 case Size: |
1777 case Size: |
1773 QCOMPARE(widget->size(), input.second.toSizeF()); |
1778 QTRY_COMPARE(widget->size(), input.second.toSizeF()); |
1774 break; |
1779 break; |
1775 case MinimumWidth: |
1780 case MinimumWidth: |
1776 QCOMPARE(widget->minimumWidth(), qreal(input.second.toDouble())); |
1781 QTRY_COMPARE(widget->minimumWidth(), qreal(input.second.toDouble())); |
1777 break; |
1782 break; |
1778 case PreferredWidth: |
1783 case PreferredWidth: |
1779 QCOMPARE(widget->preferredWidth(), qreal(input.second.toDouble())); |
1784 QTRY_COMPARE(widget->preferredWidth(), qreal(input.second.toDouble())); |
1780 break; |
1785 break; |
1781 case MaximumWidth: |
1786 case MaximumWidth: |
1782 QCOMPARE(widget->maximumWidth(), qreal(input.second.toDouble())); |
1787 QTRY_COMPARE(widget->maximumWidth(), qreal(input.second.toDouble())); |
1783 break; |
1788 break; |
1784 default: |
1789 default: |
1785 qWarning("instruction not implemented"); |
1790 qWarning("instruction not implemented"); |
1786 break; |
1791 break; |
1787 } |
1792 } |
1832 QGraphicsView view(&scene); |
1837 QGraphicsView view(&scene); |
1833 view.show(); |
1838 view.show(); |
1834 #ifdef Q_WS_X11 |
1839 #ifdef Q_WS_X11 |
1835 qt_x11_wait_for_window_manager(&view); |
1840 qt_x11_wait_for_window_manager(&view); |
1836 #endif |
1841 #endif |
1837 QTest::qWait(100); |
1842 |
1838 |
1843 QTRY_VERIFY(!scene.itemAt(25, 25)); |
1839 QVERIFY(!scene.itemAt(25, 25)); |
|
1840 widget->setGeometry(0, 112, 360, 528); |
1844 widget->setGeometry(0, 112, 360, 528); |
1841 QCOMPARE(scene.itemAt(15, 120), (QGraphicsItem *)widget); |
1845 QTRY_COMPARE(scene.itemAt(15, 120), (QGraphicsItem *)widget); |
1842 widget2->setGeometry(0, 573, 360, 67); |
1846 widget2->setGeometry(0, 573, 360, 67); |
1843 QCOMPARE(scene.itemAt(15, 120), (QGraphicsItem *)widget); |
1847 QTRY_COMPARE(scene.itemAt(15, 120), (QGraphicsItem *)widget); |
1844 QCOMPARE(scene.itemAt(50, 585), (QGraphicsItem *)widget2); |
1848 QTRY_COMPARE(scene.itemAt(50, 585), (QGraphicsItem *)widget2); |
1845 } |
1849 } |
1846 |
1850 |
1847 void tst_QGraphicsWidget::defaultSize() |
1851 void tst_QGraphicsWidget::defaultSize() |
1848 { |
1852 { |
1849 SubQGraphicsWidget *widget = new SubQGraphicsWidget; |
1853 SubQGraphicsWidget *widget = new SubQGraphicsWidget; |
1854 QGraphicsView view(&scene); |
1858 QGraphicsView view(&scene); |
1855 view.show(); |
1859 view.show(); |
1856 #ifdef Q_WS_X11 |
1860 #ifdef Q_WS_X11 |
1857 qt_x11_wait_for_window_manager(&view); |
1861 qt_x11_wait_for_window_manager(&view); |
1858 #endif |
1862 #endif |
1859 QTest::qWait(50); |
|
1860 QSizeF initialSize = widget->size(); |
1863 QSizeF initialSize = widget->size(); |
1861 |
1864 |
1862 widget->resize(initialSize); |
1865 widget->resize(initialSize); |
1863 QCOMPARE(widget->geometry().size(), initialSize); |
1866 QCOMPARE(widget->geometry().size(), initialSize); |
1864 widget->setVisible(false); |
1867 widget->setVisible(false); |
1865 widget->setMinimumSize(10, 10); |
1868 widget->setMinimumSize(10, 10); |
1866 widget->setPreferredSize(60, 60); |
1869 widget->setPreferredSize(60, 60); |
1867 widget->setMaximumSize(110, 110); |
1870 widget->setMaximumSize(110, 110); |
1868 widget->setVisible(true); |
1871 widget->setVisible(true); |
1869 QTest::qWait(50); |
|
1870 // should still have its size set to initialsize |
1872 // should still have its size set to initialsize |
1871 QCOMPARE(widget->geometry().size(), initialSize); |
1873 QTRY_COMPARE(widget->geometry().size(), initialSize); |
1872 |
1874 |
1873 } |
1875 } |
1874 |
1876 |
1875 void tst_QGraphicsWidget::explicitMouseGrabber() |
1877 void tst_QGraphicsWidget::explicitMouseGrabber() |
1876 { |
1878 { |
2732 view->show(); |
2732 view->show(); |
2733 window->setGeometry(0, 0, 70, 70); |
2733 window->setGeometry(0, 0, 70, 70); |
2734 QTest::qWaitForWindowShown(view); |
2734 QTest::qWaitForWindowShown(view); |
2735 |
2735 |
2736 { // here we go - simulate a interactive resize of the window |
2736 { // here we go - simulate a interactive resize of the window |
2737 QTest::qWait(100); |
|
2738 QTest::mouseMove(view, view->mapFromScene(71, 71)); // bottom right corner |
2737 QTest::mouseMove(view, view->mapFromScene(71, 71)); // bottom right corner |
2739 QTest::qWait(100); |
|
2740 |
2738 |
2741 QTest::mousePress(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(71, 71), 200); |
2739 QTest::mousePress(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(71, 71), 200); |
2742 view->grabMouse(); |
2740 view->grabMouse(); |
2743 // move both mouse cursor and set correct event in order to emulate resize |
2741 // move both mouse cursor and set correct event in order to emulate resize |
2744 QTest::mouseMove(view->viewport(), view->mapFromScene(60, 30), 200); |
2742 QTest::mouseMove(view->viewport(), view->mapFromScene(60, 30), 200); |