[core] Replace time_t with std::chrono::seconds

Added aliases for std::chrono typedefs (eg. 'Seconds' for
std::chrono::seconds). These aliases are used together with templated
helper functions to replace time_t with std::chrono::seconds for most
cases, in particular for 'modified' and 'expires' values in Response.
This commit is contained in:
Bruno de Oliveira Abinader
2015-11-25 13:30:32 +02:00
parent 4475f54860
commit 31fd2822f5
30 changed files with 184 additions and 121 deletions

View File

@@ -3,6 +3,7 @@
#include <uv.h>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/run_loop.hpp>
TEST_F(Storage, HTTPCoalescing) {
@@ -31,8 +32,8 @@ TEST_F(Storage, HTTPCoalescing) {
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
EXPECT_EQ("Hello World!", *res.data);
EXPECT_EQ(0, res.expires);
EXPECT_EQ(0, res.modified);
EXPECT_EQ(Seconds::zero(), res.expires);
EXPECT_EQ(Seconds::zero(), res.modified);
EXPECT_EQ("", res.etag);
if (counter >= total) {
@@ -70,8 +71,8 @@ TEST_F(Storage, HTTPMultiple) {
EXPECT_EQ(nullptr, res.error);
ASSERT_TRUE(res.data.get());
EXPECT_EQ("Hello World!", *res.data);
EXPECT_EQ(2147483647, res.expires);
EXPECT_EQ(0, res.modified);
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.
@@ -86,8 +87,8 @@ TEST_F(Storage, HTTPMultiple) {
EXPECT_EQ(nullptr, res2.error);
ASSERT_TRUE(res2.data.get());
EXPECT_EQ("Hello World!", *res2.data);
EXPECT_EQ(2147483647, res2.expires);
EXPECT_EQ(0, res2.modified);
EXPECT_EQ(2147483647, res2.expires.count());
EXPECT_EQ(Seconds::zero(), res2.modified);
EXPECT_EQ("", res2.etag);
loop.stop();
@@ -119,8 +120,8 @@ TEST_F(Storage, HTTPStale) {
ASSERT_TRUE(res.data.get());
EXPECT_EQ("Hello World!", *res.data);
EXPECT_EQ(false, res.stale);
EXPECT_EQ(0, res.expires);
EXPECT_EQ(0, res.modified);
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.
@@ -135,8 +136,8 @@ TEST_F(Storage, HTTPStale) {
EXPECT_EQ(nullptr, res2.error);
ASSERT_TRUE(res2.data.get());
EXPECT_EQ("Hello World!", *res2.data);
EXPECT_EQ(0, res2.expires);
EXPECT_EQ(0, res2.modified);
EXPECT_EQ(Seconds::zero(), res2.expires);
EXPECT_EQ(Seconds::zero(), res2.modified);
EXPECT_EQ("", res2.etag);
if (res2.stale) {