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

Unified Diff: components/offline_pages/offline_page_model_unittest.cc

Issue 1473043002: [Offline pages] Fixing a crash in URL change, when offline copy not present (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding tests for 2 crashing bugs Created 5 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
« no previous file with comments | « components/offline_pages/offline_page_model.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/offline_page_model_unittest.cc
diff --git a/components/offline_pages/offline_page_model_unittest.cc b/components/offline_pages/offline_page_model_unittest.cc
index b6b6a8a5bb94eaaeabe0cdd6076de8907d93c780..d8ba53c0995c69d039bc9ff571cb9e0ac476345b 100644
--- a/components/offline_pages/offline_page_model_unittest.cc
+++ b/components/offline_pages/offline_page_model_unittest.cc
@@ -15,6 +15,7 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
+#include "components/bookmarks/browser/bookmark_node.h"
#include "components/offline_pages/offline_page_item.h"
#include "components/offline_pages/offline_page_metadata_store.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -950,4 +951,32 @@ TEST_F(OfflinePageModelTest, ClearAll) {
EXPECT_EQ(1UL, GetStore()->offline_pages().size());
}
+TEST_F(OfflinePageModelTest, BookmarkNodeChangesUrl) {
+ scoped_ptr<OfflinePageTestArchiver> archiver(
+ BuildArchiver(kTestUrl,
+ OfflinePageArchiver::ArchiverResult::SUCCESSFULLY_CREATED)
+ .Pass());
+ model()->SavePage(
+ kTestUrl, kTestPageBookmarkId1, archiver.Pass(),
+ base::Bind(&OfflinePageModelTest::OnSavePageDone, AsWeakPtr()));
+ PumpLoop();
+
+ EXPECT_EQ(1UL, model()->GetAllPages().size());
+
+ bookmarks::BookmarkNode bookmark_node(kTestPageBookmarkId1, kTestUrl2);
+ model()->BookmarkNodeChanged(nullptr, &bookmark_node);
+ PumpLoop();
+
+ // Offline copy should be removed. Chrome should not crash.
+ // http://crbug.com/558929
+ EXPECT_EQ(0UL, model()->GetAllPages().size());
+
+ // Chrome should not crash when a bookmark with no offline copy is changed.
+ // http://crbug.com/560518
+ bookmark_node.set_url(kTestUrl);
+ model()->BookmarkNodeChanged(nullptr, &bookmark_node);
+ PumpLoop();
+ EXPECT_EQ(0UL, model()->GetAllPages().size());
+}
+
} // namespace offline_pages
« no previous file with comments | « components/offline_pages/offline_page_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698