summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-29 13:51:16 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-29 15:30:17 +0200
commit1cc571593a67f3e688a5cbb896f0be71ca5a2b30 (patch)
treec652360c9276cbf475244fd02313d64e3df11a96 /tests
parent829c59aa4acf94bd979f6a3162808be36802d79a (diff)
parentcc74452d6d259d36ac47c536f11a5efb269e8e44 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
cf53aa21bf0f8fbd13c0ce2d33ddf7bc63d0d76a and 3aaa5d6b32130d3eeac872a59a5a44bfb20dfd4a were reverted because of reconstruction in 5.7. defineTest(qtConfTest_checkCompiler) in configure.pri is smart enough to cover the case in a9474d1260a8c8cc9eae14f2984098919d9684e5. DirectWrite: Fix advances being scaled to 0 Since 131eee5cd, the stretch of a font can be 0, meaning "whatever the font provides". In combination with ec7fee96, this would cause advances in the DirectWrite engine to be scaled to 0, causing the QRawFont test to fail. Conflicts: configure mkspecs/features/uikit/device_destinations.sh mkspecs/features/uikit/xcodebuild.mk src/corelib/global/qglobal.cpp src/corelib/global/qnamespace.qdoc src/plugins/platforms/cocoa/qcocoamenuitem.h src/plugins/platforms/windows/qwindowsservices.cpp src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp src/widgets/kernel/qapplication.cpp tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp Change-Id: I4656d8133da7ee9fcc84ad3f1c7950f924432d1e
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp37
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp16
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h1
-rw-r--r--tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp12
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp2
-rw-r--r--tests/auto/other/lancelot/lancelot.pro2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp125
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp89
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp1
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp29
-rw-r--r--tests/manual/cocoa/menurama/main.cpp51
-rw-r--r--tests/manual/cocoa/menurama/mainwindow.cpp86
-rw-r--r--tests/manual/cocoa/menurama/mainwindow.h71
-rw-r--r--tests/manual/cocoa/menurama/mainwindow.ui289
-rw-r--r--tests/manual/cocoa/menurama/menurama.pro22
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.cpp81
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.h58
-rw-r--r--tests/manual/dialogs/main.cpp6
-rw-r--r--tests/manual/qopenglwindow/multiwindow/main.cpp141
-rw-r--r--tests/manual/qscreen/propertyfield.cpp3
20 files changed, 936 insertions, 186 deletions
diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
index 1b0ac7a8bc..bd53aa69fe 100644
--- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
+++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
@@ -464,6 +464,19 @@ int throwFunctionReturn()
return 0;
}
+class SlowTask : public QRunnable
+{
+public:
+ static QAtomicInt cancel;
+ void run() Q_DECL_OVERRIDE {
+ int iter = 60;
+ while (--iter && !cancel.load())
+ QThread::currentThread()->msleep(25);
+ }
+};
+
+QAtomicInt SlowTask::cancel;
+
void tst_QtConcurrentRun::exceptions()
{
QThreadPool pool;
@@ -504,6 +517,30 @@ void tst_QtConcurrentRun::exceptions()
}
if (!caught)
QFAIL("did not get exception");
+
+ caught = false;
+ try {
+ QtConcurrent::run(&pool, throwFunctionReturn).result();
+ } catch (QException &) {
+ caught = true;
+ }
+ QVERIFY2(caught, "did not get exception");
+
+ // Force the task to be run on this thread.
+ caught = false;
+ QThreadPool shortPool;
+ shortPool.setMaxThreadCount(1);
+ SlowTask *st = new SlowTask();
+ try {
+ shortPool.start(st);
+ QtConcurrent::run(&shortPool, throwFunctionReturn).result();
+ } catch (QException &) {
+ caught = true;
+ }
+
+ SlowTask::cancel.store(true);
+
+ QVERIFY2(caught, "did not get exception");
}
#endif
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
index a7ab221dda..9e369792f1 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
@@ -127,6 +127,7 @@ tst_QMimeDatabase::tst_QMimeDatabase()
void tst_QMimeDatabase::initTestCase()
{
+ QLocale::setDefault(QLocale::c());
QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString()));
QStandardPaths::setTestModeEnabled(true);
m_localMimeDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/mime";
@@ -445,6 +446,21 @@ void tst_QMimeDatabase::icons()
QCOMPARE(pub.genericIconName(), QString::fromLatin1("x-office-document"));
}
+void tst_QMimeDatabase::comment()
+{
+ struct RestoreLocale
+ {
+ ~RestoreLocale() { QLocale::setDefault(QLocale::c()); }
+ } restoreLocale;
+
+ QLocale::setDefault(QLocale("de"));
+ QMimeDatabase db;
+ QMimeType directory = db.mimeTypeForName(QStringLiteral("inode/directory"));
+ QCOMPARE(directory.comment(), QStringLiteral("Ordner"));
+ QLocale::setDefault(QLocale("fr"));
+ QCOMPARE(directory.comment(), QStringLiteral("dossier"));
+}
+
// In here we do the tests that need some content in a temporary file.
// This could also be added to shared-mime-info's testsuite...
void tst_QMimeDatabase::mimeTypeForFileWithContent()
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h
index 06e875c9e2..4918dc6f4a 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h
@@ -55,6 +55,7 @@ private slots:
void listAliases_data();
void listAliases();
void icons();
+ void comment();
void mimeTypeForFileWithContent();
void mimeTypeForUrl();
void mimeTypeForData_data();
diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
index 447b6e8468..39f7beca6f 100644
--- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
+++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
@@ -152,11 +152,13 @@ static void dumpConfiguration(QTextStream &str)
}
// On Windows, this will provide addition GPU info similar to the output of dxdiag.
- const QVariant gpuInfoV = QGuiApplication::platformNativeInterface()->property("gpu");
- if (gpuInfoV.type() == QVariant::Map) {
- const QString description = gpuInfoV.toMap().value(QStringLiteral("printable")).toString();
- if (!description.isEmpty())
- str << "\nGPU:\n" << description << "\n\n";
+ if (QGuiApplication::platformNativeInterface()) {
+ const QVariant gpuInfoV = QGuiApplication::platformNativeInterface()->property("gpu");
+ if (gpuInfoV.type() == QVariant::Map) {
+ const QString description = gpuInfoV.toMap().value(QStringLiteral("printable")).toString();
+ if (!description.isEmpty())
+ str << "\nGPU:\n" << description << "\n\n";
+ }
}
}
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index b0f70d1a59..3b47f4b17b 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -314,6 +314,8 @@ void tst_QTextDocument::find_data()
<< 15 << 6 << 11;
QTest::newRow("nbsp") << "Hello" + QString(QChar(QChar::Nbsp)) +"World" << " " << int(QTextDocument::FindCaseSensitively) << 0 << 5 << 6;
+
+ QTest::newRow("from-the-end") << "Hello World" << "Hello World" << int(QTextDocument::FindCaseSensitively| QTextDocument::FindBackward) << 11 << 0 << 11;
}
void tst_QTextDocument::find()
diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro
index 6e79566649..e9c9af7143 100644
--- a/tests/auto/other/lancelot/lancelot.pro
+++ b/tests/auto/other/lancelot/lancelot.pro
@@ -1,7 +1,7 @@
CONFIG += testcase
CONFIG -= app_bundle
TARGET = tst_lancelot
-QT += xml widgets testlib
+QT += xml testlib
SOURCES += tst_lancelot.cpp \
paintcommands.cpp
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 7d4fe2d499..844f21cfe1 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -80,18 +80,6 @@ static inline bool isCaseSensitiveFileSystem(const QString &path)
#endif
}
-
-class QNonNativeFileDialog : public QFileDialog
-{
- Q_OBJECT
-public:
- QNonNativeFileDialog(QWidget *parent = 0, const QString &caption = QString(), const QString &directory = QString(), const QString &filter = QString())
- : QFileDialog(parent, caption, directory, filter)
- {
- setOption(QFileDialog::DontUseNativeDialog, true);
- }
-};
-
class tst_QFiledialog : public QObject
{
Q_OBJECT
@@ -180,9 +168,11 @@ void tst_QFiledialog::initTestCase()
void tst_QFiledialog::init()
{
+ // all tests, except widgetlessNativeDialog, use non-native dialogs
+ QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
QFileDialogPrivate::setLastVisitedDirectory(QUrl());
// populate the sidebar with some default settings
- QNonNativeFileDialog fd;
+ QFileDialog fd;
}
void tst_QFiledialog::cleanup()
@@ -201,7 +191,7 @@ public:
// emitted any time the selection model emits current changed
void tst_QFiledialog::currentChangedSignal()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString)));
@@ -227,8 +217,7 @@ void tst_QFiledialog::currentChangedSignal()
#if defined QT_BUILD_INTERNAL
void tst_QFiledialog::directoryEnteredSignal()
{
- QNonNativeFileDialog fd(0, "", QDir::root().path());
- fd.setOptions(QFileDialog::DontUseNativeDialog);
+ QFileDialog fd(0, "", QDir::root().path());
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
QVERIFY(sidebar);
if (sidebar->model()->rowCount() < 2)
@@ -293,9 +282,8 @@ void tst_QFiledialog::filesSelectedSignal_data()
// emitted when the dialog closes with the selected files
void tst_QFiledialog::filesSelectedSignal()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
- fd.setOptions(QFileDialog::DontUseNativeDialog);
QDir testDir(SRCDIR);
fd.setDirectory(testDir);
QFETCH(QFileDialog::FileMode, fileMode);
@@ -337,7 +325,7 @@ void tst_QFiledialog::filesSelectedSignal()
// only emitted when the combo box is activated
void tst_QFiledialog::filterSelectedSignal()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.show();
QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString)));
@@ -365,7 +353,7 @@ void tst_QFiledialog::args()
QString caption = "caption";
QString directory = QDir::tempPath();
QString filter = "*.mp3";
- QNonNativeFileDialog fd(parent, caption, directory, filter);
+ QFileDialog fd(parent, caption, directory, filter);
QCOMPARE(fd.parent(), (QObject *)parent);
QCOMPARE(fd.windowTitle(), caption);
#ifndef Q_OS_WIN
@@ -376,7 +364,7 @@ void tst_QFiledialog::args()
void tst_QFiledialog::directory()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
@@ -410,12 +398,12 @@ void tst_QFiledialog::directory()
#else
QCOMPARE(list.at(0)->rootIndex().data().toString(), temp.dirName());
#endif
- QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", tempPath);
+ QFileDialog *dlg = new QFileDialog(0, "", tempPath);
QCOMPARE(model->index(tempPath), model->index(dlg->directory().absolutePath()));
QCOMPARE(model->index(tempPath).data(QFileSystemModel::FileNameRole).toString(),
model->index(dlg->directory().absolutePath()).data(QFileSystemModel::FileNameRole).toString());
delete dlg;
- dlg = new QNonNativeFileDialog();
+ dlg = new QFileDialog();
QCOMPARE(model->index(tempPath), model->index(dlg->directory().absolutePath()));
delete dlg;
}
@@ -472,10 +460,9 @@ void tst_QFiledialog::completer()
}
// ### flesh this out more
- QNonNativeFileDialog fd(0, QLatin1String(QTest::currentTestFunction())
+ QFileDialog fd(0, QLatin1String(QTest::currentTestFunction())
+ QStringLiteral(" \"") + QLatin1String(QTest::currentDataTag())
+ QLatin1Char('"'), startPath);
- fd.setOptions(QFileDialog::DontUseNativeDialog);
fd.show();
QVERIFY(QTest::qWaitForWindowExposed(&fd));
QVERIFY(fd.isVisible());
@@ -570,8 +557,7 @@ void tst_QFiledialog::completer()
void tst_QFiledialog::completer_up()
{
- QNonNativeFileDialog fd;
- fd.setOptions(QFileDialog::DontUseNativeDialog);
+ QFileDialog fd;
QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString)));
QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString)));
QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(QStringList)));
@@ -594,7 +580,7 @@ void tst_QFiledialog::completer_up()
void tst_QFiledialog::acceptMode()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.show();
QToolButton* newButton = fd.findChild<QToolButton*>("newFolderButton");
@@ -616,7 +602,7 @@ void tst_QFiledialog::acceptMode()
void tst_QFiledialog::confirmOverwrite()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QCOMPARE(fd.confirmOverwrite(), true);
fd.setConfirmOverwrite(true);
QCOMPARE(fd.confirmOverwrite(), true);
@@ -628,7 +614,7 @@ void tst_QFiledialog::confirmOverwrite()
void tst_QFiledialog::defaultSuffix()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QCOMPARE(fd.defaultSuffix(), QString());
fd.setDefaultSuffix("txt");
QCOMPARE(fd.defaultSuffix(), QString("txt"));
@@ -640,7 +626,7 @@ void tst_QFiledialog::defaultSuffix()
void tst_QFiledialog::fileMode()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QCOMPARE(fd.fileMode(), QFileDialog::AnyFile);
fd.setFileMode(QFileDialog::ExistingFile);
QCOMPARE(fd.fileMode(), QFileDialog::ExistingFile);
@@ -654,7 +640,7 @@ void tst_QFiledialog::fileMode()
void tst_QFiledialog::caption()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setWindowTitle("testing");
fd.setFileMode(QFileDialog::Directory);
QCOMPARE(fd.windowTitle(), QString("testing"));
@@ -662,8 +648,7 @@ void tst_QFiledialog::caption()
void tst_QFiledialog::filters()
{
- QNonNativeFileDialog fd;
- fd.setOptions(QFileDialog::DontUseNativeDialog);
+ QFileDialog fd;
QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString)));
QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString)));
QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(QStringList)));
@@ -698,7 +683,7 @@ void tst_QFiledialog::filters()
QCOMPARE(spyFilterSelected.count(), 0);
//Let check if filters with whitespaces
- QNonNativeFileDialog fd2;
+ QFileDialog fd2;
QStringList expected;
expected << "C++ Source Files(*.cpp)";
expected << "Any(*.*)";
@@ -716,7 +701,7 @@ void tst_QFiledialog::filters()
void tst_QFiledialog::selectFilter()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString)));
QCOMPARE(fd.selectedNameFilter(), QString("All Files (*)"));
QStringList filters;
@@ -739,7 +724,7 @@ void tst_QFiledialog::selectFilter()
void tst_QFiledialog::history()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
@@ -781,7 +766,7 @@ void tst_QFiledialog::history()
void tst_QFiledialog::iconProvider()
{
- QNonNativeFileDialog *fd = new QNonNativeFileDialog();
+ QFileDialog *fd = new QFileDialog();
QVERIFY(fd->iconProvider() != 0);
QFileIconProvider *ip = new QFileIconProvider();
fd->setIconProvider(ip);
@@ -792,7 +777,7 @@ void tst_QFiledialog::iconProvider()
void tst_QFiledialog::isReadOnly()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QPushButton* newButton = fd.findChild<QPushButton*>("newFolderButton");
QAction* renameAction = fd.findChild<QAction*>("qt_rename_action");
@@ -816,7 +801,7 @@ void tst_QFiledialog::isReadOnly()
void tst_QFiledialog::itemDelegate()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QVERIFY(fd.itemDelegate() != 0);
QItemDelegate *id = new QItemDelegate(&fd);
fd.setItemDelegate(id);
@@ -825,7 +810,7 @@ void tst_QFiledialog::itemDelegate()
void tst_QFiledialog::labelText()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QDialogButtonBox buttonBox;
QPushButton *cancelButton = buttonBox.addButton(QDialogButtonBox::Cancel);
QCOMPARE(fd.labelText(QFileDialog::LookIn), QString("Look in:"));
@@ -848,7 +833,7 @@ void tst_QFiledialog::labelText()
void tst_QFiledialog::resolveSymlinks()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
// default
QCOMPARE(fd.resolveSymlinks(), true);
@@ -874,7 +859,7 @@ void tst_QFiledialog::selectFile()
{
QFETCH(QString, file);
QFETCH(int, count);
- QScopedPointer<QNonNativeFileDialog> fd(new QNonNativeFileDialog);
+ QScopedPointer<QFileDialog> fd(new QFileDialog);
QFileSystemModel *model = fd->findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
fd->setDirectory(QDir::currentPath());
@@ -911,7 +896,7 @@ void tst_QFiledialog::selectFileWrongCaseSaveAs()
QString wrongCasePath = path;
for (int c = 0; c < wrongCasePath.size(); c += 2)
wrongCasePath[c] = wrongCasePath.at(c).isLower() ? wrongCasePath.at(c).toUpper() : wrongCasePath.at(c).toLower();
- QNonNativeFileDialog fd(0, "QTBUG-38162", wrongCasePath);
+ QFileDialog fd(0, "QTBUG-38162", wrongCasePath);
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.selectFile(wrongCasePath);
const QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
@@ -925,7 +910,7 @@ void tst_QFiledialog::selectFiles()
QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
const QString tempPath = tempDir.path();
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
fd.setDirectory(tempPath);
QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString)));
@@ -975,7 +960,7 @@ void tst_QFiledialog::selectFiles()
{
//If the selection is invalid then we fill the line edit but without the /
- QNonNativeFileDialog dialog( 0, "Save" );
+ QFileDialog dialog( 0, "Save" );
dialog.setFileMode( QFileDialog::AnyFile );
dialog.setAcceptMode( QFileDialog::AcceptSave );
dialog.selectFile(tempPath + QStringLiteral("/blah"));
@@ -989,7 +974,7 @@ void tst_QFiledialog::selectFiles()
void tst_QFiledialog::viewMode()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
fd.show();
@@ -1027,7 +1012,7 @@ void tst_QFiledialog::viewMode()
void tst_QFiledialog::proxymodel()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QCOMPARE(fd.proxyModel(), (QAbstractProxyModel*)0);
fd.setProxyModel(0);
@@ -1043,7 +1028,7 @@ void tst_QFiledialog::proxymodel()
void tst_QFiledialog::setEmptyNameFilter()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setNameFilter(QString());
fd.setNameFilters(QStringList());
}
@@ -1084,7 +1069,7 @@ void tst_QFiledialog::setNameFilter()
QFETCH(QString, selectFilter);
QFETCH(QString, expectedSelectedFilter);
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setNameFilters(filters);
fd.setNameFilterDetailsVisible(nameFilterDetailsVisible);
fd.selectNameFilter(selectFilter);
@@ -1093,7 +1078,7 @@ void tst_QFiledialog::setNameFilter()
void tst_QFiledialog::focus()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setDirectory(QDir::currentPath());
fd.show();
QApplication::setActiveWindow(&fd);
@@ -1115,7 +1100,7 @@ void tst_QFiledialog::focus()
void tst_QFiledialog::historyBack()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
QToolButton *backButton = fd.findChild<QToolButton*>("backButton");
@@ -1162,7 +1147,7 @@ void tst_QFiledialog::historyBack()
void tst_QFiledialog::historyForward()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setDirectory(QDir::currentPath());
QToolButton *backButton = fd.findChild<QToolButton*>("backButton");
QVERIFY(backButton);
@@ -1238,7 +1223,7 @@ void tst_QFiledialog::disableSaveButton()
QFETCH(QString, path);
QFETCH(bool, isEnabled);
- QNonNativeFileDialog fd(0, "caption", path);
+ QFileDialog fd(0, "caption", path);
fd.setAcceptMode(QFileDialog::AcceptSave);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
@@ -1265,7 +1250,7 @@ void tst_QFiledialog::saveButtonText()
QFETCH(QString, label);
QFETCH(QString, caption);
- QNonNativeFileDialog fd(0, "auto test", QDir::temp().absolutePath());
+ QFileDialog fd(0, "auto test", QDir::temp().absolutePath());
fd.setAcceptMode(QFileDialog::AcceptSave);
if (!label.isNull())
fd.setLabelText(QFileDialog::Accept, label);
@@ -1280,10 +1265,9 @@ void tst_QFiledialog::saveButtonText()
void tst_QFiledialog::clearLineEdit()
{
- QNonNativeFileDialog fd(0, "caption", "foo");
+ QFileDialog fd(0, "caption", "foo");
fd.setViewMode(QFileDialog::List);
fd.setFileMode(QFileDialog::AnyFile);
- fd.setOptions(QFileDialog::DontUseNativeDialog);
fd.show();
//play it really safe by creating a directory
@@ -1317,7 +1301,7 @@ void tst_QFiledialog::clearLineEdit()
// selecting a dir the text should be cleared so one can just hit ok
// and it selects that directory
- fd.setFileMode(QNonNativeFileDialog::Directory);
+ fd.setFileMode(QFileDialog::Directory);
fd.setDirectory(QDir::home());
QTest::qWait(1000);
@@ -1338,7 +1322,7 @@ void tst_QFiledialog::clearLineEdit()
void tst_QFiledialog::enableChooseButton()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setFileMode(QFileDialog::Directory);
fd.show();
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
@@ -1351,6 +1335,7 @@ void tst_QFiledialog::widgetlessNativeDialog()
{
if (!QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog))
QSKIP("This platform always uses widgets to realize its QFileDialog, instead of the native file dialog.");
+ QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, false);
QFileDialog fd;
fd.setWindowModality(Qt::ApplicationModal);
fd.show();
@@ -1374,10 +1359,9 @@ void tst_QFiledialog::trailingDotsAndSpaces()
#ifndef Q_OS_WIN
QSKIP("This is only tested on Windows");
#endif
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
fd.setFileMode(QFileDialog::ExistingFile);
- fd.setOptions(QFileDialog::DontUseNativeDialog);
fd.show();
QLineEdit *lineEdit = fd.findChild<QLineEdit *>("fileNameEdit");
QVERIFY(lineEdit);
@@ -1453,35 +1437,28 @@ public slots:
void tst_QFiledialog::rejectModalDialogs()
{
// QTBUG-38672 , static functions should return empty Urls
- const QFileDialog::Options options = QFileDialog::DontUseNativeDialog;
DialogRejecter dr;
- QUrl url = QFileDialog::getOpenFileUrl(0, QStringLiteral("getOpenFileUrl"),
- QUrl(), QString(), Q_NULLPTR, options);
+ QUrl url = QFileDialog::getOpenFileUrl(0, QStringLiteral("getOpenFileUrl"));
QVERIFY(url.isEmpty());
QVERIFY(!url.isValid());
- url = QFileDialog::getExistingDirectoryUrl(0, QStringLiteral("getExistingDirectoryUrl"),
- QUrl(), options | QFileDialog::ShowDirsOnly);
+ url = QFileDialog::getExistingDirectoryUrl(0, QStringLiteral("getExistingDirectoryUrl"));
QVERIFY(url.isEmpty());
QVERIFY(!url.isValid());
- url = QFileDialog::getSaveFileUrl(0, QStringLiteral("getSaveFileUrl"),
- QUrl(), QString(), Q_NULLPTR, options);
+ url = QFileDialog::getSaveFileUrl(0, QStringLiteral("getSaveFileUrl"));
QVERIFY(url.isEmpty());
QVERIFY(!url.isValid());
// Same test with local files
- QString file = QFileDialog::getOpenFileName(0, QStringLiteral("getOpenFileName"),
- QString(), QString(), Q_NULLPTR, options);
+ QString file = QFileDialog::getOpenFileName(0, QStringLiteral("getOpenFileName"));
QVERIFY(file.isEmpty());
- file = QFileDialog::getExistingDirectory(0, QStringLiteral("getExistingDirectory"),
- QString(), options | QFileDialog::ShowDirsOnly);
+ file = QFileDialog::getExistingDirectory(0, QStringLiteral("getExistingDirectory"));
QVERIFY(file.isEmpty());
- file = QFileDialog::getSaveFileName(0, QStringLiteral("getSaveFileName"),
- QString(), QString(), Q_NULLPTR, options);
+ file = QFileDialog::getSaveFileName(0, QStringLiteral("getSaveFileName"));
QVERIFY(file.isEmpty());
}
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index f08d78acf7..a16bd1a787 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -65,17 +65,6 @@ Q_GUI_EXPORT void qt_test_resetFetchedRoot();
QT_END_NAMESPACE
#endif
-class QNonNativeFileDialog : public QFileDialog
-{
- Q_OBJECT
-public:
- QNonNativeFileDialog(QWidget *parent = 0, const QString &caption = QString(), const QString &directory = QString(), const QString &filter = QString())
- : QFileDialog(parent, caption, directory, filter)
- {
- setOption(QFileDialog::DontUseNativeDialog, true);
- }
-};
-
static QByteArray msgDoesNotExist(const QString &name)
{
return (QLatin1Char('"') + QDir::toNativeSeparators(name)
@@ -148,6 +137,7 @@ private:
tst_QFileDialog2::tst_QFileDialog2()
: tempDir(QDir::tempPath() + "/tst_qfiledialog2.XXXXXX")
{
+ QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
}
void tst_QFileDialog2::cleanupSettingsFile()
@@ -173,7 +163,7 @@ void tst_QFileDialog2::init()
{
QFileDialogPrivate::setLastVisitedDirectory(QUrl());
// populate the sidebar with some default settings
- QNonNativeFileDialog fd;
+ QFileDialog fd;
}
void tst_QFileDialog2::cleanup()
@@ -189,7 +179,7 @@ void tst_QFileDialog2::listRoot()
QTest::qWait(1500);
qt_test_resetFetchedRoot();
QString dir(QDir::currentPath());
- QNonNativeFileDialog fd(0, QString(), dir);
+ QFileDialog fd(0, QString(), dir);
fd.show();
QCOMPARE(qt_test_isFetchedRoot(),false);
fd.setDirectory("");
@@ -200,15 +190,15 @@ void tst_QFileDialog2::listRoot()
void tst_QFileDialog2::heapCorruption()
{
- QVector<QNonNativeFileDialog*> dialogs;
+ QVector<QFileDialog*> dialogs;
for (int i=0; i < 10; i++) {
- QNonNativeFileDialog *f = new QNonNativeFileDialog(NULL);
+ QFileDialog *f = new QFileDialog(NULL);
dialogs << f;
}
qDeleteAll(dialogs);
}
-struct FriendlyQFileDialog : public QNonNativeFileDialog
+struct FriendlyQFileDialog : public QFileDialog
{
friend class tst_QFileDialog2;
Q_DECLARE_PRIVATE(QFileDialog)
@@ -239,7 +229,6 @@ void tst_QFileDialog2::deleteDirAndFiles()
t->close();
delete t;
FriendlyQFileDialog fd;
- fd.setOption(QFileDialog::DontUseNativeDialog);
fd.d_func()->removeDirectory(tempPath);
QFileInfo info(tempPath);
QTest::qWait(2000);
@@ -249,7 +238,7 @@ void tst_QFileDialog2::deleteDirAndFiles()
void tst_QFileDialog2::filter()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QAction *hiddenAction = fd.findChild<QAction*>("qt_show_hidden_action");
QVERIFY(hiddenAction);
QVERIFY(hiddenAction->isEnabled());
@@ -262,7 +251,7 @@ void tst_QFileDialog2::filter()
void tst_QFileDialog2::showNameFilterDetails()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo");
QVERIFY(filters);
QVERIFY(fd.isNameFilterDetailsVisible());
@@ -294,7 +283,7 @@ void tst_QFileDialog2::unc()
QString dir(QDir::currentPath());
#endif
QVERIFY2(QFile::exists(dir), msgDoesNotExist(dir).constData());
- QNonNativeFileDialog fd(0, QString(), dir);
+ QFileDialog fd(0, QString(), dir);
QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir));
@@ -302,7 +291,7 @@ void tst_QFileDialog2::unc()
void tst_QFileDialog2::emptyUncPath()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.show();
QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
QVERIFY(lineEdit);
@@ -371,7 +360,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
QVERIFY(ctx.file.permissions() & QFile::WriteUser);
ctx.file.close();
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
fd.setDirectory(ctx.test.absolutePath());
fd.show();
@@ -412,7 +401,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
void tst_QFileDialog2::task178897_minimumSize()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QSize oldMs = fd.layout()->minimumSize();
QStringList history = fd.history();
history << QDir::toNativeSeparators("/verylongdirectory/"
@@ -452,7 +441,7 @@ void tst_QFileDialog2::task180459_lastDirectory()
if (!QGuiApplication::platformName().compare(QLatin1String("cocoa"), Qt::CaseInsensitive))
QSKIP("Insignificant on OSX"); //QTBUG-39183
//first visit the temp directory and close the dialog
- QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", tempDir.path());
+ QFileDialog *dlg = new QFileDialog(0, "", tempDir.path());
QFileSystemModel *model = dlg->findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
QCOMPARE(model->index(tempDir.path()), model->index(dlg->directory().absolutePath()));
@@ -463,7 +452,7 @@ void tst_QFileDialog2::task180459_lastDirectory()
QFETCH(bool, isEnabled);
QFETCH(QString, result);
- dlg = new QNonNativeFileDialog(0, "", path);
+ dlg = new QFileDialog(0, "", path);
model = dlg->findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
dlg->setAcceptMode(QFileDialog::AcceptSave);
@@ -539,14 +528,14 @@ protected:
}
};
-class CrashDialog : public QNonNativeFileDialog
+class CrashDialog : public QFileDialog
{
Q_OBJECT
public:
CrashDialog(QWidget *parent, const QString &caption, const
QString &dir, const QString &filter)
- : QNonNativeFileDialog(parent, caption, dir, filter)
+ : QFileDialog(parent, caption, dir, filter)
{
sortProxy *proxyModel = new sortProxy(this);
setProxyModel(proxyModel);
@@ -556,7 +545,7 @@ QString &dir, const QString &filter)
#ifdef QT_BUILD_INTERNAL
void tst_QFileDialog2::task227304_proxyOnFileDialog()
{
- QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0);
+ QFileDialog fd(0, "", QDir::currentPath(), 0);
fd.setProxyModel(new FilterDirModel(QDir::currentPath()));
fd.show();
QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit");
@@ -579,7 +568,7 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog()
dialog->close();
fd.close();
- QNonNativeFileDialog fd2(0, "I should not crash with a proxy", tempDir.path(), 0);
+ QFileDialog fd2(0, "I should not crash with a proxy", tempDir.path(), 0);
QSortFilterProxyModel *pm = new QSortFilterProxyModel;
fd2.setProxyModel(pm);
fd2.show();
@@ -607,7 +596,7 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior()
QVERIFY(file2.open(QIODevice::WriteOnly | QIODevice::Text));
current.cdUp();
current.mkdir("test2");
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
fd.setDirectory(current.absolutePath());
fd.show();
@@ -638,7 +627,7 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior()
#if defined(Q_OS_WIN)
void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setDirectory(QDir::root().path());
fd.show();
QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit");
@@ -664,7 +653,7 @@ void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows()
void tst_QFileDialog2::completionOnLevelAfterRoot()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
#if defined(Q_OS_WIN)
fd.setDirectory("C:/");
QDir current = fd.directory();
@@ -731,7 +720,7 @@ void tst_QFileDialog2::task233037_selectingDirectory()
{
QDir current = QDir::currentPath();
current.mkdir("test");
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setViewMode(QFileDialog::List);
fd.setDirectory(current.absolutePath());
fd.setAcceptMode( QFileDialog::AcceptSave);
@@ -765,7 +754,7 @@ void tst_QFileDialog2::task235069_hideOnEscape()
QFETCH(QFileDialog::ViewMode, viewMode);
QDir current = QDir::currentPath();
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QSignalSpy spyFinished(&fd, &QDialog::finished);
QVERIFY(spyFinished.isValid());
QSignalSpy spyRejected(&fd, &QDialog::rejected);
@@ -813,7 +802,7 @@ void tst_QFileDialog2::task203703_returnProperSeparator()
{
QDir current = QDir::currentPath();
current.mkdir("aaaaaaaaaaaaaaaaaa");
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setDirectory(current.absolutePath());
fd.setViewMode(QFileDialog::List);
fd.setFileMode(QFileDialog::Directory);
@@ -850,7 +839,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
QVERIFY2(tempFile->open(), qPrintable(tempFile->errorString()));
current.cdUp();
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setDirectory(current.absolutePath());
fd.setViewMode(QFileDialog::Detail);
fd.show();
@@ -862,7 +851,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
QPushButton *button = buttonBox->button(QDialogButtonBox::Open);
QTest::mouseClick(button, Qt::LeftButton);
QTest::qWait(500);
- QNonNativeFileDialog fd2;
+ QFileDialog fd2;
fd2.setFileMode(QFileDialog::Directory);
fd2.restoreState(fd.saveState());
current.cd("aaaaaaaaaaaaaaaaaa");
@@ -881,7 +870,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
QTest::qWait(500);
QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QLatin1String("/g"));
- QNonNativeFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
+ QFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
fd3.restoreState(fd.saveState());
fd3.setFileMode(QFileDialog::Directory);
fd3.show();
@@ -914,7 +903,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
void tst_QFileDialog2::task239706_editableFilterCombo()
{
- QNonNativeFileDialog d;
+ QFileDialog d;
d.setNameFilter("*.cpp *.h");
d.show();
@@ -939,7 +928,7 @@ void tst_QFileDialog2::task218353_relativePaths()
{
QDir appDir = QDir::current();
QVERIFY(appDir.cdUp() != false);
- QNonNativeFileDialog d(0, "TestDialog", "..");
+ QFileDialog d(0, "TestDialog", "..");
QCOMPARE(d.directory().absolutePath(), appDir.absolutePath());
d.setDirectory(appDir.absolutePath() + QLatin1String("/non-existing-directory/../another-non-existing-dir/../"));
@@ -955,7 +944,7 @@ void tst_QFileDialog2::task218353_relativePaths()
#ifdef QT_BUILD_INTERNAL
void tst_QFileDialog2::task251321_sideBarHiddenEntries()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QDir current = QDir::currentPath();
current.mkdir(".hidden");
@@ -1011,7 +1000,7 @@ public :
#ifdef QT_BUILD_INTERNAL
void tst_QFileDialog2::task251341_sideBarRemoveEntries()
{
- QNonNativeFileDialog fd;
+ QFileDialog fd;
QDir current = QDir::currentPath();
current.mkdir("testDir");
@@ -1080,7 +1069,7 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes()
t = new QTemporaryFile;
QVERIFY2(t->open(), qPrintable(t->errorString()));
t->open();
- QNonNativeFileDialog fd(0, "TestFileDialog");
+ QFileDialog fd(0, "TestFileDialog");
fd.setDirectory(tempPath);
fd.setViewMode(QFileDialog::List);
@@ -1114,7 +1103,7 @@ void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls()
dir.rmdir(dirname); //makes sure it doesn't exist any more
QVERIFY(dir.mkdir(dirname));
QString url = dir.absolutePath() + QLatin1Char('/') + dirname + QLatin1String("/..");
- QNonNativeFileDialog fd;
+ QFileDialog fd;
fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
QCOMPARE(sidebar->urls().count(), 1);
@@ -1134,7 +1123,7 @@ void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls()
void tst_QFileDialog2::task259105_filtersCornerCases()
{
- QNonNativeFileDialog fd(0, "TestFileDialog");
+ QFileDialog fd(0, "TestFileDialog");
fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
fd.setOption(QFileDialog::HideNameFilterDetails, true);
fd.show();
@@ -1181,7 +1170,7 @@ void tst_QFileDialog2::QTBUG4419_lineEditSelectAll()
QString tempPath = tempDir.path();
QTemporaryFile temporaryFile(tempPath + "/tst_qfiledialog2_lineEditSelectAll.XXXXXX");
QVERIFY2(temporaryFile.open(), qPrintable(temporaryFile.errorString()));
- QNonNativeFileDialog fd(0, "TestFileDialog", temporaryFile.fileName());
+ QFileDialog fd(0, "TestFileDialog", temporaryFile.fileName());
fd.setDirectory(tempPath);
fd.setViewMode(QFileDialog::List);
@@ -1224,7 +1213,7 @@ void tst_QFileDialog2::QTBUG6558_showDirsOnly()
out << "The magic number is: " << 49 << "\n";
tempFile.close();
- QNonNativeFileDialog fd(0, "TestFileDialog");
+ QFileDialog fd(0, "TestFileDialog");
fd.setDirectory(dir.absolutePath());
fd.setViewMode(QFileDialog::List);
@@ -1273,7 +1262,7 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails()
filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)";
QString chosenFilterString("Text files (*.txt)");
- QNonNativeFileDialog fd(0, "TestFileDialog");
+ QFileDialog fd(0, "TestFileDialog");
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.setOption(QFileDialog::HideNameFilterDetails, true);
fd.setNameFilters(filtersStr);
@@ -1289,7 +1278,7 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails()
//We compare the current combobox text with the stripped version
QCOMPARE(filters->currentText(), QString("Text files"));
- QNonNativeFileDialog fd2(0, "TestFileDialog");
+ QFileDialog fd2(0, "TestFileDialog");
fd2.setAcceptMode(QFileDialog::AcceptSave);
fd2.setOption(QFileDialog::HideNameFilterDetails, false);
fd2.setNameFilters(filtersStr);
@@ -1309,7 +1298,7 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails()
void tst_QFileDialog2::dontShowCompleterOnRoot()
{
- QNonNativeFileDialog fd(0, "TestFileDialog");
+ QFileDialog fd(0, "TestFileDialog");
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.show();
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 6faeb10ce7..01708d526c 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -275,6 +275,7 @@ void tst_QGraphicsProxyWidget::initTestCase()
QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false);
// Disable combo for QTBUG_43780_visibility()/Windows Vista.
QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false);
+ QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
}
// This will be called after every test function.
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index c735d269c5..808c7f9d3d 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -138,6 +138,8 @@ private slots:
void positiveSign();
+ void interpretOnLosingFocus();
+
void setGroupSeparatorShown_data();
void setGroupSeparatorShown();
@@ -1145,6 +1147,33 @@ void tst_QSpinBox::positiveSign()
QCOMPARE(spinBox.text(), QLatin1String("+20"));
}
+void tst_QSpinBox::interpretOnLosingFocus()
+{
+ // QTBUG-55249: When typing an invalid value after QSpinBox::clear(),
+ // it should be fixed up on losing focus.
+
+ static const int minimumValue = 10;
+ static const int maximumValue = 20;
+
+ QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
+ QVBoxLayout *layout = new QVBoxLayout(&widget);
+ QLineEdit *focusDummy = new QLineEdit("focusDummy", &widget);
+ layout->addWidget(focusDummy);
+ SpinBox *spinBox = new SpinBox(&widget);
+ spinBox->setRange(minimumValue, maximumValue);
+ spinBox->setValue(minimumValue);
+ layout->addWidget(spinBox);
+ spinBox->clear();
+ spinBox->setFocus();
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowActive(&widget));
+ QTest::keyClick(spinBox, Qt::Key_1); // Too small
+ focusDummy->setFocus();
+ QCOMPARE(spinBox->value(), minimumValue);
+ QCOMPARE(spinBox->lineEdit()->text().toInt(), minimumValue);
+}
+
void tst_QSpinBox::setGroupSeparatorShown_data()
{
QTest::addColumn<QLocale::Language>("lang");
diff --git a/tests/manual/cocoa/menurama/main.cpp b/tests/manual/cocoa/menurama/main.cpp
new file mode 100644
index 0000000000..98d96b1491
--- /dev/null
+++ b/tests/manual/cocoa/menurama/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the qtbase module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+#include "menuramaapplication.h"
+
+int main(int argc, char *argv[])
+{
+ MenuramaApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/tests/manual/cocoa/menurama/mainwindow.cpp b/tests/manual/cocoa/menurama/mainwindow.cpp
new file mode 100644
index 0000000000..db8fdafc21
--- /dev/null
+++ b/tests/manual/cocoa/menurama/mainwindow.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the qtbase module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+#include "menuramaapplication.h"
+#include <QDebug>
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+
+ startTimer(1000);
+
+ connect(ui->menuAfter_aboutToShow, &QMenu::aboutToShow, [=] {
+ menuApp->populateMenu(ui->menuAfter_aboutToShow, true /*clear*/);
+ });
+
+ connect(ui->menuDynamic_Stuff, &QMenu::aboutToShow, [=] {
+ menuApp->addDynMenu(QLatin1String("Added After aboutToShow()"), ui->menuDynamic_Stuff);
+ });
+
+ connect(ui->pushButton, &QPushButton::clicked, [=] {
+ menuApp->populateMenu(ui->menuOn_Click, true /*clear*/);
+ });
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::timerEvent(QTimerEvent *)
+{
+ menuApp->populateMenu(ui->menuPopulated_by_Timer, true /*clear*/);
+ menuApp->addDynMenu(QLatin1String("Added by Timer"), ui->menuDynamic_Stuff);
+}
+
+void MainWindow::enableStuffMenu(bool enable)
+{
+ ui->menuStuff->setEnabled(enable);
+}
+
+void MainWindow::on_actionQuit_triggered()
+{
+ menuApp->exit();
+}
diff --git a/tests/manual/cocoa/menurama/mainwindow.h b/tests/manual/cocoa/menurama/mainwindow.h
new file mode 100644
index 0000000000..b9cb52d908
--- /dev/null
+++ b/tests/manual/cocoa/menurama/mainwindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the qtbase module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+protected:
+ void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
+
+public slots:
+ void enableStuffMenu(bool enable);
+
+private slots:
+ void on_actionQuit_triggered();
+
+private:
+ Ui::MainWindow *ui;
+};
+
+#endif // MAINWINDOW_H
diff --git a/tests/manual/cocoa/menurama/mainwindow.ui b/tests/manual/cocoa/menurama/mainwindow.ui
new file mode 100644
index 0000000000..f73b41b861
--- /dev/null
+++ b/tests/manual/cocoa/menurama/mainwindow.ui
@@ -0,0 +1,289 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>566</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <widget class="QCheckBox" name="checkBox">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>40</y>
+ <width>151</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Enable &quot;Stuff&quot; Menu</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>321</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>The &quot;Help&quot; menu should NOT be visible.</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButton">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>80</y>
+ <width>211</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Populate Dynamic Submenu</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>566</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuStuff">
+ <property name="title">
+ <string>Stuff</string>
+ </property>
+ <widget class="QMenu" name="menuSubmenu">
+ <property name="title">
+ <string>Submenu</string>
+ </property>
+ <widget class="QMenu" name="menuMore_Submenu_2">
+ <property name="title">
+ <string>More Submenu</string>
+ </property>
+ <addaction name="actionMOARH"/>
+ </widget>
+ <addaction name="actionWith_More_Stuff"/>
+ <addaction name="menuMore_Submenu_2"/>
+ </widget>
+ <widget class="QMenu" name="menuDisabled_Submenu">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>Disabled Submenu</string>
+ </property>
+ <widget class="QMenu" name="menuMore_Submenu">
+ <property name="title">
+ <string>More Submenu</string>
+ </property>
+ <addaction name="actionShould_be_Disabled_Too"/>
+ </widget>
+ <addaction name="actionShould_be_Disabled"/>
+ <addaction name="menuMore_Submenu"/>
+ </widget>
+ <addaction name="actionItem"/>
+ <addaction name="menuSubmenu"/>
+ <addaction name="actionDisabled_Item"/>
+ <addaction name="menuDisabled_Submenu"/>
+ </widget>
+ <widget class="QMenu" name="menuDisabled_Stuff">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>Disabled Stuff</string>
+ </property>
+ <widget class="QMenu" name="menuSubmenu_2">
+ <property name="title">
+ <string>Disabled Submenu</string>
+ </property>
+ <widget class="QMenu" name="menuSubsubmenu">
+ <property name="title">
+ <string>Disabled Subsubmenu</string>
+ </property>
+ <addaction name="actionWith_its_own_Stuff"/>
+ </widget>
+ <addaction name="actionMore_Disabled_Stuff"/>
+ <addaction name="menuSubsubmenu"/>
+ </widget>
+ <addaction name="actionItem_2"/>
+ <addaction name="menuSubmenu_2"/>
+ </widget>
+ <widget class="QMenu" name="menuShould_NOT_Be_Visible">
+ <property name="title">
+ <string>Should NOT Be Visible</string>
+ </property>
+ <addaction name="actionAbout"/>
+ </widget>
+ <widget class="QMenu" name="menuHelp">
+ <property name="title">
+ <string>Help</string>
+ </property>
+ <addaction name="actionAbout_Qt"/>
+ </widget>
+ <widget class="QMenu" name="menuDynamic_Stuff">
+ <property name="title">
+ <string>Dynamic Stuff</string>
+ </property>
+ <widget class="QMenu" name="menuAfter_aboutToShow">
+ <property name="title">
+ <string>Populated After aboutToShow()</string>
+ </property>
+ </widget>
+ <widget class="QMenu" name="menuOn_Click">
+ <property name="title">
+ <string>Click Button to Populate</string>
+ </property>
+ </widget>
+ <widget class="QMenu" name="menuPopulated_by_Timer">
+ <property name="title">
+ <string>Populated by Timer</string>
+ </property>
+ </widget>
+ <addaction name="menuOn_Click"/>
+ <addaction name="menuAfter_aboutToShow"/>
+ <addaction name="menuPopulated_by_Timer"/>
+ </widget>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>File</string>
+ </property>
+ <addaction name="actionNew"/>
+ <addaction name="actionNo_Empty_Spaces_Below"/>
+ <addaction name="actionQuit"/>
+ </widget>
+ <addaction name="menuFile"/>
+ <addaction name="menuStuff"/>
+ <addaction name="menuDisabled_Stuff"/>
+ <addaction name="menuShould_NOT_Be_Visible"/>
+ <addaction name="menuDynamic_Stuff"/>
+ <addaction name="menuHelp"/>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ <action name="actionWith_More_Stuff">
+ <property name="text">
+ <string>With More Stuff</string>
+ </property>
+ </action>
+ <action name="actionDisabled_Item">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Disabled Item</string>
+ </property>
+ </action>
+ <action name="actionItem">
+ <property name="text">
+ <string>Item</string>
+ </property>
+ </action>
+ <action name="actionShould_be_Disabled">
+ <property name="text">
+ <string>Should be Disabled</string>
+ </property>
+ </action>
+ <action name="actionShould_be_Disabled_Too">
+ <property name="text">
+ <string>Should be Disabled Too</string>
+ </property>
+ </action>
+ <action name="actionMOARH">
+ <property name="text">
+ <string>MOAR!!</string>
+ </property>
+ </action>
+ <action name="actionItem_2">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Disabled Item</string>
+ </property>
+ </action>
+ <action name="actionMore_Disabled_Stuff">
+ <property name="text">
+ <string>More Disabled Stuff</string>
+ </property>
+ </action>
+ <action name="actionWith_its_own_Stuff">
+ <property name="text">
+ <string>With its own Disabled Stuff</string>
+ </property>
+ </action>
+ <action name="actionAbout">
+ <property name="text">
+ <string>About</string>
+ </property>
+ </action>
+ <action name="actionAbout_Qt">
+ <property name="text">
+ <string>About Qt</string>
+ </property>
+ </action>
+ <action name="actionQuit">
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ </action>
+ <action name="actionNew">
+ <property name="text">
+ <string>New...</string>
+ </property>
+ </action>
+ <action name="actionNo_Empty_Spaces_Below">
+ <property name="text">
+ <string>No Empty Spaces Below</string>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>checkBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>MainWindow</receiver>
+ <slot>enableStuffMenu(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>62</x>
+ <y>94</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>72</x>
+ <y>73</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <slot>enableStuffMenu(bool)</slot>
+ </slots>
+</ui>
diff --git a/tests/manual/cocoa/menurama/menurama.pro b/tests/manual/cocoa/menurama/menurama.pro
new file mode 100644
index 0000000000..da6f224e0d
--- /dev/null
+++ b/tests/manual/cocoa/menurama/menurama.pro
@@ -0,0 +1,22 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2016-08-10T14:21:46
+#
+#-------------------------------------------------
+
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = Menurama
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ mainwindow.cpp \
+ menuramaapplication.cpp
+
+HEADERS += mainwindow.h \
+ menuramaapplication.h
+
+FORMS += mainwindow.ui
diff --git a/tests/manual/cocoa/menurama/menuramaapplication.cpp b/tests/manual/cocoa/menurama/menuramaapplication.cpp
new file mode 100644
index 0000000000..534d5fa371
--- /dev/null
+++ b/tests/manual/cocoa/menurama/menuramaapplication.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the qtbase module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "menuramaapplication.h"
+
+MenuramaApplication::MenuramaApplication(int argc, char **argv)
+ : QApplication (argc, argv)
+{
+#if 0
+ QMenuBar *mb = new QMenuBar();
+ QMenu *menu = mb->addMenu("App Dynamic");
+ QMenu *dynMenu = menu->addMenu("After aboutToShow()");
+ connect(dynMenu, &QMenu::aboutToShow, [=] {
+ qDebug() << "aboutToShow(), populating" << dynMenu;
+ menuApp->populateMenu(dynMenu, true /*clear*/);
+ });
+#endif
+}
+
+void MenuramaApplication::populateMenu(QMenu *menu, bool clear)
+{
+ if (clear)
+ menu->clear();
+
+ static const char *sym[] = { "Foo", "Bar", "Baz", "Huux" };
+ static int id = 0;
+ for (unsigned i = 0; i < sizeof(sym) / sizeof(sym[0]); i++)
+ menu->addAction(QStringLiteral("%1 — %2 %3 ")
+ .arg(menu->title()).arg(sym[i]).arg(id));
+ ++id;
+}
+
+void MenuramaApplication::addDynMenu(QLatin1String title, QMenu *parentMenu)
+{
+ foreach (QAction *a, parentMenu->actions())
+ if (a->text() == title) {
+ parentMenu->removeAction(a);
+ break;
+ }
+
+ QMenu *subMenu = new QMenu(title, parentMenu);
+ populateMenu(subMenu, false /*clear*/);
+ parentMenu->addMenu(subMenu);
+}
diff --git a/tests/manual/cocoa/menurama/menuramaapplication.h b/tests/manual/cocoa/menurama/menuramaapplication.h
new file mode 100644
index 0000000000..07c8da27a1
--- /dev/null
+++ b/tests/manual/cocoa/menurama/menuramaapplication.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the qtbase module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MENURAMAAPPLICATION_H
+#define MENURAMAAPPLICATION_H
+
+#include <QtWidgets>
+
+#define menuApp (static_cast<MenuramaApplication *>(QCoreApplication::instance()))
+
+class MenuramaApplication : public QApplication
+{
+public:
+ MenuramaApplication(int argc, char **argv);
+ void addDynMenu(QLatin1String title, QMenu *parentMenu);
+
+public slots:
+ void populateMenu(QMenu *menu, bool clear);
+};
+
+#endif // MENURAMAAPPLICATION_H
diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp
index d1c7949777..f0f4e437e9 100644
--- a/tests/manual/dialogs/main.cpp
+++ b/tests/manual/dialogs/main.cpp
@@ -80,6 +80,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
int main(int argc, char *argv[])
{
+ for (int a = 1; a < argc; ++a) {
+ if (!qstrcmp(argv[a], "-n")) {
+ qDebug("AA_DontUseNativeDialogs");
+ QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
+ }
+ }
QApplication a(argc, argv);
MainWindow w;
w.move(500, 200);
diff --git a/tests/manual/qopenglwindow/multiwindow/main.cpp b/tests/manual/qopenglwindow/multiwindow/main.cpp
index e2a2d899a0..0788408b47 100644
--- a/tests/manual/qopenglwindow/multiwindow/main.cpp
+++ b/tests/manual/qopenglwindow/multiwindow/main.cpp
@@ -32,26 +32,22 @@
#include <QOpenGLFunctions>
#include <QPainter>
#include <QElapsedTimer>
+#include <QCommandLineParser>
+#include <QScreen>
+
+const char applicationDescription[] = "\n\
+This application opens multiple windows and continuously schedules updates for\n\
+them. Each of them is a separate QOpenGLWindow so there will be a separate\n\
+context and swapBuffers call for each.\n\
+\n\
+By default the swap interval is 1 so the effect of multiple blocking swapBuffers\n\
+on the main thread can be examined. (the result is likely to be different\n\
+between platforms, for example OS X is buffer queuing meaning that it can\n\
+block outside swap, resulting in perfect vsync for all three windows, while\n\
+other systems that block on swap will kill the frame rate due to blocking the\n\
+thread three times)\
+";
-// This application opens three windows and continuously schedules updates for
-// them. Each of them is a separate QOpenGLWindow so there will be a separate
-// context and swapBuffers call for each.
-//
-// By default the swap interval is 1 so the effect of three blocking swapBuffers
-// on the main thread can be examined. (the result is likely to be different
-// between platforms, for example OS X is buffer queuing meaning that it can
-// block outside swap, resulting in perfect vsync for all three windows, while
-// other systems that block on swap will kill the frame rate due to blocking the
-// thread three times)
-//
-// Pass --novsync to set a swap interval of 0. This should give an unthrottled
-// refresh on all platforms for all three windows.
-//
-// Passing --vsyncone sets swap interval to 1 for the first window and 0 to the
-// others.
-//
-// Pass --extrawindows N to open N windows in addition to the default 3.
-//
// For reference, below is a table of some test results.
//
// swap interval 1 for all swap interval 1 for only one and 0 for others
@@ -64,12 +60,15 @@
class Window : public QOpenGLWindow
{
+ Q_OBJECT
public:
Window(int n) : idx(n) {
r = g = b = fps = 0;
y = 0;
resize(200, 200);
- t2.start();
+
+ connect(this, SIGNAL(frameSwapped()), SLOT(frameSwapped()));
+ fpsTimer.start();
}
void paintGL() {
@@ -101,27 +100,52 @@ public:
if (y > height() - 20)
y = 20;
- if (t2.elapsed() > 1000) {
- fps = 1000.0 / t.elapsed();
- t2.restart();
- }
- t.restart();
-
update();
}
+public slots:
+ void frameSwapped() {
+ ++framesSwapped;
+ if (fpsTimer.elapsed() > 1000) {
+ fps = qRound(framesSwapped * (1000.0 / fpsTimer.elapsed()));
+ framesSwapped = 0;
+ fpsTimer.restart();
+ }
+ }
+
private:
int idx;
- GLfloat r, g, b, fps;
+ GLfloat r, g, b;
int y;
- QElapsedTimer t, t2;
+
+ int framesSwapped;
+ QElapsedTimer fpsTimer;
+ int fps;
};
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
+
+ QCommandLineParser parser;
+ parser.setApplicationDescription(applicationDescription);
+ parser.addHelpOption();
+
+ QCommandLineOption noVsyncOption("novsync", "Disable Vsync by setting swap interval to 0. "
+ "This should give an unthrottled refresh on all platforms for all windows.");
+ parser.addOption(noVsyncOption);
+
+ QCommandLineOption vsyncOneOption("vsyncone", "Enable Vsync only for first window, "
+ "by setting swap interval to 1 for the first window and 0 for the others.");
+ parser.addOption(vsyncOneOption);
+
+ QCommandLineOption numWindowsOption("numwindows", "Open <N> windows instead of the default 3.", "N", "3");
+ parser.addOption(numWindowsOption);
+
+ parser.process(app);
+
QSurfaceFormat fmt;
- if (QGuiApplication::arguments().contains(QLatin1String("--novsync"))) {
+ if (parser.isSet(noVsyncOption)) {
qDebug("swap interval 0 (no throttling)");
fmt.setSwapInterval(0);
} else {
@@ -129,36 +153,41 @@ int main(int argc, char **argv)
}
QSurfaceFormat::setDefaultFormat(fmt);
- Window w1(0);
- if (QGuiApplication::arguments().contains(QLatin1String("--vsyncone"))) {
- qDebug("swap interval 1 for first window only");
- QSurfaceFormat w1fmt = fmt;
- w1fmt.setSwapInterval(1);
- w1.setFormat(w1fmt);
- fmt.setSwapInterval(0);
- QSurfaceFormat::setDefaultFormat(fmt);
- }
- Window w2(1);
- Window w3(2);
- w1.setGeometry(QRect(QPoint(10, 100), w1.size()));
- w2.setGeometry(QRect(QPoint(300, 100), w2.size()));
- w3.setGeometry(QRect(QPoint(600, 100), w3.size()));
- w1.show();
- w2.show();
- w3.show();
-
- QList<QWindow *> extraWindows;
- int countIdx;
- if ((countIdx = QGuiApplication::arguments().indexOf(QLatin1String("--extrawindows"))) >= 0) {
- int extraWindowCount = QGuiApplication::arguments().at(countIdx + 1).toInt();
- for (int i = 0; i < extraWindowCount; ++i) {
- Window *w = new Window(3 + i);
- extraWindows << w;
- w->show();
+ QRect availableGeometry = app.primaryScreen()->availableGeometry();
+
+ int numberOfWindows = qMax(parser.value(numWindowsOption).toInt(), 1);
+ QList<QWindow *> windows;
+ for (int i = 0; i < numberOfWindows; ++i) {
+ Window *w = new Window(i + 1);
+ windows << w;
+
+ if (i == 0 && parser.isSet(vsyncOneOption)) {
+ qDebug("swap interval 1 for first window only");
+ QSurfaceFormat vsyncedSurfaceFormat = fmt;
+ vsyncedSurfaceFormat.setSwapInterval(1);
+ w->setFormat(vsyncedSurfaceFormat);
+ fmt.setSwapInterval(0);
+ QSurfaceFormat::setDefaultFormat(fmt);
}
+
+ static int windowWidth = w->width() + 20;
+ static int windowHeight = w->height() + 20;
+
+ static int windowsPerRow = availableGeometry.width() / windowWidth;
+
+ int col = i;
+ int row = col / windowsPerRow;
+ col -= row * windowsPerRow;
+
+ QPoint position = availableGeometry.topLeft();
+ position += QPoint(col * windowWidth, row * windowHeight);
+ w->setFramePosition(position);
+ w->show();
}
int r = app.exec();
- qDeleteAll(extraWindows);
+ qDeleteAll(windows);
return r;
}
+
+#include "main.moc"
diff --git a/tests/manual/qscreen/propertyfield.cpp b/tests/manual/qscreen/propertyfield.cpp
index 94a85545fb..e310798573 100644
--- a/tests/manual/qscreen/propertyfield.cpp
+++ b/tests/manual/qscreen/propertyfield.cpp
@@ -44,6 +44,9 @@ PropertyField::PropertyField(QObject* subject, const QMetaProperty& prop, QWidge
QString PropertyField::valueToString(QVariant val)
{
+ if (m_prop.isEnumType())
+ return QString::fromUtf8(m_prop.enumerator().valueToKey(val.toInt()));
+
QString text;
switch (val.type()) {
case QVariant::Double: