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

Unified Diff: components/offline_pages/offline_page_model_impl_unittest.cc

Issue 2497703002: [Offline pages] Resetting offline page metadata store to handle LOAD/INIT failures (Closed)
Patch Set: Addressing STORE_INIT_FAILED 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_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 6cf5387ea06f9ec2c2a09c97d00068e717dcf5de..2cd062f8fa5a2a811c50e586ac5ad2841103a1f1 100644
--- a/components/offline_pages/offline_page_model_impl_unittest.cc
+++ b/components/offline_pages/offline_page_model_impl_unittest.cc
@@ -609,14 +609,6 @@ TEST_F(OfflinePageModelImplTest, GetAllPagesStoreEmpty) {
EXPECT_EQ(0UL, offline_pages.size());
}
-TEST_F(OfflinePageModelImplTest, GetAllPagesStoreFailure) {
- GetStore()->set_test_scenario(
- OfflinePageTestStore::TestScenario::LOAD_FAILED);
- const std::vector<OfflinePageItem>& offline_pages = GetAllPages();
-
- EXPECT_EQ(0UL, offline_pages.size());
-}
-
TEST_F(OfflinePageModelImplTest, DeletePageSuccessful) {
OfflinePageTestStore* store = GetStore();
@@ -1184,6 +1176,40 @@ TEST_F(OfflinePageModelImplTest, NewTabPageNamespace) {
static_cast<int>(SavePageResult::SUCCESS), 1);
}
+TEST_F(OfflinePageModelImplTest, StoreResetSuccessful) {
+ GetStore()->set_test_scenario(
+ OfflinePageTestStore::TestScenario::LOAD_FAILED_RESET_SUCCESS);
+ ResetModel();
+
+ const std::vector<OfflinePageItem>& offline_pages = GetAllPages();
+
+ EXPECT_TRUE(model()->is_loaded());
+ EXPECT_EQ(StoreState::LOADED, GetStore()->state());
+ EXPECT_EQ(0UL, offline_pages.size());
+
+ std::pair<SavePageResult, int64_t> result =
+ SavePage(kTestUrl, ClientId(kDownloadNamespace, "123"));
+
+ EXPECT_EQ(SavePageResult::SUCCESS, result.first);
+}
+
+TEST_F(OfflinePageModelImplTest, StoreResetFailed) {
+ GetStore()->set_test_scenario(
+ OfflinePageTestStore::TestScenario::LOAD_FAILED_RESET_FAILED);
+ ResetModel();
+
+ const std::vector<OfflinePageItem>& offline_pages = GetAllPages();
+
+ EXPECT_TRUE(model()->is_loaded());
+ EXPECT_EQ(StoreState::FAILED_RESET, GetStore()->state());
+ EXPECT_EQ(0UL, offline_pages.size());
+
+ std::pair<SavePageResult, int64_t> result =
+ SavePage(kTestUrl, ClientId(kDownloadNamespace, "123"));
+
+ EXPECT_EQ(SavePageResult::STORE_FAILURE, result.first);
+}
+
TEST(CommandLineFlagsTest, OfflineBookmarks) {
// Disabled by default.
EXPECT_FALSE(offline_pages::IsOfflineBookmarksEnabled());

Powered by Google App Engine
This is Rietveld 408576698