| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/prerender/prerender_manager.h" | 9 #include "chrome/browser/prerender/prerender_manager.h" |
| 10 #include "chrome/browser/prerender/prerender_tracker.h" | 10 #include "chrome/browser/prerender/prerender_tracker.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 RunEvents(); | 288 RunEvents(); |
| 289 | 289 |
| 290 FinalStatus final_status; | 290 FinalStatus final_status; |
| 291 EXPECT_FALSE(prerender_tracker()->GetFinalStatus(0, 0, &final_status)); | 291 EXPECT_FALSE(prerender_tracker()->GetFinalStatus(0, 0, &final_status)); |
| 292 EXPECT_FALSE(prerender_tracker()->IsPrerenderingOnIOThread(0, 0)); | 292 EXPECT_FALSE(prerender_tracker()->IsPrerenderingOnIOThread(0, 0)); |
| 293 | 293 |
| 294 EXPECT_FALSE(prerender_tracker()->GetFinalStatus(1, 2, &final_status)); | 294 EXPECT_FALSE(prerender_tracker()->GetFinalStatus(1, 2, &final_status)); |
| 295 EXPECT_FALSE(prerender_tracker()->IsPrerenderingOnIOThread(1, 2)); | 295 EXPECT_FALSE(prerender_tracker()->IsPrerenderingOnIOThread(1, 2)); |
| 296 } | 296 } |
| 297 | 297 |
| 298 // Tests that Prerender tracking works correctly | |
| 299 TEST_F(PrerenderTrackerTest, URLCounter) { | |
| 300 URLCounter url_counter; | |
| 301 GURL example_url("http://www.example.com"); | |
| 302 GURL gmail_url("https://www.gmail.com"); | |
| 303 | |
| 304 EXPECT_FALSE(url_counter.MatchesURL(example_url)); | |
| 305 EXPECT_FALSE(url_counter.MatchesURL(gmail_url)); | |
| 306 | |
| 307 url_counter.AddURL(example_url); | |
| 308 url_counter.AddURL(example_url); | |
| 309 url_counter.AddURL(gmail_url); | |
| 310 EXPECT_TRUE(url_counter.MatchesURL(example_url)); | |
| 311 EXPECT_TRUE(url_counter.MatchesURL(gmail_url)); | |
| 312 | |
| 313 std::vector<GURL> remove_urls; | |
| 314 remove_urls.push_back(example_url); | |
| 315 remove_urls.push_back(gmail_url); | |
| 316 url_counter.RemoveURLs(remove_urls); | |
| 317 EXPECT_TRUE(url_counter.MatchesURL(example_url)); | |
| 318 EXPECT_FALSE(url_counter.MatchesURL(gmail_url)); | |
| 319 | |
| 320 remove_urls.clear(); | |
| 321 remove_urls.push_back(example_url); | |
| 322 url_counter.RemoveURLs(remove_urls); | |
| 323 EXPECT_FALSE(url_counter.MatchesURL(example_url)); | |
| 324 EXPECT_FALSE(url_counter.MatchesURL(gmail_url)); | |
| 325 | |
| 326 url_counter.AddURL(example_url); | |
| 327 url_counter.AddURL(example_url); | |
| 328 EXPECT_TRUE(url_counter.MatchesURL(example_url)); | |
| 329 EXPECT_FALSE(url_counter.MatchesURL(gmail_url)); | |
| 330 | |
| 331 remove_urls.clear(); | |
| 332 remove_urls.push_back(example_url); | |
| 333 remove_urls.push_back(example_url); | |
| 334 url_counter.RemoveURLs(remove_urls); | |
| 335 EXPECT_FALSE(url_counter.MatchesURL(example_url)); | |
| 336 EXPECT_FALSE(url_counter.MatchesURL(gmail_url)); | |
| 337 } | |
| 338 | |
| 339 } // namespace prerender | 298 } // namespace prerender |
| OLD | NEW |