From f6e739d9e3125d3866651b896bdb057f1bfb4da9 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Wed, 27 Mar 2013 22:16:32 +0800 Subject: QtWidgets tests: Replace qFindChild{ren} with QObject::findChild{ren} Change-Id: I79a26387bcce0d7f79f4f9f70293e97dae52f949 Reviewed-by: Friedemann Kleint --- .../dialogs/qfiledialog/tst_qfiledialog.cpp | 76 +++++++++++----------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp') 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(&fd, "listView"); + QListView* listView = fd.findChild("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(&fd, "sidebar"); + QSidebar *sidebar = fd.findChild("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(&fd, "lookInCombo"); + QComboBox *comboBox = fd.findChild("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(&fd, "listView"); + QListView* listView = fd.findChild("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(&fd, "listView"); + QListView *listView = fd.findChild("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(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild("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(&fd, "fileTypeCombo"); + QComboBox *filters = fd.findChild("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(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild("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 list = qFindChildren(&fd, "listView"); + QList list = fd.findChildren("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(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild("qt_filesystem_model"); QVERIFY(model); - QLineEdit *lineEdit = qFindChild(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild("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(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild("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(&fd, "newFolderButton"); + QToolButton* newButton = fd.findChild("newFolderButton"); QVERIFY(newButton); // default @@ -658,7 +658,7 @@ void tst_QFiledialog::filters() QCOMPARE(fd.nameFilters(), QStringList("All Files (*)")); // effects - QList views = qFindChildren(&fd, "fileTypeCombo"); + QList views = fd.findChildren("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(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild("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(&fd, "listView"); + QListView* list = fd.findChild("listView"); QVERIFY(list); QModelIndex root = list->rootIndex(); while (root.isValid()) { @@ -781,9 +781,9 @@ void tst_QFiledialog::isReadOnly() { QNonNativeFileDialog fd; - QPushButton* newButton = qFindChild(&fd, "newFolderButton"); - QAction* renameAction = qFindChild(&fd, "qt_rename_action"); - QAction* deleteAction = qFindChild(&fd, "qt_delete_action"); + QPushButton* newButton = fd.findChild("newFolderButton"); + QAction* renameAction = fd.findChild("qt_rename_action"); + QAction* deleteAction = fd.findChild("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(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild("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(&fd, "listView"); + QListView* listView = fd.findChild("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(dialog, "fileNameEdit"); + QLineEdit *lineEdit = dialog->findChild("fileNameEdit"); QVERIFY(lineEdit); QCOMPARE(lineEdit->text(),QLatin1String("blah")); delete dialog; @@ -958,13 +958,13 @@ void tst_QFiledialog::viewMode() fd.show(); // find widgets - QList treeView = qFindChildren(&fd, "treeView"); + QList treeView = fd.findChildren("treeView"); QCOMPARE(treeView.count(), 1); - QList listView = qFindChildren(&fd, "listView"); + QList listView = fd.findChildren("listView"); QCOMPARE(listView.count(), 1); - QList listButton = qFindChildren(&fd, "listModeButton"); + QList listButton = fd.findChildren("listModeButton"); QCOMPARE(listButton.count(), 1); - QList treeButton = qFindChildren(&fd, "detailModeButton"); + QList treeButton = fd.findChildren("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 treeView = qFindChildren(&fd, "fileNameEdit"); + QList treeView = fd.findChildren("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(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild("qt_filesystem_model"); QVERIFY(model); - QToolButton *backButton = qFindChild(&fd, "backButton"); + QToolButton *backButton = fd.findChild("backButton"); QVERIFY(backButton); - QToolButton *forwardButton = qFindChild(&fd, "forwardButton"); + QToolButton *forwardButton = fd.findChild("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(&fd, "backButton"); + QToolButton *backButton = fd.findChild("backButton"); QVERIFY(backButton); - QToolButton *forwardButton = qFindChild(&fd, "forwardButton"); + QToolButton *forwardButton = fd.findChild("forwardButton"); QVERIFY(forwardButton); - QFileSystemModel *model = qFindChild(&fd, "qt_filesystem_model"); + QFileSystemModel *model = fd.findChild("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(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild("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(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild("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(&fd, "fileNameEdit"); + QLineEdit *lineEdit = fd.findChild("fileNameEdit"); QVERIFY(lineEdit); QVERIFY(lineEdit->text() == "foo"); fd.setDirectory(QDir::home()); - QListView* list = qFindChild(&fd, "listView"); + QListView* list = fd.findChild("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(&fd, "buttonBox"); + QDialogButtonBox *buttonBox = fd.findChild("buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Open); QVERIFY(button); QCOMPARE(button->isEnabled(), true); -- cgit v1.2.3