diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 20:39:01 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 20:39:01 +0000 |
commit | ca25209a0338e538e0199b07bbd5c2411f52e906 (patch) | |
tree | c4cb2c20599249e0c8a23b6424551280dfc6fd15 /webkit/appcache/appcache_database_unittest.cc | |
parent | 1ce698cdc9cec84dcd0eea437f266d5e0b217060 (diff) | |
download | chromium_src-ca25209a0338e538e0199b07bbd5c2411f52e906.zip chromium_src-ca25209a0338e538e0199b07bbd5c2411f52e906.tar.gz chromium_src-ca25209a0338e538e0199b07bbd5c2411f52e906.tar.bz2 |
Keep track of appcache creation and last access times.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/630009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39765 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_database_unittest.cc')
-rw-r--r-- | webkit/appcache/appcache_database_unittest.cc | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/webkit/appcache/appcache_database_unittest.cc b/webkit/appcache/appcache_database_unittest.cc index 763cd9a..f024026 100644 --- a/webkit/appcache/appcache_database_unittest.cc +++ b/webkit/appcache/appcache_database_unittest.cc @@ -12,7 +12,7 @@ namespace { -const base::TimeTicks kZeroTimeTicks; +const base::Time kZeroTime; class TestErrorDelegate : public sql::ErrorDelegate { public: @@ -166,7 +166,7 @@ TEST(AppCacheDatabaseTest, CacheRecords) { record.cache_id = 1; record.group_id = 1; record.online_wildcard = true; - record.update_time = kZeroTimeTicks; + record.update_time = kZeroTime; record.cache_size = 100; EXPECT_TRUE(db.InsertCache(&record)); EXPECT_FALSE(db.InsertCache(&record)); @@ -176,7 +176,7 @@ TEST(AppCacheDatabaseTest, CacheRecords) { EXPECT_EQ(1, record.cache_id); EXPECT_EQ(1, record.group_id); EXPECT_TRUE(record.online_wildcard); - EXPECT_TRUE(kZeroTimeTicks == record.update_time); + EXPECT_TRUE(kZeroTime == record.update_time); EXPECT_EQ(100, record.cache_size); record = kZeroRecord; @@ -184,7 +184,7 @@ TEST(AppCacheDatabaseTest, CacheRecords) { EXPECT_EQ(1, record.cache_id); EXPECT_EQ(1, record.group_id); EXPECT_TRUE(record.online_wildcard); - EXPECT_TRUE(kZeroTimeTicks == record.update_time); + EXPECT_TRUE(kZeroTime == record.update_time); EXPECT_EQ(100, record.cache_size); EXPECT_TRUE(db.DeleteCache(1)); @@ -204,6 +204,9 @@ TEST(AppCacheDatabaseTest, GroupRecords) { const GURL kManifestUrl("http://blah/manifest"); const GURL kOrigin(kManifestUrl.GetOrigin()); + const base::Time kLastAccessTime = base::Time::Now(); + const base::Time kCreationTime = + kLastAccessTime - base::TimeDelta::FromDays(7); const AppCacheDatabase::GroupRecord kZeroRecord; AppCacheDatabase::GroupRecord record; @@ -220,6 +223,8 @@ TEST(AppCacheDatabaseTest, GroupRecords) { record.group_id = 1; record.manifest_url = kManifestUrl; record.origin = kOrigin; + record.last_access_time = kLastAccessTime; + record.creation_time = kCreationTime; EXPECT_TRUE(db.InsertGroup(&record)); EXPECT_FALSE(db.InsertGroup(&record)); @@ -231,16 +236,26 @@ TEST(AppCacheDatabaseTest, GroupRecords) { EXPECT_EQ(1, record.group_id); EXPECT_EQ(kManifestUrl, record.manifest_url); EXPECT_EQ(kOrigin, record.origin); + EXPECT_EQ(kCreationTime.ToInternalValue(), + record.creation_time.ToInternalValue()); + EXPECT_EQ(kLastAccessTime.ToInternalValue(), + record.last_access_time.ToInternalValue()); record = kZeroRecord; EXPECT_TRUE(db.FindGroupForManifestUrl(kManifestUrl, &record)); EXPECT_EQ(1, record.group_id); EXPECT_EQ(kManifestUrl, record.manifest_url); EXPECT_EQ(kOrigin, record.origin); + EXPECT_EQ(kCreationTime.ToInternalValue(), + record.creation_time.ToInternalValue()); + EXPECT_EQ(kLastAccessTime.ToInternalValue(), + record.last_access_time.ToInternalValue()); record.group_id = 2; record.manifest_url = kOrigin; record.origin = kOrigin; + record.last_access_time = kLastAccessTime; + record.creation_time = kCreationTime; EXPECT_TRUE(db.InsertGroup(&record)); record = kZeroRecord; @@ -248,6 +263,10 @@ TEST(AppCacheDatabaseTest, GroupRecords) { EXPECT_EQ(2, record.group_id); EXPECT_EQ(kOrigin, record.manifest_url); EXPECT_EQ(kOrigin, record.origin); + EXPECT_EQ(kCreationTime.ToInternalValue(), + record.creation_time.ToInternalValue()); + EXPECT_EQ(kLastAccessTime.ToInternalValue(), + record.last_access_time.ToInternalValue()); EXPECT_TRUE(db.FindGroupsForOrigin(kOrigin, &records)); EXPECT_EQ(2U, records.size()); @@ -266,6 +285,10 @@ TEST(AppCacheDatabaseTest, GroupRecords) { EXPECT_EQ(2, records[0].group_id); EXPECT_EQ(kOrigin, records[0].manifest_url); EXPECT_EQ(kOrigin, records[0].origin); + EXPECT_EQ(kCreationTime.ToInternalValue(), + record.creation_time.ToInternalValue()); + EXPECT_EQ(kLastAccessTime.ToInternalValue(), + record.last_access_time.ToInternalValue()); std::set<GURL> origins; EXPECT_TRUE(db.FindOriginsWithGroups(&origins)); @@ -289,7 +312,7 @@ TEST(AppCacheDatabaseTest, GroupRecords) { cache_record.cache_id = 1; cache_record.group_id = 1; cache_record.online_wildcard = true; - cache_record.update_time = kZeroTimeTicks; + cache_record.update_time = kZeroTime; EXPECT_TRUE(db.InsertCache(&cache_record)); record = kZeroRecord; @@ -546,7 +569,7 @@ TEST(AppCacheDatabaseTest, Quotas) { cache_record.cache_id = 1; cache_record.group_id = 1; cache_record.online_wildcard = true; - cache_record.update_time = kZeroTimeTicks; + cache_record.update_time = kZeroTime; cache_record.cache_size = 100; EXPECT_TRUE(db.InsertCache(&cache_record)); @@ -559,7 +582,7 @@ TEST(AppCacheDatabaseTest, Quotas) { cache_record.cache_id = 2; cache_record.group_id = 2; cache_record.online_wildcard = true; - cache_record.update_time = kZeroTimeTicks; + cache_record.update_time = kZeroTime; cache_record.cache_size = 1000; EXPECT_TRUE(db.InsertCache(&cache_record)); @@ -572,7 +595,7 @@ TEST(AppCacheDatabaseTest, Quotas) { cache_record.cache_id = 3; cache_record.group_id = 3; cache_record.online_wildcard = true; - cache_record.update_time = kZeroTimeTicks; + cache_record.update_time = kZeroTime; cache_record.cache_size = 5000; EXPECT_TRUE(db.InsertCache(&cache_record)); |