summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-05-13 15:41:22 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-05-13 17:24:22 +0200
commitcd65a43855f33555eca5f3e3ad5d37661253209f (patch)
treed83b63f4baeb3672c4909a08b14783c717b74681 /test
parentc1dde52c73061a49d576454a9ab4739e72561ca6 (diff)
downloadqtlocation-mapboxgl-cd65a43855f33555eca5f3e3ad5d37661253209f.tar.gz
[core] move from microsecond precision timestamp to integer second precision
Diffstat (limited to 'test')
-rw-r--r--test/map/map.cpp2
-rw-r--r--test/storage/default_file_source.cpp4
-rw-r--r--test/storage/http_file_source.cpp6
-rw-r--r--test/storage/online_file_source.cpp10
4 files changed, 11 insertions, 11 deletions
diff --git a/test/map/map.cpp b/test/map/map.cpp
index 2c5756b156..4ee44ca613 100644
--- a/test/map/map.cpp
+++ b/test/map/map.cpp
@@ -22,7 +22,7 @@ TEST(Map, Offline) {
auto expiredItem = [] (const std::string& path) {
Response response;
response.data = std::make_shared<std::string>(util::read_file("test/fixtures/map/offline/"s + path));
- response.expires = SystemClock::from_time_t(0);
+ response.expires = Timestamp{ Seconds(0) };
return response;
};
diff --git a/test/storage/default_file_source.cpp b/test/storage/default_file_source.cpp
index 8061470fca..09b10007e4 100644
--- a/test/storage/default_file_source.cpp
+++ b/test/storage/default_file_source.cpp
@@ -104,7 +104,7 @@ TEST(DefaultFileSource, TEST_REQUIRES_SERVER(CacheRevalidateModified)) {
ASSERT_TRUE(res.data.get());
EXPECT_EQ("Response", *res.data);
EXPECT_FALSE(bool(res.expires));
- EXPECT_EQ(SystemClock::from_time_t(1420070400), *res.modified);
+ EXPECT_EQ(Timestamp{ Seconds(1420070400) }, *res.modified);
EXPECT_FALSE(res.etag);
// Second request returns the cached response, then immediately revalidates.
@@ -119,7 +119,7 @@ TEST(DefaultFileSource, TEST_REQUIRES_SERVER(CacheRevalidateModified)) {
EXPECT_TRUE(res2.notModified);
ASSERT_FALSE(res2.data.get());
EXPECT_TRUE(bool(res2.expires));
- EXPECT_EQ(SystemClock::from_time_t(1420070400), *res2.modified);
+ EXPECT_EQ(Timestamp{ Seconds(1420070400) }, *res2.modified);
EXPECT_FALSE(res2.etag);
loop.stop();
diff --git a/test/storage/http_file_source.cpp b/test/storage/http_file_source.cpp
index 53d9a248c2..5b081d7d57 100644
--- a/test/storage/http_file_source.cpp
+++ b/test/storage/http_file_source.cpp
@@ -130,8 +130,8 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(ExpiresParsing)) {
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
EXPECT_EQ("Hello World!", *res.data);
- EXPECT_EQ(SystemClock::from_time_t(1420797926), res.expires);
- EXPECT_EQ(SystemClock::from_time_t(1420794326), res.modified);
+ EXPECT_EQ(Timestamp{ Seconds(1420797926) }, res.expires);
+ EXPECT_EQ(Timestamp{ Seconds(1420794326) }, res.modified);
EXPECT_EQ("foo", *res.etag);
loop.stop();
});
@@ -147,7 +147,7 @@ TEST(HTTPFileSource, TEST_REQUIRES_SERVER(CacheControlParsing)) {
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
EXPECT_EQ("Hello World!", *res.data);
- EXPECT_GT(Seconds(2), util::abs(*res.expires - SystemClock::now() - Seconds(120))) << "Expiration date isn't about 120 seconds in the future";
+ EXPECT_GT(Seconds(2), util::abs(*res.expires - util::now() - Seconds(120))) << "Expiration date isn't about 120 seconds in the future";
EXPECT_FALSE(bool(res.modified));
EXPECT_FALSE(bool(res.etag));
loop.stop();
diff --git a/test/storage/online_file_source.cpp b/test/storage/online_file_source.cpp
index dced95c196..18179c8448 100644
--- a/test/storage/online_file_source.cpp
+++ b/test/storage/online_file_source.cpp
@@ -148,7 +148,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryDelayOnExpiredTile)) {
std::unique_ptr<AsyncRequest> req = fs.request(resource, [&](Response res) {
counter++;
EXPECT_EQ(nullptr, res.error);
- EXPECT_GT(SystemClock::now(), res.expires);
+ EXPECT_GT(util::now(), res.expires);
});
util::Timer timer;
@@ -172,12 +172,12 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RetryOnClockSkew)) {
switch (counter++) {
case 0: {
EXPECT_EQ(nullptr, res.error);
- EXPECT_GT(SystemClock::now(), res.expires);
+ EXPECT_GT(util::now(), res.expires);
} break;
case 1: {
EXPECT_EQ(nullptr, res.error);
- auto now = SystemClock::now();
+ auto now = util::now();
EXPECT_LT(now + Seconds(40), res.expires) << "Expiration not interpolated to 60s";
EXPECT_GT(now + Seconds(80), res.expires) << "Expiration not interpolated to 60s";
@@ -195,7 +195,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectPriorExpires)) {
// Very long expiration time, should never arrive.
Resource resource1{ Resource::Unknown, "http://127.0.0.1:3000/test" };
- resource1.priorExpires = SystemClock::now() + Seconds(100000);
+ resource1.priorExpires = util::now() + Seconds(100000);
std::unique_ptr<AsyncRequest> req1 = fs.request(resource1, [&](Response) {
FAIL() << "Should never be called";
@@ -210,7 +210,7 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectPriorExpires)) {
// Very long expiration time, should never arrive.
Resource resource3{ Resource::Unknown, "http://127.0.0.1:3000/test" };
- resource3.priorExpires = SystemClock::now() + Seconds(100000);
+ resource3.priorExpires = util::now() + Seconds(100000);
std::unique_ptr<AsyncRequest> req3 = fs.request(resource3, [&](Response) {
FAIL() << "Should never be called";