summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@nokia.com>2011-11-15 15:32:31 (GMT)
committerSergio Ahumada <sergio.ahumada@nokia.com>2011-11-15 15:32:31 (GMT)
commit22bfd2b05a72e1e7d7babcc9c5d824dd87903b6f (patch)
treebcfc42bd2c2b813b32e1ace72ea1182fae634209 /tests/auto
parent8da9881989ca55f7d5e9e74c91e3abc98ce8a1b5 (diff)
parentf86ca84e783c34e701f3742902161cb365e6e940 (diff)
downloadQt-22bfd2b05a72e1e7d7babcc9c5d824dd87903b6f.zip
Qt-22bfd2b05a72e1e7d7babcc9c5d824dd87903b6f.tar.gz
Qt-22bfd2b05a72e1e7d7babcc9c5d824dd87903b6f.tar.bz2
Merge branch 4.7 into qt-4.8-from-4.7
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp23
-rw-r--r--tests/auto/qtranslator/i18n/hellotr_en.qmbin0 -> 230 bytes
-rw-r--r--tests/auto/qtranslator/tst_qtranslator.cpp40
3 files changed, 61 insertions, 2 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 3d1e35e..d2e6800 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -368,6 +368,7 @@ private Q_SLOTS:
void qtbug15311doubleContentLength();
void qtbug18232gzipContentLengthZero();
+ void nb279420gzipNoContentLengthEmptyContentDisconnect();
void synchronousRequest_data();
void synchronousRequest();
@@ -6134,6 +6135,28 @@ void tst_QNetworkReply::qtbug18232gzipContentLengthZero()
QCOMPARE(reply->readAll(), QByteArray());
}
+// Reproduced a crash in QHttpNetworkReplyPrivate::gunzipBodyPartiallyEnd
+// where zlib inflateEnd was called for uninitialized zlib stream
+void tst_QNetworkReply::nb279420gzipNoContentLengthEmptyContentDisconnect()
+{
+ // Response with no Content-Length in header and empty content
+ QByteArray response("HTTP/1.0 200 OK\r\nContent-Encoding: gzip\r\n\r\n");
+ MiniHttpServer server(response);
+ server.doClose = true;
+
+ QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(reply->isFinished());
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->size(), qint64(0));
+ QVERIFY(!reply->header(QNetworkRequest::ContentLengthHeader).isValid());
+ QCOMPARE(reply->readAll(), QByteArray());
+}
+
void tst_QNetworkReply::synchronousRequest_data()
{
QTest::addColumn<QUrl>("url");
diff --git a/tests/auto/qtranslator/i18n/hellotr_en.qm b/tests/auto/qtranslator/i18n/hellotr_en.qm
new file mode 100644
index 0000000..cc42afe
--- /dev/null
+++ b/tests/auto/qtranslator/i18n/hellotr_en.qm
Binary files differ
diff --git a/tests/auto/qtranslator/tst_qtranslator.cpp b/tests/auto/qtranslator/tst_qtranslator.cpp
index 8e2ed15..6f65e6a 100644
--- a/tests/auto/qtranslator/tst_qtranslator.cpp
+++ b/tests/auto/qtranslator/tst_qtranslator.cpp
@@ -66,6 +66,10 @@ protected:
private slots:
void load();
void load2();
+ void loadSubdir();
+ void loadSubdir2();
+ void loadSubdir3();
+ void loadSubdir4();
void threadLoad();
void testLanguageChange();
void plural();
@@ -124,6 +128,38 @@ void tst_QTranslator::load2()
QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
}
+void tst_QTranslator::loadSubdir()
+{
+ QTranslator tor( 0 );
+ tor.load("hellotr_en_GB", "i18n");
+ QVERIFY(!tor.isEmpty());
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+}
+
+void tst_QTranslator::loadSubdir2()
+{
+ QTranslator tor( 0 );
+ tor.load("i18n/hellotr_en_GB");
+ QVERIFY(!tor.isEmpty());
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+}
+
+void tst_QTranslator::loadSubdir3()
+{
+ QTranslator tor( 0 );
+ tor.load(QString(QLatin1String("i18n%1hellotr_en_GB")).arg(QDir::separator()));
+ QVERIFY(!tor.isEmpty());
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+}
+
+void tst_QTranslator::loadSubdir4()
+{
+ QTranslator tor( 0 );
+ tor.load("./hellotr_en_GB", "i18n");
+ QVERIFY(!tor.isEmpty());
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+}
+
class TranslatorThread : public QThread
{
void run() {
@@ -249,10 +285,10 @@ void tst_QTranslator::loadFromResource()
void tst_QTranslator::loadDirectory()
{
- QVERIFY(QFileInfo("../qtranslator").isDir());
+ QVERIFY(QFileInfo("i18n").isDir());
QTranslator tor;
- tor.load("qtranslator", "..");
+ tor.load("qtranslator", "i18n");
QVERIFY(tor.isEmpty());
}