3325 QCOMPARE(wr->objectName(), QString("w2")); |
3331 QCOMPARE(wr->objectName(), QString("w2")); |
3326 |
3332 |
3327 w2->lower(); |
3333 w2->lower(); |
3328 qApp->processEvents(); |
3334 qApp->processEvents(); |
3329 QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); |
3335 QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); |
3330 QCOMPARE(wr->objectName(), QString("w1")); |
3336 const bool match = (wr->objectName() == QString("w1")); |
3331 |
|
3332 w2->raise(); |
3337 w2->raise(); |
|
3338 QVERIFY(match); |
|
3339 |
3333 qApp->processEvents(); |
3340 qApp->processEvents(); |
3334 QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); |
3341 QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); |
3335 QCOMPARE(wr->objectName(), QString("w2")); |
3342 QCOMPARE(wr->objectName(), QString("w2")); |
3336 |
3343 |
3337 |
3344 |
6317 QCoreApplication::postEvent(&widget, new QEvent(QEvent::Type(QEvent::User + 1))); |
6324 QCoreApplication::postEvent(&widget, new QEvent(QEvent::Type(QEvent::User + 1))); |
6318 |
6325 |
6319 widget.show(); |
6326 widget.show(); |
6320 expected = |
6327 expected = |
6321 EventRecorder::EventList() |
6328 EventRecorder::EventList() |
|
6329 << qMakePair(&widget, QEvent::WinIdChange) |
6322 << qMakePair(&widget, QEvent::Polish) |
6330 << qMakePair(&widget, QEvent::Polish) |
6323 << qMakePair(&widget, QEvent::Move) |
6331 << qMakePair(&widget, QEvent::Move) |
6324 << qMakePair(&widget, QEvent::Resize) |
6332 << qMakePair(&widget, QEvent::Resize) |
6325 << qMakePair(&widget, QEvent::Show); |
6333 << qMakePair(&widget, QEvent::Show); |
6326 |
6334 |
8270 |
8280 |
8271 QTest::qWait(10); |
8281 QTest::qWait(10); |
8272 // Make sure the resize triggers another update. |
8282 // Make sure the resize triggers another update. |
8273 QTRY_COMPARE(widget.numPaintEvents, 1); |
8283 QTRY_COMPARE(widget.numPaintEvents, 1); |
8274 } |
8284 } |
|
8285 |
|
8286 void tst_QWidget::opaqueChildren() |
|
8287 { |
|
8288 QWidget widget; |
|
8289 widget.resize(200, 200); |
|
8290 |
|
8291 QWidget child(&widget); |
|
8292 child.setGeometry(-700, -700, 200, 200); |
|
8293 |
|
8294 QWidget grandChild(&child); |
|
8295 grandChild.resize(200, 200); |
|
8296 |
|
8297 QWidget greatGrandChild(&grandChild); |
|
8298 greatGrandChild.setGeometry(50, 50, 200, 200); |
|
8299 greatGrandChild.setPalette(Qt::red); |
|
8300 greatGrandChild.setAutoFillBackground(true); // Opaque child widget. |
|
8301 |
|
8302 widget.show(); |
|
8303 #ifdef Q_WS_X11 |
|
8304 qt_x11_wait_for_window_manager(&widget); |
|
8305 #endif |
|
8306 QTest::qWait(100); |
|
8307 |
|
8308 // Child, grandChild and greatGrandChild are outside the ancestor clip. |
|
8309 QRegion expectedOpaqueRegion(50, 50, 150, 150); |
|
8310 QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), expectedOpaqueRegion); |
|
8311 |
|
8312 // Now they are all inside the ancestor clip. |
|
8313 child.setGeometry(50, 50, 150, 150); |
|
8314 QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), expectedOpaqueRegion); |
|
8315 |
|
8316 // Set mask on greatGrandChild. |
|
8317 const QRegion mask(10, 10, 50, 50); |
|
8318 greatGrandChild.setMask(mask); |
|
8319 expectedOpaqueRegion &= mask.translated(50, 50); |
|
8320 QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), expectedOpaqueRegion); |
|
8321 |
|
8322 // Make greatGrandChild "transparent". |
|
8323 greatGrandChild.setAutoFillBackground(false); |
|
8324 QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), QRegion()); |
|
8325 } |
8275 #endif |
8326 #endif |
8276 |
8327 |
8277 |
8328 |
8278 class MaskSetWidget : public QWidget |
8329 class MaskSetWidget : public QWidget |
8279 { |
8330 { |
9496 |
9547 |
9497 // Ensure the existing effect is deleted when deleting the widget. |
9548 // Ensure the existing effect is deleted when deleting the widget. |
9498 delete widget; |
9549 delete widget; |
9499 QVERIFY(!blurEffect); |
9550 QVERIFY(!blurEffect); |
9500 delete anotherWidget; |
9551 delete anotherWidget; |
|
9552 |
|
9553 // Ensure the effect is uninstalled when deleting it |
|
9554 widget = new QWidget; |
|
9555 blurEffect = new QGraphicsBlurEffect; |
|
9556 widget->setGraphicsEffect(blurEffect); |
|
9557 delete blurEffect; |
|
9558 QVERIFY(!widget->graphicsEffect()); |
|
9559 |
|
9560 // Ensure the existing effect is uninstalled and deleted when setting a null effect |
|
9561 blurEffect = new QGraphicsBlurEffect; |
|
9562 widget->setGraphicsEffect(blurEffect); |
|
9563 widget->setGraphicsEffect(0); |
|
9564 QVERIFY(!widget->graphicsEffect()); |
|
9565 QVERIFY(!blurEffect); |
|
9566 |
|
9567 delete widget; |
9501 } |
9568 } |
9502 |
9569 |
9503 void tst_QWidget::activateWindow() |
9570 void tst_QWidget::activateWindow() |
9504 { |
9571 { |
9505 // Test case for task 260685 |
9572 // Test case for task 260685 |
9571 CEikButtonGroupContainer* buttonGroup = CEikonEnv::Static()->AppUiFactory()->Cba(); |
9661 CEikButtonGroupContainer* buttonGroup = CEikonEnv::Static()->AppUiFactory()->Cba(); |
9572 QVERIFY(buttonGroup->IsVisible()); |
9662 QVERIFY(buttonGroup->IsVisible()); |
9573 } |
9663 } |
9574 #endif |
9664 #endif |
9575 |
9665 |
|
9666 class InputContextTester : public QInputContext |
|
9667 { |
|
9668 Q_OBJECT |
|
9669 public: |
|
9670 QString identifierName() { return QString(); } |
|
9671 bool isComposing() const { return false; } |
|
9672 QString language() { return QString(); } |
|
9673 void reset() { ++resets; } |
|
9674 int resets; |
|
9675 }; |
|
9676 |
|
9677 void tst_QWidget::focusProxyAndInputMethods() |
|
9678 { |
|
9679 InputContextTester *inputContext = new InputContextTester; |
|
9680 QWidget *toplevel = new QWidget(0, Qt::X11BypassWindowManagerHint); |
|
9681 toplevel->setAttribute(Qt::WA_InputMethodEnabled, true); |
|
9682 toplevel->setInputContext(inputContext); // ownership is transferred |
|
9683 |
|
9684 QWidget *child = new QWidget(toplevel); |
|
9685 child->setFocusProxy(toplevel); |
|
9686 child->setAttribute(Qt::WA_InputMethodEnabled, true); |
|
9687 |
|
9688 toplevel->setFocusPolicy(Qt::WheelFocus); |
|
9689 child->setFocusPolicy(Qt::WheelFocus); |
|
9690 |
|
9691 QVERIFY(!child->hasFocus()); |
|
9692 QVERIFY(!toplevel->hasFocus()); |
|
9693 |
|
9694 toplevel->show(); |
|
9695 QTest::qWaitForWindowShown(toplevel); |
|
9696 QApplication::setActiveWindow(toplevel); |
|
9697 QVERIFY(toplevel->hasFocus()); |
|
9698 QVERIFY(child->hasFocus()); |
|
9699 |
|
9700 // verify that toggling input methods on the child widget |
|
9701 // correctly propagate to the focus proxy's input method |
|
9702 // and that the input method gets the focus proxy passed |
|
9703 // as the focus widget instead of the child widget. |
|
9704 // otherwise input method queries go to the wrong widget |
|
9705 |
|
9706 QCOMPARE(inputContext->focusWidget(), toplevel); |
|
9707 |
|
9708 child->setAttribute(Qt::WA_InputMethodEnabled, false); |
|
9709 QVERIFY(!inputContext->focusWidget()); |
|
9710 |
|
9711 child->setAttribute(Qt::WA_InputMethodEnabled, true); |
|
9712 QCOMPARE(inputContext->focusWidget(), toplevel); |
|
9713 |
|
9714 child->setEnabled(false); |
|
9715 QVERIFY(!inputContext->focusWidget()); |
|
9716 |
|
9717 child->setEnabled(true); |
|
9718 QCOMPARE(inputContext->focusWidget(), toplevel); |
|
9719 |
|
9720 delete toplevel; |
|
9721 } |
|
9722 |
|
9723 class scrollWidgetWBS : public QWidget |
|
9724 { |
|
9725 public: |
|
9726 void deleteBackingStore() |
|
9727 { |
|
9728 if (static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) { |
|
9729 delete static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore; |
|
9730 static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = 0; |
|
9731 } |
|
9732 } |
|
9733 void enableBackingStore() |
|
9734 { |
|
9735 if (!static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) { |
|
9736 static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = new QWidgetBackingStore(this); |
|
9737 static_cast<QWidgetPrivate*>(d_ptr.data())->invalidateBuffer(this->rect()); |
|
9738 repaint(); |
|
9739 } |
|
9740 } |
|
9741 }; |
|
9742 |
|
9743 void tst_QWidget::scrollWithoutBackingStore() |
|
9744 { |
|
9745 scrollWidgetWBS scrollable; |
|
9746 scrollable.resize(100,100); |
|
9747 QLabel child(QString("@"),&scrollable); |
|
9748 child.resize(50,50); |
|
9749 scrollable.show(); |
|
9750 QTest::qWaitForWindowShown(&scrollable); |
|
9751 scrollable.scroll(50,50); |
|
9752 QCOMPARE(child.pos(),QPoint(50,50)); |
|
9753 scrollable.deleteBackingStore(); |
|
9754 scrollable.scroll(-25,-25); |
|
9755 QCOMPARE(child.pos(),QPoint(25,25)); |
|
9756 scrollable.enableBackingStore(); |
|
9757 QCOMPARE(child.pos(),QPoint(25,25)); |
|
9758 } |
|
9759 |
9576 QTEST_MAIN(tst_QWidget) |
9760 QTEST_MAIN(tst_QWidget) |
9577 #include "tst_qwidget.moc" |
9761 #include "tst_qwidget.moc" |