2011-09-22 13:43:27 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-09-22 13:43:27 +00:00
|
|
|
**
|
|
|
|
** This file is part of the test suite of the Qt Toolkit.
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2012-09-19 12:28:29 +00:00
|
|
|
** 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
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-15 12:36:27 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-09-22 13:43:27 +00:00
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-09-22 13:43:27 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <QtTest/QtTest>
|
|
|
|
|
|
|
|
#include <private/qguiapplication_p.h>
|
2012-01-24 15:44:38 +00:00
|
|
|
#include <private/qinputmethod_p.h>
|
Expose QPA API under qpa/*
The main reasons for doing this are:
1. _qpa.h end up in the master QtGui include file. QtGui is meant for
userland applications. qpa code is neither binary nor source compatible.
Inadvertant use of QPA api makes the user code binary-incompatible.
2. syncqt creates forwarding headers for non-private header files. This
gives people the impression that this is public API.
As discussed on the mailing list, even though QPA api is internal and subject
to change, it needs to treated differently from private headers since they
will be used by in-qtbase and out-of-qtbase plugins.
This commit does the following:
1. The _qpa in QPA header files is dropped.
2. syncqt now treats any file with qplatform prefix as a special file and
moves it to qpa/ directory. The recommended way of using QPA API in plugins
is: #include <qpa/qplatformfoo.h>. This allows the user include QPA API
from multiple modules (for example, qplatformfoo might be in QtPrintSupport)
3. The user needs to explicitly add QT += <module>-private to get access to
the qpa api.
4. Creates compat headers for the olden style qplatformfoo_qpa.h and QPlatformFoo
includes.
This commit does not change the cpp filenames. This requires a more careful
merging of existing non qpa cpp files and existing cpp files on a case by
case basis. This can be done at anytime.
The following files are not renamed as part of this changed but will be fixed
as part of a future change:
src/gui/kernel/qgenericpluginfactory_qpa.h
src/gui/kernel/qgenericplugin_qpa.h
src/gui/kernel/qwindowsysteminterface_qpa.h
files were renamed using
for x in `find . -name "qplatform*_qpa.h"`; do git mv $x "${x/_qpa.h/.h}"; done
for x in `find . -name "qplatform*_qpa_p.h"`; do git mv $x "${x/_qpa_p.h/_p.h}"; done
includes were renamed using script
for file in `find . -name "*.h" -or -name "*.cpp" -or -name "*.mm"`; do
sed -i -e 's,.*#.*include.*<\(Qt.*/\)\?\(QPlatform.*\)>,#include <qpa/\L\2.h>,g' \
-e 's,.*#.*include.*"\(Qt.*/\)\?\(QPlatform.*\)",#include <qpa/\L\2.h>,g' \
-e 's,.*#.*include.* "\(qplatform.*\)_qpa.h",#include <qpa/\L\1.h>,g' \
-e 's,.*#.*include.*"\(qplatform.*\)_qpa_p.h",#include <qpa/\L\1_p.h>,g' \
-e 's,.*#.*include.*<\(Qt.*/\|Qt.*/private/\|private/\)\?\(qplatform.*\)_qpa\(.*\)>,#include <qpa/\2\3>,g' \
-e 's,.*#.*include.*"\(Qt.*/\|Qt.*/private/\|private/\)\?\(qplatform.*\)_qpa\(.*\)",#include <qpa/\2\3>,g' \
$file
done
Change-Id: I04a350314a45746e3911f54b3b21ad03315afb67
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
2012-04-26 23:33:35 +00:00
|
|
|
#include <qpa/qplatforminputcontext.h>
|
2012-02-22 09:34:37 +00:00
|
|
|
#include "../../../shared/platforminputcontext.h"
|
2011-09-22 13:43:27 +00:00
|
|
|
|
|
|
|
class InputItem : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-02-23 05:02:23 +00:00
|
|
|
InputItem() : cursorRectangle(1, 2, 3, 4), m_enabled(true) {}
|
2012-02-22 09:34:37 +00:00
|
|
|
|
2011-09-22 13:43:27 +00:00
|
|
|
bool event(QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::InputMethodQuery) {
|
|
|
|
QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(event);
|
2012-02-22 09:34:37 +00:00
|
|
|
if (query->queries() & Qt::ImEnabled)
|
|
|
|
query->setValue(Qt::ImEnabled, m_enabled);
|
2011-09-22 13:43:27 +00:00
|
|
|
if (query->queries() & Qt::ImCursorRectangle)
|
2012-02-23 05:02:23 +00:00
|
|
|
query->setValue(Qt::ImCursorRectangle, cursorRectangle);
|
2011-09-22 13:43:27 +00:00
|
|
|
if (query->queries() & Qt::ImPreferredLanguage)
|
|
|
|
query->setValue(Qt::ImPreferredLanguage, QString("English"));
|
|
|
|
m_lastQueries = query->queries();
|
|
|
|
query->accept();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-02-22 09:34:37 +00:00
|
|
|
|
|
|
|
void setEnabled(bool enabled) {
|
|
|
|
if (enabled != m_enabled) {
|
|
|
|
m_enabled = enabled;
|
|
|
|
qApp->inputMethod()->update(Qt::ImEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-23 05:02:23 +00:00
|
|
|
QRectF cursorRectangle;
|
2011-09-22 13:43:27 +00:00
|
|
|
Qt::InputMethodQueries m_lastQueries;
|
2012-02-22 09:34:37 +00:00
|
|
|
bool m_enabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DummyWindow : public QWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DummyWindow() : m_focusObject(0) {}
|
|
|
|
|
|
|
|
virtual QObject *focusObject() const
|
|
|
|
{
|
|
|
|
return m_focusObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setFocusObject(QObject *object)
|
|
|
|
{
|
|
|
|
m_focusObject = object;
|
|
|
|
emit focusObjectChanged(object);
|
|
|
|
}
|
|
|
|
|
|
|
|
QObject *m_focusObject;
|
2011-09-22 13:43:27 +00:00
|
|
|
};
|
|
|
|
|
2012-02-22 09:34:37 +00:00
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
class tst_qinputmethod : public QObject
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-01-24 15:44:38 +00:00
|
|
|
tst_qinputmethod() {}
|
|
|
|
virtual ~tst_qinputmethod() {}
|
2011-09-22 13:43:27 +00:00
|
|
|
private slots:
|
|
|
|
void initTestCase();
|
2012-03-19 13:05:41 +00:00
|
|
|
void isVisible();
|
2011-09-22 13:43:27 +00:00
|
|
|
void animating();
|
|
|
|
void keyboarRectangle();
|
|
|
|
void inputItemTransform();
|
|
|
|
void cursorRectangle();
|
|
|
|
void invokeAction();
|
|
|
|
void reset();
|
|
|
|
void commit();
|
|
|
|
void update();
|
|
|
|
void query();
|
2012-01-05 16:03:49 +00:00
|
|
|
void inputDirection();
|
2012-02-23 13:57:14 +00:00
|
|
|
void inputMethodAccepted();
|
|
|
|
|
2011-09-22 13:43:27 +00:00
|
|
|
private:
|
|
|
|
InputItem m_inputItem;
|
|
|
|
PlatformInputContext m_platformInputContext;
|
|
|
|
};
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::initTestCase()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
2012-01-24 15:44:38 +00:00
|
|
|
QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
|
|
|
|
inputMethodPrivate->testContext = &m_platformInputContext;
|
2011-09-22 13:43:27 +00:00
|
|
|
}
|
|
|
|
|
2012-03-19 13:05:41 +00:00
|
|
|
void tst_qinputmethod::isVisible()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
2012-03-19 13:05:41 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->isVisible(), false);
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->show();
|
2012-03-19 13:05:41 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->isVisible(), true);
|
2011-09-22 13:43:27 +00:00
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->hide();
|
2012-03-19 13:05:41 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->isVisible(), false);
|
2011-09-22 13:43:27 +00:00
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->setVisible(true);
|
2012-03-19 13:05:41 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->isVisible(), true);
|
2011-09-22 13:43:27 +00:00
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->setVisible(false);
|
2012-03-19 13:05:41 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->isVisible(), false);
|
2011-09-22 13:43:27 +00:00
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::animating()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->isAnimating(), false);
|
2011-09-22 13:43:27 +00:00
|
|
|
|
|
|
|
m_platformInputContext.m_animating = true;
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->isAnimating(), true);
|
2011-09-22 13:43:27 +00:00
|
|
|
|
|
|
|
m_platformInputContext.m_animating = false;
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->isAnimating(), false);
|
2011-09-22 13:43:27 +00:00
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
QSignalSpy spy(qApp->inputMethod(), SIGNAL(animatingChanged()));
|
2011-09-22 13:43:27 +00:00
|
|
|
m_platformInputContext.emitAnimatingChanged();
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::keyboarRectangle()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->keyboardRectangle(), QRectF());
|
2011-09-22 13:43:27 +00:00
|
|
|
|
|
|
|
m_platformInputContext.m_keyboardRect = QRectF(10, 20, 30, 40);
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->keyboardRectangle(), QRectF(10, 20, 30, 40));
|
2011-09-22 13:43:27 +00:00
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
QSignalSpy spy(qApp->inputMethod(), SIGNAL(keyboardRectangleChanged()));
|
2011-09-22 13:43:27 +00:00
|
|
|
m_platformInputContext.emitKeyboardRectChanged();
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::inputItemTransform()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->inputItemTransform(), QTransform());
|
|
|
|
QSignalSpy spy(qApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
|
2011-09-22 13:43:27 +00:00
|
|
|
|
|
|
|
QTransform transform;
|
|
|
|
transform.translate(10, 10);
|
|
|
|
transform.scale(2, 2);
|
|
|
|
transform.shear(2, 2);
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->setInputItemTransform(transform);
|
2011-09-22 13:43:27 +00:00
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->inputItemTransform(), transform);
|
2011-09-22 13:43:27 +00:00
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
|
|
|
|
// reset
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->setInputItemTransform(QTransform());
|
2011-09-22 13:43:27 +00:00
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::cursorRectangle()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->cursorRectangle(), QRectF());
|
2011-09-22 13:43:27 +00:00
|
|
|
|
2015-09-24 07:25:25 +00:00
|
|
|
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
|
2014-08-21 10:40:49 +00:00
|
|
|
QSKIP("Wayland: This fails. Figure out why.");
|
|
|
|
|
2012-09-03 21:32:29 +00:00
|
|
|
DummyWindow window;
|
|
|
|
window.show();
|
|
|
|
QVERIFY(QTest::qWaitForWindowExposed(&window));
|
Rename all QWindow properties that have "window" in them
windowTitle, windowModality, windowIcon and so on are named that way
to be similar to the ones in QWidget. However QQuickWindow inherits
all of the declared properties, and we would like to have shorter
property names in QML. If you are working with a Window then it's
obvious the title property is the window title. Unfortunately,
there must be patches in many other modules which depend on this one.
In order to avoid the need to merge them all at the same time,
there is also patch https://codereview.qt-project.org/#change,39001
which temporarily adds backwards-compatible accessors, which can be
removed after the other modules are able to build without them.
We should not rename windowState to state, because in QML, state
usually drives the state machine for animation transitions etc.
(although QWindow is not an Item, a user might get confused about it).
Related patches are
https://codereview.qt-project.org/#change,39001
https://codereview.qt-project.org/#change,37764
https://codereview.qt-project.org/#change,37765
https://codereview.qt-project.org/#change,37766
https://codereview.qt-project.org/#change,37762
Change-Id: Ie4424ec15fbdef6b29b137f90a2ae33f173edd21
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
2012-10-22 10:47:34 +00:00
|
|
|
window.requestActivate();
|
2012-09-03 21:32:29 +00:00
|
|
|
QTRY_COMPARE(qApp->focusWindow(), &window);
|
|
|
|
window.setFocusObject(&m_inputItem);
|
|
|
|
|
2011-09-22 13:43:27 +00:00
|
|
|
QTransform transform;
|
|
|
|
transform.translate(10, 10);
|
|
|
|
transform.scale(2, 2);
|
|
|
|
transform.shear(2, 2);
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->setInputItemTransform(transform);
|
|
|
|
QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4)));
|
2011-09-22 13:43:27 +00:00
|
|
|
|
2012-02-23 05:02:23 +00:00
|
|
|
m_inputItem.cursorRectangle = QRectF(1.5, 2, 1, 8);
|
|
|
|
QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1.5, 2, 1, 8)));
|
|
|
|
|
2011-09-22 13:43:27 +00:00
|
|
|
// reset
|
2012-02-23 05:02:23 +00:00
|
|
|
m_inputItem.cursorRectangle = QRectF(1, 2, 3, 4);
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->setInputItemTransform(QTransform());
|
2011-09-22 13:43:27 +00:00
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::invokeAction()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_action, QInputMethod::Click);
|
2011-09-22 13:43:27 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_cursorPosition, 0);
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->invokeAction(QInputMethod::ContextMenu, 5);
|
|
|
|
QCOMPARE(m_platformInputContext.m_action, QInputMethod::ContextMenu);
|
2011-09-22 13:43:27 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_cursorPosition, 5);
|
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::reset()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
|
|
|
QCOMPARE(m_platformInputContext.m_resetCallCount, 0);
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->reset();
|
2011-09-22 13:43:27 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_resetCallCount, 1);
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->reset();
|
2011-09-22 13:43:27 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_resetCallCount, 2);
|
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::commit()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
|
|
|
QCOMPARE(m_platformInputContext.m_commitCallCount, 0);
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->commit();
|
2011-09-22 13:43:27 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_commitCallCount, 1);
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->commit();
|
2011-09-22 13:43:27 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_commitCallCount, 2);
|
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::update()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
|
|
|
QCOMPARE(m_platformInputContext.m_updateCallCount, 0);
|
|
|
|
QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImhNone));
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->update(Qt::ImQueryInput);
|
2011-09-22 13:43:27 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_updateCallCount, 1);
|
|
|
|
QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImQueryInput));
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->update(Qt::ImQueryAll);
|
2011-09-22 13:43:27 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_updateCallCount, 2);
|
|
|
|
QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImQueryAll));
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
QCOMPARE(qApp->inputMethod()->keyboardRectangle(), QRectF(10, 20, 30, 40));
|
2011-09-22 13:43:27 +00:00
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::query()
|
2011-09-22 13:43:27 +00:00
|
|
|
{
|
|
|
|
QInputMethodQueryEvent query(Qt::InputMethodQueries(Qt::ImPreferredLanguage | Qt::ImCursorRectangle));
|
|
|
|
QGuiApplication::sendEvent(&m_inputItem, &query);
|
|
|
|
|
|
|
|
QString language = query.value(Qt::ImPreferredLanguage).toString();
|
|
|
|
QCOMPARE(language, QString("English"));
|
|
|
|
|
|
|
|
QRect cursorRectangle = query.value(Qt::ImCursorRectangle).toRect();
|
|
|
|
QCOMPARE(cursorRectangle, QRect(1,2,3,4));
|
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
void tst_qinputmethod::inputDirection()
|
2012-01-05 16:03:49 +00:00
|
|
|
{
|
|
|
|
QCOMPARE(m_platformInputContext.m_inputDirectionCallCount, 0);
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->inputDirection();
|
2012-01-05 16:03:49 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_inputDirectionCallCount, 1);
|
|
|
|
|
|
|
|
QCOMPARE(m_platformInputContext.m_localeCallCount, 0);
|
2012-01-24 15:44:38 +00:00
|
|
|
qApp->inputMethod()->locale();
|
2012-01-05 16:03:49 +00:00
|
|
|
QCOMPARE(m_platformInputContext.m_localeCallCount, 1);
|
|
|
|
}
|
|
|
|
|
2012-02-23 13:57:14 +00:00
|
|
|
void tst_qinputmethod::inputMethodAccepted()
|
|
|
|
{
|
2015-09-24 07:25:25 +00:00
|
|
|
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
|
2014-08-21 10:40:49 +00:00
|
|
|
QSKIP("Wayland: This fails. Figure out why.");
|
|
|
|
|
2017-01-20 11:28:42 +00:00
|
|
|
if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)
|
|
|
|
|| !QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) {
|
|
|
|
QSKIP("minimal/offscreen: This fails. Figure out why.");
|
|
|
|
}
|
|
|
|
|
2015-09-24 07:25:25 +00:00
|
|
|
if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive))
|
2015-03-23 10:53:16 +00:00
|
|
|
QSKIP("XCB: depends on dedicated platform context.");
|
|
|
|
|
2012-02-23 13:57:14 +00:00
|
|
|
InputItem disabledItem;
|
|
|
|
disabledItem.setEnabled(false);
|
|
|
|
|
|
|
|
DummyWindow window;
|
|
|
|
window.show();
|
2012-07-20 10:49:12 +00:00
|
|
|
QVERIFY(QTest::qWaitForWindowExposed(&window));
|
Rename all QWindow properties that have "window" in them
windowTitle, windowModality, windowIcon and so on are named that way
to be similar to the ones in QWidget. However QQuickWindow inherits
all of the declared properties, and we would like to have shorter
property names in QML. If you are working with a Window then it's
obvious the title property is the window title. Unfortunately,
there must be patches in many other modules which depend on this one.
In order to avoid the need to merge them all at the same time,
there is also patch https://codereview.qt-project.org/#change,39001
which temporarily adds backwards-compatible accessors, which can be
removed after the other modules are able to build without them.
We should not rename windowState to state, because in QML, state
usually drives the state machine for animation transitions etc.
(although QWindow is not an Item, a user might get confused about it).
Related patches are
https://codereview.qt-project.org/#change,39001
https://codereview.qt-project.org/#change,37764
https://codereview.qt-project.org/#change,37765
https://codereview.qt-project.org/#change,37766
https://codereview.qt-project.org/#change,37762
Change-Id: Ie4424ec15fbdef6b29b137f90a2ae33f173edd21
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
2012-10-22 10:47:34 +00:00
|
|
|
window.requestActivate();
|
2012-02-23 13:57:14 +00:00
|
|
|
QTRY_COMPARE(qApp->focusWindow(), &window);
|
|
|
|
window.setFocusObject(&disabledItem);
|
|
|
|
|
|
|
|
QCOMPARE(m_platformInputContext.inputMethodAccepted(), false);
|
|
|
|
|
|
|
|
window.setFocusObject(&m_inputItem);
|
|
|
|
QCOMPARE(m_platformInputContext.inputMethodAccepted(), true);
|
|
|
|
}
|
|
|
|
|
2012-01-24 15:44:38 +00:00
|
|
|
QTEST_MAIN(tst_qinputmethod)
|
|
|
|
#include "tst_qinputmethod.moc"
|