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

Side by Side Diff: chrome/browser/history/top_sites_cache_unittest.cc

Issue 655413002: Convert ARRAYSIZE_UNSAFE -> arraysize in chrome/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/history/top_sites_cache.h" 5 #include "chrome/browser/history/top_sites_cache.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 {"http://www.youtube.com/a/b?test", "http://www.youtube.com/a/b?test"}, 94 {"http://www.youtube.com/a/b?test", "http://www.youtube.com/a/b?test"},
95 // Never-seen-before URL: as-is. 95 // Never-seen-before URL: as-is.
96 {"http://maps.google.com/", "http://maps.google.com/"}, 96 {"http://maps.google.com/", "http://maps.google.com/"},
97 // Changing port number, does not match: as-is. 97 // Changing port number, does not match: as-is.
98 {"http://www.example.com:1234/", "http://www.example.com:1234"}, 98 {"http://www.example.com:1234/", "http://www.example.com:1234"},
99 // Smart enough to know that port 80 is HTTP: redirects. 99 // Smart enough to know that port 80 is HTTP: redirects.
100 {"http://www.google.com/", "http://www.gooogle.com:80"}, 100 {"http://www.google.com/", "http://www.gooogle.com:80"},
101 // Prefix should not work: as-is. 101 // Prefix should not work: as-is.
102 {"http://www.youtube.com/a", "http://www.youtube.com/a"}, 102 {"http://www.youtube.com/a", "http://www.youtube.com/a"},
103 }; 103 };
104 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 104 for (size_t i = 0; i < arraysize(test_cases); ++i) {
105 std::string expected(test_cases[i].expected); 105 std::string expected(test_cases[i].expected);
106 std::string query(test_cases[i].query); 106 std::string query(test_cases[i].query);
107 EXPECT_EQ(expected, cache_.GetCanonicalURL(GURL(query)).spec()) 107 EXPECT_EQ(expected, cache_.GetCanonicalURL(GURL(query)).spec())
108 << " for test_case[" << i << "]"; 108 << " for test_case[" << i << "]";
109 } 109 }
110 } 110 }
111 111
112 TEST_F(TopSitesCacheTest, IsKnownUrl) { 112 TEST_F(TopSitesCacheTest, IsKnownUrl) {
113 InitTopSiteCache(kTopSitesSpecBasic, arraysize(kTopSitesSpecBasic)); 113 InitTopSiteCache(kTopSitesSpecBasic, arraysize(kTopSitesSpecBasic));
114 // Matches. 114 // Matches.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 {"", "http://www.chromium.org/a/beeswax"}, 193 {"", "http://www.chromium.org/a/beeswax"},
194 // String prefix match and URL-prefix match: redirects. 194 // String prefix match and URL-prefix match: redirects.
195 {"http://www.google.com/", "http://www.google.com/shhhhhh"}, 195 {"http://www.google.com/", "http://www.google.com/shhhhhh"},
196 // Different protocol: fails. 196 // Different protocol: fails.
197 {"", "https://www.google.com/test"}, 197 {"", "https://www.google.com/test"},
198 // Smart enough to know that port 80 is HTTP: redirects. 198 // Smart enough to know that port 80 is HTTP: redirects.
199 {"http://www.google.com/", "http://www.google.com:80/test"}, 199 {"http://www.google.com/", "http://www.google.com:80/test"},
200 // Specialized match only: fails. 200 // Specialized match only: fails.
201 {"", "http://www.chromium.org/a"}, 201 {"", "http://www.chromium.org/a"},
202 }; 202 };
203 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 203 for (size_t i = 0; i < arraysize(test_cases); ++i) {
204 std::string expected(test_cases[i].expected); 204 std::string expected(test_cases[i].expected);
205 std::string query(test_cases[i].query); 205 std::string query(test_cases[i].query);
206 GURL result(cache_.GetGeneralizedCanonicalURL(GURL(query))); 206 GURL result(cache_.GetGeneralizedCanonicalURL(GURL(query)));
207 EXPECT_EQ(expected, result.spec()) << " for test_case[" << i << "]"; 207 EXPECT_EQ(expected, result.spec()) << " for test_case[" << i << "]";
208 } 208 }
209 } 209 }
210 210
211 // This tests a special case where there are 2 generalized matches, and both 211 // This tests a special case where there are 2 generalized matches, and both
212 // should be checked to find the correct match. 212 // should be checked to find the correct match.
213 TEST_F(TopSitesCacheTest, GetPrefixCanonicalURLDiffByQuery) { 213 TEST_F(TopSitesCacheTest, GetPrefixCanonicalURLDiffByQuery) {
(...skipping 12 matching lines...) Expand all
226 // Slightly before "http://www.source.com/a?m=5". 226 // Slightly before "http://www.source.com/a?m=5".
227 {"http://www.dest.com/1", "http://www.source.com/a?l=5"}, 227 {"http://www.dest.com/1", "http://www.source.com/a?l=5"},
228 // Slightly after "http://www.source.com/a?m=5". 228 // Slightly after "http://www.source.com/a?m=5".
229 {"http://www.dest.com/1", "http://www.source.com/a?n=5"}, 229 {"http://www.dest.com/1", "http://www.source.com/a?n=5"},
230 // Slightly before "http://www.source.com/a/t?q=3". 230 // Slightly before "http://www.source.com/a/t?q=3".
231 {"http://www.dest.com/2", "http://www.source.com/a/t?q=2"}, 231 {"http://www.dest.com/2", "http://www.source.com/a/t?q=2"},
232 // Slightly after "http://www.source.com/a/t?q=3". 232 // Slightly after "http://www.source.com/a/t?q=3".
233 {"http://www.dest.com/2", "http://www.source.com/a/t?q=4"}, 233 {"http://www.dest.com/2", "http://www.source.com/a/t?q=4"},
234 }; 234 };
235 235
236 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 236 for (size_t i = 0; i < arraysize(test_cases); ++i) {
237 std::string expected(test_cases[i].expected); 237 std::string expected(test_cases[i].expected);
238 std::string query(test_cases[i].query); 238 std::string query(test_cases[i].query);
239 GURL result(cache_.GetGeneralizedCanonicalURL(GURL(query))); 239 GURL result(cache_.GetGeneralizedCanonicalURL(GURL(query)));
240 EXPECT_EQ(expected, result.spec()) << " for test_case[" << i << "]"; 240 EXPECT_EQ(expected, result.spec()) << " for test_case[" << i << "]";
241 } 241 }
242 } 242 }
243 243
244 // This test ensures forced URLs behave in the expected way. 244 // This test ensures forced URLs behave in the expected way.
245 TEST_F(TopSitesCacheTest, CacheForcedURLs) { 245 TEST_F(TopSitesCacheTest, CacheForcedURLs) {
246 // Forced URLs must always appear at the beginning of the list. 246 // Forced URLs must always appear at the beginning of the list.
247 BuildTopSites(kTopSitesSpecBasic, arraysize(kTopSitesSpecBasic)); 247 BuildTopSites(kTopSitesSpecBasic, arraysize(kTopSitesSpecBasic));
248 top_sites_[0].last_forced_time = base::Time::FromJsTime(1000); 248 top_sites_[0].last_forced_time = base::Time::FromJsTime(1000);
249 top_sites_[1].last_forced_time = base::Time::FromJsTime(2000); 249 top_sites_[1].last_forced_time = base::Time::FromJsTime(2000);
250 cache_.SetTopSites(top_sites_); 250 cache_.SetTopSites(top_sites_);
251 251
252 EXPECT_EQ(2u, cache_.GetNumForcedURLs()); 252 EXPECT_EQ(2u, cache_.GetNumForcedURLs());
253 EXPECT_EQ(2u, cache_.GetNumNonForcedURLs()); 253 EXPECT_EQ(2u, cache_.GetNumNonForcedURLs());
254 } 254 }
255 255
256 } // namespace 256 } // namespace
257 257
258 } // namespace history 258 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/in_memory_url_index_unittest.cc ('k') | chrome/browser/history/url_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698