mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 00:35:27 +08:00
6.5.3 clean
This commit is contained in:
@ -29,6 +29,8 @@ private slots:
|
||||
void QTBUG_43548_initialColor();
|
||||
void hexColor_data();
|
||||
void hexColor();
|
||||
|
||||
void hideNativeByDestruction();
|
||||
};
|
||||
|
||||
class TestNativeDialog : public QColorDialog
|
||||
@ -179,5 +181,32 @@ void tst_QColorDialog::hexColor()
|
||||
QCOMPARE(color.name(QColor::HexRgb), expectedHexColor.toLower());
|
||||
}
|
||||
|
||||
void tst_QColorDialog::hideNativeByDestruction()
|
||||
{
|
||||
QWidget window;
|
||||
QWidget *child = new QWidget(&window);
|
||||
QPointer<QColorDialog> dialog = new QColorDialog(child);
|
||||
// Make it application modal so that we don't end up with a sheet on macOS
|
||||
dialog->setWindowModality(Qt::ApplicationModal);
|
||||
window.show();
|
||||
QVERIFY(QTest::qWaitForWindowActive(&window));
|
||||
dialog->open();
|
||||
|
||||
// We test that the dialog opens and closes by watching the activation of the
|
||||
// transient parent window. If it doesn't deactivate, then we have to skip.
|
||||
const auto windowActive = [&window]{ return window.isActiveWindow(); };
|
||||
const auto windowInactive = [&window]{ return !window.isActiveWindow(); };
|
||||
if (!QTest::qWaitFor(windowInactive, 2000))
|
||||
QSKIP("Dialog didn't activate");
|
||||
|
||||
// This should destroy the dialog and close the native window
|
||||
child->deleteLater();
|
||||
QTRY_VERIFY(!dialog);
|
||||
// If the native window is still open, then the transient parent can't become
|
||||
// active
|
||||
window.activateWindow();
|
||||
QVERIFY(QTest::qWaitFor(windowActive));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QColorDialog)
|
||||
#include "tst_qcolordialog.moc"
|
||||
|
@ -128,9 +128,10 @@ private slots:
|
||||
void QTBUG49600_nativeIconProviderCrash();
|
||||
void focusObjectDuringDestruction();
|
||||
|
||||
// NOTE: Please keep widgetlessNativeDialog() as the LAST test!
|
||||
// NOTE: Please keep widgetlessNativeDialog() and
|
||||
// hideNativeByDestruction() as the LAST tests!
|
||||
//
|
||||
// widgetlessNativeDialog() is the only test function that creates
|
||||
// widgetlessNativeDialog() are the only test functions that create
|
||||
// a native file dialog instance. GTK+ versions prior 3.15.5 have
|
||||
// a nasty bug (https://bugzilla.gnome.org/show_bug.cgi?id=725164)
|
||||
// in GtkFileChooserWidget, which makes it leak its folder change
|
||||
@ -141,6 +142,7 @@ private slots:
|
||||
// The crash has been fixed in GTK+ 3.15.5, but the RHEL 7.2 CI has
|
||||
// GTK+ 3.14.13 installed (QTBUG-55276).
|
||||
void widgetlessNativeDialog();
|
||||
void hideNativeByDestruction();
|
||||
|
||||
private:
|
||||
void cleanupSettingsFile();
|
||||
@ -517,7 +519,6 @@ void tst_QFiledialog::completer()
|
||||
for (int i = 0; i < input.size(); ++i)
|
||||
QTest::keyPress(lineEdit, input[i].toLatin1());
|
||||
|
||||
QStringList expectedFiles;
|
||||
if (expected == -1) {
|
||||
QString fullPath = startPath;
|
||||
if (!fullPath.endsWith(QLatin1Char('/')))
|
||||
@ -530,11 +531,11 @@ void tst_QFiledialog::completer()
|
||||
|
||||
QFileInfo fi(fullPath);
|
||||
QDir x(fi.absolutePath());
|
||||
expectedFiles = x.entryList(model->filter());
|
||||
const QStringList expectedFiles = x.entryList(model->filter());
|
||||
expected = 0;
|
||||
if (input.startsWith(".."))
|
||||
input.clear();
|
||||
foreach (const QString &expectedFile, expectedFiles) {
|
||||
for (const QString &expectedFile : expectedFiles) {
|
||||
if (expectedFile.startsWith(input, caseSensitivity))
|
||||
++expected;
|
||||
}
|
||||
@ -1438,7 +1439,7 @@ void tst_QFiledialog::widgetlessNativeDialog()
|
||||
QSKIP("This platform always uses widgets to realize its QFileDialog, instead of the native file dialog.");
|
||||
#ifdef Q_OS_ANDROID
|
||||
// QTBUG-101194
|
||||
QSKIP("Android: This keeeps the window open. Figure out why.");
|
||||
QSKIP("Android: This keeps the window open. Figure out why.");
|
||||
#endif
|
||||
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, false);
|
||||
QFileDialog fd;
|
||||
@ -1452,6 +1453,46 @@ void tst_QFiledialog::widgetlessNativeDialog()
|
||||
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, true);
|
||||
}
|
||||
|
||||
void tst_QFiledialog::hideNativeByDestruction()
|
||||
{
|
||||
if (!QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog))
|
||||
QSKIP("This platform always uses widgets to realize its QFileDialog, instead of the native file dialog.");
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
// QTBUG-101194
|
||||
QSKIP("Android: This keeps the native window open. Figure out why.");
|
||||
#endif
|
||||
|
||||
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, false);
|
||||
auto resetAttribute = qScopeGuard([]{
|
||||
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs, true);
|
||||
});
|
||||
|
||||
QWidget window;
|
||||
QWidget *child = new QWidget(&window);
|
||||
QPointer<QFileDialog> dialog = new QFileDialog(child);
|
||||
// Make it application modal so that we don't end up with a sheet on macOS
|
||||
dialog->setWindowModality(Qt::ApplicationModal);
|
||||
window.show();
|
||||
QVERIFY(QTest::qWaitForWindowActive(&window));
|
||||
dialog->open();
|
||||
|
||||
// We test that the dialog opens and closes by watching the activation of the
|
||||
// transient parent window. If it doesn't deactivate, then we have to skip.
|
||||
const auto windowActive = [&window]{ return window.isActiveWindow(); };
|
||||
const auto windowInactive = [&window]{ return !window.isActiveWindow(); };
|
||||
if (!QTest::qWaitFor(windowInactive, 2000))
|
||||
QSKIP("Dialog didn't activate");
|
||||
|
||||
// This should destroy the dialog and close the native window
|
||||
child->deleteLater();
|
||||
QTRY_VERIFY(!dialog);
|
||||
// If the native window is still open, then the transient parent can't become
|
||||
// active
|
||||
window.activateWindow();
|
||||
QVERIFY(QTest::qWaitFor(windowActive, 2000));
|
||||
}
|
||||
|
||||
void tst_QFiledialog::selectedFilesWithoutWidgets()
|
||||
{
|
||||
// Test for a crash when widgets are not instantiated yet.
|
||||
|
@ -682,13 +682,13 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
|
||||
#if defined(Q_OS_WIN)
|
||||
fd.setDirectory("C:/");
|
||||
QDir current = fd.directory();
|
||||
QStringList entryList = current.entryList(QStringList(), QDir::Dirs);
|
||||
const QStringList entryList = current.entryList(QStringList(), QDir::Dirs);
|
||||
// Find a suitable test dir under c:-root:
|
||||
// - At least 6 characters long
|
||||
// - Ascii, letters only
|
||||
// - No another dir with same start
|
||||
QString testDir;
|
||||
foreach (const QString &entry, entryList) {
|
||||
for (const QString &entry : entryList) {
|
||||
if (entry.size() > 5 && QString(entry.toLatin1()).compare(entry) == 0) {
|
||||
bool invalid = false;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
@ -698,7 +698,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot()
|
||||
}
|
||||
}
|
||||
if (!invalid) {
|
||||
foreach (const QString &check, entryList) {
|
||||
for (const QString &check : entryList) {
|
||||
if (check.startsWith(entry.left(5), Qt::CaseInsensitive) && check != entry) {
|
||||
invalid = true;
|
||||
break;
|
||||
@ -948,9 +948,9 @@ void tst_QFileDialog2::task239706_editableFilterCombo()
|
||||
d.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&d));
|
||||
|
||||
QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
|
||||
const QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
|
||||
QComboBox *filterCombo = nullptr;
|
||||
foreach (QComboBox *combo, comboList) {
|
||||
for (QComboBox *combo : comboList) {
|
||||
if (combo->objectName() == QString("fileTypeCombo")) {
|
||||
filterCombo = combo;
|
||||
break;
|
||||
|
@ -45,6 +45,7 @@ private slots:
|
||||
void qtbug_41513_stylesheetStyle();
|
||||
#endif
|
||||
|
||||
void hideNativeByDestruction();
|
||||
|
||||
private:
|
||||
void runSlotWithFailsafeTimer(const char *member);
|
||||
@ -238,5 +239,32 @@ void tst_QFontDialog::testNonStandardFontSize()
|
||||
qWarning("Fail using a non-standard font size.");
|
||||
}
|
||||
|
||||
void tst_QFontDialog::hideNativeByDestruction()
|
||||
{
|
||||
QWidget window;
|
||||
QWidget *child = new QWidget(&window);
|
||||
QPointer<QFontDialog> dialog = new QFontDialog(child);
|
||||
// Make it application modal so that we don't end up with a sheet on macOS
|
||||
dialog->setWindowModality(Qt::ApplicationModal);
|
||||
window.show();
|
||||
QVERIFY(QTest::qWaitForWindowActive(&window));
|
||||
dialog->open();
|
||||
|
||||
// We test that the dialog opens and closes by watching the activation of the
|
||||
// transient parent window. If it doesn't deactivate, then we have to skip.
|
||||
const auto windowActive = [&window]{ return window.isActiveWindow(); };
|
||||
const auto windowInactive = [&window]{ return !window.isActiveWindow(); };
|
||||
if (!QTest::qWaitFor(windowInactive, 2000))
|
||||
QSKIP("Dialog didn't activate");
|
||||
|
||||
// This should destroy the dialog and close the native window
|
||||
child->deleteLater();
|
||||
QTRY_VERIFY(!dialog);
|
||||
// If the native window is still open, then the transient parent can't become
|
||||
// active
|
||||
window.activateWindow();
|
||||
QVERIFY(QTest::qWaitFor(windowActive));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QFontDialog)
|
||||
#include "tst_qfontdialog.moc"
|
||||
|
@ -55,6 +55,11 @@ private slots:
|
||||
void acceptedRejectedSignals();
|
||||
void acceptedRejectedSignals_data();
|
||||
|
||||
void overrideDone_data();
|
||||
void overrideDone();
|
||||
|
||||
void hideNativeByDestruction();
|
||||
|
||||
void cleanup();
|
||||
};
|
||||
|
||||
@ -149,6 +154,44 @@ void tst_QMessageBox::init()
|
||||
qApp->setAttribute(Qt::AA_DontUseNativeDialogs, !useNativeDialog);
|
||||
}
|
||||
|
||||
class OverridingMessageBox : public QMessageBox
|
||||
{
|
||||
public:
|
||||
void done(int result) override {
|
||||
doneResult = result;
|
||||
QMessageBox::done(result);
|
||||
}
|
||||
std::optional<int> doneResult;
|
||||
};
|
||||
|
||||
void tst_QMessageBox::overrideDone_data()
|
||||
{
|
||||
QTest::addColumn<QMessageBox::StandardButton>("button");
|
||||
QTest::addColumn<int>("closeAction");
|
||||
QTest::addColumn<int>("result");
|
||||
|
||||
QTest::newRow("close") << QMessageBox::Help << int(ExecCloseHelper::CloseWindow) << 0;
|
||||
QTest::newRow("yes") << QMessageBox::Yes << int(Qt::Key_Enter) << int(QMessageBox::Yes);
|
||||
QTest::newRow("no") << QMessageBox::No << int(Qt::Key_Enter) << int(QMessageBox::No);
|
||||
}
|
||||
|
||||
void tst_QMessageBox::overrideDone()
|
||||
{
|
||||
QFETCH(QMessageBox::StandardButton, button);
|
||||
QFETCH(int, closeAction);
|
||||
QFETCH(int, result);
|
||||
|
||||
OverridingMessageBox messageBox;
|
||||
messageBox.addButton(button);
|
||||
messageBox.setDefaultButton(button);
|
||||
ExecCloseHelper closeHelper;
|
||||
closeHelper.start(closeAction, &messageBox);
|
||||
messageBox.exec();
|
||||
QVERIFY(messageBox.doneResult.has_value());
|
||||
QCOMPARE(*messageBox.doneResult, result);
|
||||
|
||||
}
|
||||
|
||||
void tst_QMessageBox::cleanup()
|
||||
{
|
||||
QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty()); // OS X requires TRY
|
||||
@ -741,5 +784,32 @@ void tst_QMessageBox::acceptedRejectedSignals_data()
|
||||
addCustomButtonsData();
|
||||
}
|
||||
|
||||
void tst_QMessageBox::hideNativeByDestruction()
|
||||
{
|
||||
QWidget window;
|
||||
QWidget *child = new QWidget(&window);
|
||||
QPointer<QMessageBox> dialog = new QMessageBox(child);
|
||||
// Make it application modal so that we don't end up with a sheet on macOS
|
||||
dialog->setWindowModality(Qt::ApplicationModal);
|
||||
window.show();
|
||||
QVERIFY(QTest::qWaitForWindowActive(&window));
|
||||
dialog->open();
|
||||
|
||||
// We test that the dialog opens and closes by watching the activation of the
|
||||
// transient parent window. If it doesn't deactivate, then we have to skip.
|
||||
const auto windowActive = [&window]{ return window.isActiveWindow(); };
|
||||
const auto windowInactive = [&window]{ return !window.isActiveWindow(); };
|
||||
if (!QTest::qWaitFor(windowInactive, 2000))
|
||||
QSKIP("Dialog didn't activate");
|
||||
|
||||
// This should destroy the dialog and close the native window
|
||||
child->deleteLater();
|
||||
QTRY_VERIFY(!dialog);
|
||||
// If the native window is still open, then the transient parent can't become
|
||||
// active
|
||||
window.activateWindow();
|
||||
QVERIFY(QTest::qWaitFor(windowActive));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMessageBox)
|
||||
#include "tst_qmessagebox.moc"
|
||||
|
@ -565,9 +565,9 @@ void tst_QWizard::addPage()
|
||||
|
||||
#define CHECK_VISITED(wizard, list) \
|
||||
do { \
|
||||
QList<int> myList = list; \
|
||||
const QList<int> myList = list; \
|
||||
QCOMPARE((wizard).visitedIds(), myList); \
|
||||
Q_FOREACH(int id, myList) \
|
||||
for (int id : myList) \
|
||||
QVERIFY((wizard).hasVisitedPage(id)); \
|
||||
} while (0)
|
||||
|
||||
@ -1642,7 +1642,7 @@ class OptionInfo
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
QMap<QWizard::WizardOption, QSharedPointer<Operation> > operations_;
|
||||
foreach (QWizard::WizardOption option, tags.keys())
|
||||
for (const auto &[option, _] : std::as_const(tags).asKeyValueRange())
|
||||
operations_[option] = SetOption::create(option, i == 1);
|
||||
operations << operations_;
|
||||
}
|
||||
@ -1785,7 +1785,7 @@ public:
|
||||
|
||||
~TestWizard()
|
||||
{
|
||||
foreach (int id, pageIds) {
|
||||
for (int id : std::as_const(pageIds)) {
|
||||
QWizardPage *page_to_delete = page(id);
|
||||
removePage(id);
|
||||
delete page_to_delete;
|
||||
@ -1794,7 +1794,7 @@ public:
|
||||
|
||||
void applyOperations(const QList<QSharedPointer<Operation>> &operations)
|
||||
{
|
||||
foreach (const QSharedPointer<Operation> &op, operations) {
|
||||
for (const QSharedPointer<Operation> &op : operations) {
|
||||
if (op) {
|
||||
op->apply(this);
|
||||
opsDescr += QLatin1Char('(') + op->describe() + QLatin1String(") ");
|
||||
@ -1814,8 +1814,16 @@ public:
|
||||
class CombinationsTestData
|
||||
{
|
||||
TestGroup testGroup;
|
||||
QList<QSharedPointer<Operation>> pageOps;
|
||||
QList<QSharedPointer<Operation>> styleOps;
|
||||
const QSharedPointer<Operation> pageOps[3] = {
|
||||
SetPage::create(0),
|
||||
SetPage::create(1),
|
||||
SetPage::create(2),
|
||||
};
|
||||
const QSharedPointer<Operation> styleOps[3] = {
|
||||
SetStyle::create(QWizard::ClassicStyle),
|
||||
SetStyle::create(QWizard::ModernStyle),
|
||||
SetStyle::create(QWizard::MacStyle),
|
||||
};
|
||||
QMap<bool, QList<QSharedPointer<Operation>>> setAllOptions;
|
||||
|
||||
public:
|
||||
@ -1824,15 +1832,13 @@ public:
|
||||
QTest::addColumn<bool>("ref");
|
||||
QTest::addColumn<bool>("testEquality");
|
||||
QTest::addColumn<QList<QSharedPointer<Operation>>>("operations");
|
||||
pageOps << SetPage::create(0) << SetPage::create(1) << SetPage::create(2);
|
||||
styleOps << SetStyle::create(QWizard::ClassicStyle) << SetStyle::create(QWizard::ModernStyle)
|
||||
<< SetStyle::create(QWizard::MacStyle);
|
||||
#define SETPAGE(page) pageOps.at(page)
|
||||
#define SETSTYLE(style) styleOps.at(style)
|
||||
#define SETPAGE(page) pageOps[page]
|
||||
#define SETSTYLE(style) styleOps[style]
|
||||
#define OPT(option, on) OptionInfo::instance().operation(option, on)
|
||||
#define CLROPT(option) OPT(option, false)
|
||||
#define SETOPT(option) OPT(option, true)
|
||||
foreach (QWizard::WizardOption option, OptionInfo::instance().options()) {
|
||||
const auto options = OptionInfo::instance().options();
|
||||
for (QWizard::WizardOption option : options) {
|
||||
setAllOptions[false] << CLROPT(option);
|
||||
setAllOptions[true] << SETOPT(option);
|
||||
}
|
||||
@ -1906,7 +1912,7 @@ public:
|
||||
testGroup.createTestRows();
|
||||
}
|
||||
|
||||
foreach (const QSharedPointer<Operation> &pageOp, pageOps) {
|
||||
for (const QSharedPointer<Operation> &pageOp : pageOps) {
|
||||
testGroup.reset("testAll 4.1");
|
||||
testGroup.add() << pageOp;
|
||||
testGroup.add() << pageOp << pageOp;
|
||||
@ -1919,7 +1925,8 @@ public:
|
||||
testGroup.add() << pageOp << optionOps;
|
||||
testGroup.createTestRows();
|
||||
|
||||
foreach (QWizard::WizardOption option, OptionInfo::instance().options()) {
|
||||
const auto options = OptionInfo::instance().options();
|
||||
for (QWizard::WizardOption option : options) {
|
||||
QSharedPointer<Operation> optionOp = OPT(option, i == 1);
|
||||
testGroup.reset("testAll 4.3");
|
||||
testGroup.add() << optionOp << pageOp;
|
||||
@ -1929,7 +1936,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const QSharedPointer<Operation> &styleOp, styleOps) {
|
||||
for (const QSharedPointer<Operation> &styleOp : styleOps) {
|
||||
testGroup.reset("testAll 5.1");
|
||||
testGroup.add() << styleOp;
|
||||
testGroup.add() << styleOp << styleOp;
|
||||
@ -1942,7 +1949,8 @@ public:
|
||||
testGroup.add() << styleOp << optionOps;
|
||||
testGroup.createTestRows();
|
||||
|
||||
foreach (QWizard::WizardOption option, OptionInfo::instance().options()) {
|
||||
const auto options = OptionInfo::instance().options();
|
||||
for (QWizard::WizardOption option : options) {
|
||||
QSharedPointer<Operation> optionOp = OPT(option, i == 1);
|
||||
testGroup.reset("testAll 5.3");
|
||||
testGroup.add() << optionOp << styleOp;
|
||||
@ -1952,8 +1960,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const QSharedPointer<Operation> &pageOp, pageOps) {
|
||||
foreach (const QSharedPointer<Operation> &styleOp, styleOps) {
|
||||
for (const QSharedPointer<Operation> &pageOp : pageOps) {
|
||||
for (const QSharedPointer<Operation> &styleOp : styleOps) {
|
||||
|
||||
testGroup.reset("testAll 6.1");
|
||||
testGroup.add() << pageOp;
|
||||
@ -1981,7 +1989,8 @@ public:
|
||||
testGroup.add() << styleOp << pageOp << optionOps;
|
||||
testGroup.createTestRows();
|
||||
|
||||
foreach (QWizard::WizardOption option, OptionInfo::instance().options()) {
|
||||
const auto options = OptionInfo::instance().options();
|
||||
for (QWizard::WizardOption option : options) {
|
||||
QSharedPointer<Operation> optionOp = OPT(option, i == 1);
|
||||
testGroup.reset("testAll 6.5");
|
||||
testGroup.add() << optionOp << pageOp << styleOp;
|
||||
@ -2044,7 +2053,7 @@ void tst_QWizard::combinations()
|
||||
{
|
||||
QFETCH(bool, ref);
|
||||
QFETCH(bool, testEquality);
|
||||
QFETCH(QList<QSharedPointer<Operation>>, operations);
|
||||
QFETCH(const QList<QSharedPointer<Operation>>, operations);
|
||||
|
||||
TestWizard wizard;
|
||||
#if !defined(QT_NO_STYLE_WINDOWSVISTA)
|
||||
@ -2113,7 +2122,7 @@ public:
|
||||
QList<WizardPage *> shown() const
|
||||
{
|
||||
QList<WizardPage *> result;
|
||||
foreach (WizardPage *page, pages)
|
||||
for (WizardPage *page : pages)
|
||||
if (page->shown())
|
||||
result << page;
|
||||
return result;
|
||||
@ -2565,7 +2574,8 @@ void tst_QWizard::task161658_alignments()
|
||||
wizard.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&wizard));
|
||||
|
||||
foreach (QLabel *subtitleLabel, wizard.findChildren<QLabel *>()) {
|
||||
const auto subtitleLabels = wizard.findChildren<QLabel *>();
|
||||
for (QLabel *subtitleLabel : subtitleLabels) {
|
||||
if (subtitleLabel->text().startsWith("SUBTITLE#")) {
|
||||
QCOMPARE(lineEdit1.mapToGlobal(lineEdit1.contentsRect().bottomRight()).x(),
|
||||
subtitleLabel->mapToGlobal(subtitleLabel->contentsRect().bottomRight()).x());
|
||||
|
Reference in New Issue
Block a user