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

Side by Side Diff: components/offline_pages/offline_page_model_impl_unittest.cc

Issue 2384423003: [Offline pages] Resetting offline page metadata store if initial load fails (Closed)
Patch Set: Rebased and comments addressed Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/offline_page_model_impl.h" 5 #include "components/offline_pages/offline_page_model_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 } 581 }
582 582
583 TEST_F(OfflinePageModelImplTest, GetAllPagesStoreFailure) { 583 TEST_F(OfflinePageModelImplTest, GetAllPagesStoreFailure) {
584 GetStore()->set_test_scenario( 584 GetStore()->set_test_scenario(
585 OfflinePageTestStore::TestScenario::LOAD_FAILED); 585 OfflinePageTestStore::TestScenario::LOAD_FAILED);
586 const std::vector<OfflinePageItem>& offline_pages = GetAllPages(); 586 const std::vector<OfflinePageItem>& offline_pages = GetAllPages();
587 587
588 EXPECT_EQ(0UL, offline_pages.size()); 588 EXPECT_EQ(0UL, offline_pages.size());
589 } 589 }
590 590
591 TEST_F(OfflinePageModelImplTest, ResetStoreSuccess) {
592 GetStore()->set_test_scenario(
593 OfflinePageTestStore::TestScenario::RESET_SUCCESS);
594 ResetModel();
595 const std::vector<OfflinePageItem>& offline_pages = GetAllPages();
596
597 EXPECT_EQ(0UL, offline_pages.size());
598 EXPECT_TRUE(GetStore()->reset_called());
599 EXPECT_EQ(StoreState::LOADED, GetStore()->state());
600 }
601
602 TEST_F(OfflinePageModelImplTest, ResetStoreFailed) {
603 GetStore()->set_test_scenario(
604 OfflinePageTestStore::TestScenario::RESET_FAILED);
605 ResetModel();
606 const std::vector<OfflinePageItem>& offline_pages = GetAllPages();
607
608 EXPECT_EQ(0UL, offline_pages.size());
609 EXPECT_TRUE(GetStore()->reset_called());
610 EXPECT_EQ(StoreState::FAILED_RESET, GetStore()->state());
611 }
612
591 TEST_F(OfflinePageModelImplTest, DeletePageSuccessful) { 613 TEST_F(OfflinePageModelImplTest, DeletePageSuccessful) {
592 OfflinePageTestStore* store = GetStore(); 614 OfflinePageTestStore* store = GetStore();
593 615
594 // Save one page. 616 // Save one page.
595 SavePage(kTestUrl, kTestClientId1); 617 SavePage(kTestUrl, kTestClientId1);
596 int64_t offline1 = last_save_offline_id(); 618 int64_t offline1 = last_save_offline_id();
597 EXPECT_EQ(SavePageResult::SUCCESS, last_save_result()); 619 EXPECT_EQ(SavePageResult::SUCCESS, last_save_result());
598 EXPECT_EQ(1u, store->GetAllPages().size()); 620 EXPECT_EQ(1u, store->GetAllPages().size());
599 621
600 ResetResults(); 622 ResetResults();
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 // Check if feature is correctly enabled by command-line flag. 1205 // Check if feature is correctly enabled by command-line flag.
1184 scoped_feature_list.reset(new base::test::ScopedFeatureList); 1206 scoped_feature_list.reset(new base::test::ScopedFeatureList);
1185 scoped_feature_list->InitFromCommandLine( 1207 scoped_feature_list->InitFromCommandLine(
1186 std::string(kOfflineBookmarksFeature.name) + "," + 1208 std::string(kOfflineBookmarksFeature.name) + "," +
1187 kOfflinePagesSharingFeature.name, 1209 kOfflinePagesSharingFeature.name,
1188 ""); 1210 "");
1189 EXPECT_TRUE(offline_pages::IsOfflinePagesSharingEnabled()); 1211 EXPECT_TRUE(offline_pages::IsOfflinePagesSharingEnabled());
1190 } 1212 }
1191 1213
1192 } // namespace offline_pages 1214 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698