| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 ContextMenuNotificationObserver menu_observer( | 199 ContextMenuNotificationObserver menu_observer( |
| 200 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 200 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 201 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( | 201 ui_test_utils::WindowedTabAddedNotificationObserver tab_observer( |
| 202 content::NotificationService::AllSources()); | 202 content::NotificationService::AllSources()); |
| 203 | 203 |
| 204 // Go to a page with a link | 204 // Go to a page with a link |
| 205 ui_test_utils::NavigateToURL( | 205 ui_test_utils::NavigateToURL( |
| 206 browser(), GURL("data:text/html,<a href='about:blank'>link</a>")); | 206 browser(), GURL("data:text/html,<a href='about:blank'>link</a>")); |
| 207 | 207 |
| 208 // Open a context menu. | 208 // Open a context menu. |
| 209 blink::WebMouseEvent mouse_event; | 209 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown, |
| 210 mouse_event.type = blink::WebInputEvent::MouseDown; | 210 blink::WebInputEvent::NoModifiers, |
| 211 blink::WebInputEvent::TimeStampForTesting); |
| 211 mouse_event.button = blink::WebMouseEvent::Button::Right; | 212 mouse_event.button = blink::WebMouseEvent::Button::Right; |
| 212 mouse_event.x = 15; | 213 mouse_event.x = 15; |
| 213 mouse_event.y = 15; | 214 mouse_event.y = 15; |
| 214 content::WebContents* tab = | 215 content::WebContents* tab = |
| 215 browser()->tab_strip_model()->GetActiveWebContents(); | 216 browser()->tab_strip_model()->GetActiveWebContents(); |
| 216 gfx::Rect offset = tab->GetContainerBounds(); | 217 gfx::Rect offset = tab->GetContainerBounds(); |
| 217 mouse_event.globalX = 15 + offset.x(); | 218 mouse_event.globalX = 15 + offset.x(); |
| 218 mouse_event.globalY = 15 + offset.y(); | 219 mouse_event.globalY = 15 + offset.y(); |
| 219 mouse_event.clickCount = 1; | 220 mouse_event.clickCount = 1; |
| 220 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 221 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 221 mouse_event.type = blink::WebInputEvent::MouseUp; | 222 mouse_event.setType(blink::WebInputEvent::MouseUp); |
| 222 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 223 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 223 | 224 |
| 224 // The menu_observer will select "Open in new tab", wait for the new tab to | 225 // The menu_observer will select "Open in new tab", wait for the new tab to |
| 225 // be added. | 226 // be added. |
| 226 tab_observer.Wait(); | 227 tab_observer.Wait(); |
| 227 tab = tab_observer.GetTab(); | 228 tab = tab_observer.GetTab(); |
| 228 content::WaitForLoadStop(tab); | 229 content::WaitForLoadStop(tab); |
| 229 | 230 |
| 230 // Verify that it's the correct tab. | 231 // Verify that it's the correct tab. |
| 231 EXPECT_EQ(GURL("about:blank"), tab->GetURL()); | 232 EXPECT_EQ(GURL("about:blank"), tab->GetURL()); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 ContextMenuWaiter menu_observer(content::NotificationService::AllSources()); | 341 ContextMenuWaiter menu_observer(content::NotificationService::AllSources()); |
| 341 | 342 |
| 342 // Go to a page with a link having download attribute. | 343 // Go to a page with a link having download attribute. |
| 343 const std::string kSuggestedFilename("test_filename.png"); | 344 const std::string kSuggestedFilename("test_filename.png"); |
| 344 ui_test_utils::NavigateToURL( | 345 ui_test_utils::NavigateToURL( |
| 345 browser(), | 346 browser(), |
| 346 GURL("data:text/html,<a href='about:blank' download='" + | 347 GURL("data:text/html,<a href='about:blank' download='" + |
| 347 kSuggestedFilename + "'>link</a>")); | 348 kSuggestedFilename + "'>link</a>")); |
| 348 | 349 |
| 349 // Open a context menu. | 350 // Open a context menu. |
| 350 blink::WebMouseEvent mouse_event; | 351 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown, |
| 351 mouse_event.type = blink::WebInputEvent::MouseDown; | 352 blink::WebInputEvent::NoModifiers, |
| 353 blink::WebInputEvent::TimeStampForTesting); |
| 352 mouse_event.button = blink::WebMouseEvent::Button::Right; | 354 mouse_event.button = blink::WebMouseEvent::Button::Right; |
| 353 mouse_event.x = 15; | 355 mouse_event.x = 15; |
| 354 mouse_event.y = 15; | 356 mouse_event.y = 15; |
| 355 content::WebContents* tab = | 357 content::WebContents* tab = |
| 356 browser()->tab_strip_model()->GetActiveWebContents(); | 358 browser()->tab_strip_model()->GetActiveWebContents(); |
| 357 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 359 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 358 mouse_event.type = blink::WebInputEvent::MouseUp; | 360 mouse_event.setType(blink::WebInputEvent::MouseUp); |
| 359 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 361 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 360 | 362 |
| 361 // Wait for context menu to be visible. | 363 // Wait for context menu to be visible. |
| 362 menu_observer.WaitForMenuOpenAndClose(); | 364 menu_observer.WaitForMenuOpenAndClose(); |
| 363 | 365 |
| 364 // Compare filename. | 366 // Compare filename. |
| 365 base::string16 suggested_filename = menu_observer.params().suggested_filename; | 367 base::string16 suggested_filename = menu_observer.params().suggested_filename; |
| 366 ASSERT_EQ(kSuggestedFilename, base::UTF16ToUTF8(suggested_filename).c_str()); | 368 ASSERT_EQ(kSuggestedFilename, base::UTF16ToUTF8(suggested_filename).c_str()); |
| 367 } | 369 } |
| 368 | 370 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) { | 843 IN_PROC_BROWSER_TEST_F(LoadImageBrowserTest, LoadImage) { |
| 842 static const char kValidImage[] = "/load_image/image.png"; | 844 static const char kValidImage[] = "/load_image/image.png"; |
| 843 SetupAndLoadImagePage(kValidImage); | 845 SetupAndLoadImagePage(kValidImage); |
| 844 AddLoadImageInterceptor(kValidImage); | 846 AddLoadImageInterceptor(kValidImage); |
| 845 AttemptLoadImage(); | 847 AttemptLoadImage(); |
| 846 interceptor_->WaitForRequests(1); | 848 interceptor_->WaitForRequests(1); |
| 847 EXPECT_EQ(1, interceptor_->num_requests()); | 849 EXPECT_EQ(1, interceptor_->num_requests()); |
| 848 } | 850 } |
| 849 | 851 |
| 850 } // namespace | 852 } // namespace |
| OLD | NEW |