summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-01-08 14:37:31 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-01-13 13:43:05 -0800
commit618902e06ca1287920154e81f3f95779fe9c96f4 (patch)
tree2f21980dbb2b3d2a52a6bbe3d04150bb941c31de /test
parent716a9c92cbfd75323dab2514c608fbe7563f5b70 (diff)
downloadqtlocation-mapboxgl-618902e06ca1287920154e81f3f95779fe9c96f4.tar.gz
[core] Remove request coalescing in OnlineFileSource
Diffstat (limited to 'test')
-rw-r--r--test/storage/cache_revalidate.cpp2
-rw-r--r--test/storage/http_coalescing.cpp158
-rw-r--r--test/test.gypi1
3 files changed, 0 insertions, 161 deletions
diff --git a/test/storage/cache_revalidate.cpp b/test/storage/cache_revalidate.cpp
index e0e0672ad5..ffc622f37c 100644
--- a/test/storage/cache_revalidate.cpp
+++ b/test/storage/cache_revalidate.cpp
@@ -49,7 +49,6 @@ TEST_F(Storage, CacheRevalidateSame) {
EXPECT_EQ(nullptr, res2.error);
EXPECT_EQ(false, res2.stale);
ASSERT_TRUE(res2.data.get());
- EXPECT_EQ(res.data, res2.data);
EXPECT_EQ("Response", *res2.data);
// We use this to indicate that a 304 reply came back.
EXPECT_LT(Seconds::zero(), res2.expires);
@@ -111,7 +110,6 @@ TEST_F(Storage, CacheRevalidateModified) {
EXPECT_EQ(false, res2.stale);
ASSERT_TRUE(res2.data.get());
EXPECT_EQ("Response", *res2.data);
- EXPECT_EQ(res.data, res2.data);
// We use this to indicate that a 304 reply came back.
EXPECT_LT(Seconds::zero(), res2.expires);
EXPECT_EQ(1420070400, res2.modified.count());
diff --git a/test/storage/http_coalescing.cpp b/test/storage/http_coalescing.cpp
deleted file mode 100644
index dc4d993b35..0000000000
--- a/test/storage/http_coalescing.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-#include "storage.hpp"
-
-#include <mbgl/storage/online_file_source.hpp>
-#include <mbgl/util/chrono.hpp>
-#include <mbgl/util/run_loop.hpp>
-
-TEST_F(Storage, HTTPCoalescing) {
- SCOPED_TEST(HTTPCoalescing)
-
- static int counter = 0;
- const static int total = 4;
-
- using namespace mbgl;
-
- util::RunLoop loop;
- OnlineFileSource fs(nullptr);
-
- static const Response *reference = nullptr;
-
- const auto complete = [&](const Response &res) {
- counter++;
-
- // Make sure all of the Response objects are the same.
- if (!reference) {
- reference = &res;
- } else {
- EXPECT_EQ(&res, reference);
- }
-
- EXPECT_EQ(nullptr, res.error);
- ASSERT_TRUE(res.data.get());
- EXPECT_EQ("Hello World!", *res.data);
- EXPECT_EQ(Seconds::zero(), res.expires);
- EXPECT_EQ(Seconds::zero(), res.modified);
- EXPECT_EQ("", res.etag);
-
- if (counter >= total) {
- loop.stop();
- HTTPCoalescing.finish();
- }
- };
-
- const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" };
-
- std::unique_ptr<FileRequest> reqs[total];
- for (int i = 0; i < total; i++) {
- reqs[i] = fs.request(resource, [&complete, &fs, &reqs, i] (Response res) {
- reqs[i].reset();
- complete(res);
- });
- }
-
- loop.run();
-}
-
-TEST_F(Storage, HTTPMultiple) {
- SCOPED_TEST(HTTPMultiple)
-
- using namespace mbgl;
-
- util::RunLoop loop;
- OnlineFileSource fs(nullptr);
-
- const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test?expires=2147483647" };
- std::unique_ptr<FileRequest> req1;
- std::unique_ptr<FileRequest> req2;
- req1 = fs.request(resource, [&] (Response res) {
- // Do not cancel the request right away.
- EXPECT_EQ(nullptr, res.error);
- ASSERT_TRUE(res.data.get());
- EXPECT_EQ("Hello World!", *res.data);
- EXPECT_EQ(2147483647, res.expires.count());
- EXPECT_EQ(Seconds::zero(), res.modified);
- EXPECT_EQ("", res.etag);
-
- // Start a second request for the same resource after the first one has been completed.
- req2 = fs.request(resource, [&, res] (Response res2) {
- // Make sure we get the same data as before.
- EXPECT_EQ(res.data.get(), res2.data.get());
-
- // Now cancel both requests after both have been notified.
- req1.reset();
- req2.reset();
-
- EXPECT_EQ(nullptr, res2.error);
- ASSERT_TRUE(res2.data.get());
- EXPECT_EQ("Hello World!", *res2.data);
- EXPECT_EQ(2147483647, res2.expires.count());
- EXPECT_EQ(Seconds::zero(), res2.modified);
- EXPECT_EQ("", res2.etag);
-
- loop.stop();
- HTTPMultiple.finish();
- });
- });
-
- loop.run();
-}
-
-// Tests that we get stale responses from previous requests when requesting the same thing again.
-TEST_F(Storage, HTTPStale) {
- SCOPED_TEST(HTTPStale)
-
- using namespace mbgl;
-
- util::RunLoop loop;
- OnlineFileSource fs(nullptr);
-
- int updates = 0;
- int stale = 0;
-
- const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" };
- std::unique_ptr<FileRequest> req1;
- std::unique_ptr<FileRequest> req2;
- req1 = fs.request(resource, [&] (Response res) {
- // Do not cancel the request right away.
- EXPECT_EQ(nullptr, res.error);
- ASSERT_TRUE(res.data.get());
- EXPECT_EQ("Hello World!", *res.data);
- EXPECT_EQ(false, res.stale);
- EXPECT_EQ(Seconds::zero(), res.expires);
- EXPECT_EQ(Seconds::zero(), res.modified);
- EXPECT_EQ("", res.etag);
-
- // Don't start the request twice in case this callback gets fired multiple times.
- if (req2) {
- return;
- }
-
- updates++;
-
- // Start a second request for the same resource after the first one has been completed.
- req2 = fs.request(resource, [&] (Response res2) {
- EXPECT_EQ(nullptr, res2.error);
- ASSERT_TRUE(res2.data.get());
- EXPECT_EQ("Hello World!", *res2.data);
- EXPECT_EQ(Seconds::zero(), res2.expires);
- EXPECT_EQ(Seconds::zero(), res2.modified);
- EXPECT_EQ("", res2.etag);
-
- if (res2.stale) {
- EXPECT_EQ(0, stale);
- stale++;
- } else {
- // Now cancel both requests after both have been notified.
- req1.reset();
- req2.reset();
- loop.stop();
- HTTPStale.finish();
- }
- });
- });
-
- loop.run();
-
- EXPECT_EQ(1, stale);
- EXPECT_EQ(1, updates);
-}
diff --git a/test/test.gypi b/test/test.gypi
index e92a706894..f8818e2084 100644
--- a/test/test.gypi
+++ b/test/test.gypi
@@ -76,7 +76,6 @@
'storage/asset_file_source.cpp',
'storage/headers.cpp',
'storage/http_cancel.cpp',
- 'storage/http_coalescing.cpp',
'storage/http_error.cpp',
'storage/http_header_parsing.cpp',
'storage/http_issue_1369.cpp',