| OLD | NEW |
| 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 DISALLOW_COPY_AND_ASSIGN(LoadImageRequestInterceptor); | 736 DISALLOW_COPY_AND_ASSIGN(LoadImageRequestInterceptor); |
| 737 }; | 737 }; |
| 738 | 738 |
| 739 class LoadImageBrowserTest : public InProcessBrowserTest { | 739 class LoadImageBrowserTest : public InProcessBrowserTest { |
| 740 protected: | 740 protected: |
| 741 void SetupAndLoadImagePage(const std::string& image_path) { | 741 void SetupAndLoadImagePage(const std::string& image_path) { |
| 742 ASSERT_TRUE(embedded_test_server()->Start()); | 742 ASSERT_TRUE(embedded_test_server()->Start()); |
| 743 // Go to a page with an image in it. The test server doesn't serve the image | 743 // Go to a page with an image in it. The test server doesn't serve the image |
| 744 // with the right MIME type, so use a data URL to make a page containing it. | 744 // with the right MIME type, so use a data URL to make a page containing it. |
| 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( |
| 747 "data:text/html,<img width=50 height=50 " |
| 748 "src='" + |
| 749 image_url.spec() + "'>"); |
| 747 ui_test_utils::NavigateToURL(browser(), page); | 750 ui_test_utils::NavigateToURL(browser(), page); |
| 748 } | 751 } |
| 749 | 752 |
| 750 void AddLoadImageInterceptor(const std::string& image_path) { | 753 void AddLoadImageInterceptor(const std::string& image_path) { |
| 751 interceptor_ = new LoadImageRequestInterceptor(); | 754 interceptor_ = new LoadImageRequestInterceptor(); |
| 752 std::unique_ptr<net::URLRequestInterceptor> owned_interceptor(interceptor_); | 755 std::unique_ptr<net::URLRequestInterceptor> owned_interceptor(interceptor_); |
| 753 content::BrowserThread::PostTask( | 756 content::BrowserThread::PostTask( |
| 754 content::BrowserThread::IO, FROM_HERE, | 757 content::BrowserThread::IO, FROM_HERE, |
| 755 base::Bind(&LoadImageBrowserTest::AddInterceptorForURL, | 758 base::Bind(&LoadImageBrowserTest::AddInterceptorForURL, |
| 756 base::Unretained(this), | 759 base::Unretained(this), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 786 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) { | 789 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) { |
| 787 static const char kValidImage[] = "/load_image/image.png"; | 790 static const char kValidImage[] = "/load_image/image.png"; |
| 788 SetupAndLoadImagePage(kValidImage); | 791 SetupAndLoadImagePage(kValidImage); |
| 789 AddLoadImageInterceptor(kValidImage); | 792 AddLoadImageInterceptor(kValidImage); |
| 790 AttemptLoadImage(); | 793 AttemptLoadImage(); |
| 791 interceptor_->WaitForRequests(1); | 794 interceptor_->WaitForRequests(1); |
| 792 EXPECT_EQ(1, interceptor_->num_requests()); | 795 EXPECT_EQ(1, interceptor_->num_requests()); |
| 793 } | 796 } |
| 794 | 797 |
| 795 } // namespace | 798 } // namespace |
| OLD | NEW |