summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qdir/tst_qdir.cpp33
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp12
-rw-r--r--tests/auto/qfilesystementry/tst_qfilesystementry.cpp32
-rw-r--r--tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp4
-rw-r--r--tests/auto/qtextedit/tst_qtextedit.cpp41
5 files changed, 116 insertions, 6 deletions
diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp
index 419eaae..9693480 100644
--- a/tests/auto/qdir/tst_qdir.cpp
+++ b/tests/auto/qdir/tst_qdir.cpp
@@ -1133,6 +1133,11 @@ void tst_QDir::absolutePath_data()
QTest::newRow("4") << "c:/machine/share/dir1" << "c:/machine/share/dir1";
QTest::newRow("5") << "c:\\machine\\share\\dir1" << "c:/machine/share/dir1";
#endif
+ //test dirty paths are cleaned (QTBUG-19995)
+ QTest::newRow("/home/qt/.") << QDir::rootPath() + "home/qt/." << QDir::rootPath() + "home/qt";
+ QTest::newRow("/system/data/../config") << QDir::rootPath() + "system/data/../config" << QDir::rootPath() + "system/config";
+ QTest::newRow("//home//qt/") << QDir::rootPath() + "/home//qt/" << QDir::rootPath() + "home/qt";
+ QTest::newRow("foo/../bar") << "foo/../bar" << QDir::currentPath() + "/bar";
QTest::newRow("resource") << ":/prefix/foo.bar" << ":/prefix/foo.bar";
}
@@ -1942,6 +1947,34 @@ void tst_QDir::equalityOperator_data()
<< "./entrylist" << "*.cpp" << int(QDir::Name) << int(QDir::Files)
<< true;
+ QTest::newRow("QTBUG-20495") << QDir::currentPath() + "/entrylist/.." << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << "." << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << true;
+
+ //need a path in the root directory that is unlikely to be a symbolic link.
+#if defined (Q_OS_WIN)
+ QString pathinroot("c:/windows/..");
+#elif defined (Q_OS_SYMBIAN)
+ QString pathinroot("c:/data/..");
+#else
+ QString pathinroot("/sbin/..");
+#endif
+ QTest::newRow("QTBUG-20495-root") << pathinroot << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << QDir::rootPath() << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << true;
+
+ QTest::newRow("slashdot") << QDir::rootPath() + "." << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << QDir::rootPath() << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << true;
+
+ QTest::newRow("slashdotslash") << QDir::rootPath() + "./" << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << QDir::rootPath() << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << true;
+
+ QTest::newRow("nonexistantpaths") << "dir-that-dont-exist" << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << "another-dir-that-dont-exist" << "*.cpp" << int(QDir::Name) << int(QDir::Files)
+ << false;
+
QTest::newRow("diff-filters") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files)
<< SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Dirs)
<< false;
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index c7d9979..d7d57f6 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -482,6 +482,11 @@ void tst_QFileInfo::absolutePath_data()
QTest::newRow("c:\\autoexec.bat") << "c:\\autoexec.bat" << "C:/"
<< "autoexec.bat";
#endif
+ QTest::newRow("QTBUG-19995.1") << drivePrefix + "/System/Library/StartupItems/../Frameworks"
+ << drivePrefix + "/System/Library"
+ << "Frameworks";
+ QTest::newRow("QTBUG-19995.2") << drivePrefix + "/System/Library/StartupItems/../Frameworks/"
+ << drivePrefix + "/System/Library/Frameworks" << "";
}
void tst_QFileInfo::absolutePath()
@@ -503,6 +508,7 @@ void tst_QFileInfo::absFilePath_data()
QTest::newRow("relativeFile") << "tmp.txt" << QDir::currentPath() + "/tmp.txt";
QTest::newRow("relativeFileInSubDir") << "temp/tmp.txt" << QDir::currentPath() + "/" + "temp/tmp.txt";
+ QString drivePrefix;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
QString curr = QDir::currentPath();
@@ -511,7 +517,7 @@ void tst_QFileInfo::absFilePath_data()
QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "C:/home/andy/tmp.txt";
// Make sure drive-relative paths return correct absolute paths (task 255326)
- QString drivePrefix = QDir::currentPath().left(2);
+ drivePrefix = QDir::currentPath().left(2);
QString nonCurrentDrivePrefix =
drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:");
@@ -521,6 +527,8 @@ void tst_QFileInfo::absFilePath_data()
#else
QTest::newRow("absFilePath") << "/home/andy/tmp.txt" << "/home/andy/tmp.txt";
#endif
+ QTest::newRow("QTBUG-19995") << drivePrefix + "/System/Library/StartupItems/../Frameworks"
+ << drivePrefix + "/System/Library/Frameworks";
}
void tst_QFileInfo::absFilePath()
@@ -1395,7 +1403,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
wchar_t errstr[0x100];
DWORD count = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
0, err, 0, errstr, 0x100, 0);
- QString error(QString::fromUtf16(errstr, count));
+ QString error(QString::fromWCharArray (errstr, count));
qWarning() << error;
//we need at least one data set for the test not to assert fail when skipping _data function
QDir target("target");
diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp
index 016bcbf..2daabee 100644
--- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp
+++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp
@@ -68,6 +68,8 @@ private slots:
void absoluteOrRelative_data();
void absoluteOrRelative();
#endif
+ void isClean_data();
+ void isClean();
};
#if defined(WIN_STUFF)
@@ -383,5 +385,35 @@ void tst_QFileSystemEntry::absoluteOrRelative()
}
#endif
+void tst_QFileSystemEntry::isClean_data()
+{
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<bool>("isClean");
+
+ QTest::newRow("simple") << "foo" << true;
+ QTest::newRow("complex") << "/foo/bar/bz" << true;
+ QTest::newRow(".file") << "/foo/.file" << true;
+ QTest::newRow("..file") << "/foo/..file" << true;
+ QTest::newRow("...") << "/foo/.../bar" << true;
+ QTest::newRow("./") << "./" << false;
+ QTest::newRow("../") << "../" << false;
+ QTest::newRow(".") << "." << false;
+ QTest::newRow("..") << ".." << false;
+ QTest::newRow("/.") << "/." << false;
+ QTest::newRow("/..") << "/.." << false;
+ QTest::newRow("/../") << "foo/../bar" << false;
+ QTest::newRow("/./") << "foo/./bar" << false;
+ QTest::newRow("//") << "foo//bar" << false;
+}
+
+void tst_QFileSystemEntry::isClean()
+{
+ QFETCH(QString, path);
+ QFETCH(bool, isClean);
+
+ QFileSystemEntry fi(path);
+ QCOMPARE(fi.isClean(), isClean);
+}
+
QTEST_MAIN(tst_QFileSystemEntry)
#include <tst_qfilesystementry.moc>
diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
index f4249ab..336dc71 100644
--- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
+++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
@@ -2320,10 +2320,6 @@ void tst_QtConcurrentMap::stlContainers()
{
#ifdef QT_NO_STL
QSKIP("Qt compiled without STL support", SkipAll);
-#elif defined(Q_COMPILER_RVALUE_REFS)
- //mapped uses &Container::push_back, but in c++0x, std::vector has two overload of it
- // meaning it is not possible to take the address of that function anymore.
- QSKIP("mapped do not work with c++0x stl vector", SkipAll);
#else
std::vector<int> vector;
vector.push_back(1);
diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp
index 42ea3b1..73d09f4 100644
--- a/tests/auto/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/qtextedit/tst_qtextedit.cpp
@@ -138,6 +138,8 @@ private slots:
void textSemantics();
#endif
void cursorPositionChanged();
+ void mouseSelection();
+ void mouseSelectionDClick();
void setTextCursor();
#ifndef QT_NO_CLIPBOARD
void undoAvailableAfterPaste();
@@ -785,6 +787,45 @@ void tst_QTextEdit::cursorPositionChanged()
QCOMPARE(ed->textCursor().position(), 0);
}
+void tst_QTextEdit::mouseSelection()
+{
+ ed->show();
+ ed->setPlainText(("Hello World"));
+ QTextCursor cursor = ed->textCursor();
+ cursor.setPosition(1);
+ QPoint p1 = ed->cursorRect(cursor).center();
+ cursor.setPosition(10);
+ QPoint p2 = ed->cursorRect(cursor).center();
+ QTest::mousePress(ed->viewport(), Qt::LeftButton, 0, p1);
+ { QMouseEvent ev(QEvent::MouseMove, p2, Qt::LeftButton, Qt::LeftButton, 0);
+ QCoreApplication::sendEvent(ed->viewport(), &ev); }
+ QTest::mouseRelease(ed->viewport(), Qt::LeftButton, 0, p2);
+ QVERIFY(ed->textCursor().hasSelection());
+ QCOMPARE(ed->textCursor().selectedText(), QString("ello Worl"));
+
+}
+
+void tst_QTextEdit::mouseSelectionDClick()
+{
+ ed->show();
+ ed->setPlainText(("Hello World"));
+ QTextCursor cursor = ed->textCursor();
+ cursor.setPosition(1);
+ QPoint p1 = ed->cursorRect(cursor).center();
+ cursor.setPosition(10);
+ QPoint p2 = ed->cursorRect(cursor).center();
+ QTest::mousePress(ed->viewport(), Qt::LeftButton, 0, p1);
+ QTest::mouseRelease(ed->viewport(), Qt::LeftButton, 0, p1);
+ QTest::mouseDClick(ed->viewport(), Qt::LeftButton, 0, p1);
+ QVERIFY(ed->textCursor().hasSelection());
+ QCOMPARE(ed->textCursor().selectedText(), QString("Hello"));
+ { QMouseEvent ev(QEvent::MouseMove, p2, Qt::LeftButton, Qt::LeftButton, 0);
+ QCoreApplication::sendEvent(ed->viewport(), &ev); }
+ QTest::mouseRelease(ed->viewport(), Qt::LeftButton, 0, p2);
+ QVERIFY(ed->textCursor().hasSelection());
+ QCOMPARE(ed->textCursor().selectedText(), QString("Hello World"));
+}
+
void tst_QTextEdit::setTextCursor()
{
QSignalSpy spy(ed, SIGNAL(cursorPositionChanged()));