diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-04-20 16:30:01 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-04-20 16:30:01 (GMT) |
commit | 4708acb70e1e71bf22e85f7335dcaf1401aba3bb (patch) | |
tree | 36043e3def5d50dde51846dea44e376e902524ac /tests | |
parent | 556216129bf5738c6ad92807ece1dac233b8b96f (diff) | |
parent | 07703ade86edcd6565c373f63e34306209d1a90a (diff) | |
download | Qt-4708acb70e1e71bf22e85f7335dcaf1401aba3bb.zip Qt-4708acb70e1e71bf22e85f7335dcaf1401aba3bb.tar.gz Qt-4708acb70e1e71bf22e85f7335dcaf1401aba3bb.tar.bz2 |
Merge branch '4.5'
Conflicts:
tests/auto/qaction/tst_qaction.cpp
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qaction/tst_qaction.cpp | 33 | ||||
-rw-r--r-- | tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 41 | ||||
-rw-r--r-- | tests/auto/qshortcut/tst_qshortcut.cpp | 7 |
3 files changed, 77 insertions, 4 deletions
diff --git a/tests/auto/qaction/tst_qaction.cpp b/tests/auto/qaction/tst_qaction.cpp index 1ec21f2..1b73f06 100644 --- a/tests/auto/qaction/tst_qaction.cpp +++ b/tests/auto/qaction/tst_qaction.cpp @@ -46,6 +46,7 @@ #include <qevent.h> #include <qaction.h> #include <qmenu.h> +#include <qlineedit.h> //TESTED_CLASS= //TESTED_FILES= @@ -74,6 +75,7 @@ private slots: void setStandardKeys(); void alternateShortcuts(); void enabledVisibleInteraction(); + void invisibleActionWithComplexShortcut(); void task200823_tooltip(); void task229128TriggeredSignalWithoutActiongroup(); void task229128TriggeredSignalWhenInActiongroup(); @@ -365,5 +367,36 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() QCOMPARE(actionSpy.count(), 1); } +void tst_QAction::invisibleActionWithComplexShortcut() +{ + QAction action(0); + action.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E, Qt::Key_1)); + + QLineEdit edit; + edit.addAction(&action); + edit.show(); + QTest::qWait(100); + + QSignalSpy spy(&action, SIGNAL(triggered())); + + action.setVisible(true); + QTest::keyPress(&edit, Qt::Key_E, Qt::ControlModifier); + QTest::keyRelease(&edit, Qt::Key_E, Qt::ControlModifier); + QTest::keyPress(&edit, Qt::Key_1, Qt::NoModifier); + QTest::keyRelease(&edit, Qt::Key_1, Qt::NoModifier); + QCOMPARE(spy.count(), 1); + QCOMPARE(edit.text(), QLatin1String("")); + + edit.clear(); + spy.clear(); + action.setVisible(false); + QTest::keyPress(&edit, Qt::Key_E, Qt::ControlModifier); + QTest::keyRelease(&edit, Qt::Key_E, Qt::ControlModifier); + QTest::keyPress(&edit, Qt::Key_1, Qt::NoModifier); + QTest::keyRelease(&edit, Qt::Key_1, Qt::NoModifier); + QCOMPARE(spy.count(), 0); + QCOMPARE(edit.text(), QLatin1String("1")); +} + QTEST_MAIN(tst_QAction) #include "tst_qaction.moc" diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index 826d278..59d57ce 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -45,6 +45,7 @@ #include <QFileIconProvider> #include "../../shared/util.h" #include <QTime> +#include <QStyle> #include <QtGlobal> //TESTED_CLASS= @@ -284,6 +285,33 @@ void tst_QFileSystemModel::readOnly() QVERIFY(model->flags(model->index(file.fileName())) & Qt::ItemIsEditable); } +class CustomFileIconProvider : public QFileIconProvider +{ +public: + CustomFileIconProvider() : QFileIconProvider() { + mb = qApp->style()->standardIcon(QStyle::SP_MessageBoxCritical); + dvd = qApp->style()->standardIcon(QStyle::SP_DriveDVDIcon); + } + + virtual QIcon icon(const QFileInfo &info) const + { + if (info.isDir()) + return mb; + + return QFileIconProvider::icon(info); + } + virtual QIcon icon(IconType type) const + { + if (type == QFileIconProvider::Folder) + return dvd; + + return QFileIconProvider::icon(type); + } +private: + QIcon mb; + QIcon dvd; +}; + void tst_QFileSystemModel::iconProvider() { QVERIFY(model->iconProvider()); @@ -292,6 +320,19 @@ void tst_QFileSystemModel::iconProvider() QCOMPARE(model->iconProvider(), p); model->setIconProvider(0); delete p; + + QFileSystemModel *myModel = new QFileSystemModel(); + myModel->setRootPath(QDir::homePath()); + //Let's wait to populate the model + QTest::qWait(250); + //We change the provider, icons must me updated + CustomFileIconProvider *custom = new CustomFileIconProvider(); + myModel->setIconProvider(custom); + + QPixmap mb = qApp->style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(50, 50); + QCOMPARE(myModel->fileIcon(myModel->index(QDir::homePath())).pixmap(50, 50), mb); + delete myModel; + delete custom; } bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount, const QStringList &initial_dirs, const QString &dir) diff --git a/tests/auto/qshortcut/tst_qshortcut.cpp b/tests/auto/qshortcut/tst_qshortcut.cpp index 69ebf74..cd80204 100644 --- a/tests/auto/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/qshortcut/tst_qshortcut.cpp @@ -987,17 +987,16 @@ void tst_QShortcut::keypressConsumption() cut1->setEnabled(false); cut2->setEnabled(false); - // Make sure keypresses is passed on, since all multiple keysequences - // with Ctrl+I are disabled + edit->clear(); sendKeyEvents(edit, Qt::CTRL + Qt::Key_I, 0); // Send key to edit QCOMPARE( currentResult, NoResult ); QCOMPARE( ambigResult, NoResult ); - QVERIFY(edit->toPlainText().endsWith("<Ctrl+I>")); + QVERIFY(edit->toPlainText().isEmpty()); sendKeyEvents(edit, Qt::Key_A, 'a'); // Send key to edit QCOMPARE( currentResult, NoResult ); QCOMPARE( ambigResult, NoResult ); - QVERIFY(edit->toPlainText().endsWith("<Ctrl+I>a")); + QVERIFY(edit->toPlainText().isEmpty()); clearAllShortcuts(); } |