summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsproxywidget
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-10 18:48:16 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-10 18:55:12 (GMT)
commit6bffb9055a6548730ba915630007ba44b292b03f (patch)
treec07d32efbba69e35318e4c9ea078afd5fe1f9987 /tests/auto/qgraphicsproxywidget
parent435fae071798817f57bc89bf5d1ac20aae488625 (diff)
parent4d31527417419d4f7c1417b9360ef91d72469aa0 (diff)
downloadQt-6bffb9055a6548730ba915630007ba44b292b03f.zip
Qt-6bffb9055a6548730ba915630007ba44b292b03f.tar.gz
Qt-6bffb9055a6548730ba915630007ba44b292b03f.tar.bz2
Merge commit 'qt/master' into graphicssceneindex
Conflicts: src/gui/graphicsview/qgraphicsitem_p.h tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp tests/auto/qgraphicsview/tst_qgraphicsview.cpp
Diffstat (limited to 'tests/auto/qgraphicsproxywidget')
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 3b13bcc..1d0663a 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -179,6 +179,7 @@ private slots:
void windowFlags();
void comboboxWindowFlags();
void updateAndDelete();
+ void inputMethod();
};
// Subclass that exposes the protected functions.
@@ -1573,7 +1574,7 @@ void tst_QGraphicsProxyWidget::resize_simple()
QGraphicsProxyWidget proxy;
QWidget *widget = new QWidget;
- widget->setGeometry(0, 0, size.width(), size.height());
+ widget->setGeometry(0, 0, (int)size.width(), (int)size.height());
proxy.setWidget(widget);
widget->show();
QCOMPARE(widget->pos(), QPoint());
@@ -3256,10 +3257,51 @@ void tst_QGraphicsProxyWidget::updateAndDelete()
QCOMPARE(view.paintEventRegion, expectedRegion);
}
+class InputMethod_LineEdit : public QLineEdit
+{
+ bool event(QEvent *e)
+ {
+ if (e->type() == QEvent::InputMethod)
+ ++inputMethodEvents;
+ return QLineEdit::event(e);
+ }
+public:
+ int inputMethodEvents;
+};
+
+void tst_QGraphicsProxyWidget::inputMethod()
+{
+ QGraphicsScene scene;
+
+ // check that the proxy is initialized with the correct input method sensitivity
+ for (int i = 0; i < 2; ++i)
+ {
+ QLineEdit *lineEdit = new QLineEdit;
+ lineEdit->setAttribute(Qt::WA_InputMethodEnabled, !!i);
+ QGraphicsProxyWidget *proxy = scene.addWidget(lineEdit);
+ QCOMPARE(!!(proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod), !!i);
+ }
+
+ // check that input method events are only forwarded to widgets with focus
+ for (int i = 0; i < 2; ++i)
+ {
+ InputMethod_LineEdit *lineEdit = new InputMethod_LineEdit;
+ lineEdit->setAttribute(Qt::WA_InputMethodEnabled, true);
+ QGraphicsProxyWidget *proxy = scene.addWidget(lineEdit);
+
+ if (i)
+ lineEdit->setFocus();
+
+ lineEdit->inputMethodEvents = 0;
+ QInputMethodEvent event;
+ qApp->sendEvent(proxy, &event);
+ QCOMPARE(lineEdit->inputMethodEvents, i);
+ }
+}
+
QTEST_MAIN(tst_QGraphicsProxyWidget)
#include "tst_qgraphicsproxywidget.moc"
#else // QT_NO_STYLE_CLEANLOOKS
QTEST_NOOP_MAIN
#endif
-