summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-07-01 10:21:37 +0200
committerLiang Qi <liang.qi@qt.io>2019-07-01 10:21:37 +0200
commitd25c3227299a6a281db37e68e45f0b02db3f5297 (patch)
tree08f436f8aebe2c8aaaee570f88e71bd2d0c8f6e7 /tests
parent222b81f5dac2a5d32027b15d3a784819291431f6 (diff)
parenta39b19b0c7419021b3c22dc4d4bced0995f3a29f (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts: src/network/ssl/qsslsocket_openssl.cpp src/platformsupport/vkconvenience/qvkconvenience.cpp Change-Id: I97ce6ed185f7fdad8102cc58d3cfec0119fd7bb4
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp26
-rw-r--r--tests/manual/diaglib/debugproxystyle.h26
-rw-r--r--tests/manual/diaglib/eventfilter.cpp2
-rw-r--r--tests/manual/diaglib/eventfilter.h6
-rw-r--r--tests/manual/diaglib/logwidget.cpp4
-rw-r--r--tests/manual/diaglib/logwidget.h2
-rw-r--r--tests/manual/diaglib/qwidgetdump.cpp4
-rw-r--r--tests/manual/diaglib/qwidgetdump.h2
-rw-r--r--tests/manual/diaglib/qwindowdump.cpp4
-rw-r--r--tests/manual/diaglib/qwindowdump.h6
-rw-r--r--tests/manual/diaglib/textdump.cpp21
11 files changed, 63 insertions, 40 deletions
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index b78287f84b..2c9295d995 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -30,6 +30,8 @@
#include <QtTest/QtTest>
#include <qapplication.h>
#include <qtextedit.h>
+#include <qlineedit.h>
+#include <qcompleter.h>
#include <qpushbutton.h>
#include <qmainwindow.h>
#include <qstatusbar.h>
@@ -120,6 +122,7 @@ private slots:
void unicodeCompare();
void context();
void duplicatedShortcutOverride();
+ void shortcutToFocusProxy();
protected:
static Qt::KeyboardModifiers toButtons( int key );
@@ -1279,5 +1282,28 @@ void tst_QShortcut::testElement()
}
}
+void tst_QShortcut::shortcutToFocusProxy()
+{
+ QLineEdit le;
+ QCompleter completer;
+ QStringListModel *slm = new QStringListModel(QStringList() << "a0" << "a1" << "a2", &completer);
+ completer.setModel(slm);
+ completer.setCompletionMode(QCompleter::PopupCompletion);
+ le.setCompleter(&completer);
+ QShortcut *shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_S), &le);
+ QObject::connect(shortcut, &QShortcut::activated, &le, &QLineEdit::clear);
+ le.setFocus();
+ le.show();
+
+ QVERIFY(QTest::qWaitForWindowActive(&le));
+ QCOMPARE(QApplication::focusWidget(), &le);
+ QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_A);
+
+ QCOMPARE(le.text(), QString::fromLocal8Bit("a"));
+ QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Alt);
+ QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_S, Qt::AltModifier);
+ QCOMPARE(le.text(), QString());
+}
+
QTEST_MAIN(tst_QShortcut)
#include "tst_qshortcut.moc"
diff --git a/tests/manual/diaglib/debugproxystyle.h b/tests/manual/diaglib/debugproxystyle.h
index 01e1e6b6d1..51bf79374e 100644
--- a/tests/manual/diaglib/debugproxystyle.h
+++ b/tests/manual/diaglib/debugproxystyle.h
@@ -39,19 +39,19 @@ class DebugProxyStyle : public QProxyStyle {
public:
explicit DebugProxyStyle(QStyle *style);
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const;
- QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
- QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const;
- QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const;
- QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
- int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
+ void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const override;
+ void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override;
+ QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override;
+ QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override;
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override;
+ QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override;
+ QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override;
+ int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override;
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = nullptr) const override;
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override;
};
} // namespace QtDiag
diff --git a/tests/manual/diaglib/eventfilter.cpp b/tests/manual/diaglib/eventfilter.cpp
index 39898f0781..b99d4099e3 100644
--- a/tests/manual/diaglib/eventfilter.cpp
+++ b/tests/manual/diaglib/eventfilter.cpp
@@ -197,7 +197,7 @@ static void formatApplicationState(QDebug debug)
static void formatMouseState(QObject *o, QDebug debug)
{
if (o->isWidgetType()) {
- const QWidget *w = static_cast<const QWidget *>(o);
+ auto w = static_cast<const QWidget *>(o);
if (QWidget::mouseGrabber() == w)
debug << " [grabbed]";
if (w->hasMouseTracking())
diff --git a/tests/manual/diaglib/eventfilter.h b/tests/manual/diaglib/eventfilter.h
index 1f57fbeb8b..a8740bb4e9 100644
--- a/tests/manual/diaglib/eventfilter.h
+++ b/tests/manual/diaglib/eventfilter.h
@@ -68,10 +68,10 @@ public:
};
Q_DECLARE_FLAGS(ObjectTypes, ObjectType)
- explicit EventFilter(EventCategories eventCategories, QObject *p = 0);
- explicit EventFilter(QObject *p = 0);
+ explicit EventFilter(EventCategories eventCategories, QObject *p = nullptr);
+ explicit EventFilter(QObject *p = nullptr);
- bool eventFilter(QObject *, QEvent *);
+ bool eventFilter(QObject *, QEvent *) override;
ObjectTypes objectTypes() const { return m_objectTypes; }
void setObjectTypes(ObjectTypes objectTypes) { m_objectTypes = objectTypes; }
diff --git a/tests/manual/diaglib/logwidget.cpp b/tests/manual/diaglib/logwidget.cpp
index 35fabd6e2e..18a82d819e 100644
--- a/tests/manual/diaglib/logwidget.cpp
+++ b/tests/manual/diaglib/logwidget.cpp
@@ -40,7 +40,7 @@
#include <iostream>
-LogWidget *LogWidget::m_instance = 0;
+LogWidget *LogWidget::m_instance = nullptr;
bool LogWidget::m_lineNumberingEnabled = true;
bool LogWidget::m_showMessageType = true;
int LogWidget::m_indent = 0;
@@ -54,7 +54,7 @@ LogWidget::LogWidget(QWidget *parent)
LogWidget::~LogWidget()
{
- LogWidget::m_instance = 0;
+ LogWidget::m_instance = nullptr;
}
QString LogWidget::startupMessage()
diff --git a/tests/manual/diaglib/logwidget.h b/tests/manual/diaglib/logwidget.h
index 55324e3100..b1ce43f231 100644
--- a/tests/manual/diaglib/logwidget.h
+++ b/tests/manual/diaglib/logwidget.h
@@ -46,7 +46,7 @@ class LogWidget : public QPlainTextEdit
{
Q_OBJECT
public:
- explicit LogWidget(QWidget *parent = 0);
+ explicit LogWidget(QWidget *parent = nullptr);
~LogWidget();
static LogWidget *instance() { return m_instance; }
diff --git a/tests/manual/diaglib/qwidgetdump.cpp b/tests/manual/diaglib/qwidgetdump.cpp
index 6c1e7d8f79..5a2966021b 100644
--- a/tests/manual/diaglib/qwidgetdump.cpp
+++ b/tests/manual/diaglib/qwidgetdump.cpp
@@ -59,8 +59,8 @@ static const char *qtWidgetClasses[] = {
static bool isQtWidget(const char *className)
{
- for (size_t i = 0, count = sizeof(qtWidgetClasses) / sizeof(qtWidgetClasses[0]); i < count; ++i) {
- if (!qstrcmp(className, qtWidgetClasses[i]))
+ for (auto qtWidgetClass : qtWidgetClasses) {
+ if (qstrcmp(className, qtWidgetClass) == 0)
return true;
}
return false;
diff --git a/tests/manual/diaglib/qwidgetdump.h b/tests/manual/diaglib/qwidgetdump.h
index f3eb1fda8d..c9b2db72dd 100644
--- a/tests/manual/diaglib/qwidgetdump.h
+++ b/tests/manual/diaglib/qwidgetdump.h
@@ -35,7 +35,7 @@ QT_FORWARD_DECLARE_CLASS(QWidget)
namespace QtDiag {
-void dumpAllWidgets(FormatWindowOptions options = 0, const QWidget *root = 0);
+void dumpAllWidgets(FormatWindowOptions options = {}, const QWidget *root = nullptr);
} // namespace QtDiag
diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp
index 0e613753ef..381b683359 100644
--- a/tests/manual/diaglib/qwindowdump.cpp
+++ b/tests/manual/diaglib/qwindowdump.cpp
@@ -73,7 +73,7 @@ if ((type & typeConstant) == typeConstant) \
if (flags & flagConstant) \
s << ' ' << #flagConstant;
-void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags)
+void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags)
{
str << showbase << hex << unsigned(flags) << dec << noshowbase;
const Qt::WindowFlags windowType = flags & Qt::WindowType_Mask;
@@ -158,7 +158,7 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option
}
static void dumpWindowRecursion(QTextStream &str, const QWindow *w,
- FormatWindowOptions options = 0, int depth = 0)
+ FormatWindowOptions options = {}, int depth = 0)
{
indentStream(str, 2 * depth);
formatWindow(str, w, options);
diff --git a/tests/manual/diaglib/qwindowdump.h b/tests/manual/diaglib/qwindowdump.h
index 74f976567a..9d7491eab2 100644
--- a/tests/manual/diaglib/qwindowdump.h
+++ b/tests/manual/diaglib/qwindowdump.h
@@ -49,10 +49,10 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(FormatWindowOptions)
void indentStream(QTextStream &s, int indent);
void formatObject(QTextStream &str, const QObject *o);
void formatRect(QTextStream &str, const QRect &geom);
-void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags);
+void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags);
-void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = 0);
-void dumpAllWindows(FormatWindowOptions options = 0);
+void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = {});
+void dumpAllWindows(FormatWindowOptions options = {});
} // namespace QtDiag
diff --git a/tests/manual/diaglib/textdump.cpp b/tests/manual/diaglib/textdump.cpp
index e070a920e7..8bb899783b 100644
--- a/tests/manual/diaglib/textdump.cpp
+++ b/tests/manual/diaglib/textdump.cpp
@@ -381,7 +381,7 @@ static const EnumLookup *enumLookup(int v, const EnumLookup *array, size_t size)
if (p->value == v)
return p;
}
- return 0;
+ return nullptr;
}
static const char *enumName(int v, const EnumLookup *array, size_t size)
@@ -394,15 +394,12 @@ static const char *enumName(int v, const EnumLookup *array, size_t size)
// that change will be output.
struct FormattingContext
{
- FormattingContext() : category(-1), direction(-1), joiningType(-1)
- , decompositionTag(-1), script(-1), unicodeVersion(-1) {}
-
- int category;
- int direction;
- int joiningType;
- int decompositionTag;
- int script;
- int unicodeVersion;
+ int category = -1;
+ int direction = -1;
+ int joiningType = -1;
+ int decompositionTag = -1;
+ int script = -1;
+ int unicodeVersion = -1;
};
static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context)
@@ -478,8 +475,8 @@ QString dumpTextAsCode(const QString &text)
QString result;
QTextStream str(&result);
str << " QString result;\n" << hex << showbase;
- for (int i = 0; i < text.size(); ++i)
- str << " result += QChar(" << text.at(i).unicode() << ");\n";
+ for (QChar c : text)
+ str << " result += QChar(" << c.unicode() << ");\n";
str << '\n';
return result;
}