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

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

Issue 2353813002: Match offline page url with fragment identifier stripped (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « components/offline_pages/offline_page_model_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 namespace offline_pages { 38 namespace offline_pages {
39 39
40 namespace { 40 namespace {
41 const char kTestClientNamespace[] = "CLIENT_NAMESPACE"; 41 const char kTestClientNamespace[] = "CLIENT_NAMESPACE";
42 const char kUserRequestedNamespace[] = "download"; 42 const char kUserRequestedNamespace[] = "download";
43 const GURL kTestUrl("http://example.com"); 43 const GURL kTestUrl("http://example.com");
44 const GURL kTestUrl2("http://other.page.com"); 44 const GURL kTestUrl2("http://other.page.com");
45 const GURL kTestUrl3("http://test.xyz"); 45 const GURL kTestUrl3("http://test.xyz");
46 const GURL kTestUrl4("http://page.net"); 46 const GURL kTestUrl4("http://page.net");
47 const GURL kFileUrl("file:///foo"); 47 const GURL kFileUrl("file:///foo");
48 const GURL kTestUrlWithFragment("http://example.com#frag");
49 const GURL kTestUrl2WithFragment("http://other.page.com#frag");
50 const GURL kTestUrl2WithFragment2("http://other.page.com#frag2");
48 const ClientId kTestClientId1(kTestClientNamespace, "1234"); 51 const ClientId kTestClientId1(kTestClientNamespace, "1234");
49 const ClientId kTestClientId2(kTestClientNamespace, "5678"); 52 const ClientId kTestClientId2(kTestClientNamespace, "5678");
50 const ClientId kTestClientId3(kTestClientNamespace, "42"); 53 const ClientId kTestClientId3(kTestClientNamespace, "42");
51 const ClientId kTestUserRequestedClientId(kUserRequestedNamespace, "714"); 54 const ClientId kTestUserRequestedClientId(kUserRequestedNamespace, "714");
52 const int64_t kTestFileSize = 876543LL; 55 const int64_t kTestFileSize = 876543LL;
53 const base::string16 kTestTitle = base::UTF8ToUTF16("a title"); 56 const base::string16 kTestTitle = base::UTF8ToUTF16("a title");
54 57
55 bool URLSpecContains(std::string contains_value, const GURL& url) { 58 bool URLSpecContains(std::string contains_value, const GURL& url) {
56 std::string spec = url.spec(); 59 std::string spec = url.spec();
57 return spec.find(contains_value) != std::string::npos; 60 return spec.find(contains_value) != std::string::npos;
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 929
927 pages = GetPagesByOnlineURL(kTestUrl); 930 pages = GetPagesByOnlineURL(kTestUrl);
928 EXPECT_EQ(1U, pages.size()); 931 EXPECT_EQ(1U, pages.size());
929 EXPECT_EQ(kTestUrl, pages[0].url); 932 EXPECT_EQ(kTestUrl, pages[0].url);
930 EXPECT_EQ(kTestClientId1, pages[0].client_id); 933 EXPECT_EQ(kTestClientId1, pages[0].client_id);
931 934
932 pages = GetPagesByOnlineURL(GURL("http://foo")); 935 pages = GetPagesByOnlineURL(GURL("http://foo"));
933 EXPECT_EQ(0U, pages.size()); 936 EXPECT_EQ(0U, pages.size());
934 } 937 }
935 938
939 TEST_F(OfflinePageModelImplTest, GetPagesByOnlineURLWithFragment) {
940 SavePage(kTestUrl, kTestClientId1);
941 SavePage(kTestUrl2WithFragment, kTestClientId2);
942
943 MultipleOfflinePageItemResult pages =
944 GetPagesByOnlineURL(kTestUrlWithFragment);
945 EXPECT_EQ(1U, pages.size());
946 EXPECT_EQ(kTestUrl, pages[0].url);
947 EXPECT_EQ(kTestClientId1, pages[0].client_id);
948
949 pages = GetPagesByOnlineURL(kTestUrl2);
950 EXPECT_EQ(1U, pages.size());
951 EXPECT_EQ(kTestUrl2WithFragment, pages[0].url);
952 EXPECT_EQ(kTestClientId2, pages[0].client_id);
953
954 pages = GetPagesByOnlineURL(kTestUrl2WithFragment2);
955 EXPECT_EQ(1U, pages.size());
956 EXPECT_EQ(kTestUrl2WithFragment, pages[0].url);
957 EXPECT_EQ(kTestClientId2, pages[0].client_id);
958 }
959
936 TEST_F(OfflinePageModelImplTest, CheckPagesExistOffline) { 960 TEST_F(OfflinePageModelImplTest, CheckPagesExistOffline) {
937 SavePage(kTestUrl, kTestClientId1); 961 SavePage(kTestUrl, kTestClientId1);
938 SavePage(kTestUrl2, kTestClientId2); 962 SavePage(kTestUrl2, kTestClientId2);
939 963
940 // TODO(dewittj): Remove the "Last N" restriction in favor of a better query 964 // TODO(dewittj): Remove the "Last N" restriction in favor of a better query
941 // interface. See https://crbug.com/622763 for information. 965 // interface. See https://crbug.com/622763 for information.
942 const ClientId last_n_client_id(kLastNNamespace, "1234"); 966 const ClientId last_n_client_id(kLastNNamespace, "1234");
943 SavePage(kTestUrl3, last_n_client_id); 967 SavePage(kTestUrl3, last_n_client_id);
944 968
945 std::set<GURL> input; 969 std::set<GURL> input;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 // Check if feature is correctly enabled by command-line flag. 1251 // Check if feature is correctly enabled by command-line flag.
1228 scoped_feature_list.reset(new base::test::ScopedFeatureList); 1252 scoped_feature_list.reset(new base::test::ScopedFeatureList);
1229 scoped_feature_list->InitFromCommandLine( 1253 scoped_feature_list->InitFromCommandLine(
1230 std::string(kOfflineBookmarksFeature.name) + "," + 1254 std::string(kOfflineBookmarksFeature.name) + "," +
1231 kOfflinePagesSharingFeature.name, 1255 kOfflinePagesSharingFeature.name,
1232 ""); 1256 "");
1233 EXPECT_TRUE(offline_pages::IsOfflinePagesSharingEnabled()); 1257 EXPECT_TRUE(offline_pages::IsOfflinePagesSharingEnabled());
1234 } 1258 }
1235 1259
1236 } // namespace offline_pages 1260 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698