summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJustin McPherson <justin.mcpherson@nokia.com>2010-04-16 00:12:15 (GMT)
committerJustin McPherson <justin.mcpherson@nokia.com>2010-04-16 00:12:15 (GMT)
commit655088bc1942698ee060ca5237a4220365e49ee1 (patch)
tree908437dbe06f9639534bc3546a9f3fe619d53449 /tests
parent06d71fb79ad850c62a1b95fbeec607dfc4220489 (diff)
parent07f724cd5abd0548fb32ed3469bde113daf028c4 (diff)
downloadQt-655088bc1942698ee060ca5237a4220365e49ee1.zip
Qt-655088bc1942698ee060ca5237a4220365e49ee1.tar.gz
Qt-655088bc1942698ee060ca5237a4220365e49ee1.tar.bz2
Merge branch '4.7' of ../../qt/4.7 into 4.7
Conflicts: configure
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qftp/tst_qftp.cpp26
-rw-r--r--tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp2
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp30
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp2
-rw-r--r--tests/auto/qscriptengine/qscriptengine.pro1
-rw-r--r--tests/auto/qscriptengine/qscriptengine.qrc5
-rw-r--r--tests/auto/qscriptengine/translatable.js7
-rw-r--r--tests/auto/qscriptengine/translations/translatable_la.qmbin0 -> 241 bytes
-rw-r--r--tests/auto/qscriptengine/translations/translatable_la.ts34
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp40
-rw-r--r--tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp2
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp2
12 files changed, 147 insertions, 4 deletions
diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp
index 638c810..2a42d6d 100644
--- a/tests/auto/qftp/tst_qftp.cpp
+++ b/tests/auto/qftp/tst_qftp.cpp
@@ -123,6 +123,8 @@ private slots:
void doneSignal();
void queueMoreCommandsInDoneSlot();
+ void qtbug7359Crash();
+
protected slots:
void stateChanged( int );
void listInfo( const QUrlInfo & );
@@ -2052,6 +2054,30 @@ void tst_QFtp::cdUpSlot(bool error)
}
}
+void tst_QFtp::qtbug7359Crash()
+{
+ QFtp ftp;
+ ftp.connectToHost("127.0.0.1");
+
+ QTime t;
+ int elapsed;
+
+ t.start();
+ while ((elapsed = t.elapsed()) < 200)
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 200 - elapsed);
+
+ ftp.close();
+ t.restart();
+ while ((elapsed = t.elapsed()) < 1000)
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 1000 - elapsed);
+
+ ftp.connectToHost("127.0.0.1");
+
+ t.restart();
+ while ((elapsed = t.elapsed()) < 2000)
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 2000 - elapsed);
+}
+
QTEST_MAIN(tst_QFtp)
#include "tst_qftp.moc"
diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp
index 3a3ea79..f86ba63 100644
--- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp
+++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp
@@ -641,7 +641,7 @@ void tst_QHttpSocketEngine::downloadBigFile()
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
- QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0);
+ QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("Host: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
QVERIFY(tmpSocket->write("\r\n") > 0);
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index d2181f8..f5c32cd 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -123,6 +123,7 @@ private slots:
void taskQTBUG_435_deselectOnViewportClick();
void taskQTBUG_2678_spacingAndWrappedText();
void taskQTBUG_5877_skippingItemInPageDownUp();
+ void taskQTBUG_9455_wrongScrollbarRanges();
};
// Testing get/set functions
@@ -1941,5 +1942,34 @@ void tst_QListView::taskQTBUG_5877_skippingItemInPageDownUp()
}
}
+class ListView_9455 : public QListView
+{
+public:
+ QSize contentsSize() const
+ {
+ return QListView::contentsSize();
+ }
+};
+
+void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges()
+{
+ QStringList list;
+ const int nrItems = 8;
+ for (int i = 0; i < nrItems; i++)
+ list << QString().sprintf("item %d", i);
+
+ QStringListModel model(list);
+ ListView_9455 w;
+ w.setModel(&model);
+ w.setViewMode(QListView::IconMode);
+ w.resize(116, 132);
+ w.setMovement(QListView::Static);
+ const int spacing = 40;
+ w.setSpacing(spacing);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height());
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index dd497b0..ff79c09 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -4113,7 +4113,7 @@ public slots:
}
}
void startOne() {
- QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif";
+ QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/fluke.gif";
QNetworkRequest request(url);
QNetworkReply *reply = manager.get(request);
reply->setParent(this);
diff --git a/tests/auto/qscriptengine/qscriptengine.pro b/tests/auto/qscriptengine/qscriptengine.pro
index dd058a4..7d0f5d0 100644
--- a/tests/auto/qscriptengine/qscriptengine.pro
+++ b/tests/auto/qscriptengine/qscriptengine.pro
@@ -1,6 +1,7 @@
load(qttest_p4)
QT = core gui script
SOURCES += tst_qscriptengine.cpp
+RESOURCES += qscriptengine.qrc
wince* {
DEFINES += SRCDIR=\\\"./\\\"
diff --git a/tests/auto/qscriptengine/qscriptengine.qrc b/tests/auto/qscriptengine/qscriptengine.qrc
new file mode 100644
index 0000000..b87f985
--- /dev/null
+++ b/tests/auto/qscriptengine/qscriptengine.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>translations/translatable_la.qm</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/qscriptengine/translatable.js b/tests/auto/qscriptengine/translatable.js
new file mode 100644
index 0000000..0c948e7
--- /dev/null
+++ b/tests/auto/qscriptengine/translatable.js
@@ -0,0 +1,7 @@
+qsTr("One");
+qsTranslate("FooContext", "Two");
+
+var greeting_strings = [
+ QT_TR_NOOP("Hello"),
+ QT_TRANSLATE_NOOP("FooContext", "Goodbye")
+];
diff --git a/tests/auto/qscriptengine/translations/translatable_la.qm b/tests/auto/qscriptengine/translations/translatable_la.qm
new file mode 100644
index 0000000..03fcc52
--- /dev/null
+++ b/tests/auto/qscriptengine/translations/translatable_la.qm
Binary files differ
diff --git a/tests/auto/qscriptengine/translations/translatable_la.ts b/tests/auto/qscriptengine/translations/translatable_la.ts
new file mode 100644
index 0000000..3f631de
--- /dev/null
+++ b/tests/auto/qscriptengine/translations/translatable_la.ts
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="nb_NO">
+<context>
+ <name>FooContext</name>
+ <message>
+ <location filename="translatable.js" line="2"/>
+ <source>Two</source>
+ <translation>To</translation>
+ </message>
+ <message>
+ <location filename="translatable.js" line="6"/>
+ <source>Goodbye</source>
+ <translation>Farvel</translation>
+ </message>
+</context>
+<context>
+ <name>translatable</name>
+ <message>
+ <location filename="translatable.js" line="1"/>
+ <source>One</source>
+ <translation>En</translation>
+ </message>
+ <message>
+ <location filename="translatable.js" line="5"/>
+ <source>Hello</source>
+ <translation>Hallo</translation>
+ </message>
+ <message>
+ <source>Goodbye</source>
+ <translation type="obsolete">Farvel</translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 25d8e3df..96043f9 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -155,6 +155,7 @@ private slots:
void incDecNonObjectProperty();
void installTranslatorFunctions_data();
void installTranslatorFunctions();
+ void translateScript();
void functionScopes();
void nativeFunctionScopes();
void evaluateProgram();
@@ -4335,6 +4336,45 @@ void tst_QScriptEngine::installTranslatorFunctions()
}
}
+void tst_QScriptEngine::translateScript()
+{
+ QScriptEngine engine;
+
+ QTranslator translator;
+ translator.load(":/translations/translatable_la");
+ QCoreApplication::instance()->installTranslator(&translator);
+ engine.installTranslatorFunctions();
+
+ QString fileName = QString::fromLatin1("translatable.js");
+ // Top-level
+ QCOMPARE(engine.evaluate("qsTr('One')", fileName).toString(), QString::fromLatin1("En"));
+ QCOMPARE(engine.evaluate("qsTr('Hello')", fileName).toString(), QString::fromLatin1("Hallo"));
+ // From function
+ QCOMPARE(engine.evaluate("(function() { return qsTr('One'); })()", fileName).toString(), QString::fromLatin1("En"));
+ QCOMPARE(engine.evaluate("(function() { return qsTr('Hello'); })()", fileName).toString(), QString::fromLatin1("Hallo"));
+ // From eval
+ QCOMPARE(engine.evaluate("eval('qsTr(\\'One\\')')", fileName).toString(), QString::fromLatin1("En"));
+ QCOMPARE(engine.evaluate("eval('qsTr(\\'Hello\\')')", fileName).toString(), QString::fromLatin1("Hallo"));
+
+ QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Two')", fileName).toString(), QString::fromLatin1("To"));
+ QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Farvel"));
+ // From eval
+ QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')", fileName).toString(), QString::fromLatin1("To"));
+ QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')", fileName).toString(), QString::fromLatin1("Farvel"));
+
+ // Don't exist in translation
+ QCOMPARE(engine.evaluate("qsTr('Three')", fileName).toString(), QString::fromLatin1("Three"));
+ QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'So long')", fileName).toString(), QString::fromLatin1("So long"));
+ QCOMPARE(engine.evaluate("qsTranslate('BarContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Goodbye"));
+
+ // From C++
+ // There is no context, but it shouldn't crash
+ QCOMPARE(engine.globalObject().property("qsTr").call(
+ QScriptValue(), QScriptValueList() << "One").toString(), QString::fromLatin1("One"));
+
+ QCoreApplication::instance()->removeTranslator(&translator);
+}
+
void tst_QScriptEngine::functionScopes()
{
QScriptEngine eng;
diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp
index a679765..8f0cbc3 100644
--- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp
+++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp
@@ -780,7 +780,7 @@ void tst_QSocks5SocketEngine::downloadBigFile()
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
- QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0);
+ QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("HOST: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
QVERIFY(tmpSocket->write("\r\n") > 0);
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index 5a209c2..cd512a1 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -1117,7 +1117,7 @@ void tst_QTcpSocket::downloadBigFile()
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
- QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0);
+ QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("HOST: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
QVERIFY(tmpSocket->write("\r\n") > 0);