/****************************************************************************
**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
#include <QtWidgets/QGraphicsSceneMouseEvent>
#include "private/qquickfocusscope_p.h"
#include "private/qquickitem_p.h"
+#include <qpa/qwindowsysteminterface.h>
#include <QDebug>
#include <QTimer>
#include "../../shared/util.h"
void ensureFocus(QWindow *w) {
w->show();
- w->requestActivateWindow();
+ w->requestActivate();
QTest::qWaitForWindowActive(w);
}
};
else if (qobject_cast<TestFocusScope *>(window.activeFocusItem())) \
QCOMPARE(qobject_cast<TestFocusScope *>(window.activeFocusItem())->focused, true); \
} else { \
- QCOMPARE(window.activeFocusItem(), window.rootItem()); \
+ QCOMPARE(window.activeFocusItem(), window.contentItem()); \
} \
for (QHash<QQuickItem *, FocusData>::Iterator iter = focusState.begin(); \
iter != focusState.end(); \
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *l1c1 = new TestItem(window.rootItem());
- QQuickItem *l1c2 = new TestItem(window.rootItem());
- QQuickItem *l1c3 = new TestItem(window.rootItem());
+ QQuickItem *l1c1 = new TestItem(window.contentItem());
+ QQuickItem *l1c2 = new TestItem(window.contentItem());
+ QQuickItem *l1c3 = new TestItem(window.contentItem());
QQuickItem *l2c1 = new TestItem(l1c1);
QQuickItem *l2c2 = new TestItem(l1c1);
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *l1c1 = new TestItem(window.rootItem());
- QQuickItem *l1c2 = new TestItem(window.rootItem());
- QQuickItem *l1c3 = new TestItem(window.rootItem());
+ QQuickItem *l1c1 = new TestItem(window.contentItem());
+ QQuickItem *l1c2 = new TestItem(window.contentItem());
+ QQuickItem *l1c3 = new TestItem(window.contentItem());
QQuickItem *l2c1 = new TestItem(l1c1);
QQuickItem *l2c2 = new TestItem(l1c1);
focusState[item].set(true, false);
FVERIFY();
- item->setParentItem(window.rootItem());
+ item->setParentItem(window.contentItem());
focusState[item].set(true, true);
focusState.active(item);
FVERIFY();
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *item = new TestItem(window.rootItem());
+ QQuickItem *item = new TestItem(window.contentItem());
QQuickItem *tree = new TestItem;
QQuickItem *c1 = new TestItem(tree);
focusState[c2].set(true, false);
FVERIFY();
- tree->setParentItem(window.rootItem());
+ tree->setParentItem(window.contentItem());
focusState[c1].set(false, false);
focusState[c2].set(true, true);
focusState.active(c2);
focusState[c2].set(true, false);
FVERIFY();
- tree->setParentItem(window.rootItem());
+ tree->setParentItem(window.contentItem());
focusState[c1].set(false, false);
focusState[c2].set(true, false);
FVERIFY();
focusState[c2].set(true, false);
FVERIFY();
- tree->setParentItem(window.rootItem());
+ tree->setParentItem(window.contentItem());
focusState[tree].set(true, true);
focusState[c1].set(false, false);
focusState[c2].set(true, true);
QQuickWindow window;
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *child = new TestItem(window.rootItem());
+ QQuickItem *child = new TestItem(window.contentItem());
QQuickItem *tree = new TestFocusScope;
QQuickItem *c1 = new TestItem(tree);
QQuickItem *c2 = new TestItem(tree);
focusState.active(child);
FVERIFY();
- tree->setParentItem(window.rootItem());
+ tree->setParentItem(window.contentItem());
focusState[tree].set(false, false);
focusState[c1].set(false, false);
focusState[c2].set(true, false);
QQuickWindow window;
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *child = new TestItem(window.rootItem());
+ QQuickItem *child = new TestItem(window.contentItem());
FocusState focusState;
focusState << child;
QQuickWindow window;
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *child = new TestItem(window.rootItem());
- QQuickItem *child2 = new TestItem(window.rootItem());
+ QQuickItem *child = new TestItem(window.contentItem());
+ QQuickItem *child2 = new TestItem(window.contentItem());
FocusState focusState;
focusState << child << child2;
QQuickWindow window;
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *child = new TestItem(window.rootItem());
- QQuickItem *child2 = new TestFocusScope(window.rootItem());
+ QQuickItem *child = new TestItem(window.contentItem());
+ QQuickItem *child2 = new TestFocusScope(window.contentItem());
QQuickItem *item = new TestItem(child);
FocusState focusState;
QQuickWindow window;
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *child = new TestItem(window.rootItem());
- QQuickItem *child2 = new TestFocusScope(window.rootItem());
+ QQuickItem *child = new TestItem(window.contentItem());
+ QQuickItem *child2 = new TestFocusScope(window.contentItem());
QQuickItem *item = new TestItem(child2);
FocusState focusState;
QQuickWindow window;
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *child = new TestItem(window.rootItem());
- QQuickItem *child2 = new TestFocusScope(window.rootItem());
+ QQuickItem *child = new TestItem(window.contentItem());
+ QQuickItem *child2 = new TestFocusScope(window.contentItem());
QQuickItem *item = new TestItem(child2);
FocusState focusState;
QQuickWindow window;
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem *item = new TestFocusScope(window.rootItem());
+ QQuickItem *item = new TestFocusScope(window.contentItem());
QQuickItem *child = new TestItem(item);
QQuickItem *child2 = new TestItem;
focusState.remove(child);
delete child;
- item->setParentItem(window.rootItem());
+ item->setParentItem(window.contentItem());
focusState[item].set(true, true);
focusState.active(item);
FVERIFY();
focusState[&child].set(false, false);
FVERIFY();
- parent.setParentItem(window.rootItem());
+ parent.setParentItem(window.contentItem());
focusState[&parent].set(true, true);
focusState[&child].set(false, false);
focusState.active(&parent);
focusState[&grandchild].set(false, false);
FVERIFY();
- parent.setParentItem(window.rootItem());
+ parent.setParentItem(window.contentItem());
focusState[&parent].set(true, true);
focusState[&child].set(false, false);
focusState[&grandchild].set(false, false);
ensureFocus(&window);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
- QQuickItem parent(window.rootItem());
+ QQuickItem parent(window.contentItem());
QQuickItem child(&parent);
QQuickItem sibling(&parent);
QQuickItem grandchild(&child);
QCOMPARE(root.hasFocus(), true);
QCOMPARE(root.hasActiveFocus(), false);
- root.setParentItem(window.rootItem());
+ root.setParentItem(window.contentItem());
QCOMPARE(root.isEnabled(), false);
QCOMPARE(root.hasFocus(), true);
QCOMPARE(root.hasActiveFocus(), false);
- QCOMPARE(window.activeFocusItem(), window.rootItem());
+ QCOMPARE(window.activeFocusItem(), window.contentItem());
root.setEnabled(true);
QCOMPARE(root.isEnabled(), true);
QCOMPARE(child1.isEnabled(), true);
QCOMPARE(child1.hasFocus(), true);
QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(window.activeFocusItem(), window.rootItem());
+ QCOMPARE(window.activeFocusItem(), window.contentItem());
child2.forceActiveFocus();
QCOMPARE(root.isEnabled(), true);
QCOMPARE(child2.isEnabled(), false);
QCOMPARE(child2.hasFocus(), true);
QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(window.activeFocusItem(), window.rootItem());
+ QCOMPARE(window.activeFocusItem(), window.contentItem());
child1.forceActiveFocus();
QCOMPARE(root.isEnabled(), false);
QCOMPARE(child2.isEnabled(), false);
QCOMPARE(child2.hasFocus(), false);
QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(window.activeFocusItem(), window.rootItem());
+ QCOMPARE(window.activeFocusItem(), window.contentItem());
root.setEnabled(true);
QCOMPARE(root.isEnabled(), true);
TestItem *child1 = new TestItem;
child1->setAcceptedMouseButtons(Qt::LeftButton);
child1->setSize(QSizeF(200, 100));
- child1->setParentItem(window->rootItem());
+ child1->setParentItem(window->contentItem());
TestItem *child2 = new TestItem;
child2->setAcceptedMouseButtons(Qt::LeftButton);
child2->setY(51);
child2->setSize(QSizeF(200, 100));
- child2->setParentItem(window->rootItem());
+ child2->setParentItem(window->contentItem());
QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50,50));
QTest::qWait(100);
TestItem *item = new TestItem;
item->setSize(QSizeF(100, 100));
- item->setParentItem(window->rootItem());
+ item->setParentItem(window->contentItem());
item->acceptIncomingTouchEvents = itemSupportsTouch;
static QTouchDevice* device = 0;
window->resize(200, 200);
window->show();
- TestPolishItem *item = new TestPolishItem(window->rootItem());
+ TestPolishItem *item = new TestPolishItem(window->contentItem());
item->setSize(QSizeF(200, 100));
QTest::qWait(50);
TestItem *item = new TestItem;
item->setSize(QSizeF(200, 100));
- item->setParentItem(window->rootItem());
+ item->setParentItem(window->contentItem());
item->setEnabled(enabled);
item->setVisible(visible);
HoverItem *item = new HoverItem;
item->setSize(QSizeF(100, 100));
- item->setParentItem(window->rootItem());
+ item->setParentItem(window->contentItem());
item->setEnabled(enabled);
item->setVisible(visible);
window->resize(200, 200);
window->show();
- HoverItem *parentItem = new HoverItem(window->rootItem());
+ HoverItem *parentItem = new HoverItem(window->contentItem());
parentItem->setSize(QSizeF(200, 200));
parentItem->setAcceptHoverEvents(true);
QQuickWindow window;
item.setSize(QSizeF(200,100));
- item.setParentItem(window.rootItem());
+ item.setParentItem(window.contentItem());
QTest::mousePress(&window, Qt::LeftButton, 0, QPoint(50, 50));
QTest::mouseRelease(&window, Qt::LeftButton, 0, QPoint(50, 50));