summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2012-06-23 10:02:11 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-16 16:30:55 +0200
commit199741d0260f5cbdb05e64fe73cfca1820da93d1 (patch)
tree82276c92bd8c986fa71b76a45e067ab996b79e24 /tests
parentcbddca5f02eb4fec367ce7fd6b3d71191ca5c348 (diff)
Fix applicationName() being empty in QApplication.
A virtual method was reimplemented to return an always-empty string, probably a leftover from a refactoring. This fix showed that tst_qwidget_window was buggy: between Qt4 and Qt5, a "Before" became "After", which made "Before" unused, and was masking the fact that the app name was empty by default. In addition, the earlier Qt5 change that made the app name default to argv[0] now requires updating this test, now that it's actually working. Change-Id: I5360026821a9b95bedd0ff09dba3d51a22e542b7 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp11
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp30
2 files changed, 26 insertions, 15 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 120ed9127c..e0028be780 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -101,6 +101,7 @@ private slots:
void args_data();
void args();
+ void appName();
void lastWindowClosed();
void quitOnLastWindowClosed();
@@ -489,6 +490,16 @@ void tst_QApplication::args()
delete [] argv;
}
+void tst_QApplication::appName()
+{
+ char argv0[] = "tst_qapplication";
+ char *argv[] = { argv0, 0 };
+ int argc = 1;
+ QApplication app(argc, argv);
+ QCOMPARE(::qAppName(), QString::fromLatin1("tst_qapplication"));
+ QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1("tst_qapplication"));
+}
+
class CloseWidget : public QWidget
{
Q_OBJECT
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
index 78d9d36bc9..edb7133fe7 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -187,21 +187,28 @@ void tst_QWidget_window::tst_windowFilePathAndwindowTitle_data()
QTest::addColumn<QString>("finalTitleAfter");
QString validPath = QApplication::applicationFilePath();
- QString appName = QLatin1String("Killer App");
QString fileNameOnly = QFileInfo(validPath).fileName() + QLatin1String("[*]");
- QString fileAndApp = fileNameOnly + QLatin1String(" ") + QChar(0x2014) + QLatin1String(" ") + appName;
+ QString fileAndSep = fileNameOnly + QLatin1String(" ") + QChar(0x2014) + QLatin1String(" ");
QString windowTitle = QLatin1String("Here is a Window Title");
- QTest::newRow("never Set Title nor AppName") << false << false << validPath << QString() << windowTitle << fileNameOnly << fileNameOnly;
- QTest::newRow("set title after only, but no AppName") << false << true << validPath << QString() << windowTitle << fileNameOnly << windowTitle;
+ QString defaultPlatString =
+#if 0 // was ifdef Q_OS_MAC, but that code is disabled in qwidget.cpp and caption handling should move to QPA anyway
+ fileNameOnly;
+#else
+ fileAndSep + "tst_qwidget_window"; // default app name in Qt5
+#endif
+
+ QTest::newRow("never Set Title nor AppName") << false << false << validPath << QString() << windowTitle << defaultPlatString << defaultPlatString;
+ QTest::newRow("set title after only, but no AppName") << false << true << validPath << QString() << windowTitle << defaultPlatString << windowTitle;
QTest::newRow("set title before only, not AppName") << true << false << validPath << QString() << windowTitle << windowTitle << windowTitle;
QTest::newRow("always set title, not appName") << true << true << validPath << QString() << windowTitle << windowTitle << windowTitle;
+ QString appName = QLatin1String("Killer App");
QString platString =
-#ifdef Q_OS_MAC
+#if 0 // was ifdef Q_OS_MAC, but that code is disabled in qwidget.cpp and caption handling should move to QPA anyway
fileNameOnly;
#else
- fileAndApp;
+ fileAndSep + appName;
#endif
QTest::newRow("never Set Title, yes AppName") << false << false << validPath << appName << windowTitle << platString << platString;
@@ -233,20 +240,13 @@ void tst_QWidget_window::tst_windowFilePathAndwindowTitle()
widget.setWindowTitle(indyWindowTitle);
}
widget.setWindowFilePath(filePath);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("never Set Title, yes AppName", "QTBUG-23682", Continue);
- QEXPECT_FAIL("set title after only, yes AppName", "QTBUG-23682", Continue);
-#endif
- QCOMPARE(finalTitleBefore, widget.windowTitle());
+ QCOMPARE(widget.windowTitle(), finalTitleBefore);
QCOMPARE(widget.windowFilePath(), filePath);
if (setWindowTitleAfter) {
widget.setWindowTitle(indyWindowTitle);
}
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("never Set Title, yes AppName", "QTBUG-23682", Continue);
-#endif
- QCOMPARE(finalTitleAfter, widget.windowTitle());
+ QCOMPARE(widget.windowTitle(), finalTitleAfter);
QCOMPARE(widget.windowFilePath(), filePath);
}