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

Side by Side Diff: chrome/browser/renderer_context_menu/render_view_context_menu_browsertest.cc

Issue 2828663002: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/{i,l,m,n,p,r}* (Closed)
Patch Set: Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer_context_menu/render_view_context_menu.h" 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 ~LoadImageRequestInterceptor() override {} 679 ~LoadImageRequestInterceptor() override {}
680 680
681 // net::URLRequestInterceptor implementation 681 // net::URLRequestInterceptor implementation
682 net::URLRequestJob* MaybeInterceptRequest( 682 net::URLRequestJob* MaybeInterceptRequest(
683 net::URLRequest* request, 683 net::URLRequest* request,
684 net::NetworkDelegate* network_delegate) const override { 684 net::NetworkDelegate* network_delegate) const override {
685 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 685 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
686 EXPECT_TRUE(request->load_flags() & net::LOAD_BYPASS_CACHE); 686 EXPECT_TRUE(request->load_flags() & net::LOAD_BYPASS_CACHE);
687 content::BrowserThread::PostTask( 687 content::BrowserThread::PostTask(
688 content::BrowserThread::UI, FROM_HERE, 688 content::BrowserThread::UI, FROM_HERE,
689 base::Bind(&LoadImageRequestInterceptor::RequestCreated, 689 base::BindOnce(&LoadImageRequestInterceptor::RequestCreated,
690 weak_factory_.GetWeakPtr())); 690 weak_factory_.GetWeakPtr()));
691 return nullptr; 691 return nullptr;
692 } 692 }
693 693
694 void WaitForRequests(int requests_to_wait_for) { 694 void WaitForRequests(int requests_to_wait_for) {
695 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 695 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
696 DCHECK_EQ(-1, requests_to_wait_for_); 696 DCHECK_EQ(-1, requests_to_wait_for_);
697 DCHECK(!run_loop_); 697 DCHECK(!run_loop_);
698 698
699 if (num_requests_ >= requests_to_wait_for) 699 if (num_requests_ >= requests_to_wait_for)
700 return; 700 return;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 GURL image_url(embedded_test_server()->GetURL(image_path)); 745 GURL image_url(embedded_test_server()->GetURL(image_path));
746 GURL page("data:text/html,<img src='" + image_url.spec() + "'>"); 746 GURL page("data:text/html,<img src='" + image_url.spec() + "'>");
747 ui_test_utils::NavigateToURL(browser(), page); 747 ui_test_utils::NavigateToURL(browser(), page);
748 } 748 }
749 749
750 void AddLoadImageInterceptor(const std::string& image_path) { 750 void AddLoadImageInterceptor(const std::string& image_path) {
751 interceptor_ = new LoadImageRequestInterceptor(); 751 interceptor_ = new LoadImageRequestInterceptor();
752 std::unique_ptr<net::URLRequestInterceptor> owned_interceptor(interceptor_); 752 std::unique_ptr<net::URLRequestInterceptor> owned_interceptor(interceptor_);
753 content::BrowserThread::PostTask( 753 content::BrowserThread::PostTask(
754 content::BrowserThread::IO, FROM_HERE, 754 content::BrowserThread::IO, FROM_HERE,
755 base::Bind(&LoadImageBrowserTest::AddInterceptorForURL, 755 base::BindOnce(&LoadImageBrowserTest::AddInterceptorForURL,
756 base::Unretained(this), 756 base::Unretained(this),
757 GURL(embedded_test_server()->GetURL(image_path).spec()), 757 GURL(embedded_test_server()->GetURL(image_path).spec()),
758 base::Passed(&owned_interceptor))); 758 base::Passed(&owned_interceptor)));
759 } 759 }
760 760
761 void AttemptLoadImage() { 761 void AttemptLoadImage() {
762 // Right-click where the image should be. 762 // Right-click where the image should be.
763 // |menu_observer_| will cause the "Load image" menu item to be clicked. 763 // |menu_observer_| will cause the "Load image" menu item to be clicked.
764 menu_observer_.reset(new ContextMenuNotificationObserver( 764 menu_observer_.reset(new ContextMenuNotificationObserver(
765 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE)); 765 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE));
766 content::WebContents* tab = 766 content::WebContents* tab =
767 browser()->tab_strip_model()->GetActiveWebContents(); 767 browser()->tab_strip_model()->GetActiveWebContents();
768 content::SimulateMouseClickAt(tab, 0, blink::WebMouseEvent::Button::kRight, 768 content::SimulateMouseClickAt(tab, 0, blink::WebMouseEvent::Button::kRight,
(...skipping 17 matching lines...) Expand all
786 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) { 786 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) {
787 static const char kValidImage[] = "/load_image/image.png"; 787 static const char kValidImage[] = "/load_image/image.png";
788 SetupAndLoadImagePage(kValidImage); 788 SetupAndLoadImagePage(kValidImage);
789 AddLoadImageInterceptor(kValidImage); 789 AddLoadImageInterceptor(kValidImage);
790 AttemptLoadImage(); 790 AttemptLoadImage();
791 interceptor_->WaitForRequests(1); 791 interceptor_->WaitForRequests(1);
792 EXPECT_EQ(1, interceptor_->num_requests()); 792 EXPECT_EQ(1, interceptor_->num_requests());
793 } 793 }
794 794
795 } // namespace 795 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698