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

Unified Diff: components/offline_pages/offline_page_model_impl_unittest.cc

Issue 2067143004: [Offline Pages] Duplicate pages when save/delete bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments from dimich@. Created 4 years, 6 months 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_model_impl_unittest.cc
diff --git a/components/offline_pages/offline_page_model_impl_unittest.cc b/components/offline_pages/offline_page_model_impl_unittest.cc
index cb0ee364f6a5416e3d3d9ddf46dbd0aec76feb60..d17536b49f1674f7fa8e6bfb3577478ef63063e4 100644
--- a/components/offline_pages/offline_page_model_impl_unittest.cc
+++ b/components/offline_pages/offline_page_model_impl_unittest.cc
@@ -941,7 +941,7 @@ TEST_F(OfflinePageModelImplTest, SaveRetrieveMultipleClientIds) {
int64_t offline1 = last_save_offline_id();
EXPECT_TRUE(HasPages(kTestClientNamespace));
- SavePage(kTestUrl, kTestClientId1);
+ SavePage(kTestUrl2, kTestClientId1);
int64_t offline2 = last_save_offline_id();
EXPECT_NE(offline1, offline2);
@@ -959,6 +959,29 @@ TEST_F(OfflinePageModelImplTest, SaveRetrieveMultipleClientIds) {
EXPECT_TRUE(id_set.find(offline2) != id_set.end());
}
+TEST_F(OfflinePageModelImplTest, SaveMultiplePagesWithSameURLBySameClientId) {
+ EXPECT_FALSE(HasPages(kTestClientNamespace));
+ SavePage(kTestUrl, kTestClientId1);
+ int64_t offline1 = last_save_offline_id();
+ EXPECT_TRUE(HasPages(kTestClientNamespace));
+
+ SavePage(kTestUrl, kTestClientId1);
+ int64_t offline2 = last_save_offline_id();
+
+ EXPECT_NE(offline1, offline2);
+
+ const std::vector<int64_t> ids = GetOfflineIdsForClientId(kTestClientId1);
+
+ EXPECT_EQ(1UL, ids.size());
+
+ std::set<int64_t> id_set;
+ for (size_t i = 0; i < ids.size(); i++) {
+ id_set.insert(ids[i]);
+ }
+
+ EXPECT_TRUE(id_set.find(offline2) != id_set.end());
+}
+
TEST_F(OfflinePageModelImplTest, GetBestPage) {
// We will save 3 pages - two for the same URL, and one for a different URL.
// Correct behavior will pick the most recently saved page for the correct
« no previous file with comments | « components/offline_pages/offline_page_model_impl.cc ('k') | components/offline_pages/offline_page_storage_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698