summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-27 16:42:14 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-27 16:42:14 (GMT)
commita17339e943f21bb6c6e16884f716dd9ab8f94938 (patch)
treef75b19e3a5f9d436c00c6b269488414513d943c5 /tests
parentc78fb096c31df3b7d3cd9018f26518f59f4fde65 (diff)
parentba97ea29d33acf9ab421f4d8ef5202ec83231d7e (diff)
downloadQt-a17339e943f21bb6c6e16884f716dd9ab8f94938.zip
Qt-a17339e943f21bb6c6e16884f716dd9ab8f94938.tar.gz
Qt-a17339e943f21bb6c6e16884f716dd9ab8f94938.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (30 commits) Ensure text document is created before we access it. Plugins documentation. Fix update issue when an item has an effect and child. Fix QDeclarativeTextInput and QGraphicsView in regards of input methods hints. Disallow "Qt" as namespace import Don't "adjust" the z value of a delegate that has been cached. Correctly inherit extension properties Autotests More QDeclarativeNetworkAccessManagerFactory doc clarification. Fix QDeclarativeNetworkAccessManagerFactory docs. Don't crash on invalid model remove signal. Ensure scheduled layout can occur before testing. Fix remaining 4.6 type registrations (to 4.7). doc anchor margins vs. anchor (line) state/animation. These examples should not be included in this test Unify naming of settings / UI to be "Qt Qml Runtime" Improved error messages for type resolving, new debug option Link to example files from tutorial pages Add tutorial for writing QML extensions no export in plugin ...
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp32
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp54
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/formatting.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp17
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp99
14 files changed, 247 insertions, 30 deletions
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index c650346..16b0cbe 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -81,6 +81,7 @@ tst_examples::tst_examples()
// Add directories you want excluded here
excludedDirs << "examples/declarative/extending";
+ excludedDirs << "examples/declarative/tutorials/extending";
excludedDirs << "examples/declarative/plugins";
excludedDirs << "examples/declarative/proxywidgets";
excludedDirs << "examples/declarative/gestures";
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml
new file mode 100644
index 0000000..9c46c3f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml
@@ -0,0 +1,10 @@
+import Qt.test 1.0
+import Qt 4.7
+
+MyDeferredObject {
+ value: undefined // error is resolved before complete
+ objectProperty: undefined // immediate error
+ objectProperty2: QtObject {
+ Component.onCompleted: value = 10
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
index 154ff4d..8a4605a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
#include "testtypes.h"
+#include <QWidget>
+#include <QPlainTextEdit>
class BaseExtensionObject : public QObject
{
@@ -80,6 +82,24 @@ public:
DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {}
};
+class QWidgetDeclarativeUI : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
+
+signals:
+ void widthChanged();
+
+public:
+ QWidgetDeclarativeUI(QObject *other) : QObject(other) { }
+
+public:
+ int width() const { return 0; }
+ void setWidth(int) { }
+};
+
+
void registerTypes()
{
qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
@@ -91,6 +111,9 @@ void registerTypes()
qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment");
qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject");
qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject");
+
+ qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget");
+ qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
}
#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 97fced4..491a736 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -89,6 +89,7 @@ private slots:
void contextPropertiesTriggerReeval();
void objectPropertiesTriggerReeval();
void deferredProperties();
+ void deferredPropertiesErrors();
void extensionObjects();
void overrideExtensionProperties();
void attachedProperties();
@@ -133,6 +134,7 @@ private slots:
void numberAssignment();
void bug1();
+ void bug2();
void dynamicCreationCrash();
void regExpBug();
void nullObjectBinding();
@@ -543,6 +545,25 @@ void tst_qdeclarativeecmascript::deferredProperties()
QCOMPARE(qmlObject->value(), 19);
}
+// Check errors on deferred properties are correctly emitted
+void tst_qdeclarativeecmascript::deferredPropertiesErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("deferredPropertiesErrors.qml"));
+ MyDeferredObject *object =
+ qobject_cast<MyDeferredObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->value(), 0);
+ QVERIFY(object->objectProperty() == 0);
+ QVERIFY(object->objectProperty2() == 0);
+
+ QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ qmlExecuteDeferred(object);
+
+ delete object;
+}
+
void tst_qdeclarativeecmascript::extensionObjects()
{
QDeclarativeComponent component(&engine, TEST_FILE("extensionObjects.qml"));
@@ -1231,6 +1252,17 @@ void tst_qdeclarativeecmascript::bug1()
delete object;
}
+void tst_qdeclarativeecmascript::bug2()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
// Don't crash in createObject when the component has errors.
void tst_qdeclarativeecmascript::dynamicCreationCrash()
{
diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
index ee320aa..b0db771 100644
--- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
+++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
@@ -297,6 +297,8 @@ void tst_qdeclarativeengine::objectOwnership()
{
QObject o;
QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
+ QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
+ QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::JavaScriptOwnership);
QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::JavaScriptOwnership);
QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml
index 8eb9768..2f49418 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml
@@ -1,5 +1,5 @@
-import Qt 4.7 as Qt
+import Qt 4.7 as Qt47
-Qt.QtObject {
- Qt: 10
+Qt47.QtObject {
+ Qt47: 10
}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
index e870046..c997356 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
@@ -1,6 +1,6 @@
import Test 1.0
import Qt 4.7
-import Qt 4.7 as Qt
+import Qt 4.7 as Qt47
QtObject {
property QtObject objectProperty
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
index 6d33361..303b5a5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
@@ -1,2 +1,2 @@
-import Qt 4.7 as Qt
-Qt.Rectangle {}
+import Qt 4.7 as Qt47
+Qt47.Rectangle {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index c39e6f7..ff03005 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -48,12 +48,16 @@
#include <private/qdeclarativeproperty_p.h>
#include <private/qdeclarativemetatype_p.h>
+#include <private/qdeclarativeglobal_p.h>
#include "testtypes.h"
#include "../../../shared/util.h"
#include "testhttpserver.h"
+DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
+
+
/*
This test case covers QML language issues. This covers everything that does not
involve evaluating ECMAScript expressions and bindings.
@@ -1257,14 +1261,14 @@ void tst_qdeclarativelanguage::importsBuiltin_data()
<< "import com.nokia.Test 1.11\n"
"import com.nokia.Test 1.12\n"
"Test {}"
- << "TestType2"
- << "";
+ << (!qmlCheckTypes()?"TestType2":"")
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
QTest::newRow("multiversion 2")
<< "import com.nokia.Test 1.11\n"
"import com.nokia.Test 1.12\n"
"OldTest {}"
- << "TestType"
- << "";
+ << (!qmlCheckTypes()?"TestType":"")
+ << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
QTest::newRow("qualified multiversion 3")
<< "import com.nokia.Test 1.0 as T0\n"
"import com.nokia.Test 1.8 as T8\n"
@@ -1312,12 +1316,12 @@ void tst_qdeclarativelanguage::importsLocal_data()
QTest::newRow("local import QTBUG-7721 A")
<< "subdir.Test {}" // no longer allowed (QTBUG-7721)
<< ""
- << "subdir.Test is not a type";
+ << "subdir.Test - subdir is not a namespace";
QTest::newRow("local import QTBUG-7721 B")
<< "import \"subdir\" as X\n"
"X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
<< ""
- << "X.subsubdir.SubTest is not a type";
+ << "X.subsubdir.SubTest - nested namespaces not allowed";
QTest::newRow("local import as")
<< "import \"subdir\" as T\n"
"T.Test {}"
@@ -1332,8 +1336,8 @@ void tst_qdeclarativelanguage::importsLocal_data()
<< "import \"subdir\"\n"
"import com.nokia.Test 1.0\n"
"Test {}"
- << "TestType"
- << "";
+ << (!qmlCheckTypes()?"TestType":"")
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir");
}
void tst_qdeclarativelanguage::importsLocal()
@@ -1478,46 +1482,52 @@ void tst_qdeclarativelanguage::importsOrder_data()
QTest::addColumn<QString>("type");
QTest::addColumn<QString>("error");
+ QTest::newRow("double import") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QDeclarativeText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4");
QTest::newRow("installed import overrides 1") <<
"import com.nokia.installedtest 1.0\n"
"import com.nokia.installedtest 1.4\n"
"InstalledTest {}"
- << "QDeclarativeText"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
QTest::newRow("installed import overrides 2") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"InstalledTest {}"
- << "QDeclarativeRectangle"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
QTest::newRow("installed import re-overrides 1") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"import com.nokia.installedtest 1.4\n"
"InstalledTest {}"
- << "QDeclarativeText"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
QTest::newRow("installed import re-overrides 2") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"InstalledTest {}"
- << "QDeclarativeRectangle"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
QTest::newRow("installed import versus builtin 1") <<
"import com.nokia.installedtest 1.5\n"
"import Qt 4.7\n"
"Rectangle {}"
- << "QDeclarativeRectangle"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest");
QTest::newRow("installed import versus builtin 2") <<
"import Qt 4.7\n"
"import com.nokia.installedtest 1.5\n"
"Rectangle {}"
- << "QDeclarativeText"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeText":"")
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt");
QTest::newRow("namespaces cannot be overridden by types 1") <<
"import Qt 4.7 as Rectangle\n"
"import com.nokia.installedtest 1.5\n"
@@ -1537,8 +1547,8 @@ void tst_qdeclarativelanguage::importsOrder_data()
QTest::newRow("local last 2") <<
"import com.nokia.installedtest 1.0\n"
"LocalLast {}"
- << "QDeclarativeRectangle"
- << ""; // i.e. from com.nokia.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory");
}
void tst_qdeclarativelanguage::importsOrder()
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index cab4d52..22eb734 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -571,6 +571,7 @@ void tst_QDeclarativeListView::removed(bool animated)
// Remove items not visible
model.removeItem(18);
+ qApp->processEvents();
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
@@ -586,6 +587,7 @@ void tst_QDeclarativeListView::removed(bool animated)
listview->setCurrentIndex(10);
model.removeItem(1); // post: top item will be at 40
+ qApp->processEvents();
// Confirm items positioned correctly
for (int i = 2; i < 18; ++i) {
diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
index 59a15929..7f48639 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
@@ -16,4 +16,14 @@ QtObject {
property string test8: Qt.formatDateTime(dateTime1)
property string test9: Qt.formatDateTime(dateTime1, Qt.DefaultLocaleLongDate)
property string test10: Qt.formatDateTime(dateTime1, "M/d/yy H:m:s a")
+
+ // Error cases
+ property string test11: Qt.formatDate()
+ property string test12: Qt.formatDate(new Date, new Object)
+
+ property string test13: Qt.formatTime()
+ property string test14: Qt.formatTime(new Date, new Object)
+
+ property string test15: Qt.formatDateTime()
+ property string test16: Qt.formatDateTime(new Date, new Object)
}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index f5d5926..7cbd8db 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -398,6 +398,21 @@ void tst_qdeclarativeqt::consoleLog()
void tst_qdeclarativeqt::formatting()
{
QDeclarativeComponent component(&engine, TEST_FILE("formatting.qml"));
+
+ QString warning1 = component.url().toString() + ":22: Error: Qt.formatDate(): Invalid date format";
+ QString warning2 = component.url().toString() + ":21: Error: Qt.formatDate(): Invalid arguments";
+ QString warning3 = component.url().toString() + ":28: Error: Qt.formatDateTime(): Invalid datetime format";
+ QString warning4 = component.url().toString() + ":27: Error: Qt.formatDateTime(): Invalid arguments";
+ QString warning5 = component.url().toString() + ":25: Error: Qt.formatTime(): Invalid time format";
+ QString warning6 = component.url().toString() + ":24: Error: Qt.formatTime(): Invalid arguments";
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning6));
+
QObject *object = component.create();
QVERIFY(object != 0);
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index fcd7527..83ebe6c 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -644,21 +644,38 @@ void tst_qdeclarativetextinput::echoMode()
QVERIFY(input != 0);
QTRY_VERIFY(input->hasFocus() == true);
QString initial = input->text();
+ Qt::InputMethodHints ref;
QCOMPARE(initial, QLatin1String("ABCDefgh"));
QCOMPARE(input->echoMode(), QDeclarativeTextInput::Normal);
QCOMPARE(input->displayText(), input->text());
+ //Normal
+ ref &= ~Qt::ImhHiddenText;
+ ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
input->setEchoMode(QDeclarativeTextInput::NoEcho);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String(""));
QCOMPARE(input->passwordCharacter(), QLatin1String("*"));
+ //NoEcho
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
input->setEchoMode(QDeclarativeTextInput::Password);
+ //Password
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("********"));
+ QCOMPARE(input->inputMethodHints(), ref);
input->setPasswordCharacter(QChar('Q'));
QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
input->setEchoMode(QDeclarativeTextInput::PasswordEchoOnEdit);
+ //PasswordEchoOnEdit
+ ref &= ~Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
QTest::keyPress(canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index e2f7f18..055ae80 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -63,6 +63,7 @@
#include <QGraphicsEffect>
#include <QInputContext>
#include <QPushButton>
+#include <QLineEdit>
#include "../../shared/util.h"
@@ -445,6 +446,7 @@ private slots:
void QT_2653_fullUpdateDiscardingOpacityUpdate();
void QT_2649_focusScope();
void sortItemsWhileAdding();
+ void doNotMarkFullUpdateIfNotInScene();
private:
QList<QGraphicsItem *> paintedItems;
@@ -945,8 +947,52 @@ class ImhTester : public QGraphicsItem
void tst_QGraphicsItem::inputMethodHints()
{
- ImhTester item;
- QCOMPARE(item.inputMethodHints(), Qt::ImhNone);
+ ImhTester *item = new ImhTester;
+ item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
+ item->setFlag(QGraphicsItem::ItemIsFocusable, true);
+ QCOMPARE(item->inputMethodHints(), Qt::ImhNone);
+ ImhTester *item2 = new ImhTester;
+ item2->setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
+ item2->setFlag(QGraphicsItem::ItemIsFocusable, true);
+ Qt::InputMethodHints imHints = item2->inputMethodHints();
+ imHints |= Qt::ImhHiddenText;
+ item2->setInputMethodHints(imHints);
+ QGraphicsScene scene;
+ scene.addItem(item);
+ scene.addItem(item2);
+ QGraphicsView view(&scene);
+ QApplication::setActiveWindow(&view);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ item->setFocus();
+ QTRY_VERIFY(item->hasFocus());
+ QCOMPARE(view.inputMethodHints(), item->inputMethodHints());
+ item2->setFocus();
+ QTRY_VERIFY(item2->hasFocus());
+ QCOMPARE(view.inputMethodHints(), item2->inputMethodHints());
+ item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, false);
+ item->setFocus();
+ QTRY_VERIFY(item->hasFocus());
+ //Focus has changed but the new item doesn't accept input method, no hints.
+ QCOMPARE(view.inputMethodHints(), 0);
+ item2->setFocus();
+ QTRY_VERIFY(item2->hasFocus());
+ QCOMPARE(view.inputMethodHints(), item2->inputMethodHints());
+ imHints = item2->inputMethodHints();
+ imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ item2->setInputMethodHints(imHints);
+ QCOMPARE(view.inputMethodHints(), item2->inputMethodHints());
+ QGraphicsProxyWidget *widget = new QGraphicsProxyWidget;
+ QLineEdit *edit = new QLineEdit;
+ edit->setEchoMode(QLineEdit::Password);
+ scene.addItem(widget);
+ widget->setFocus();
+ QTRY_VERIFY(widget->hasFocus());
+ //No widget on the proxy, so no hints
+ QCOMPARE(view.inputMethodHints(), 0);
+ widget->setWidget(edit);
+ //View should match with the line edit
+ QCOMPARE(view.inputMethodHints(), edit->inputMethodHints());
}
void tst_QGraphicsItem::toolTip()
@@ -10055,6 +10101,9 @@ void tst_QGraphicsItem::updateMicroFocus()
QApplication::setActiveWindow(&parent);
QTest::qWaitForWindowShown(&parent);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&parent));
+ //We reset the number of updates that happened previously (initialisation)
+ ic.nbUpdates = 0;
+ ic2.nbUpdates = 0;
input.doUpdateMicroFocus();
QApplication::processEvents();
QTRY_COMPARE(ic.nbUpdates, 1);
@@ -10383,5 +10432,51 @@ void tst_QGraphicsItem::sortItemsWhileAdding()
grandParent.setParentItem(&grandGrandParent);
}
+void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene()
+{
+ struct Item : public QGraphicsTextItem
+ {
+ int painted;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *wid)
+ {
+ painted++;
+ QGraphicsTextItem::paint(painter, opt, wid);
+ }
+ };
+ QGraphicsScene scene;
+ MyGraphicsView view(&scene);
+ Item *item = new Item;
+ item->painted = 0;
+ item->setPlainText("Grandparent");
+ Item *item2 = new Item;
+ item2->setPlainText("parent");
+ item2->painted = 0;
+ Item *item3 = new Item;
+ item3->setPlainText("child");
+ item3->painted = 0;
+ QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect;
+ effect->setOpacity(0.5);
+ item2->setGraphicsEffect(effect);
+ item3->setParentItem(item2);
+ item2->setParentItem(item);
+ scene.addItem(item);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(view.repaints, 1);
+ QTRY_COMPARE(item->painted, 1);
+ QTRY_COMPARE(item2->painted, 1);
+ QTRY_COMPARE(item3->painted, 1);
+ item2->update();
+ QApplication::processEvents();
+ QTRY_COMPARE(item->painted, 2);
+ QTRY_COMPARE(item2->painted, 2);
+ QTRY_COMPARE(item3->painted, 2);
+ item2->update();
+ QApplication::processEvents();
+ QTRY_COMPARE(item->painted, 3);
+ QTRY_COMPARE(item2->painted, 3);
+ QTRY_COMPARE(item3->painted, 3);
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"