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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "net/test/embedded_test_server/embedded_test_server.h" | 53 #include "net/test/embedded_test_server/embedded_test_server.h" |
54 #include "ui/base/resource/resource_bundle.h" | 54 #include "ui/base/resource/resource_bundle.h" |
55 #include "url/gurl.h" | 55 #include "url/gurl.h" |
56 | 56 |
57 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) | 57 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) |
58 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 58 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
59 #endif | 59 #endif |
60 | 60 |
61 const int kNumberLoadTestParts = 10; | 61 const int kNumberLoadTestParts = 10; |
62 | 62 |
| 63 #if defined(OS_MACOSX) |
| 64 const int kDefaultKeyModifier = blink::WebInputEvent::MetaKey; |
| 65 #else |
| 66 const int kDefaultKeyModifier = blink::WebInputEvent::ControlKey; |
| 67 #endif |
| 68 |
63 // Using ASSERT_TRUE deliberately instead of ASSERT_EQ or ASSERT_STREQ | 69 // Using ASSERT_TRUE deliberately instead of ASSERT_EQ or ASSERT_STREQ |
64 // in order to print a more readable message if the strings differ. | 70 // in order to print a more readable message if the strings differ. |
65 #define ASSERT_MULTILINE_STREQ(expected, actual) \ | 71 #define ASSERT_MULTILINE_STREQ(expected, actual) \ |
66 ASSERT_TRUE(expected == actual) \ | 72 ASSERT_TRUE(expected == actual) \ |
67 << "Expected:\n" << expected \ | 73 << "Expected:\n" << expected \ |
68 << "\n\nActual:\n" << actual | 74 << "\n\nActual:\n" << actual |
69 | 75 |
70 bool GetGuestCallback(content::WebContents** guest_out, | 76 bool GetGuestCallback(content::WebContents** guest_out, |
71 content::WebContents* guest) { | 77 content::WebContents* guest) { |
72 EXPECT_FALSE(*guest_out); | 78 EXPECT_FALSE(*guest_out); |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 ASSERT_TRUE(guest_contents); | 714 ASSERT_TRUE(guest_contents); |
709 | 715 |
710 // The link position of the test-link.pdf in page coordinates is (110, 110). | 716 // The link position of the test-link.pdf in page coordinates is (110, 110). |
711 // Convert the link position from page coordinates to screen coordinates. | 717 // Convert the link position from page coordinates to screen coordinates. |
712 gfx::Point link_position(110, 110); | 718 gfx::Point link_position(110, 110); |
713 ConvertPageCoordToScreenCoord(guest_contents, &link_position); | 719 ConvertPageCoordToScreenCoord(guest_contents, &link_position); |
714 | 720 |
715 content::WebContents* web_contents = | 721 content::WebContents* web_contents = |
716 browser()->tab_strip_model()->GetActiveWebContents(); | 722 browser()->tab_strip_model()->GetActiveWebContents(); |
717 | 723 |
718 #if defined(OS_MACOSX) | |
719 int modifiers = blink::WebInputEvent::MetaKey; | |
720 #else | |
721 int modifiers = blink::WebInputEvent::ControlKey; | |
722 #endif | |
723 | |
724 content::WindowedNotificationObserver observer( | 724 content::WindowedNotificationObserver observer( |
725 chrome::NOTIFICATION_TAB_ADDED, | 725 chrome::NOTIFICATION_TAB_ADDED, |
726 content::NotificationService::AllSources()); | 726 content::NotificationService::AllSources()); |
727 content::SimulateMouseClickAt(web_contents, modifiers, | 727 content::SimulateMouseClickAt(web_contents, kDefaultKeyModifier, |
728 blink::WebMouseEvent::ButtonLeft, link_position); | 728 blink::WebMouseEvent::ButtonLeft, link_position); |
729 observer.Wait(); | 729 observer.Wait(); |
730 | 730 |
731 int tab_count = browser()->tab_strip_model()->count(); | 731 int tab_count = browser()->tab_strip_model()->count(); |
732 ASSERT_EQ(2, tab_count); | 732 ASSERT_EQ(2, tab_count); |
733 | 733 |
734 content::WebContents* active_web_contents = | 734 content::WebContents* active_web_contents = |
735 browser()->tab_strip_model()->GetActiveWebContents(); | 735 browser()->tab_strip_model()->GetActiveWebContents(); |
736 ASSERT_EQ(web_contents, active_web_contents); | 736 ASSERT_EQ(web_contents, active_web_contents); |
737 | 737 |
(...skipping 35 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 int modifiers = blink::WebInputEvent::ShiftKey | kDefaultKeyModifier; |
| 799 |
| 800 content::WindowedNotificationObserver observer( |
| 801 chrome::NOTIFICATION_TAB_ADDED, |
| 802 content::NotificationService::AllSources()); |
| 803 content::SimulateMouseClickAt(web_contents, modifiers, |
| 804 blink::WebMouseEvent::ButtonLeft, link_position); |
| 805 observer.Wait(); |
| 806 |
| 807 int tab_count = browser()->tab_strip_model()->count(); |
| 808 ASSERT_EQ(2, tab_count); |
| 809 |
| 810 content::WebContents* active_web_contents = |
| 811 browser()->tab_strip_model()->GetActiveWebContents(); |
| 812 ASSERT_NE(web_contents, active_web_contents); |
| 813 |
| 814 const GURL& url = active_web_contents->GetURL(); |
| 815 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
| 816 } |
| 817 |
| 818 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkShiftMiddleClick) { |
| 819 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 820 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test-link.pdf")); |
| 821 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); |
| 822 ASSERT_TRUE(guest_contents); |
| 823 |
| 824 // The link position of the test-link.pdf in page coordinates is (110, 110). |
| 825 // Convert the link position from page coordinates to screen coordinates. |
| 826 gfx::Point link_position(110, 110); |
| 827 ConvertPageCoordToScreenCoord(guest_contents, &link_position); |
| 828 |
| 829 content::WebContents* web_contents = |
| 830 browser()->tab_strip_model()->GetActiveWebContents(); |
| 831 |
| 832 content::WindowedNotificationObserver observer( |
| 833 chrome::NOTIFICATION_TAB_ADDED, |
| 834 content::NotificationService::AllSources()); |
| 835 content::SimulateMouseClickAt(web_contents, blink::WebInputEvent::ShiftKey, |
| 836 blink::WebMouseEvent::ButtonMiddle, link_position); |
| 837 observer.Wait(); |
| 838 |
| 839 int tab_count = browser()->tab_strip_model()->count(); |
| 840 ASSERT_EQ(2, tab_count); |
| 841 |
| 842 content::WebContents* active_web_contents = |
| 843 browser()->tab_strip_model()->GetActiveWebContents(); |
| 844 ASSERT_NE(web_contents, active_web_contents); |
| 845 |
| 846 const GURL& url = active_web_contents->GetURL(); |
| 847 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); |
| 848 } |
OLD | NEW |