Index: components/precache/core/precache_session_table_unittest.cc |
diff --git a/components/precache/core/precache_session_table_unittest.cc b/components/precache/core/precache_session_table_unittest.cc |
index c0d37d502730e7523d430121f2d58e97e72e934b..9302a166343d92659c44e1f3e94fb6d027ba96a0 100644 |
--- a/components/precache/core/precache_session_table_unittest.cc |
+++ b/components/precache/core/precache_session_table_unittest.cc |
@@ -2,6 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include <stdint.h> |
+ |
#include "base/compiler_specific.h" |
#include "base/time/time.h" |
#include "components/precache/core/precache_session_table.h" |
@@ -31,6 +33,33 @@ class PrecacheSessionTableTest : public testing::Test { |
std::unique_ptr<sql::Connection> db_; |
}; |
+TEST_F(PrecacheSessionTableTest, LastPrecacheTimestamp) { |
+ const base::Time sometime = base::Time::FromDoubleT(42); |
+ |
+ precache_session_table_->SetLastPrecacheTimestamp(sometime); |
+ |
+ EXPECT_EQ(sometime, precache_session_table_->GetLastPrecacheTimestamp()); |
+ |
+ precache_session_table_->DeleteLastPrecacheTimestamp(); |
+ |
+ EXPECT_EQ(base::Time(), precache_session_table_->GetLastPrecacheTimestamp()); |
+} |
+ |
+TEST_F(PrecacheSessionTableTest, LastPrecacheTimestampSaturatedInt64) { |
+ // If I merely add 1 it won't change the double due to the lack of resolution: |
+ // 63 bits of int64 vs 55 of double. |
+ const double beyond_int64_seconds = |
+ static_cast<double>(std::numeric_limits<int64_t>::max()) * 2; |
+ const base::Time large_time = base::Time::FromDoubleT(beyond_int64_seconds); |
+ |
+ precache_session_table_->SetLastPrecacheTimestamp(large_time); |
+ |
+ EXPECT_EQ(large_time, precache_session_table_->GetLastPrecacheTimestamp()); |
+ // Anyway, base::Time does int64_t saturation for us, so these saturated casts |
+ // are not strictly needed with the current implementation of base::Time. |
+ EXPECT_TRUE(large_time.is_max()); |
+} |
+ |
TEST_F(PrecacheSessionTableTest, SaveAndGetUnfinishedWork) { |
std::unique_ptr<PrecacheUnfinishedWork> unfinished_work( |
new PrecacheUnfinishedWork()); |