diff options
author | Debao Zhang <hello@debao.me> | 2013-03-27 22:16:32 +0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-27 19:34:22 +0100 |
commit | f6e739d9e3125d3866651b896bdb057f1bfb4da9 (patch) | |
tree | db59223373a94ad38798b3f7c5ea0b27933acf15 /tests/auto/widgets/dialogs | |
parent | 8d009b38c8c1ce3e63cc28190250b766a24774da (diff) |
QtWidgets tests: Replace qFindChild{ren} with QObject::findChild{ren}
Change-Id: I79a26387bcce0d7f79f4f9f70293e97dae52f949
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'tests/auto/widgets/dialogs')
7 files changed, 106 insertions, 106 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index b4042a5857..6d847086d9 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -247,7 +247,7 @@ void tst_QDialog::showMaximized() QDialog dialog(0); dialog.setSizeGripEnabled(true); #ifndef QT_NO_SIZEGRIP - QSizeGrip *sizeGrip = qFindChild<QSizeGrip *>(&dialog); + QSizeGrip *sizeGrip = dialog.findChild<QSizeGrip *>(); QVERIFY(sizeGrip); #endif @@ -324,7 +324,7 @@ void tst_QDialog::showFullScreen() QDialog dialog(0, Qt::X11BypassWindowManagerHint); dialog.setSizeGripEnabled(true); #ifndef QT_NO_SIZEGRIP - QSizeGrip *sizeGrip = qFindChild<QSizeGrip *>(&dialog); + QSizeGrip *sizeGrip = dialog.findChild<QSizeGrip *>(); QVERIFY(sizeGrip); #endif @@ -438,7 +438,7 @@ void tst_QDialog::showSizeGrip() QVERIFY(!dialog.isSizeGripEnabled()); dialog.setSizeGripEnabled(true); - QPointer<QSizeGrip> sizeGrip = qFindChild<QSizeGrip *>(&dialog); + QPointer<QSizeGrip> sizeGrip = dialog.findChild<QSizeGrip *>(); QVERIFY(sizeGrip); QVERIFY(sizeGrip->isVisible()); QVERIFY(dialog.isSizeGripEnabled()); @@ -456,7 +456,7 @@ void tst_QDialog::showSizeGrip() dialog.showExtension(false); QVERIFY(dialog.extension() && !dialog.extension()->isVisible()); QVERIFY(dialog.isSizeGripEnabled()); - sizeGrip = qFindChild<QSizeGrip *>(&dialog); + sizeGrip = dialog.findChild<QSizeGrip *>(); QVERIFY(sizeGrip); QVERIFY(sizeGrip->isVisible()); @@ -474,7 +474,7 @@ void tst_QDialog::showSizeGrip() QVERIFY(!dialog.isSizeGripEnabled()); dialog.setSizeGripEnabled(true); - sizeGrip = qFindChild<QSizeGrip *>(&dialog); + sizeGrip = dialog.findChild<QSizeGrip *>(); QVERIFY(sizeGrip); QVERIFY(sizeGrip->isVisible()); sizeGrip->hide(); diff --git a/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp b/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp index e091267889..cb2aaeea46 100644 --- a/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp +++ b/tests/auto/widgets/dialogs/qerrormessage/tst_qerrormessage.cpp @@ -64,14 +64,14 @@ void tst_QErrorMessage::dontShowAgain() // show an error with plain string errorMessageDialog.showMessage(plainString); QVERIFY(errorMessageDialog.isVisible()); - checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); + checkBox = errorMessageDialog.findChild<QCheckBox*>(); QVERIFY(checkBox); QVERIFY(checkBox->isChecked()); errorMessageDialog.close(); errorMessageDialog.showMessage(plainString); QVERIFY(errorMessageDialog.isVisible()); - checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); + checkBox = errorMessageDialog.findChild<QCheckBox*>(); QVERIFY(checkBox); QVERIFY(checkBox->isChecked()); checkBox->setChecked(false); @@ -83,7 +83,7 @@ void tst_QErrorMessage::dontShowAgain() // show an error with an html string errorMessageDialog.showMessage(htmlString); QVERIFY(errorMessageDialog.isVisible()); - checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); + checkBox = errorMessageDialog.findChild<QCheckBox*>(); QVERIFY(checkBox); QVERIFY(!checkBox->isChecked()); checkBox->setChecked(true); @@ -91,7 +91,7 @@ void tst_QErrorMessage::dontShowAgain() errorMessageDialog.showMessage(htmlString); QVERIFY(errorMessageDialog.isVisible()); - checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); + checkBox = errorMessageDialog.findChild<QCheckBox*>(); QVERIFY(checkBox); QVERIFY(checkBox->isChecked()); checkBox->setChecked(false); @@ -111,7 +111,7 @@ void tst_QErrorMessage::dontShowCategoryAgain() errorMessageDialog.showMessage(htmlString,"Cat 1"); QVERIFY(errorMessageDialog.isVisible()); - checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); + checkBox = errorMessageDialog.findChild<QCheckBox*>(); QVERIFY(checkBox); QVERIFY(checkBox->isChecked()); checkBox->setChecked(true); @@ -119,7 +119,7 @@ void tst_QErrorMessage::dontShowCategoryAgain() errorMessageDialog.showMessage(htmlString,"Cat 1"); QVERIFY(errorMessageDialog.isVisible()); - checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); + checkBox = errorMessageDialog.findChild<QCheckBox*>(); QVERIFY(checkBox); QVERIFY(checkBox->isChecked()); checkBox->setChecked(true); @@ -127,7 +127,7 @@ void tst_QErrorMessage::dontShowCategoryAgain() errorMessageDialog.showMessage(htmlString2,"Cat 1"); QVERIFY(errorMessageDialog.isVisible()); - checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); + checkBox = errorMessageDialog.findChild<QCheckBox*>(); QVERIFY(checkBox); QVERIFY(checkBox->isChecked()); checkBox->setChecked(true); @@ -135,7 +135,7 @@ void tst_QErrorMessage::dontShowCategoryAgain() errorMessageDialog.showMessage(htmlString,"Cat 1"); QVERIFY(errorMessageDialog.isVisible()); - checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); + checkBox = errorMessageDialog.findChild<QCheckBox*>(); QVERIFY(checkBox); QVERIFY(checkBox->isChecked()); checkBox->setChecked(false); diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 5e37c12fbf..d797c553db 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -200,7 +200,7 @@ void tst_QFiledialog::currentChangedSignal() fd.setViewMode(QFileDialog::List); QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); - QListView* listView = qFindChild<QListView*>(&fd, "listView"); + QListView* listView = fd.findChild<QListView*>("listView"); QVERIFY(listView); fd.setDirectory(QDir::root()); QModelIndex root = listView->rootIndex(); @@ -229,14 +229,14 @@ void tst_QFiledialog::directoryEnteredSignal() QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); // sidebar - QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar"); + QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar"); sidebar->setCurrentIndex(sidebar->model()->index(1, 0)); QTest::keyPress(sidebar->viewport(), Qt::Key_Return); QCOMPARE(spyDirectoryEntered.count(), 1); spyDirectoryEntered.clear(); // lookInCombo - QComboBox *comboBox = qFindChild<QComboBox*>(&fd, "lookInCombo"); + QComboBox *comboBox = fd.findChild<QComboBox*>("lookInCombo"); comboBox->showPopup(); QVERIFY(comboBox->view()->model()->index(1, 0).isValid()); comboBox->view()->setCurrentIndex(comboBox->view()->model()->index(1, 0)); @@ -248,7 +248,7 @@ void tst_QFiledialog::directoryEnteredSignal() /* // platform specific fd.setViewMode(QFileDialog::ViewMode(QFileDialog::List)); - QListView* listView = qFindChild<QListView*>(&fd, "listView"); + QListView* listView = fd.findChild<QListView*>("listView"); QVERIFY(listView); QModelIndex root = listView->rootIndex(); QTRY_COMPARE(listView->model()->rowCount(root) > 0, true); @@ -293,7 +293,7 @@ void tst_QFiledialog::filesSelectedSignal() fd.show(); QVERIFY(QTest::qWaitForWindowExposed(&fd)); - QListView *listView = qFindChild<QListView*>(&fd, "listView"); + QListView *listView = fd.findChild<QListView*>("listView"); QVERIFY(listView); QModelIndex root = listView->rootIndex(); @@ -314,7 +314,7 @@ void tst_QFiledialog::filesSelectedSignal() listView->selectionModel()->select(file, QItemSelectionModel::Select | QItemSelectionModel::Rows); listView->setCurrentIndex(file); - QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Open); QVERIFY(button); QVERIFY(button->isEnabled()); @@ -338,7 +338,7 @@ void tst_QFiledialog::filterSelectedSignal() fd.setNameFilters(filterChoices); QCOMPARE(fd.nameFilters(), filterChoices); - QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); + QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo"); QVERIFY(filters); QVERIFY(filters->view()); QCOMPARE(filters->isVisible(), true); @@ -367,7 +367,7 @@ void tst_QFiledialog::directory() { QNonNativeFileDialog fd; fd.setViewMode(QFileDialog::List); - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); fd.setDirectory(QDir::currentPath()); QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); @@ -392,7 +392,7 @@ void tst_QFiledialog::directory() QCOMPARE(spyFilterSelected.count(), 0); // Check my way - QList<QListView*> list = qFindChildren<QListView*>(&fd, "listView"); + QList<QListView*> list = fd.findChildren<QListView*>("listView"); QVERIFY(list.count() > 0); #ifdef Q_OS_WIN QCOMPARE(list.at(0)->rootIndex().data().toString().toLower(), temp.dirName().toLower()); @@ -476,9 +476,9 @@ void tst_QFiledialog::completer() fd.show(); QVERIFY(QTest::qWaitForWindowExposed(&fd)); QVERIFY(fd.isVisible()); - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); - QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); QCompleter *completer = lineEdit->completer(); QVERIFY(completer); @@ -567,7 +567,7 @@ void tst_QFiledialog::completer_up() QSignalSpy spyFilterSelected(&fd, SIGNAL(filterSelected(QString))); fd.show(); - QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); QCOMPARE(spyFilesSelected.count(), 0); int depth = QDir::currentPath().split('/').count(); @@ -586,7 +586,7 @@ void tst_QFiledialog::acceptMode() QNonNativeFileDialog fd; fd.show(); - QToolButton* newButton = qFindChild<QToolButton*>(&fd, "newFolderButton"); + QToolButton* newButton = fd.findChild<QToolButton*>("newFolderButton"); QVERIFY(newButton); // default @@ -658,7 +658,7 @@ void tst_QFiledialog::filters() QCOMPARE(fd.nameFilters(), QStringList("All Files (*)")); // effects - QList<QComboBox*> views = qFindChildren<QComboBox*>(&fd, "fileTypeCombo"); + QList<QComboBox*> views = fd.findChildren<QComboBox*>("fileTypeCombo"); QVERIFY(views.count() == 1); QCOMPARE(views.at(0)->isVisible(), false); @@ -728,7 +728,7 @@ void tst_QFiledialog::history() { QNonNativeFileDialog fd; fd.setViewMode(QFileDialog::List); - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); @@ -744,7 +744,7 @@ void tst_QFiledialog::history() if (fd.history() != history) { qDebug() << fd.history() << history; // quick and dirty output for windows failure. - QListView* list = qFindChild<QListView*>(&fd, "listView"); + QListView* list = fd.findChild<QListView*>("listView"); QVERIFY(list); QModelIndex root = list->rootIndex(); while (root.isValid()) { @@ -781,9 +781,9 @@ void tst_QFiledialog::isReadOnly() { QNonNativeFileDialog fd; - QPushButton* newButton = qFindChild<QPushButton*>(&fd, "newFolderButton"); - QAction* renameAction = qFindChild<QAction*>(&fd, "qt_rename_action"); - QAction* deleteAction = qFindChild<QAction*>(&fd, "qt_delete_action"); + QPushButton* newButton = fd.findChild<QPushButton*>("newFolderButton"); + QAction* renameAction = fd.findChild<QAction*>("qt_rename_action"); + QAction* deleteAction = fd.findChild<QAction*>("qt_delete_action"); QCOMPARE(fd.isReadOnly(), false); @@ -862,7 +862,7 @@ void tst_QFiledialog::selectFile() QFETCH(QString, file); QFETCH(int, count); QNonNativeFileDialog fd; - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); fd.setDirectory(QDir::currentPath()); // default value @@ -912,7 +912,7 @@ void tst_QFiledialog::selectFiles() QStringList list = fd.directory().entryList(QDir::Files); QModelIndexList toSelect; QVERIFY(list.count() > 1); - QListView* listView = qFindChild<QListView*>(&fd, "listView"); + QListView* listView = fd.findChild<QListView*>("listView"); QVERIFY(listView); for (int i = 0; i < list.count(); ++i) { fd.selectFile(fd.directory().path() + "/" + list.at(i)); @@ -945,7 +945,7 @@ void tst_QFiledialog::selectFiles() dialog->selectFile(temporary); dialog->show(); QVERIFY(QTest::qWaitForWindowExposed(dialog)); - QLineEdit *lineEdit = qFindChild<QLineEdit*>(dialog, "fileNameEdit"); + QLineEdit *lineEdit = dialog->findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); QCOMPARE(lineEdit->text(),QLatin1String("blah")); delete dialog; @@ -958,13 +958,13 @@ void tst_QFiledialog::viewMode() fd.show(); // find widgets - QList<QTreeView*> treeView = qFindChildren<QTreeView*>(&fd, "treeView"); + QList<QTreeView*> treeView = fd.findChildren<QTreeView*>("treeView"); QCOMPARE(treeView.count(), 1); - QList<QListView*> listView = qFindChildren<QListView*>(&fd, "listView"); + QList<QListView*> listView = fd.findChildren<QListView*>("listView"); QCOMPARE(listView.count(), 1); - QList<QToolButton*> listButton = qFindChildren<QToolButton*>(&fd, "listModeButton"); + QList<QToolButton*> listButton = fd.findChildren<QToolButton*>("listModeButton"); QCOMPARE(listButton.count(), 1); - QList<QToolButton*> treeButton = qFindChildren<QToolButton*>(&fd, "detailModeButton"); + QList<QToolButton*> treeButton = fd.findChildren<QToolButton*>("detailModeButton"); QCOMPARE(treeButton.count(), 1); // default value @@ -1069,7 +1069,7 @@ void tst_QFiledialog::focus() // make sure the tests work with focus follows mouse QCursor::setPos(fd.geometry().center()); - QList<QWidget*> treeView = qFindChildren<QWidget*>(&fd, "fileNameEdit"); + QList<QWidget*> treeView = fd.findChildren<QWidget*>("fileNameEdit"); QCOMPARE(treeView.count(), 1); QVERIFY(treeView.at(0)); QTRY_COMPARE(treeView.at(0)->hasFocus(), true); @@ -1080,11 +1080,11 @@ void tst_QFiledialog::focus() void tst_QFiledialog::historyBack() { QNonNativeFileDialog fd; - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); - QToolButton *backButton = qFindChild<QToolButton*>(&fd, "backButton"); + QToolButton *backButton = fd.findChild<QToolButton*>("backButton"); QVERIFY(backButton); - QToolButton *forwardButton = qFindChild<QToolButton*>(&fd, "forwardButton"); + QToolButton *forwardButton = fd.findChild<QToolButton*>("forwardButton"); QVERIFY(forwardButton); QSignalSpy spy(model, SIGNAL(rootPathChanged(QString))); @@ -1128,12 +1128,12 @@ void tst_QFiledialog::historyForward() { QNonNativeFileDialog fd; fd.setDirectory(QDir::currentPath()); - QToolButton *backButton = qFindChild<QToolButton*>(&fd, "backButton"); + QToolButton *backButton = fd.findChild<QToolButton*>("backButton"); QVERIFY(backButton); - QToolButton *forwardButton = qFindChild<QToolButton*>(&fd, "forwardButton"); + QToolButton *forwardButton = fd.findChild<QToolButton*>("forwardButton"); QVERIFY(forwardButton); - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); QSignalSpy spy(model, SIGNAL(rootPathChanged(QString))); @@ -1204,7 +1204,7 @@ void tst_QFiledialog::disableSaveButton() QNonNativeFileDialog fd(0, "caption", path); fd.setAcceptMode(QFileDialog::AcceptSave); - QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Save); QVERIFY(button); QCOMPARE(button->isEnabled(), isEnabled); @@ -1235,7 +1235,7 @@ void tst_QFiledialog::saveButtonText() fd.setLabelText(QFileDialog::Accept, label); fd.setDirectory(QDir::temp()); fd.selectFile(path); - QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QVERIFY(buttonBox); QPushButton *button = buttonBox->button(QDialogButtonBox::Save); QVERIFY(button); @@ -1253,12 +1253,12 @@ void tst_QFiledialog::clearLineEdit() //play it really safe by creating a directory QDir::home().mkdir("_____aaaaaaaaaaaaaaaaaaaaaa"); - QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); QVERIFY(lineEdit->text() == "foo"); fd.setDirectory(QDir::home()); - QListView* list = qFindChild<QListView*>(&fd, "listView"); + QListView* list = fd.findChild<QListView*>("listView"); QVERIFY(list); // saving a file the text shouldn't be cleared @@ -1308,7 +1308,7 @@ void tst_QFiledialog::enableChooseButton() QNonNativeFileDialog fd; fd.setFileMode(QFileDialog::Directory); fd.show(); - QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Open); QVERIFY(button); QCOMPARE(button->isEnabled(), true); diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 018021ddac..98b096031e 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -257,7 +257,7 @@ void tst_QFileDialog2::deleteDirAndFiles() void tst_QFileDialog2::filter() { QNonNativeFileDialog fd; - QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action"); + QAction *hiddenAction = fd.findChild<QAction*>("qt_show_hidden_action"); QVERIFY(hiddenAction); QVERIFY(hiddenAction->isEnabled()); QVERIFY(!hiddenAction->isChecked()); @@ -270,7 +270,7 @@ void tst_QFileDialog2::filter() void tst_QFileDialog2::showNameFilterDetails() { QNonNativeFileDialog fd; - QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); + QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo"); QVERIFY(filters); QVERIFY(fd.isNameFilterDetailsVisible()); @@ -302,7 +302,7 @@ void tst_QFileDialog2::unc() #endif QVERIFY(QFile::exists(dir)); QNonNativeFileDialog fd(0, QString(), dir); - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir)); } @@ -311,12 +311,12 @@ void tst_QFileDialog2::emptyUncPath() { QNonNativeFileDialog fd; fd.show(); - QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); // press 'keys' for the input for (int i = 0; i < 3 ; ++i) QTest::keyPress(lineEdit, Qt::Key_Backslash); - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); } @@ -327,7 +327,7 @@ struct MenuCloser : public QObject { void close() { - QMenu *menu = qFindChild<QMenu*>(w); + QMenu *menu = w->findChild<QMenu*>(); if (!menu) { qDebug("%s: cannot find file dialog child of type QMenu", Q_FUNC_INFO); w->close(); @@ -337,7 +337,7 @@ struct MenuCloser : public QObject { }; static bool openContextMenu(QFileDialog &fd) { - QListView *list = qFindChild<QListView*>(&fd, "listView"); + QListView *list = fd.findChild<QListView*>("listView"); if (!list) { qDebug("%s: didn't find file dialog child \"listView\"", Q_FUNC_INFO); return false; @@ -386,9 +386,9 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() QTest::qWaitForWindowActive(&fd); // grab some internals: - QAction *rm = qFindChild<QAction*>(&fd, "qt_delete_action"); + QAction *rm = fd.findChild<QAction*>("qt_delete_action"); QVERIFY(rm); - QAction *mv = qFindChild<QAction*>(&fd, "qt_rename_action"); + QAction *mv = fd.findChild<QAction*>("qt_rename_action"); QVERIFY(mv); // these are the real test cases: @@ -458,7 +458,7 @@ void tst_QFileDialog2::task180459_lastDirectory() { //first visit the temp directory and close the dialog QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", tempDir.path()); - QFileSystemModel *model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model"); + QFileSystemModel *model = dlg->findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); QCOMPARE(model->index(tempDir.path()), model->index(dlg->directory().absolutePath())); delete dlg; @@ -469,12 +469,12 @@ void tst_QFileDialog2::task180459_lastDirectory() QFETCH(QString, result); dlg = new QNonNativeFileDialog(0, "", path); - model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model"); + model = dlg->findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); dlg->setAcceptMode(QFileDialog::AcceptSave); QCOMPARE(model->index(dlg->directory().absolutePath()), model->index(directory)); - QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(dlg, "buttonBox"); + QDialogButtonBox *buttonBox = dlg->findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Save); QVERIFY(button); QCOMPARE(button->isEnabled(), isEnabled); @@ -564,7 +564,7 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog() QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0); fd.setProxyModel(new FilterDirModel(QDir::currentPath())); fd.show(); - QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit"); QTest::qWait(200); QTest::keyClick(edit, Qt::Key_T); QTest::keyClick(edit, Qt::Key_S); @@ -575,7 +575,7 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog() dialog->setFileMode(QFileDialog::ExistingFile); dialog->show(); - QListView *list = qFindChild<QListView*>(dialog, "listView"); + QListView *list = dialog->findChild<QListView*>("listView"); QTest::qWait(200); QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Return); @@ -588,7 +588,7 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog() QSortFilterProxyModel *pm = new QSortFilterProxyModel; fd2.setProxyModel(pm); fd2.show(); - QSidebar *sidebar = qFindChild<QSidebar*>(&fd2, "sidebar"); + QSidebar *sidebar = fd2.findChild<QSidebar*>("sidebar"); sidebar->setFocus(); sidebar->selectUrl(QUrl::fromLocalFile(QDir::homePath())); QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center()); @@ -616,7 +616,7 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() fd.setViewMode(QFileDialog::List); fd.setDirectory(current.absolutePath()); fd.show(); - QListView *list = qFindChild<QListView*>(&fd, "listView"); + QListView *list = fd.findChild<QListView*>("listView"); QTest::qWait(200); QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Return); @@ -646,8 +646,8 @@ void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() QNonNativeFileDialog fd; fd.setDirectory(QDir::root().path()); fd.show(); - QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); - QToolButton *buttonParent = qFindChild<QToolButton*>(&fd, "toParentButton"); + QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit"); + QToolButton *buttonParent = fd.findChild<QToolButton*>("toParentButton"); QTest::qWait(200); QTest::mouseClick(buttonParent, Qt::LeftButton,0,QPoint(0,0)); QTest::qWait(2000); @@ -712,7 +712,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot() QSKIP("This test requires to have an etc directory under /"); #endif fd.show(); - QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit"); QTest::qWait(2000); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) //I love testlib :D @@ -741,14 +741,14 @@ void tst_QFileDialog2::task233037_selectingDirectory() fd.setDirectory(current.absolutePath()); fd.setAcceptMode( QFileDialog::AcceptSave); fd.show(); - QListView *list = qFindChild<QListView*>(&fd, "listView"); + QListView *list = fd.findChild<QListView*>("listView"); QTest::qWait(3000); // Wait for sort to settle (I need a signal). #ifdef QT_KEYPAD_NAVIGATION list->setEditFocus(true); #endif QTest::keyClick(list, Qt::Key_Down); QTest::qWait(100); - QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Save); QVERIFY(button); QCOMPARE(button->isEnabled(), true); @@ -763,7 +763,7 @@ void tst_QFileDialog2::task235069_hideOnEscape() fd.setDirectory(current.absolutePath()); fd.setAcceptMode( QFileDialog::AcceptSave); fd.show(); - QListView *list = qFindChild<QListView*>(&fd, "listView"); + QListView *list = fd.findChild<QListView*>("listView"); list->setFocus(); QTest::qWait(200); QTest::keyClick(list, Qt::Key_Escape); @@ -772,7 +772,7 @@ void tst_QFileDialog2::task235069_hideOnEscape() fd2.setDirectory(current.absolutePath()); fd2.setAcceptMode( QFileDialog::AcceptSave); fd2.show(); - QLineEdit *edit = qFindChild<QLineEdit*>(&fd2, "fileNameEdit"); + QLineEdit *edit = fd2.findChild<QLineEdit*>("fileNameEdit"); QTest::keyClick(edit, Qt::Key_Escape); QCOMPARE(fd2.isVisible(), false); } @@ -789,7 +789,7 @@ void tst_QFileDialog2::task236402_dontWatchDeletedDir() fd.setDirectory(current.absolutePath()); fd.setAcceptMode( QFileDialog::AcceptSave); fd.show(); - QListView *list = qFindChild<QListView*>(&fd, "listView"); + QListView *list = fd.findChild<QListView*>("listView"); list->setFocus(); QTest::qWait(200); QTest::keyClick(list, Qt::Key_Return); @@ -812,12 +812,12 @@ void tst_QFileDialog2::task203703_returnProperSeparator() fd.setFileMode(QFileDialog::Directory); fd.show(); QTest::qWait(500); - QListView *list = qFindChild<QListView*>(&fd, "listView"); + QListView *list = fd.findChild<QListView*>("listView"); list->setFocus(); QTest::qWait(200); QTest::keyClick(list, Qt::Key_Return); QTest::qWait(1000); - QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel); QTest::keyClick(button, Qt::Key_Return); QTest::qWait(500); @@ -852,10 +852,10 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting() #else QTest::qWait(500); #endif - QTreeView *tree = qFindChild<QTreeView*>(&fd, "treeView"); + QTreeView *tree = fd.findChild<QTreeView*>("treeView"); tree->header()->setSortIndicator(3,Qt::DescendingOrder); QTest::qWait(200); - QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Open); QTest::mouseClick(button, Qt::LeftButton); #if defined(Q_OS_WINCE) @@ -874,12 +874,12 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting() #else QTest::qWait(500); #endif - QTreeView *tree2 = qFindChild<QTreeView*>(&fd2, "treeView"); + QTreeView *tree2 = fd2.findChild<QTreeView*>("treeView"); tree2->setFocus(); QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath()); - QDialogButtonBox *buttonBox2 = qFindChild<QDialogButtonBox*>(&fd2, "buttonBox"); + QDialogButtonBox *buttonBox2 = fd2.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open); fd2.selectFile("g"); QTest::mouseClick(button2, Qt::LeftButton); @@ -899,12 +899,12 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting() #else QTest::qWait(500); #endif - QTreeView *tree3 = qFindChild<QTreeView*>(&fd3, "treeView"); + QTreeView *tree3 = fd3.findChild<QTreeView*>("treeView"); tree3->setFocus(); QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath()); - QDialogButtonBox *buttonBox3 = qFindChild<QDialogButtonBox*>(&fd3, "buttonBox"); + QDialogButtonBox *buttonBox3 = fd3.findChild<QDialogButtonBox*>("buttonBox"); QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open); QTest::mouseClick(button3, Qt::LeftButton); #if defined(Q_OS_WINCE) @@ -988,7 +988,7 @@ void tst_QFileDialog2::task251321_sideBarHiddenEntries() fd.show(); QTest::qWait(250); - QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar"); + QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar"); sidebar->setFocus(); sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath())); QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center()); @@ -999,7 +999,7 @@ void tst_QFileDialog2::task251321_sideBarHiddenEntries() QTest::qWait(250); #endif - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QCOMPARE(model->rowCount(model->index(hiddenSubDir.absolutePath())), 2); hiddenSubDir.rmdir("happy2"); @@ -1045,14 +1045,14 @@ void tst_QFileDialog2::task251341_sideBarRemoveEntries() fd.show(); QTest::qWait(250); - QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar"); + QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar"); sidebar->setFocus(); //We enter in the first bookmark sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath())); QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center()); QTest::qWait(250); - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); //There is no file QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0); //Icon is not enabled QUrlModel::EnabledRole @@ -1116,10 +1116,10 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes() fd.show(); QTest::qWait(250); - QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); QCOMPARE(lineEdit->text(),QLatin1String("new_file.txt")); - QListView *list = qFindChild<QListView*>(&fd, "listView"); + QListView *list = fd.findChild<QListView*>("listView"); QVERIFY(list); QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0); @@ -1136,7 +1136,7 @@ void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls() QString url = QString::fromLatin1("%1/%2/..").arg(dir.absolutePath()).arg(dirname); QNonNativeFileDialog fd; fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url)); - QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar"); + QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar"); QCOMPARE(sidebar->urls().count(), 1); QVERIFY(sidebar->urls().first().toLocalFile() != url); QCOMPARE(sidebar->urls().first().toLocalFile(), QDir::cleanPath(url)); @@ -1161,7 +1161,7 @@ void tst_QFileDialog2::task259105_filtersCornerCases() QTest::qWait(250); //Extensions are hidden - QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); + QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo"); QVERIFY(filters); QCOMPARE(filters->currentText(), QLatin1String("All Files!")); filters->setCurrentIndex(1); @@ -1215,7 +1215,7 @@ void tst_QFileDialog2::QTBUG4419_lineEditSelectAll() QCOMPARE(fd.isVisible(), true); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); - QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); QTRY_COMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName()); @@ -1258,7 +1258,7 @@ void tst_QFileDialog2::QTBUG6558_showDirsOnly() QCOMPARE(fd.isVisible(), true); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); - QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); fd.setOption(QFileDialog::ShowDirsOnly, false); @@ -1306,7 +1306,7 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() QCOMPARE(fd.isVisible(), true); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); - QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); + QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo"); //We compare the current combobox text with the stripped version QCOMPARE(filters->currentText(), QString("Text files")); @@ -1322,7 +1322,7 @@ void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() QCOMPARE(fd2.isVisible(), true); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd2)); - QComboBox *filters2 = qFindChild<QComboBox*>(&fd2, "fileTypeCombo"); + QComboBox *filters2 = fd2.findChild<QComboBox*>("fileTypeCombo"); //We compare the current combobox text with the non stripped version QCOMPARE(filters2->currentText(), chosenFilterString); @@ -1340,7 +1340,7 @@ void tst_QFileDialog2::dontShowCompleterOnRoot() QCOMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); fd.setDirectory(""); - QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QTRY_VERIFY(lineEdit->text().isEmpty()); //The gatherer thread will then return the result diff --git a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp index 581696c509..7d8077d77d 100644 --- a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp +++ b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp @@ -153,13 +153,13 @@ void testInvalidateAndRestore( template <typename SpinBoxType, typename ValueType> void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0) { - SpinBoxType *sbox = qFindChild<SpinBoxType *>(dialog); + SpinBoxType *sbox = dialog->findChild<SpinBoxType *>(); QVERIFY(sbox != 0); - QLineEdit *ledit = qFindChild<QLineEdit *>(static_cast<QObject *>(sbox)); + QLineEdit *ledit = static_cast<QObject *>(sbox)->findChild<QLineEdit *>(); QVERIFY(ledit != 0); - QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog); + QDialogButtonBox *bbox = dialog->findChild<QDialogButtonBox *>(); QVERIFY(bbox != 0); QPushButton *okButton = bbox->button(QDialogButtonBox::Ok); QVERIFY(okButton != 0); @@ -189,10 +189,10 @@ void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0) void testGetText(QInputDialog *dialog) { - QLineEdit *ledit = qFindChild<QLineEdit *>(dialog); + QLineEdit *ledit = dialog->findChild<QLineEdit *>(); QVERIFY(ledit); - QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog); + QDialogButtonBox *bbox = dialog->findChild<QDialogButtonBox *>(); QVERIFY(bbox); QPushButton *okButton = bbox->button(QDialogButtonBox::Ok); QVERIFY(okButton); @@ -207,10 +207,10 @@ void testGetText(QInputDialog *dialog) void testGetItem(QInputDialog *dialog) { - QComboBox *cbox = qFindChild<QComboBox *>(dialog); + QComboBox *cbox = dialog->findChild<QComboBox *>(); QVERIFY(cbox); - QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog); + QDialogButtonBox *bbox = dialog->findChild<QDialogButtonBox *>(); QVERIFY(bbox); QPushButton *okButton = bbox->button(QDialogButtonBox::Ok); QVERIFY(okButton); @@ -245,7 +245,7 @@ void tst_QInputDialog::testFuncGetItem(QInputDialog *dialog) void tst_QInputDialog::timerEvent(QTimerEvent *event) { killTimer(event->timerId()); - QInputDialog *dialog = qFindChild<QInputDialog *>(parent); + QInputDialog *dialog = parent->findChild<QInputDialog *>(); QVERIFY(dialog); if (testFunc) testFunc(dialog); diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp index 09f115a489..d49f356d8c 100644 --- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp +++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp @@ -141,7 +141,7 @@ void tst_QProgressDialog::task198202() QProgressDialog dlg(QLatin1String("test"),QLatin1String("test"),1,10); dlg.show(); QVERIFY(QTest::qWaitForWindowExposed(&dlg)); - int futureHeight = dlg.sizeHint().height() - qFindChild<QLabel*>(&dlg)->sizeHint().height(); + int futureHeight = dlg.sizeHint().height() - dlg.findChild<QLabel*>()->sizeHint().height(); dlg.setLabel(0); QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setBar: Cannot set a null progress bar"); dlg.setBar(0); diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index ae5853f3c8..c3fc050275 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -2518,7 +2518,7 @@ void tst_QWizard::task161658_alignments() wizard.show(); QVERIFY(QTest::qWaitForWindowExposed(&wizard)); - foreach (QLabel *subtitleLabel, qFindChildren<QLabel *>(&wizard)) { + foreach (QLabel *subtitleLabel, wizard.findChildren<QLabel *>()) { if (subtitleLabel->text().startsWith("SUBTITLE#")) { QCOMPARE(lineEdit1.mapToGlobal(lineEdit1.contentsRect().bottomRight()).x(), subtitleLabel->mapToGlobal(subtitleLabel->contentsRect().bottomRight()).x()); |