OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/prefs/pref_service.h" | |
7 #include "base/strings/utf_string_conversions.h" | |
6 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
10 #include "chrome/browser/profiles/profile.h" | |
7 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
10 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/pref_names.h" | |
11 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
18 #include "chrome/test/base/ui_test_utils.h" | |
13 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
20 #include "content/public/test/browser_test_utils.h" | |
14 #include "content/public/test/test_navigation_observer.h" | 21 #include "content/public/test/test_navigation_observer.h" |
15 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
16 | 23 |
24 #if defined(OS_WIN) && defined(USE_AURA) | |
25 #include "content/public/browser/web_contents_view.h" | |
26 #include "ui/aura/root_window.h" | |
27 #endif | |
28 | |
17 namespace { | 29 namespace { |
18 | 30 |
19 class PrintPreviewTest : public InProcessBrowserTest { | 31 class PrintPreviewTest : public InProcessBrowserTest { |
20 public: | 32 public: |
21 PrintPreviewTest() {} | 33 PrintPreviewTest() {} |
22 | 34 |
23 #if !defined(GOOGLE_CHROME_BUILD) | 35 #if !defined(GOOGLE_CHROME_BUILD) |
24 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 36 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
25 command_line->AppendSwitch(switches::kEnablePrintPreview); | 37 command_line->AppendSwitch(switches::kEnablePrintPreview); |
26 } | 38 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 browser()->tab_strip_model()->GetActiveWebContents()); | 70 browser()->tab_strip_model()->GetActiveWebContents()); |
59 chrome::Reload(browser(), CURRENT_TAB); | 71 chrome::Reload(browser(), CURRENT_TAB); |
60 reload_observer.Wait(); | 72 reload_observer.Wait(); |
61 | 73 |
62 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_PRINT)); | 74 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_PRINT)); |
63 | 75 |
64 // Make sure advanced print command (Ctrl+Shift+p) is enabled. | 76 // Make sure advanced print command (Ctrl+Shift+p) is enabled. |
65 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ADVANCED_PRINT)); | 77 ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ADVANCED_PRINT)); |
66 } | 78 } |
67 | 79 |
80 #if defined(OS_WIN) && defined(USE_AURA) | |
81 | |
82 BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) { | |
83 HWND* child = reinterpret_cast<HWND*>(l_param); | |
84 *child = hwnd; | |
85 // The first child window is the plugin, then its children. So stop | |
86 // enumerating after the first callback. | |
87 return FALSE; | |
88 } | |
89 | |
90 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, WindowedNPAPIPluginHidden) { | |
Ben Goodger (Google)
2013/11/06 18:11:37
I would add a comment here that this test is for t
jam
2013/11/06 18:15:20
Done.
| |
91 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, | |
92 true); | |
93 | |
94 // First load the page and wait for the NPAPI plugin's window to display. | |
95 string16 expected_title(ASCIIToUTF16("ready")); | |
96 content::WebContents* tab = | |
97 browser()->tab_strip_model()->GetActiveWebContents(); | |
98 content::TitleWatcher title_watcher(tab, expected_title); | |
99 | |
100 GURL url = ui_test_utils::GetTestUrl( | |
101 base::FilePath().AppendASCII("printing"), | |
102 base::FilePath().AppendASCII("npapi_plugin.html")); | |
103 ui_test_utils::NavigateToURL(browser(), url); | |
104 | |
105 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | |
106 | |
107 // Now get the region of the plugin before and after the print preview is | |
108 // shown. They should be different. | |
109 HWND hwnd = | |
110 tab->GetView()->GetNativeView()->GetDispatcher()->GetAcceleratedWidget(); | |
111 HWND child = NULL; | |
112 EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child)); | |
113 | |
114 RECT region_before, region_after; | |
115 int result = GetWindowRgnBox(child, ®ion_before); | |
116 ASSERT_EQ(result, SIMPLEREGION); | |
117 | |
118 // Now print preview. | |
119 Print(); | |
120 | |
121 result = GetWindowRgnBox(child, ®ion_after); | |
122 ASSERT_EQ(result, SIMPLEREGION); | |
123 bool rects_equal = | |
124 region_before.left == region_after.left && | |
125 region_before.top == region_after.top && | |
126 region_before.right == region_after.right && | |
127 region_before.bottom == region_after.bottom; | |
128 ASSERT_FALSE(rects_equal); | |
129 } | |
130 #endif | |
131 | |
68 } // namespace | 132 } // namespace |
OLD | NEW |