diff options
author | Alex Zolotarev <alex@maps.me> | 2016-01-10 20:33:21 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2016-01-10 20:33:21 +0300 |
commit | 40e67c893c402b23e86d6406d0b227b5c7550825 (patch) | |
tree | 201135036d31dbc7039abff0c4ff4a531abc31ca /platform | |
parent | d47810932c82bdc53eca3952cbce74df328b6800 (diff) |
Correct implementation for download test.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/downloader_tests/downloader_test.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/platform/downloader_tests/downloader_test.cpp b/platform/downloader_tests/downloader_test.cpp index c204dbd97a..df3ef426df 100644 --- a/platform/downloader_tests/downloader_test.cpp +++ b/platform/downloader_tests/downloader_test.cpp @@ -34,7 +34,8 @@ using namespace downloader; class DownloadObserver { bool m_progressWasCalled; - unique_ptr<HttpRequest::StatusT> m_status; + // Chunked downloads can return one status per chunk (thread). + vector<HttpRequest::StatusT> m_statuses; // Interrupt download after this number of chunks int m_chunksToFail; @@ -53,20 +54,22 @@ public: void Reset() { m_progressWasCalled = false; - m_status.reset(); + m_statuses.clear(); } void TestOk() { + TEST_NOT_EQUAL(0, m_statuses.size(), ("Observer was not called.")); TEST(m_progressWasCalled, ("Download progress wasn't called")); - TEST(m_status.get(), ()); - TEST_EQUAL(*m_status, HttpRequest::ECompleted, ()); + for (auto const & status : m_statuses) + TEST_EQUAL(status, HttpRequest::ECompleted, ()); } void TestFailed() { - TEST(m_status.get(), ()); - TEST_EQUAL(*m_status, HttpRequest::EFailed, ()); + TEST_NOT_EQUAL(0, m_statuses.size(), ("Observer was not called.")); + for (auto const & status : m_statuses) + TEST_EQUAL(status, HttpRequest::EFailed, ()); } void OnDownloadProgress(HttpRequest & request) @@ -87,14 +90,13 @@ public: } } - void OnDownloadFinish(HttpRequest & request) + virtual void OnDownloadFinish(HttpRequest & request) { - TEST(!m_status.get(), ()); - m_status.reset(new HttpRequest::StatusT(request.Status())); - TEST(*m_status == HttpRequest::EFailed || *m_status == HttpRequest::ECompleted, ()); + auto const status = request.Status(); + m_statuses.emplace_back(status); + TEST(status == HttpRequest::EFailed || status == HttpRequest::ECompleted, ()); QCoreApplication::quit(); } - }; struct CancelDownload |