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

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

Issue 2227563003: Refactoring button field and its type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix new instances Created 4 years, 4 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
« no previous file with comments | « chrome/browser/referrer_policy_browsertest.cc ('k') | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( 200 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer(
201 content::NotificationService::AllSources()); 201 content::NotificationService::AllSources());
202 202
203 // Go to a page with a link 203 // Go to a page with a link
204 ui_test_utils::NavigateToURL( 204 ui_test_utils::NavigateToURL(
205 browser(), GURL("data:text/html,<a href='about:blank'>link</a>")); 205 browser(), GURL("data:text/html,<a href='about:blank'>link</a>"));
206 206
207 // Open a context menu. 207 // Open a context menu.
208 blink::WebMouseEvent mouse_event; 208 blink::WebMouseEvent mouse_event;
209 mouse_event.type = blink::WebInputEvent::MouseDown; 209 mouse_event.type = blink::WebInputEvent::MouseDown;
210 mouse_event.button = blink::WebMouseEvent::ButtonRight; 210 mouse_event.button = blink::WebMouseEvent::Button::Right;
211 mouse_event.x = 15; 211 mouse_event.x = 15;
212 mouse_event.y = 15; 212 mouse_event.y = 15;
213 content::WebContents* tab = 213 content::WebContents* tab =
214 browser()->tab_strip_model()->GetActiveWebContents(); 214 browser()->tab_strip_model()->GetActiveWebContents();
215 gfx::Rect offset = tab->GetContainerBounds(); 215 gfx::Rect offset = tab->GetContainerBounds();
216 mouse_event.globalX = 15 + offset.x(); 216 mouse_event.globalX = 15 + offset.x();
217 mouse_event.globalY = 15 + offset.y(); 217 mouse_event.globalY = 15 + offset.y();
218 mouse_event.clickCount = 1; 218 mouse_event.clickCount = 1;
219 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); 219 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event);
220 mouse_event.type = blink::WebInputEvent::MouseUp; 220 mouse_event.type = blink::WebInputEvent::MouseUp;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // Go to a page with a link having download attribute. 341 // Go to a page with a link having download attribute.
342 const std::string kSuggestedFilename("test_filename.png"); 342 const std::string kSuggestedFilename("test_filename.png");
343 ui_test_utils::NavigateToURL( 343 ui_test_utils::NavigateToURL(
344 browser(), 344 browser(),
345 GURL("data:text/html,<a href='about:blank' download='" + 345 GURL("data:text/html,<a href='about:blank' download='" +
346 kSuggestedFilename + "'>link</a>")); 346 kSuggestedFilename + "'>link</a>"));
347 347
348 // Open a context menu. 348 // Open a context menu.
349 blink::WebMouseEvent mouse_event; 349 blink::WebMouseEvent mouse_event;
350 mouse_event.type = blink::WebInputEvent::MouseDown; 350 mouse_event.type = blink::WebInputEvent::MouseDown;
351 mouse_event.button = blink::WebMouseEvent::ButtonRight; 351 mouse_event.button = blink::WebMouseEvent::Button::Right;
352 mouse_event.x = 15; 352 mouse_event.x = 15;
353 mouse_event.y = 15; 353 mouse_event.y = 15;
354 content::WebContents* tab = 354 content::WebContents* tab =
355 browser()->tab_strip_model()->GetActiveWebContents(); 355 browser()->tab_strip_model()->GetActiveWebContents();
356 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); 356 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event);
357 mouse_event.type = blink::WebInputEvent::MouseUp; 357 mouse_event.type = blink::WebInputEvent::MouseUp;
358 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); 358 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event);
359 359
360 // Wait for context menu to be visible. 360 // Wait for context menu to be visible.
361 menu_observer.WaitForMenuOpenAndClose(); 361 menu_observer.WaitForMenuOpenAndClose();
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 ui_test_utils::NavigateToURL(browser(), page); 646 ui_test_utils::NavigateToURL(browser(), page);
647 } 647 }
648 648
649 void AttemptImageSearch() { 649 void AttemptImageSearch() {
650 // Right-click where the image should be. 650 // Right-click where the image should be.
651 // |menu_observer_| will cause the search-by-image menu item to be clicked. 651 // |menu_observer_| will cause the search-by-image menu item to be clicked.
652 menu_observer_.reset(new ContextMenuNotificationObserver( 652 menu_observer_.reset(new ContextMenuNotificationObserver(
653 IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE)); 653 IDC_CONTENT_CONTEXT_SEARCHWEBFORIMAGE));
654 content::WebContents* tab = 654 content::WebContents* tab =
655 browser()->tab_strip_model()->GetActiveWebContents(); 655 browser()->tab_strip_model()->GetActiveWebContents();
656 content::SimulateMouseClickAt(tab, 0, blink::WebMouseEvent::ButtonRight, 656 content::SimulateMouseClickAt(tab, 0, blink::WebMouseEvent::Button::Right,
657 gfx::Point(15, 15)); 657 gfx::Point(15, 15));
658 } 658 }
659 659
660 GURL GetImageSearchURL() { 660 GURL GetImageSearchURL() {
661 static const char kImageSearchURL[] = "/imagesearch"; 661 static const char kImageSearchURL[] = "/imagesearch";
662 return embedded_test_server()->GetURL(kImageSearchURL); 662 return embedded_test_server()->GetURL(kImageSearchURL);
663 } 663 }
664 664
665 private: 665 private:
666 void SetupImageSearchEngine() { 666 void SetupImageSearchEngine() {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 base::Passed(&owned_interceptor))); 813 base::Passed(&owned_interceptor)));
814 } 814 }
815 815
816 void AttemptLoadImage() { 816 void AttemptLoadImage() {
817 // Right-click where the image should be. 817 // Right-click where the image should be.
818 // |menu_observer_| will cause the "Load image" menu item to be clicked. 818 // |menu_observer_| will cause the "Load image" menu item to be clicked.
819 menu_observer_.reset(new ContextMenuNotificationObserver( 819 menu_observer_.reset(new ContextMenuNotificationObserver(
820 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE)); 820 IDC_CONTENT_CONTEXT_LOAD_ORIGINAL_IMAGE));
821 content::WebContents* tab = 821 content::WebContents* tab =
822 browser()->tab_strip_model()->GetActiveWebContents(); 822 browser()->tab_strip_model()->GetActiveWebContents();
823 content::SimulateMouseClickAt(tab, 0, blink::WebMouseEvent::ButtonRight, 823 content::SimulateMouseClickAt(tab, 0, blink::WebMouseEvent::Button::Right,
824 gfx::Point(15, 15)); 824 gfx::Point(15, 15));
825 } 825 }
826 826
827 void AddInterceptorForURL( 827 void AddInterceptorForURL(
828 const GURL& url, 828 const GURL& url,
829 std::unique_ptr<net::URLRequestInterceptor> handler) { 829 std::unique_ptr<net::URLRequestInterceptor> handler) {
830 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 830 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
831 net::URLRequestFilter::GetInstance()->AddUrlInterceptor(url, 831 net::URLRequestFilter::GetInstance()->AddUrlInterceptor(url,
832 std::move(handler)); 832 std::move(handler));
833 } 833 }
834 834
835 LoadImageRequestInterceptor* interceptor_; 835 LoadImageRequestInterceptor* interceptor_;
836 836
837 private: 837 private:
838 std::unique_ptr<ContextMenuNotificationObserver> menu_observer_; 838 std::unique_ptr<ContextMenuNotificationObserver> menu_observer_;
839 }; 839 };
840 840
841 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) { 841 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) {
842 static const char kValidImage[] = "/load_image/image.png"; 842 static const char kValidImage[] = "/load_image/image.png";
843 SetupAndLoadImagePage(kValidImage); 843 SetupAndLoadImagePage(kValidImage);
844 AddLoadImageInterceptor(kValidImage); 844 AddLoadImageInterceptor(kValidImage);
845 AttemptLoadImage(); 845 AttemptLoadImage();
846 interceptor_->WaitForRequests(1); 846 interceptor_->WaitForRequests(1);
847 EXPECT_EQ(1, interceptor_->num_requests()); 847 EXPECT_EQ(1, interceptor_->num_requests());
848 } 848 }
849 849
850 } // namespace 850 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/referrer_policy_browsertest.cc ('k') | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698