diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-07-21 02:23:15 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-07-21 02:33:18 (GMT) |
commit | 21806ff0921641b4e4d9d39721ab4ebeae74dddc (patch) | |
tree | 6f854d6279385c120986f0288eb997373058106a /tests/auto/declarative | |
parent | 4f6e480acce94d8ae920c3eda4879fc4f9cb2598 (diff) | |
download | Qt-21806ff0921641b4e4d9d39721ab4ebeae74dddc.zip Qt-21806ff0921641b4e4d9d39721ab4ebeae74dddc.tar.gz Qt-21806ff0921641b4e4d9d39721ab4ebeae74dddc.tar.bz2 |
QML focus API updates.
The wantsFocus property has been renamed to activeFocus, to better
reflect its value. Reading and writing the focus property is also now
consistent -- this property represents focus within a scope. Other small
changes were made to keep things consistent with the new naming.
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests/auto/declarative')
13 files changed, 154 insertions, 159 deletions
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml index 6c39f20..42b50cf 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml @@ -4,11 +4,11 @@ Rectangle { id: root width:300; height:400 - property bool focus1: root.wantsFocus - property bool focus2: item1.wantsFocus - property bool focus3: fs1.wantsFocus - property bool focus4: fs2.wantsFocus - property bool focus5: theItem.wantsFocus + property bool focus1: root.activeFocus + property bool focus2: item1.activeFocus + property bool focus3: fs1.activeFocus + property bool focus4: fs2.activeFocus + property bool focus5: theItem.activeFocus Item { id: item1 diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml index af9c420..9144854 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml @@ -15,28 +15,28 @@ Rectangle { height: 120; width: 420 color: "transparent" - border.width: 5; border.color: firstScope.wantsFocus?"blue":"black" + border.width: 5; border.color: firstScope.activeFocus?"blue":"black" Rectangle { id: item1; objectName: "item1" x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" focus: true Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } Rectangle { id: item2; objectName: "item2" x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -50,32 +50,32 @@ Rectangle { y: 160; height: 120; width: 420 color: "transparent" - border.width: 5; border.color: secondScope.wantsFocus?"blue":"black" + border.width: 5; border.color: secondScope.activeFocus?"blue":"black" Rectangle { id: item4; objectName: "item4" x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } Rectangle { id: item5; objectName: "item5" x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } } } Keys.onDigit4Pressed: item4.focus = true - Keys.onDigit5Pressed: item5.forceFocus() + Keys.onDigit5Pressed: item5.forceActiveFocus() } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml index aa43ba8..55be103 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml @@ -20,21 +20,21 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { id: item1; objectName: "item1" x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.debug("Top Left"); KeyNavigation.right: item2 focus: true Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } @@ -43,13 +43,13 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onDigit9Pressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -63,14 +63,14 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Bottom Left"); KeyNavigation.up: myScope Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml index 216277e..5ed701d 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml @@ -10,27 +10,27 @@ Rectangle { FocusScope { y: 100 focus: true; objectName: "item1" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item2" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item3" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item4" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item5" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } } } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml index 2ac0d18..c6d112f 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml @@ -13,7 +13,7 @@ Rectangle { ListElement { name: "4" } ListElement { name: "5" } ListElement { name: "6" } - ListElement { name: "6" } + ListElement { name: "7" } ListElement { name: "8" } ListElement { name: "9" } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml index 8862b39..3c6d3bd 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml @@ -19,21 +19,21 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { id: item1; objectName: "item1" x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Error - Top Left"); KeyNavigation.right: item2 focus: true Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } @@ -42,13 +42,13 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onDigit9Pressed: console.log("Error - Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -62,14 +62,14 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Error - Bottom Left"); KeyNavigation.up: myScope Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml index cdb5164..4417d5f 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml @@ -20,13 +20,13 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: item1.wantsFocus?"blue":"black" + border.color: item1.activeFocus?"blue":"black" } TextEdit { @@ -47,13 +47,13 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onReturnPressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -66,7 +66,7 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: item3.wantsFocus?"blue":"black" + border.color: item3.activeFocus?"blue":"black" } TextEdit { diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index 2559087..b0c9c03 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -118,22 +118,22 @@ void tst_qdeclarativefocusscope::basic() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == true); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == true); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); delete view; } @@ -166,16 +166,11 @@ void tst_qdeclarativefocusscope::nested() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item1->wantsFocus() == true); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->wantsFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == true); - QVERIFY(item3->hasFocus() == false); - QVERIFY(item4->wantsFocus() == true); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->wantsFocus() == true); - QVERIFY(item5->hasFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == true); + QVERIFY(item4->hasActiveFocus() == true); + QVERIFY(item5->hasActiveFocus() == true); delete view; } @@ -204,22 +199,22 @@ void tst_qdeclarativefocusscope::noFocus() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); delete view; } @@ -249,32 +244,32 @@ void tst_qdeclarativefocusscope::textEdit() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == true); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == true); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); delete view; } @@ -308,28 +303,28 @@ void tst_qdeclarativefocusscope::forceFocus() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == false); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_4); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == false); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_5); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == true); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->hasFocus() == true); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == true); delete view; } diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index ffb2105..345ce38 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -371,7 +371,7 @@ void tst_QDeclarativeItem::keyNavigation() QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // right QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); @@ -380,7 +380,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // down key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); @@ -389,7 +389,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // left key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); @@ -398,7 +398,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // up key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); @@ -407,7 +407,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // tab key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); @@ -416,7 +416,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // backtab key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); @@ -425,7 +425,7 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); QVERIFY(item); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); delete canvas; } @@ -618,21 +618,21 @@ void tst_QDeclarativeItem::mouseFocus() QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "declarativeItem"); QVERIFY(item); - QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); + QSignalSpy focusSpy(item, SIGNAL(activeFocusChanged(bool))); QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); QApplication::processEvents(); QCOMPARE(focusSpy.count(), 1); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); // make sure focusable graphics widget underneath does not steal focus QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); QApplication::processEvents(); QCOMPARE(focusSpy.count(), 1); - QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); item->setFocus(false); - QVERIFY(!item->hasFocus()); + QVERIFY(!item->hasActiveFocus()); QCOMPARE(focusSpy.count(), 2); item->setFocus(true); QCOMPARE(focusSpy.count(), 3); @@ -664,7 +664,7 @@ void tst_QDeclarativeItem::propertyChanges() QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal))); QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF))); QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); - QSignalSpy wantsFocusSpy(parentItem, SIGNAL(wantsFocusChanged(bool))); + QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool))); item->setParentItem(parentItem); item->setWidth(100.0); @@ -696,14 +696,14 @@ void tst_QDeclarativeItem::propertyChanges() QVERIFY(childrenRectArguments.count() == 1); QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF()); - QCOMPARE(item->hasFocus(), true); + QCOMPARE(item->hasActiveFocus(), true); QCOMPARE(focusSpy.count(),1); QList<QVariant> focusArguments = focusSpy.first(); QVERIFY(focusArguments.count() == 1); QCOMPARE(focusArguments.at(0).toBool(), true); + QCOMPARE(parentItem->hasActiveFocus(), false); QCOMPARE(parentItem->hasFocus(), false); - QCOMPARE(parentItem->wantsFocus(), false); QCOMPARE(wantsFocusSpy.count(),0); delete canvas; diff --git a/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml index 807eec9..8f9a7f2 100644 --- a/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml +++ b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml @@ -5,6 +5,6 @@ Rectangle { color: "red" states: State { name: "blue" - PropertyChanges { target: myRectangle; colr: "blue"; wantsFocus: true } + PropertyChanges { target: myRectangle; colr: "blue"; activeFocus: true } } } diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 7bc4fd4..3b6a420 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -922,7 +922,7 @@ void tst_qdeclarativestates::propertyErrors() QCOMPARE(rect->color(),QColor("red")); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); - QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"wantsFocus\""); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\""); QDeclarativeItemPrivate::get(rect)->setState("blue"); } diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 4783bc7..93351a8 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -604,7 +604,7 @@ void tst_qdeclarativetextedit::persistentSelection() void tst_qdeclarativetextedit::focusOnPress() { { - QString componentStr = "import Qt 4.7\nTextEdit { focusOnPress: true; text: \"Hello World\" }"; + QString componentStr = "import Qt 4.7\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); @@ -613,7 +613,7 @@ void tst_qdeclarativetextedit::focusOnPress() } { - QString componentStr = "import Qt 4.7\nTextEdit { focusOnPress: false; text: \"Hello World\" }"; + QString componentStr = "import Qt 4.7\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create()); @@ -840,15 +840,15 @@ void tst_qdeclarativetextedit::navigation() QDeclarativeItem *input = qobject_cast<QDeclarativeItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); - QTRY_VERIFY(input->hasFocus() == true); + QTRY_VERIFY(input->hasActiveFocus() == true); simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasFocus() == false); + QVERIFY(input->hasActiveFocus() == false); simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasFocus() == false); + QVERIFY(input->hasActiveFocus() == false); simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); } void tst_qdeclarativetextedit::copyAndPaste() { @@ -908,7 +908,7 @@ void tst_qdeclarativetextedit::readOnly() QDeclarativeTextEdit *edit = qobject_cast<QDeclarativeTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(edit != 0); - QTRY_VERIFY(edit->hasFocus() == true); + QTRY_VERIFY(edit->hasActiveFocus() == true); QVERIFY(edit->isReadOnly() == true); QString initial = edit->text(); for(int k=Qt::Key_0; k<=Qt::Key_Z; k++) @@ -968,7 +968,7 @@ void tst_qdeclarativetextedit::openInputPanelOnClick() MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextEdit edit; - QSignalSpy focusOnPressSpy(&edit, SIGNAL(focusOnPressChanged(bool))); + QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool))); edit.setText("Hello world"); edit.setPos(0, 0); scene.addItem(&edit); @@ -1016,7 +1016,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextEdit edit; - QSignalSpy focusOnPressSpy(&edit, SIGNAL(focusOnPressChanged(bool))); + QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool))); edit.setText("Hello world"); edit.setPos(0, 0); scene.addItem(&edit); @@ -1038,7 +1038,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() // focus on press, input panel on focus QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); QApplication::processEvents(); - QVERIFY(edit.hasFocus()); + QVERIFY(edit.hasActiveFocus()); QCOMPARE(ic.openInputPanelReceived, true); ic.openInputPanelReceived = false; @@ -1048,7 +1048,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() ic.openInputPanelReceived = false; // if already focused, input panel can be opened on press - QVERIFY(edit.hasFocus()); + QVERIFY(edit.hasActiveFocus()); QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, true); @@ -1076,7 +1076,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); // no automatic input panel events should - // be sent if focusOnPress is false + // be sent if activeFocusOnPress is false edit.setFocusOnPress(false); QCOMPARE(focusOnPressSpy.count(),1); edit.setFocusOnPress(false); @@ -1103,7 +1103,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() QCOMPARE(ic.closeInputPanelReceived, true); ic.closeInputPanelReceived = false; - // set focusOnPress back to true + // set activeFocusOnPress back to true edit.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); edit.setFocusOnPress(true); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index a48bc39..e5e495e 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -494,7 +494,7 @@ void tst_qdeclarativetextinput::maxLength() } textinputObject->setText(""); - QTRY_VERIFY(textinputObject->hasFocus() == true); + QTRY_VERIFY(textinputObject->hasActiveFocus() == true); for(int i=0; i<20; i++){ QCOMPARE(textinputObject->text().length(), qMin(i,10)); //simulateKey(canvas, Qt::Key_A); @@ -515,7 +515,7 @@ void tst_qdeclarativetextinput::masks() QVERIFY(canvas->rootObject() != 0); QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); QVERIFY(textinputObject != 0); - QTRY_VERIFY(textinputObject->hasFocus() == true); + QTRY_VERIFY(textinputObject->hasActiveFocus() == true); QVERIFY(textinputObject->text().length() == 0); QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; ")); for(int i=0; i<10; i++){ @@ -544,7 +544,7 @@ void tst_qdeclarativetextinput::validators() QDeclarativeTextInput *intInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput"))); QVERIFY(intInput); intInput->setFocus(true); - QTRY_VERIFY(intInput->hasFocus()); + QTRY_VERIFY(intInput->hasActiveFocus()); QTest::keyPress(canvas, Qt::Key_1); QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); QCOMPARE(intInput->text(), QLatin1String("1")); @@ -565,7 +565,7 @@ void tst_qdeclarativetextinput::validators() QDeclarativeTextInput *dblInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput"))); QTRY_VERIFY(dblInput); dblInput->setFocus(true); - QVERIFY(dblInput->hasFocus() == true); + QVERIFY(dblInput->hasActiveFocus() == true); QTest::keyPress(canvas, Qt::Key_1); QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); QCOMPARE(dblInput->text(), QLatin1String("1")); @@ -594,7 +594,7 @@ void tst_qdeclarativetextinput::validators() QDeclarativeTextInput *strInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput"))); QTRY_VERIFY(strInput); strInput->setFocus(true); - QVERIFY(strInput->hasFocus() == true); + QVERIFY(strInput->hasActiveFocus() == true); QTest::keyPress(canvas, Qt::Key_1); QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); QCOMPARE(strInput->text(), QLatin1String("")); @@ -642,7 +642,7 @@ void tst_qdeclarativetextinput::inputMethods() QVERIFY(canvas->rootObject() != 0); input->setFocus(true); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); // test that input method event is committed QInputMethodEvent event; event.setCommitString( "My ", -12, 0); @@ -669,11 +669,11 @@ void tst_qdeclarativetextinput::navigation() QVERIFY(input != 0); input->setCursorPosition(0); - QTRY_VERIFY(input->hasFocus() == true); + QTRY_VERIFY(input->hasActiveFocus() == true); simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasFocus() == false); + QVERIFY(input->hasActiveFocus() == false); simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); //QT-2944: If text is selected, ensure we deselect upon cursor motion input->setCursorPosition(input->text().length()); input->select(0,input->text().length()); @@ -681,11 +681,11 @@ void tst_qdeclarativetextinput::navigation() simulateKey(canvas, Qt::Key_Right); QVERIFY(input->selectionStart() == input->selectionEnd()); QVERIFY(input->selectionStart() == input->text().length()); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasFocus() == false); + QVERIFY(input->hasActiveFocus() == false); simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasFocus() == true); + QVERIFY(input->hasActiveFocus() == true); // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438). input->setCursorPosition(2); @@ -784,7 +784,7 @@ void tst_qdeclarativetextinput::readOnly() QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); - QTRY_VERIFY(input->hasFocus() == true); + QTRY_VERIFY(input->hasActiveFocus() == true); QVERIFY(input->isReadOnly() == true); QString initial = input->text(); for(int k=Qt::Key_0; k<=Qt::Key_Z; k++) @@ -808,7 +808,7 @@ void tst_qdeclarativetextinput::echoMode() QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); - QTRY_VERIFY(input->hasFocus() == true); + QTRY_VERIFY(input->hasActiveFocus() == true); QString initial = input->text(); Qt::InputMethodHints ref; QCOMPARE(initial, QLatin1String("ABCDefgh")); @@ -901,7 +901,7 @@ void tst_qdeclarativetextinput::openInputPanelOnClick() MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextInput input; - QSignalSpy focusOnPressSpy(&input, SIGNAL(focusOnPressChanged(bool))); + QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool))); input.setText("Hello world"); input.setPos(0, 0); scene.addItem(&input); @@ -948,7 +948,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextInput input; - QSignalSpy focusOnPressSpy(&input, SIGNAL(focusOnPressChanged(bool))); + QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool))); input.setText("Hello world"); input.setPos(0, 0); scene.addItem(&input); @@ -970,7 +970,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() // focus on press, input panel on focus QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); QApplication::processEvents(); - QVERIFY(input.hasFocus()); + QVERIFY(input.hasActiveFocus()); QCOMPARE(ic.openInputPanelReceived, true); ic.openInputPanelReceived = false; @@ -980,7 +980,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() ic.openInputPanelReceived = false; // if already focused, input panel can be opened on press - QVERIFY(input.hasFocus()); + QVERIFY(input.hasActiveFocus()); QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, true); @@ -1008,7 +1008,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); // no automatic input panel events should - // be sent if focusOnPress is false + // be sent if activeFocusOnPress is false input.setFocusOnPress(false); QCOMPARE(focusOnPressSpy.count(),1); input.setFocusOnPress(false); @@ -1035,7 +1035,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QCOMPARE(ic.closeInputPanelReceived, true); ic.closeInputPanelReceived = false; - // set focusOnPress back to true + // set activeFocusOnPress back to true input.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); input.setFocusOnPress(true); |