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

Side by Side Diff: net/url_request/request_tracker_unittest.cc

Issue 579004: Pull latest googleurl to get various fixes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/base/net_util_unittest.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 (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "net/url_request/request_tracker.h" 5 #include "net/url_request/request_tracker.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 // Check that we can exclude "chrome://" URLs and "data:" URLs from being 193 // Check that we can exclude "chrome://" URLs and "data:" URLs from being
194 // saved into the recent requests list (graveyard), by using a filter. 194 // saved into the recent requests list (graveyard), by using a filter.
195 TEST(RequestTrackerTest, GraveyardCanBeFiltered) { 195 TEST(RequestTrackerTest, GraveyardCanBeFiltered) {
196 RequestTracker<TestRequest> tracker; 196 RequestTracker<TestRequest> tracker;
197 EXPECT_FALSE(tracker.IsUnbounded()); 197 EXPECT_FALSE(tracker.IsUnbounded());
198 198
199 tracker.SetGraveyardFilter(ShouldRequestBeAddedToGraveyard); 199 tracker.SetGraveyardFilter(ShouldRequestBeAddedToGraveyard);
200 200
201 // This will be excluded. 201 // This will be excluded.
202 TestRequest req1(GURL("chrome://dontcare")); 202 GURL url1("chrome://dontcare/");
203 TestRequest req1(url1);
203 tracker.Add(&req1); 204 tracker.Add(&req1);
204 tracker.Remove(&req1); 205 tracker.Remove(&req1);
205 206
206 // This will be be added to graveyard. 207 // This will be be added to graveyard.
207 TestRequest req2(GURL("chrome2://dontcare")); 208 GURL url2("chrome2://dontcare/");
209 TestRequest req2(url2);
208 tracker.Add(&req2); 210 tracker.Add(&req2);
209 tracker.Remove(&req2); 211 tracker.Remove(&req2);
210 212
211 // This will be be added to graveyard. 213 // This will be be added to graveyard.
212 TestRequest req3(GURL("http://foo")); 214 GURL url3("http://foo/");
215 TestRequest req3(url3);
213 tracker.Add(&req3); 216 tracker.Add(&req3);
214 tracker.Remove(&req3); 217 tracker.Remove(&req3);
215 218
216 // This will be be excluded. 219 // This will be be excluded.
217 TestRequest req4(GURL("data:sup")); 220 GURL url4("data:sup");
221 TestRequest req4(url4);
218 tracker.Add(&req4); 222 tracker.Add(&req4);
219 tracker.Remove(&req4); 223 tracker.Remove(&req4);
220 224
221 ASSERT_EQ(2u, tracker.GetRecentlyDeceased().size()); 225 ASSERT_EQ(2u, tracker.GetRecentlyDeceased().size());
222 EXPECT_EQ("chrome2://dontcare/", 226 EXPECT_EQ(url2, tracker.GetRecentlyDeceased()[0].original_url);
223 tracker.GetRecentlyDeceased()[0].original_url.spec()); 227 EXPECT_EQ(url3, tracker.GetRecentlyDeceased()[1].original_url);
224 EXPECT_EQ("http://foo/",
225 tracker.GetRecentlyDeceased()[1].original_url.spec());
226 } 228 }
227 229
228 // Convert an unbounded tracker back to being bounded. 230 // Convert an unbounded tracker back to being bounded.
229 TEST(RequestTrackerTest, ConvertUnboundedToBounded) { 231 TEST(RequestTrackerTest, ConvertUnboundedToBounded) {
230 RequestTracker<TestRequest> tracker; 232 RequestTracker<TestRequest> tracker;
231 EXPECT_FALSE(tracker.IsUnbounded()); 233 EXPECT_FALSE(tracker.IsUnbounded());
232 EXPECT_EQ(0u, tracker.GetLiveRequests().size()); 234 EXPECT_EQ(0u, tracker.GetLiveRequests().size());
233 EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size()); 235 EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size());
234 236
235 tracker.SetUnbounded(true); 237 tracker.SetUnbounded(true);
(...skipping 19 matching lines...) Expand all
255 TestRequest req(GURL(StringPrintf("http://req%" PRIuS, i).c_str())); 257 TestRequest req(GURL(StringPrintf("http://req%" PRIuS, i).c_str()));
256 tracker.Add(&req); 258 tracker.Add(&req);
257 tracker.Remove(&req); 259 tracker.Remove(&req);
258 } 260 }
259 261
260 // We should only have kMaxGraveyardSize entries now. 262 // We should only have kMaxGraveyardSize entries now.
261 ASSERT_EQ(kMaxSize, tracker.GetRecentlyDeceased().size()); 263 ASSERT_EQ(kMaxSize, tracker.GetRecentlyDeceased().size());
262 } 264 }
263 265
264 } // namespace 266 } // namespace
OLDNEW
« no previous file with comments | « net/base/net_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698