Skip to content

Commit

Permalink
Fix warnings & deprs in tst_qcoreapplication and tst_qguiapplication
Browse files Browse the repository at this point in the history
It's perhaps best to ensure that functions we are deprecating shall no
longer be used in tests.  Also, fix the "0 as nullptr" warnings.

Change-Id: I2f22c9b9482e80fa120bcd728ec269198a36678f
Reviewed-by: Richard Moe Gustavsen <[email protected]>
  • Loading branch information
ec1oud committed Jun 5, 2019
1 parent b3cc940 commit 29e3a4d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
TestApplication app(argc, argv);

ProcessEventsAlwaysSendsPostedEventsObject object;
QTime t;
QElapsedTimer t;
t.start();
int i = 1;
do {
Expand Down
1 change: 1 addition & 0 deletions tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ INCLUDEPATH += $$CORE_TEST_PATH

TARGET = tst_qguiapplication
QT += gui-private
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050E00
SOURCES += tst_qguiapplication.cpp

RESOURCES = tst_qguiapplication.qrc
50 changes: 25 additions & 25 deletions tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void tst_QGuiApplication::windowIcon()
class DummyWindow : public QWindow
{
public:
DummyWindow() : m_focusObject(0) {}
DummyWindow() : m_focusObject(nullptr) {}

virtual QObject *focusObject() const
{
Expand All @@ -204,7 +204,7 @@ class DummyWindow : public QWindow
void tst_QGuiApplication::focusObject()
{
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);

if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
QSKIP("QWindow::requestActivate() is not supported.");
Expand Down Expand Up @@ -271,15 +271,15 @@ void tst_QGuiApplication::focusObject()
void tst_QGuiApplication::allWindows()
{
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);
QWindow *window1 = new QWindow;
QWindow *window2 = new QWindow(window1);
QVERIFY(app.allWindows().contains(window1));
QVERIFY(app.allWindows().contains(window2));
QCOMPARE(app.allWindows().count(), 2);
delete window1;
window1 = 0;
window2 = 0;
window1 = nullptr;
window2 = nullptr;
QVERIFY(!app.allWindows().contains(window2));
QVERIFY(!app.allWindows().contains(window1));
QCOMPARE(app.allWindows().count(), 0);
Expand All @@ -288,15 +288,15 @@ void tst_QGuiApplication::allWindows()
void tst_QGuiApplication::topLevelWindows()
{
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);
QWindow *window1 = new QWindow;
QWindow *window2 = new QWindow(window1);
QVERIFY(app.topLevelWindows().contains(window1));
QVERIFY(!app.topLevelWindows().contains(window2));
QCOMPARE(app.topLevelWindows().count(), 1);
delete window1;
window1 = 0;
window2 = 0;
window1 = nullptr;
window2 = nullptr;
QVERIFY(!app.topLevelWindows().contains(window2));
QVERIFY(!app.topLevelWindows().contains(window1));
QCOMPARE(app.topLevelWindows().count(), 0);
Expand All @@ -306,7 +306,7 @@ class ShowCloseShowWindow : public QWindow
{
Q_OBJECT
public:
ShowCloseShowWindow(bool showAgain, QWindow *parent = 0)
ShowCloseShowWindow(bool showAgain, QWindow *parent = nullptr)
: QWindow(parent), showAgain(showAgain)
{
QTimer::singleShot(0, this, SLOT(doClose()));
Expand All @@ -331,7 +331,7 @@ private slots:
void tst_QGuiApplication::abortQuitOnShow()
{
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);
const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();

QScopedPointer<QWindow> window1(new ShowCloseShowWindow(false));
Expand Down Expand Up @@ -366,7 +366,7 @@ class FocusChangeWindow: public QWindow
}

public:
FocusChangeWindow() : QWindow(), windowDuringFocusAboutToChange(0), windowDuringFocusOut(0) {}
FocusChangeWindow() : QWindow(), windowDuringFocusAboutToChange(nullptr), windowDuringFocusOut(nullptr) {}

QWindow *windowDuringFocusAboutToChange;
QWindow *windowDuringFocusOut;
Expand All @@ -378,7 +378,7 @@ void tst_QGuiApplication::changeFocusWindow()
QSKIP("WinRt does not support multiple native windows.");
#endif
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);

if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
QSKIP("QWindow::requestActivate() is not supported.");
Expand Down Expand Up @@ -430,7 +430,7 @@ void tst_QGuiApplication::changeFocusWindow()
void tst_QGuiApplication::keyboardModifiers()
{
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);
const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();

QScopedPointer<QWindow> window(new QWindow);
Expand Down Expand Up @@ -564,7 +564,7 @@ class BlockableWindow : public QWindow
int leaves;
int enters;

inline explicit BlockableWindow(QWindow *parent = 0)
inline explicit BlockableWindow(QWindow *parent = nullptr)
: QWindow(parent), blocked(false), leaves(0), enters(0) {}

bool event(QEvent *e)
Expand Down Expand Up @@ -601,7 +601,7 @@ void tst_QGuiApplication::modalWindow()
QSKIP("WinRt does not support multiple native windows.");
#endif
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);
const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();

int x = screenGeometry.left() + spacing;
Expand Down Expand Up @@ -654,7 +654,7 @@ void tst_QGuiApplication::modalWindow()
window2->show();
QVERIFY(QTest::qWaitForWindowExposed(window1.data()));
QVERIFY(QTest::qWaitForWindowExposed(window2.data()));
QCOMPARE(app.modalWindow(), static_cast<QWindow *>(0));
QCOMPARE(app.modalWindow(), static_cast<QWindow *>(nullptr));
QCOMPARE(window1->blocked, 0);
QCOMPARE(childWindow1->blocked, 0);
QCOMPARE(window2->blocked, 0);
Expand Down Expand Up @@ -698,7 +698,7 @@ void tst_QGuiApplication::modalWindow()

// everything is unblocked when applicationModalWindow1 is hidden
applicationModalWindow1->hide();
QCOMPARE(app.modalWindow(), static_cast<QWindow *>(0));
QCOMPARE(app.modalWindow(), static_cast<QWindow *>(nullptr));
QCOMPARE(window1->blocked, 0);
QCOMPARE(childWindow1->blocked, 0); // QTBUG-32242, blocked status needs to be set on children as well.
QCOMPARE(window2->blocked, 0);
Expand Down Expand Up @@ -750,7 +750,7 @@ void tst_QGuiApplication::modalWindow()

// hide windowModalWindow2, windowModalWindow1 and window1 are unblocked
windowModalWindow2->hide();
QCOMPARE(app.modalWindow(), static_cast<QWindow *>(0));
QCOMPARE(app.modalWindow(), static_cast<QWindow *>(nullptr));
QCOMPARE(window1->blocked, 0);
QCOMPARE(window2->blocked, 0);
QCOMPARE(windowModalWindow1->blocked, 0);
Expand Down Expand Up @@ -815,7 +815,7 @@ void tst_QGuiApplication::modalWindow()

// hide windowModalWindow1, everything is unblocked
windowModalWindow1->hide();
QCOMPARE(app.modalWindow(), static_cast<QWindow *>(0));
QCOMPARE(app.modalWindow(), static_cast<QWindow *>(nullptr));
QCOMPARE(window1->blocked, 0);
QCOMPARE(window2->blocked, 0);
QCOMPARE(windowModalWindow1->blocked, 0);
Expand All @@ -829,7 +829,7 @@ void tst_QGuiApplication::modalWindow()
void tst_QGuiApplication::quitOnLastWindowClosed()
{
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);
const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();

QTimer timer;
Expand Down Expand Up @@ -869,7 +869,7 @@ void tst_QGuiApplication::quitOnLastWindowClosed()
void tst_QGuiApplication::quitOnLastWindowClosedMulti()
{
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);
const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();

QTimer timer;
Expand Down Expand Up @@ -909,7 +909,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedMulti()
void tst_QGuiApplication::dontQuitOnLastWindowClosed()
{
int argc = 0;
QGuiApplication app(argc, 0);
QGuiApplication app(argc, nullptr);
app.setQuitOnLastWindowClosed(false);

QTimer timer;
Expand Down Expand Up @@ -959,7 +959,7 @@ class TestPluginFactory : public QGenericPlugin
{
if (key == "testplugin")
return new TestPlugin;
return 0;
return nullptr;
}
};

Expand Down Expand Up @@ -1069,7 +1069,7 @@ void tst_QGuiApplication::testSetPaletteAttribute()

QVERIFY(!QCoreApplication::testAttribute(Qt::AA_SetPalette));
QPalette palette;
palette.setColor(QPalette::Foreground, Qt::red);
palette.setColor(QPalette::WindowText, Qt::red);
QGuiApplication::setPalette(palette);

QVERIFY(QCoreApplication::testAttribute(Qt::AA_SetPalette));
Expand Down Expand Up @@ -1126,7 +1126,7 @@ void tst_QGuiApplication::settableStyleHints()
int argc = 0;
QScopedPointer<QGuiApplication> app;
if (appInstance)
app.reset(new QGuiApplication(argc, 0));
app.reset(new QGuiApplication(argc, nullptr));

const int keyboardInputInterval = 555;
QGuiApplication::styleHints()->setKeyboardInputInterval(keyboardInputInterval);
Expand Down

0 comments on commit 29e3a4d

Please sign in to comment.