diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2015-12-18 23:05:13 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2015-12-18 23:42:17 +0100 |
commit | d24a9ea3b2eaec28e44608bfc50d02cb14cea51b (patch) | |
tree | 9eb2bf3a52559b1b45d7f226fab03bb660f42b07 /rbutil/rbutilqt/test/test-httpget.cpp | |
parent | 4627d4b56e63e5689ad6ffd652636f112081a0ea (diff) | |
download | rockbox-d24a9ea3b2eaec28e44608bfc50d02cb14cea51b.tar.gz rockbox-d24a9ea3b2eaec28e44608bfc50d02cb14cea51b.zip |
Add support file:// URLs in HttpGet.
QNetworkAccessManager can handle file:// URLs without additional work. Make
HttpGet aware of that so you can now also use it to retrieve file:// URLs. Add
a unit test for it as well.
Change-Id: If64b57453460b70bca9e5b0c725bb78344617bcd
Diffstat (limited to 'rbutil/rbutilqt/test/test-httpget.cpp')
-rw-r--r-- | rbutil/rbutilqt/test/test-httpget.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/test/test-httpget.cpp b/rbutil/rbutilqt/test/test-httpget.cpp index c9ae86bc6c..a062203e70 100644 --- a/rbutil/rbutilqt/test/test-httpget.cpp +++ b/rbutil/rbutilqt/test/test-httpget.cpp | |||
@@ -118,6 +118,7 @@ class TestHttpGet : public QObject | |||
118 | { | 118 | { |
119 | Q_OBJECT | 119 | Q_OBJECT |
120 | private slots: | 120 | private slots: |
121 | void testFileUrlRequest(void); | ||
121 | void testCachedRequest(void); | 122 | void testCachedRequest(void); |
122 | void testUncachedRepeatedRequest(void); | 123 | void testUncachedRepeatedRequest(void); |
123 | void testUncachedMovedRequest(void); | 124 | void testUncachedMovedRequest(void); |
@@ -188,6 +189,27 @@ void TestHttpGet::cleanup(void) | |||
188 | if(m_doneSpy) delete m_doneSpy; | 189 | if(m_doneSpy) delete m_doneSpy; |
189 | } | 190 | } |
190 | 191 | ||
192 | void TestHttpGet::testFileUrlRequest(void) | ||
193 | { | ||
194 | QTimer::singleShot(TEST_HTTP_TIMEOUT, this, SLOT(waitTimeout(void))); | ||
195 | |||
196 | QString teststring = "The quick brown fox jumps over the lazy dog."; | ||
197 | QTemporaryFile datafile; | ||
198 | datafile.open(); | ||
199 | datafile.write(teststring.toLatin1()); | ||
200 | m_getter->getFile("file://" + datafile.fileName()); | ||
201 | datafile.close(); | ||
202 | while(m_doneSpy->count() == 0 && m_waitTimeoutOccured == false) | ||
203 | QCoreApplication::processEvents(); | ||
204 | |||
205 | QCOMPARE(m_doneSpy->count(), 1); | ||
206 | QCOMPARE(m_waitTimeoutOccured, false); | ||
207 | QCOMPARE(m_daemon->lastRequestData().size(), 0); | ||
208 | QCOMPARE(m_getter->readAll(), teststring.toLatin1()); | ||
209 | QCOMPARE(m_getter->httpResponse(), 200); | ||
210 | } | ||
211 | |||
212 | |||
191 | /* On uncached requests, HttpGet is supposed to sent a GET request only. | 213 | /* On uncached requests, HttpGet is supposed to sent a GET request only. |
192 | */ | 214 | */ |
193 | void TestHttpGet::testUncachedRepeatedRequest(void) | 215 | void TestHttpGet::testUncachedRepeatedRequest(void) |