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

Side by Side Diff: chrome/browser/prerender/prerender_nostate_prefetch_browsertest.cc

Issue 2950803002: Use ContainsValue() instead of std::find() in chrome/browser/ and chrome/test/ (Closed)
Patch Set: Created 3 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/stl_util.h"
8 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
9 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "base/task_scheduler/post_task.h" 13 #include "base/task_scheduler/post_task.h"
13 #include "base/test/simple_test_tick_clock.h" 14 #include "base/test/simple_test_tick_clock.h"
14 #include "chrome/browser/history/history_service_factory.h" 15 #include "chrome/browser/history/history_service_factory.h"
15 #include "chrome/browser/history/history_test_utils.h" 16 #include "chrome/browser/history/history_test_utils.h"
16 #include "chrome/browser/prerender/prerender_handle.h" 17 #include "chrome/browser/prerender/prerender_handle.h"
17 #include "chrome/browser/prerender/prerender_manager.h" 18 #include "chrome/browser/prerender/prerender_manager.h"
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 WaitForHistoryBackendToRun(profile); 587 WaitForHistoryBackendToRun(profile);
587 588
588 // Navigate to another page. 589 // Navigate to another page.
589 GURL navigated_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage2)); 590 GURL navigated_url = src_server()->GetURL(MakeAbsolute(kPrefetchPage2));
590 ui_test_utils::NavigateToURL(current_browser(), navigated_url); 591 ui_test_utils::NavigateToURL(current_browser(), navigated_url);
591 WaitForHistoryBackendToRun(profile); 592 WaitForHistoryBackendToRun(profile);
592 593
593 // Check that the URL that was explicitly navigated to is already in history. 594 // Check that the URL that was explicitly navigated to is already in history.
594 ui_test_utils::HistoryEnumerator enumerator(profile); 595 ui_test_utils::HistoryEnumerator enumerator(profile);
595 std::vector<GURL>& urls = enumerator.urls(); 596 std::vector<GURL>& urls = enumerator.urls();
596 EXPECT_TRUE(std::find(urls.begin(), urls.end(), navigated_url) != urls.end()); 597 EXPECT_TRUE(base::ContainsValue(urls, navigated_url));
597 598
598 // Check that the URL that was prefetched is not in history. 599 // Check that the URL that was prefetched is not in history.
599 EXPECT_TRUE(std::find(urls.begin(), urls.end(), prefetched_url) == 600 EXPECT_TRUE(!base::ContainsValue(urls, prefetched_url));
Nico 2017/06/20 15:05:07 EXPECT_FALSE(Contains) instead of EXPECT_TRUE(!Con
Tripta 2017/06/22 07:01:19 Done.
600 urls.end());
601 601
602 // The loader URL is the remaining entry. 602 // The loader URL is the remaining entry.
603 EXPECT_EQ(2U, urls.size()); 603 EXPECT_EQ(2U, urls.size());
604 } 604 }
605 605
606 // Checks that prefetch requests have net::IDLE priority. 606 // Checks that prefetch requests have net::IDLE priority.
607 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, IssuesIdlePriorityRequests) { 607 IN_PROC_BROWSER_TEST_F(NoStatePrefetchBrowserTest, IssuesIdlePriorityRequests) {
608 GURL script_url = src_server()->GetURL(MakeAbsolute(kPrefetchScript)); 608 GURL script_url = src_server()->GetURL(MakeAbsolute(kPrefetchScript));
609 RequestCounter script_counter; 609 RequestCounter script_counter;
610 prerender::test_utils::InterceptRequestAndCount( 610 prerender::test_utils::InterceptRequestAndCount(
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 CountRequestFor(kPrefetchPage, &page_counter); 752 CountRequestFor(kPrefetchPage, &page_counter);
753 RequestCounter script_counter; 753 RequestCounter script_counter;
754 CountRequestFor(kPrefetchScript, &script_counter); 754 CountRequestFor(kPrefetchScript, &script_counter);
755 PrefetchFromURL(prefetch_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED); 755 PrefetchFromURL(prefetch_page_url, FINAL_STATUS_NOSTATE_PREFETCH_FINISHED);
756 // Neither the page nor the script should be prefetched. 756 // Neither the page nor the script should be prefetched.
757 script_counter.WaitForCount(0); 757 script_counter.WaitForCount(0);
758 page_counter.WaitForCount(0); 758 page_counter.WaitForCount(0);
759 } 759 }
760 760
761 } // namespace prerender 761 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698