summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2011-09-19 04:12:35 (GMT)
committerRohan McGovern <rohan.mcgovern@nokia.com>2011-09-19 04:12:35 (GMT)
commit5055f13683dd0670d62a81e61bf097fd220f0d42 (patch)
tree1cf10d701b6d6ba5fffe9a2267ecf894d505e1bd /tests/auto
parentfc602cb1737e58b4b814c4a799fa2a68acb6dbcd (diff)
parent53d9e3620ede7492c141402d9365d5c0dd7c10fd (diff)
downloadQt-5055f13683dd0670d62a81e61bf097fd220f0d42.zip
Qt-5055f13683dd0670d62a81e61bf097fd220f0d42.tar.gz
Qt-5055f13683dd0670d62a81e61bf097fd220f0d42.tar.bz2
Merge remote branch 'origin/4.8' into doc-staging-master
Conflicts: dist/changes-4.8.0
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/collections/tst_collections.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp44
-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/qgraphicseffect/tst_qgraphicseffect.cpp95
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp68
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp53
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp7
-rw-r--r--tests/auto/qpixmapcache/tst_qpixmapcache.cpp25
-rw-r--r--tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp4
-rw-r--r--tests/auto/qtextedit/tst_qtextedit.cpp41
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp19
13 files changed, 425 insertions, 12 deletions
diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp
index 00cdec3..e13e1d9 100644
--- a/tests/auto/collections/tst_collections.cpp
+++ b/tests/auto/collections/tst_collections.cpp
@@ -2442,6 +2442,7 @@ void tst_Collections::cache()
QVERIFY(!cache.contains(2));
delete cache.take(10);
}
+#if 0
{
QCache<int, QString> cache(120);
int i;
@@ -2455,6 +2456,7 @@ void tst_Collections::cache()
QVERIFY(!cache.contains(3));
QVERIFY(cache.contains(2));
}
+#endif
{
QCache<int, int> cache(100);
cache.insert(2, new int(2));
@@ -3505,7 +3507,7 @@ void testVectorAlignment()
for (int i = 0; i < 200; ++i)
container.append(Aligned());
-
+
for (int i = 0; i < container.size(); ++i)
QVERIFY(container.at(i).checkAligned());
}
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index fde0588..33f74a9 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -147,6 +147,8 @@ private slots:
void pastingRichText_QTBUG_14003();
void implicitSize_data();
void implicitSize();
+ void implicitSizePreedit_data();
+ void implicitSizePreedit();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
@@ -2368,6 +2370,48 @@ void tst_qdeclarativetextedit::implicitSize()
QVERIFY(textObject->height() == textObject->implicitHeight());
}
+void tst_qdeclarativetextedit::implicitSizePreedit_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("wrap");
+ QTest::addColumn<bool>("wrapped");
+ QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap" << false;
+ QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap" << true;
+
+}
+
+void tst_qdeclarativetextedit::implicitSizePreedit()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, wrap);
+ QFETCH(bool, wrapped);
+
+ QString componentStr = "import QtQuick 1.1\nTextEdit { focus: true; width: 50; wrapMode: " + wrap + " }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeTextEdit *textObject = qobject_cast<QDeclarativeTextEdit*>(textComponent.create());
+
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ scene.addItem(textObject);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+
+ QInputMethodEvent event(text, QList<QInputMethodEvent::Attribute>());
+ QCoreApplication::sendEvent(&view, &event);
+
+ QVERIFY(textObject->width() < textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+ qreal wrappedHeight = textObject->height();
+
+ textObject->resetWidth();
+ QVERIFY(textObject->width() == textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+ QCOMPARE(textObject->height() < wrappedHeight, wrapped);
+}
+
void tst_qdeclarativetextedit::testQtQuick11Attributes()
{
QFETCH(QString, code);
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/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index 1f5563c..9c189cb 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -78,6 +78,8 @@ private slots:
void dropShadowClipping();
void childrenVisibilityShouldInvalidateCache();
void prepareGeometryChangeInvalidateCache();
+ void graphicsEffectUpdateShouldNotInvalidateGraphicsItemCache();
+ void graphicsEffectUpdateShouldInvalidateParentGraphicsEffect();
void itemHasNoContents();
};
@@ -732,6 +734,99 @@ void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache()
QCOMPARE(item->nbPaint, 0);
}
+class MyGraphicsEffect : public QGraphicsEffect
+{
+ public:
+ MyGraphicsEffect(QObject *parent = 0) :
+ QGraphicsEffect(parent), nbSourceInvalidations(0)
+ {}
+ int nbSourceInvalidations;
+ protected:
+ void draw(QPainter *painter)
+ {
+ drawSource(painter);
+ }
+
+ void sourceChanged(ChangeFlags flags)
+ {
+ if (flags == SourceInvalidated)
+ nbSourceInvalidations++;
+ }
+};
+
+void tst_QGraphicsEffect::graphicsEffectUpdateShouldNotInvalidateGraphicsItemCache()
+{
+ QGraphicsScene scene;
+ MyGraphicsItem parent;
+ parent.resize(200, 200);
+ parent.setCacheMode(QGraphicsItem::ItemCoordinateCache);
+ scene.addItem(&parent);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(parent.nbPaint, 1);
+
+ //we set an effect on the parent
+ MyGraphicsEffect* opacityEffect = new MyGraphicsEffect(&parent);
+ opacityEffect->update();
+ parent.setGraphicsEffect(opacityEffect);
+ //flush the events
+ QApplication::processEvents();
+ //new effect applied->repaint
+ QCOMPARE(parent.nbPaint, 1);
+
+ opacityEffect->update();
+ //flush the events
+ QApplication::processEvents();
+ //A change to the effect shouldn't invalidate the graphicsitem's cache
+ // => it shouldn't trigger a paint
+ QCOMPARE(parent.nbPaint, 1);
+}
+
+void tst_QGraphicsEffect::graphicsEffectUpdateShouldInvalidateParentGraphicsEffect()
+{
+ QGraphicsScene scene;
+ // Add the parent
+ MyGraphicsItem parent;
+ parent.resize(200, 200);
+ scene.addItem(&parent);
+ // Add a child to the parent
+ MyGraphicsItem child(&parent);
+ child.resize(100, 100);
+
+ QGraphicsView view(&scene);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ //flush the events
+ QApplication::processEvents();
+ QTRY_COMPARE(parent.nbPaint, 1);
+ QTRY_COMPARE(child.nbPaint, 1);
+
+ //we set an effect on the parent and the child
+ MyGraphicsEffect* effectForParent = new MyGraphicsEffect(&parent);
+ parent.setGraphicsEffect(effectForParent);
+
+ MyGraphicsEffect* effectForChild = new MyGraphicsEffect(&child);
+ child.setGraphicsEffect(effectForChild);
+ //flush the events
+ QApplication::processEvents();
+ // Both effects should start with no source invalidations
+ QCOMPARE(effectForParent->nbSourceInvalidations, 0);
+ QCOMPARE(effectForChild->nbSourceInvalidations, 0);
+
+ // Trigger an update of the child graphics effect
+ effectForChild->update();
+ //flush the events
+ QApplication::processEvents();
+ // An update of the effect on the child shouldn't tell that effect that its source has been invalidated
+ QCOMPARE(effectForChild->nbSourceInvalidations, 0);
+ // The effect on the parent should however be notified of an invalidated source
+ QCOMPARE(effectForParent->nbSourceInvalidations, 1);
+}
+
void tst_QGraphicsEffect::itemHasNoContents()
{
QGraphicsRectItem *parent = new QGraphicsRectItem;
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index b8741fe..8a26323 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -290,6 +290,7 @@ private slots:
void taskQT_3674_doNotCrash();
void taskQTBUG_15977_renderWithDeviceCoordinateCache();
void taskQTBUG_16401_focusItem();
+ void taskQTBUG_19680_tabWidgetFocus();
};
void tst_QGraphicsScene::initTestCase()
@@ -4711,5 +4712,72 @@ void tst_QGraphicsScene::taskQTBUG_16401_focusItem()
QVERIFY(!scene.focusItem());
}
+void tst_QGraphicsScene::taskQTBUG_19680_tabWidgetFocus()
+{
+ QTabWidget tabWidget;
+ QGraphicsScene scene1;
+ QGraphicsScene scene2;
+ QGraphicsView view1(&scene1);
+ QGraphicsView view2(&scene2);
+
+ tabWidget.show();
+
+ tabWidget.addTab(&view1, "view1");
+ tabWidget.setCurrentWidget(&view1);
+
+ QGraphicsTextItem *textItem1 = scene1.addText("Text1");
+ textItem1->setFlags(QGraphicsItem::ItemIsFocusable);
+ textItem1->setTextInteractionFlags(Qt::TextEditorInteraction);
+ textItem1->setEnabled(true);
+ textItem1->setFocus();
+
+ tabWidget.addTab(&view2, "view2");
+ tabWidget.setCurrentWidget(&view2);
+
+ QGraphicsTextItem *textItem2 = scene2.addText("Text2");
+ textItem2->setFlags(QGraphicsItem::ItemIsFocusable);
+ textItem2->setTextInteractionFlags(Qt::TextEditorInteraction);
+ textItem2->setEnabled(true);
+ textItem2->setFocus();
+
+ scene2.clearFocus();
+
+ view2.clearFocus();
+ view2.setEnabled(false);
+ view2.setInteractive(false);
+ view2.setVisible(false);
+ view2.setShown(false);
+ view2.hide();
+
+ tabWidget.clearFocus();
+ tabWidget.setEnabled(false);
+ tabWidget.setShown(false);
+ tabWidget.setVisible(false);
+ tabWidget.hide();
+
+ tabWidget.setFocus();
+ tabWidget.setEnabled(true);
+ tabWidget.activateWindow();
+ tabWidget.setShown(true);
+ tabWidget.setVisible(true);
+ tabWidget.show();
+
+ view2.setFocus();
+ view2.setEnabled(true);
+ view2.activateWindow();
+ view2.setInteractive(true);
+ view2.setVisible(true);
+ view2.setShown(true);
+ view2.show();
+
+ QTest::qWaitForWindowShown(&view2);
+ QApplication::setActiveWindow(&tabWidget);
+
+ textItem2->setFocus();
+
+ QVERIFY(scene2.isActive());
+ QVERIFY(textItem2->hasFocus());
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 1df9d38..7b273d2 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -124,6 +124,8 @@ private slots:
void layout();
void layoutDirection_data();
void layoutDirection();
+ void recursiveLayoutDirection_data();
+ void recursiveLayoutDirection();
void paint_data();
void paint();
void palettePropagation();
@@ -1213,14 +1215,20 @@ void tst_QGraphicsWidget::layout()
void tst_QGraphicsWidget::layoutDirection_data()
{
QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::newRow("rtl") << Qt::RightToLeft;
- QTest::newRow("ltr") << Qt::LeftToRight;
+ QTest::addColumn<bool>("setDirectionBeforeAddingWidget");
+
+ QTest::newRow("rtl, setting direction before adding widget") << Qt::RightToLeft << true;
+ QTest::newRow("ltr, setting direction before adding widget") << Qt::LeftToRight << true;
+ QTest::newRow("rtl, setting direction after adding widget") << Qt::RightToLeft << false;
+ QTest::newRow("ltr, setting direction after adding widget") << Qt::LeftToRight << false;
+
}
// Qt::LayoutDirection layoutDirection() const public
void tst_QGraphicsWidget::layoutDirection()
{
QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(bool, setDirectionBeforeAddingWidget);
QGraphicsScene scene;
QGraphicsView *view = new QGraphicsView(&scene);
SubQGraphicsWidget widget;
@@ -1228,13 +1236,16 @@ void tst_QGraphicsWidget::layoutDirection()
QCOMPARE(widget.layoutDirection(), Qt::LeftToRight);
QCOMPARE(widget.testAttribute(Qt::WA_SetLayoutDirection), false);
+ if (setDirectionBeforeAddingWidget)
+ widget.setLayoutDirection(layoutDirection);
QList<SubQGraphicsWidget*> children;
for (int i = 0; i < 10; ++i) {
SubQGraphicsWidget *item = new SubQGraphicsWidget(&widget);
children.append(item);
QCOMPARE(item->testAttribute(Qt::WA_SetLayoutDirection), false);
}
- widget.setLayoutDirection(layoutDirection);
+ if (!setDirectionBeforeAddingWidget)
+ widget.setLayoutDirection(layoutDirection);
QCOMPARE(widget.testAttribute(Qt::WA_SetLayoutDirection), true);
view->show();
QTest::qWaitForWindowShown(view);
@@ -1247,6 +1258,42 @@ void tst_QGraphicsWidget::layoutDirection()
delete view;
}
+void tst_QGraphicsWidget::recursiveLayoutDirection_data()
+{
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<bool>("setDirectionBeforeAddingWidget");
+
+ QTest::newRow("rtl, setting direction before adding widget") << Qt::RightToLeft << true;
+ QTest::newRow("ltr, setting direction before adding widget") << Qt::LeftToRight << true;
+ QTest::newRow("rtl, setting direction after adding widget") << Qt::RightToLeft << false;
+ QTest::newRow("ltr, setting direction after adding widget") << Qt::LeftToRight << false;
+}
+
+void tst_QGraphicsWidget::recursiveLayoutDirection()
+{
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(bool, setDirectionBeforeAddingWidget);
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(widget);
+ QGraphicsWidget *widget2 = new QGraphicsWidget;
+ QGraphicsLinearLayout *layout2 = new QGraphicsLinearLayout(widget2);
+ QGraphicsWidget *widget3 = new QGraphicsWidget;
+ QGraphicsLinearLayout *layout3 = new QGraphicsLinearLayout(widget3);
+
+ if (setDirectionBeforeAddingWidget)
+ widget->setLayoutDirection(layoutDirection);
+ layout->addItem(widget2);
+ layout2->addItem(widget3);
+ if (!setDirectionBeforeAddingWidget)
+ widget->setLayoutDirection(layoutDirection);
+
+ QCOMPARE(widget->layoutDirection(), layoutDirection);
+ QCOMPARE(widget2->layoutDirection(), layoutDirection);
+ QCOMPARE(widget3->layoutDirection(), layoutDirection);
+
+ delete widget;
+}
+
void tst_QGraphicsWidget::paint_data()
{
// currently QGraphicsWidget doesn't paint or do anything ...
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 6abbdcd..2c88561 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -1770,6 +1770,13 @@ void tst_QLineEdit::passwordEchoDelay()
QApplication::sendEvent(testWidget, &ev);
QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+ testWidget->setCursorPosition(3);
+ QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+ QTest::keyPress(testWidget, 'a');
+ QCOMPARE(testWidget->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar));
+ QTest::keyPress(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->displayText(), QString(8, fillChar));
+
// restore clean state
testWidget->setEchoMode(QLineEdit::Normal);
}
diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
index 9f7192d..b36cf98 100644
--- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
@@ -72,6 +72,7 @@ private slots:
void clear();
void pixmapKey();
void noLeak();
+ void strictCacheLimit();
};
static QPixmapCache::KeyData* getPrivate(QPixmapCache::Key &key)
@@ -517,5 +518,29 @@ void tst_QPixmapCache::noLeak()
QCOMPARE(oldSize, newSize);
}
+
+void tst_QPixmapCache::strictCacheLimit()
+{
+ const int limit = 1024; // 1024 KB
+
+ QPixmapCache::clear();
+ QPixmapCache::setCacheLimit(limit);
+
+ // insert 200 64x64 pixmaps
+ // 3200 KB for 32-bit depths
+ // 1600 KB for 16-bit depths
+ // not counting the duplicate entries
+ for (int i = 0; i < 200; ++i) {
+ QPixmap pixmap(64, 64);
+ pixmap.fill(Qt::transparent);
+
+ QString id = QString::number(i);
+ QPixmapCache::insert(id + "-a", pixmap);
+ QPixmapCache::insert(id + "-b", pixmap);
+ }
+
+ QVERIFY(QPixmapCache::totalUsed() <= limit);
+}
+
QTEST_MAIN(tst_QPixmapCache)
#include "tst_qpixmapcache.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()));
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index 2414ab3..67d8269 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -129,6 +129,7 @@ private slots:
void textWidthWithLineSeparator();
void cursorInLigatureWithMultipleLines();
void xToCursorForLigatures();
+ void cursorInNonStopChars();
private:
QFont testFont;
@@ -1465,7 +1466,7 @@ void tst_QTextLayout::textWidthWithLineSeparator()
void tst_QTextLayout::cursorInLigatureWithMultipleLines()
{
#if !defined(Q_WS_MAC)
- QSKIP("This test can not be run on Mac", SkipAll);
+ QSKIP("This test can only be run on Mac", SkipAll);
#endif
QTextLayout layout("first line finish", QFont("Times", 20));
layout.beginLayout();
@@ -1481,7 +1482,7 @@ void tst_QTextLayout::cursorInLigatureWithMultipleLines()
void tst_QTextLayout::xToCursorForLigatures()
{
#if !defined(Q_WS_MAC)
- QSKIP("This test can not be run on Mac", SkipAll);
+ QSKIP("This test can only be run on Mac", SkipAll);
#endif
QTextLayout layout("fi", QFont("Times", 20));
layout.beginLayout();
@@ -1502,5 +1503,19 @@ void tst_QTextLayout::xToCursorForLigatures()
line.xToCursor(width) == line.xToCursor(width / 2));
}
+void tst_QTextLayout::cursorInNonStopChars()
+{
+#if defined(Q_WS_MAC)
+ QSKIP("This test can not be run on Mac", SkipAll);
+#endif
+ QTextLayout layout(QString::fromUtf8("\xE0\xA4\xA4\xE0\xA5\x8D\xE0\xA4\xA8"));
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ QVERIFY(line.cursorToX(1) == line.cursorToX(3));
+ QVERIFY(line.cursorToX(2) == line.cursorToX(3));
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"