| OLD | NEW |
| 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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 input.insert(kTestUrl2); | 875 input.insert(kTestUrl2); |
| 876 input.insert(kTestUrl3); | 876 input.insert(kTestUrl3); |
| 877 | 877 |
| 878 CheckPagesExistOfflineResult existing_pages = CheckPagesExistOffline(input); | 878 CheckPagesExistOfflineResult existing_pages = CheckPagesExistOffline(input); |
| 879 EXPECT_EQ(2U, existing_pages.size()); | 879 EXPECT_EQ(2U, existing_pages.size()); |
| 880 EXPECT_NE(existing_pages.end(), existing_pages.find(kTestUrl)); | 880 EXPECT_NE(existing_pages.end(), existing_pages.find(kTestUrl)); |
| 881 EXPECT_NE(existing_pages.end(), existing_pages.find(kTestUrl2)); | 881 EXPECT_NE(existing_pages.end(), existing_pages.find(kTestUrl2)); |
| 882 EXPECT_EQ(existing_pages.end(), existing_pages.find(kTestUrl3)); | 882 EXPECT_EQ(existing_pages.end(), existing_pages.find(kTestUrl3)); |
| 883 } | 883 } |
| 884 | 884 |
| 885 TEST_F(OfflinePageModelImplTest, CanSavePage) { | |
| 886 EXPECT_TRUE(OfflinePageModel::CanSavePage(GURL("http://foo"))); | |
| 887 EXPECT_TRUE(OfflinePageModel::CanSavePage(GURL("https://foo"))); | |
| 888 EXPECT_FALSE(OfflinePageModel::CanSavePage(GURL("file:///foo"))); | |
| 889 EXPECT_FALSE(OfflinePageModel::CanSavePage(GURL("data:image/png;base64,ab"))); | |
| 890 EXPECT_FALSE(OfflinePageModel::CanSavePage(GURL("chrome://version"))); | |
| 891 EXPECT_FALSE(OfflinePageModel::CanSavePage(GURL("chrome-native://newtab/"))); | |
| 892 } | |
| 893 | |
| 894 TEST_F(OfflinePageModelImplTest, ClearAll) { | 885 TEST_F(OfflinePageModelImplTest, ClearAll) { |
| 895 SavePage(kTestUrl, kTestClientId1); | 886 SavePage(kTestUrl, kTestClientId1); |
| 896 SavePage(kTestUrl2, kTestClientId2); | 887 SavePage(kTestUrl2, kTestClientId2); |
| 897 | 888 |
| 898 const std::vector<OfflinePageItem>& offline_pages = GetAllPages(); | 889 const std::vector<OfflinePageItem>& offline_pages = GetAllPages(); |
| 899 EXPECT_EQ(2UL, offline_pages.size()); | 890 EXPECT_EQ(2UL, offline_pages.size()); |
| 900 EXPECT_EQ(2UL, GetStore()->GetAllPages().size()); | 891 EXPECT_EQ(2UL, GetStore()->GetAllPages().size()); |
| 901 base::FilePath archiver_path = offline_pages[0].file_path; | 892 base::FilePath archiver_path = offline_pages[0].file_path; |
| 902 EXPECT_TRUE(base::PathExists(archiver_path)); | 893 EXPECT_TRUE(base::PathExists(archiver_path)); |
| 903 | 894 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 std::unique_ptr<base::FeatureList> feature_list2(new base::FeatureList); | 1043 std::unique_ptr<base::FeatureList> feature_list2(new base::FeatureList); |
| 1053 feature_list2->InitializeFromCommandLine( | 1044 feature_list2->InitializeFromCommandLine( |
| 1054 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," + | 1045 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," + |
| 1055 offline_pages::kOfflinePagesBackgroundLoadingFeature.name, | 1046 offline_pages::kOfflinePagesBackgroundLoadingFeature.name, |
| 1056 ""); | 1047 ""); |
| 1057 base::FeatureList::SetInstance(std::move(feature_list2)); | 1048 base::FeatureList::SetInstance(std::move(feature_list2)); |
| 1058 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled()); | 1049 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled()); |
| 1059 } | 1050 } |
| 1060 | 1051 |
| 1061 } // namespace offline_pages | 1052 } // namespace offline_pages |
| OLD | NEW |