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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 ASSERT_EQ(web_contents, active_web_contents); | 773 ASSERT_EQ(web_contents, active_web_contents); |
774 | 774 |
775 content::WebContents* new_web_contents = | 775 content::WebContents* new_web_contents = |
776 browser()->tab_strip_model()->GetWebContentsAt(1); | 776 browser()->tab_strip_model()->GetWebContentsAt(1); |
777 ASSERT_TRUE(new_web_contents); | 777 ASSERT_TRUE(new_web_contents); |
778 ASSERT_NE(web_contents, new_web_contents); | 778 ASSERT_NE(web_contents, new_web_contents); |
779 | 779 |
780 const GURL& url = new_web_contents->GetURL(); | 780 const GURL& url = new_web_contents->GetURL(); |
781 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); | 781 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
782 } | 782 } |
| 783 |
| 784 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkCtrlShiftLeftClick) { |
| 785 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 786 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); |
| 787 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
| 788 ASSERT_TRUE(guest_contents); |
| 789 |
| 790 // The link position of the test-link.pdf in page coordinates is (110, 110). |
| 791 // Convert the link position from page coordinates to screen coordinates. |
| 792 gfx::Point link_position(110, 110); |
| 793 ConvertPageCoordToScreenCoord(guest_contents, &link_position); |
| 794 |
| 795 content::WebContents* web_contents = |
| 796 browser()->tab_strip_model()->GetActiveWebContents(); |
| 797 |
| 798 #if defined(OS_MACOSX) |
| 799 int modifiers = |
| 800 blink::WebInputEvent::MetaKey | blink::WebInputEvent::ShiftKey; |
| 801 #else |
| 802 int modifiers = |
| 803 blink::WebInputEvent::ControlKey | blink::WebInputEvent::ShiftKey; |
| 804 #endif |
| 805 |
| 806 content::WindowedNotificationObserver observer( |
| 807 chrome::NOTIFICATION_TAB_ADDED, |
| 808 content::NotificationService::AllSources()); |
| 809 content::SimulateMouseClickAt(web_contents, modifiers, |
| 810 blink::WebMouseEvent::ButtonLeft, link_position); |
| 811 observer.Wait(); |
| 812 |
| 813 int tab_count = browser()->tab_strip_model()->count(); |
| 814 ASSERT_EQ(2, tab_count); |
| 815 |
| 816 content::WebContents* active_web_contents = |
| 817 browser()->tab_strip_model()->GetActiveWebContents(); |
| 818 ASSERT_NE(web_contents, active_web_contents); |
| 819 |
| 820 const GURL& url = active_web_contents->GetURL(); |
| 821 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
| 822 } |
| 823 |
| 824 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkShiftMiddleClick) { |
| 825 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 826 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); |
| 827 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
| 828 ASSERT_TRUE(guest_contents); |
| 829 |
| 830 // The link position of the test-link.pdf in page coordinates is (110, 110). |
| 831 // Convert the link position from page coordinates to screen coordinates. |
| 832 gfx::Point link_position(110, 110); |
| 833 ConvertPageCoordToScreenCoord(guest_contents, &link_position); |
| 834 |
| 835 content::WebContents* web_contents = |
| 836 browser()->tab_strip_model()->GetActiveWebContents(); |
| 837 |
| 838 content::WindowedNotificationObserver observer( |
| 839 chrome::NOTIFICATION_TAB_ADDED, |
| 840 content::NotificationService::AllSources()); |
| 841 content::SimulateMouseClickAt(web_contents, blink::WebInputEvent::ShiftKey, |
| 842 blink::WebMouseEvent::ButtonMiddle, link_position); |
| 843 observer.Wait(); |
| 844 |
| 845 int tab_count = browser()->tab_strip_model()->count(); |
| 846 ASSERT_EQ(2, tab_count); |
| 847 |
| 848 content::WebContents* active_web_contents = |
| 849 browser()->tab_strip_model()->GetActiveWebContents(); |
| 850 ASSERT_NE(web_contents, active_web_contents); |
| 851 |
| 852 const GURL& url = active_web_contents->GetURL(); |
| 853 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
| 854 } |
OLD | NEW |