Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3956)

Unified Diff: components/offline_pages/offline_page_metadata_store_impl_unittest.cc

Issue 2512073002: [Offline Pages] Removes two-step expiration related. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/offline_page_metadata_store_impl_unittest.cc
diff --git a/components/offline_pages/offline_page_metadata_store_impl_unittest.cc b/components/offline_pages/offline_page_metadata_store_impl_unittest.cc
index b62809eefcb1407015821158181f52ece6a69d35..c9fc9e3fdf95d3712fa24be5e91e8738ebaed10b 100644
--- a/components/offline_pages/offline_page_metadata_store_impl_unittest.cc
+++ b/components/offline_pages/offline_page_metadata_store_impl_unittest.cc
@@ -149,7 +149,7 @@ void BuildTestStoreWithSchemaFromM54(const base::FilePath& file) {
"client_id VARCHAR NOT NULL, "
"online_url VARCHAR NOT NULL, "
"offline_url VARCHAR NOT NULL DEFAULT '', "
- "file_path VARCHAR NOT NULL "
+ "file_path VARCHAR NOT NULL, "
"title VARCHAR NOT NULL DEFAULT ''"
")"));
ASSERT_TRUE(connection.CommitTransaction());
@@ -158,7 +158,7 @@ void BuildTestStoreWithSchemaFromM54(const base::FilePath& file) {
"(offline_id, creation_time, file_size, version, "
"last_access_time, access_count, client_namespace, "
"client_id, online_url, file_path, expiration_time, title) "
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"));
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"));
statement.BindInt64(0, kOfflineId);
statement.BindInt(1, 0);
statement.BindInt64(2, kFileSize);
@@ -221,6 +221,12 @@ void BuildTestStoreWithSchemaFromM55(const base::FilePath& file) {
ASSERT_TRUE(statement.Run());
ASSERT_TRUE(connection.DoesTableExist(OFFLINE_PAGES_TABLE_V1));
ASSERT_TRUE(connection.DoesColumnExist(OFFLINE_PAGES_TABLE_V1, "title"));
+ ASSERT_FALSE(connection.DoesColumnExist(OFFLINE_PAGES_TABLE_V1, "version"));
fgorski 2016/11/18 00:13:04 don't touch M55 code, Jian has appropriate fix in
romax 2016/11/18 20:50:48 Done.
+ ASSERT_FALSE(connection.DoesColumnExist(OFFLINE_PAGES_TABLE_V1, "status"));
+ ASSERT_FALSE(
+ connection.DoesColumnExist(OFFLINE_PAGES_TABLE_V1, "user_initiated"));
+ ASSERT_FALSE(
+ connection.DoesColumnExist(OFFLINE_PAGES_TABLE_V1, "offline_url"));
}
class OfflinePageMetadataStoreFactory {
@@ -376,9 +382,6 @@ void OfflinePageMetadataStoreTest::CheckThatOfflinePageCanBeSaved(
OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestClientId1,
base::FilePath(kFilePath), kFileSize);
offline_page.title = base::UTF8ToUTF16("a title");
- base::Time expiration_time = base::Time::Now();
- offline_page.expiration_time = expiration_time;
- offline_page.original_url = GURL(kOriginalTestURL);
fgorski 2016/11/18 00:13:04 be careful about what you are removing. original_u
romax 2016/11/18 20:50:49 Done.
store->AddOfflinePage(offline_page,
base::Bind(&OfflinePageMetadataStoreTest::AddCallback,
@@ -442,7 +445,7 @@ OfflinePageMetadataStoreTest::BuildStoreWithSchemaFromM53() {
std::unique_ptr<OfflinePageMetadataStore>
OfflinePageMetadataStoreTest::BuildStoreWithSchemaFromM54() {
std::unique_ptr<OfflinePageMetadataStore> store(
- factory_.BuildStoreM53(temp_directory_.GetPath()));
+ factory_.BuildStoreM54(temp_directory_.GetPath()));
PumpLoop();
store->GetOfflinePages(
base::Bind(&OfflinePageMetadataStoreTest::GetOfflinePagesCallback,
@@ -550,7 +553,7 @@ TEST_F(OfflinePageMetadataStoreTest, LoadVersion52Store) {
std::unique_ptr<OfflinePageMetadataStore> store(
BuildStoreWithSchemaFromM52());
- CheckThatStoreHasOneItem();
+ OfflinePageItem item = CheckThatStoreHasOneItem();
CheckThatOfflinePageCanBeSaved(std::move(store));
}
@@ -563,10 +566,6 @@ TEST_F(OfflinePageMetadataStoreTest, LoadVersion53Store) {
BuildStoreWithSchemaFromM53());
OfflinePageItem item = CheckThatStoreHasOneItem();
- // We should have a valid expiration time after upgrade.
- EXPECT_NE(base::Time::FromInternalValue(0),
- offline_pages_[0].expiration_time);
-
CheckThatOfflinePageCanBeSaved(std::move(store));
}
@@ -579,20 +578,18 @@ TEST_F(OfflinePageMetadataStoreTest, LoadVersion54Store) {
BuildStoreWithSchemaFromM54());
OfflinePageItem item = CheckThatStoreHasOneItem();
-
CheckThatOfflinePageCanBeSaved(std::move(store));
}
// Loads a string with schema from M55.
-// Because for now we only reduce the number of fields it just makes sure there
-// are no crashes in the process.
+// Because for now we only removed 'title' and added 'original_url' , it just
+// makes sure there are no crashes in the process.
// TODO(romax): Move this to sql_unittest.
TEST_F(OfflinePageMetadataStoreTest, LoadVersion55Store) {
std::unique_ptr<OfflinePageMetadataStore> store(
BuildStoreWithSchemaFromM55());
OfflinePageItem item = CheckThatStoreHasOneItem();
-
CheckThatOfflinePageCanBeSaved(std::move(store));
}
@@ -608,8 +605,6 @@ TEST_F(OfflinePageMetadataStoreTest, AddSameOfflinePageTwice) {
OfflinePageItem offline_page(GURL(kTestURL), 1234LL, kTestClientId1,
base::FilePath(kFilePath), kFileSize);
offline_page.title = base::UTF8ToUTF16("a title");
- base::Time expiration_time = base::Time::Now();
- offline_page.expiration_time = expiration_time;
store->AddOfflinePage(offline_page,
base::Bind(&OfflinePageMetadataStoreTest::AddCallback,
@@ -695,6 +690,11 @@ TEST_F(OfflinePageMetadataStoreTest, AddRemoveMultipleOfflinePages) {
// Add an offline page.
OfflinePageItem offline_page_1(GURL(kTestURL), 12345LL, kTestClientId1,
base::FilePath(kFilePath), kFileSize);
+ base::FilePath file_path_2 =
+ base::FilePath(FILE_PATH_LITERAL("//other.page.com.mhtml"));
+ OfflinePageItem offline_page_2(GURL("https://other.page.com"), 5678LL,
fgorski 2016/11/18 00:13:04 given line 710, does this compile?
romax 2016/11/18 20:50:49 Done.
+ kTestClientId2, file_path_2, 12345,
+ base::Time::Now());
store->AddOfflinePage(offline_page_1,
base::Bind(&OfflinePageMetadataStoreTest::AddCallback,
base::Unretained(this)));
@@ -767,7 +767,6 @@ TEST_F(OfflinePageMetadataStoreTest, AddRemoveMultipleOfflinePages) {
EXPECT_EQ(offline_page_2.creation_time, offline_pages_[0].creation_time);
EXPECT_EQ(offline_page_2.last_access_time,
offline_pages_[0].last_access_time);
- EXPECT_EQ(offline_page_2.expiration_time, offline_pages_[0].expiration_time);
EXPECT_EQ(offline_page_2.access_count, offline_pages_[0].access_count);
EXPECT_EQ(offline_page_2.client_id, offline_pages_[0].client_id);
}
@@ -800,7 +799,6 @@ TEST_F(OfflinePageMetadataStoreTest, UpdateOfflinePage) {
// Then update some data.
offline_page.file_size = kFileSize + 1;
offline_page.access_count++;
- offline_page.expiration_time = base::Time::Now();
offline_page.original_url = GURL("https://example.com/bar");
std::vector<OfflinePageItem> items_to_update;
items_to_update.push_back(offline_page);

Powered by Google App Engine
This is Rietveld 408576698