| 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) { | 885 TEST_F(OfflinePageModelImplTest, CanSaveURL) { |
| 886 EXPECT_TRUE(OfflinePageModel::CanSavePage(GURL("http://foo"))); | 886 EXPECT_TRUE(OfflinePageModel::CanSaveURL(GURL("http://foo"))); |
| 887 EXPECT_TRUE(OfflinePageModel::CanSavePage(GURL("https://foo"))); | 887 EXPECT_TRUE(OfflinePageModel::CanSaveURL(GURL("https://foo"))); |
| 888 EXPECT_FALSE(OfflinePageModel::CanSavePage(GURL("file:///foo"))); | 888 EXPECT_FALSE(OfflinePageModel::CanSaveURL(GURL("file:///foo"))); |
| 889 EXPECT_FALSE(OfflinePageModel::CanSavePage(GURL("data:image/png;base64,ab"))); | 889 EXPECT_FALSE(OfflinePageModel::CanSaveURL(GURL("data:image/png;base64,ab"))); |
| 890 EXPECT_FALSE(OfflinePageModel::CanSavePage(GURL("chrome://version"))); | 890 EXPECT_FALSE(OfflinePageModel::CanSaveURL(GURL("chrome://version"))); |
| 891 EXPECT_FALSE(OfflinePageModel::CanSavePage(GURL("chrome-native://newtab/"))); | 891 EXPECT_FALSE(OfflinePageModel::CanSaveURL(GURL("chrome-native://newtab/"))); |
| 892 EXPECT_FALSE(OfflinePageModel::CanSaveURL(GURL("/invalid/url.mhtml"))); |
| 892 } | 893 } |
| 893 | 894 |
| 894 TEST_F(OfflinePageModelImplTest, ClearAll) { | 895 TEST_F(OfflinePageModelImplTest, ClearAll) { |
| 895 SavePage(kTestUrl, kTestClientId1); | 896 SavePage(kTestUrl, kTestClientId1); |
| 896 SavePage(kTestUrl2, kTestClientId2); | 897 SavePage(kTestUrl2, kTestClientId2); |
| 897 | 898 |
| 898 const std::vector<OfflinePageItem>& offline_pages = GetAllPages(); | 899 const std::vector<OfflinePageItem>& offline_pages = GetAllPages(); |
| 899 EXPECT_EQ(2UL, offline_pages.size()); | 900 EXPECT_EQ(2UL, offline_pages.size()); |
| 900 EXPECT_EQ(2UL, GetStore()->GetAllPages().size()); | 901 EXPECT_EQ(2UL, GetStore()->GetAllPages().size()); |
| 901 base::FilePath archiver_path = offline_pages[0].file_path; | 902 base::FilePath archiver_path = offline_pages[0].file_path; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 std::unique_ptr<base::FeatureList> feature_list2(new base::FeatureList); | 1053 std::unique_ptr<base::FeatureList> feature_list2(new base::FeatureList); |
| 1053 feature_list2->InitializeFromCommandLine( | 1054 feature_list2->InitializeFromCommandLine( |
| 1054 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," + | 1055 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," + |
| 1055 offline_pages::kOfflinePagesBackgroundLoadingFeature.name, | 1056 offline_pages::kOfflinePagesBackgroundLoadingFeature.name, |
| 1056 ""); | 1057 ""); |
| 1057 base::FeatureList::SetInstance(std::move(feature_list2)); | 1058 base::FeatureList::SetInstance(std::move(feature_list2)); |
| 1058 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled()); | 1059 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled()); |
| 1059 } | 1060 } |
| 1060 | 1061 |
| 1061 } // namespace offline_pages | 1062 } // namespace offline_pages |
| OLD | NEW |