31 #include <QtCore/qcoreapplication.h>
32 #include <QtGui/qevent.h>
33 #include <QtGui/qwindow.h>
66 void basicEventDelivery();
67 #if QT_CONFIG(shortcut)
68 void modifiers_data();
81 void tst_QKeyEvent::basicEventDelivery()
97 QCOMPARE(Qt::KeyboardModifiers(
event->modifiers()), modifiers);
103 if (
v1.size() !=
v2.size())
104 return v1.size() <
v2.size();
106 for (
int i = 0;
i < qMin(
v1.size(),
v2.size()); ++
i) {
110 return v1.at(
i) <
v2.at(
i);
123 if (uc > 32 && uc < 128)
124 str <<
'"' <<
c <<
'"';
133 #if QT_CONFIG(shortcut)
135 void tst_QKeyEvent::modifiers_data()
142 static const Modifier modifiers[] = {
152 static const int kNumModifiers =
sizeof(modifiers) /
sizeof(
Modifier);
153 for (
quint64 bitmask = 1; bitmask < (1 << kNumModifiers) ; ++bitmask) {
155 for (
quint64 modifier = 0; modifier < kNumModifiers; ++modifier) {
156 if (bitmask & (
quint64(1) << modifier))
157 modifierCombination.
append(modifier);
159 modifierCombinations.
append(modifierCombination);
162 std::sort(modifierCombinations.
begin(), modifierCombinations.
end(), orderByModifier);
164 QTest::addColumn<Qt::KeyboardModifiers>(
"modifiers");
165 foreach (
const QList<int> combination, modifierCombinations) {
167 Qt::KeyboardModifiers mods;
168 for (
int i = 0;
i < combination.
size(); ++
i) {
170 keys[
i] = modifier.key;
171 mods |= modifier.modifier;
179 void tst_QKeyEvent::modifiers()
186 QFETCH(Qt::KeyboardModifiers, modifiers);
188 QTest::keyClick(&
window,
key, modifiers);
193 for (
int i = 0;
i <
window.keyEvents.size(); ++
i) {
196 if (
i == numKeys - 1 ||
i == numKeys) {
208 #include "tst_qkeyevent.moc"
small capitals from c petite p scientific i
[1]
The QByteArray class provides an array of bytes.
const char * constData() const noexcept
The QChar class provides a 16-bit Unicode character.
constexpr char16_t unicode() const noexcept
The QKeyEvent class describes a key event.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
The QObject class is the base class of all Qt objects.
The QString class provides a Unicode character string.
const QChar at(qsizetype i) const
The QTextStream class provides a convenient interface for reading and writing text.
The QWindow class represents a window in the underlying windowing system.
[Window class definition]
void keyPressEvent(QKeyEvent *event) override
QList< QKeyEvent * > keyEvents
void keyReleaseEvent(QKeyEvent *event) override
qDeleteAll(list.begin(), list.end())
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout=5000)
QTextStream & hex(QTextStream &stream)
QTextStream & dec(QTextStream &stream)
Q_DECL_CONST_FUNCTION QT_POPCOUNT_CONSTEXPR uint qPopulationCount(quint32 v) noexcept
unsigned long long quint64
GLint GLfloat GLfloat GLfloat v2
GLenum GLuint GLintptr GLsizeiptr size
[1]
#define QTEST_MAIN(TestObject)
#define QFETCH(Type, name)
#define QVERIFY(statement)