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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc

Issue 53153003: Fix windowed NPAPI plugins covering up dialogs on Win Aura. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix test with small browser size Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/printing/npapi_plugin.html » ('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 (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
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 // This test verifies that constrained windows aren't covered by windowed NPAPI
91 // plugins. The code which fixes this is in WebContentsViewAura::WindowObserver.
92 IN_PROC_BROWSER_TEST_F(PrintPreviewTest, WindowedNPAPIPluginHidden) {
93 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize,
94 true);
95
96 // First load the page and wait for the NPAPI plugin's window to display.
97 string16 expected_title(ASCIIToUTF16("ready"));
98 content::WebContents* tab =
99 browser()->tab_strip_model()->GetActiveWebContents();
100 content::TitleWatcher title_watcher(tab, expected_title);
101
102 GURL url = ui_test_utils::GetTestUrl(
103 base::FilePath().AppendASCII("printing"),
104 base::FilePath().AppendASCII("npapi_plugin.html"));
105 ui_test_utils::NavigateToURL(browser(), url);
106
107 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
108
109 // Now get the region of the plugin before and after the print preview is
110 // shown. They should be different.
111 HWND hwnd =
112 tab->GetView()->GetNativeView()->GetDispatcher()->GetAcceleratedWidget();
113 HWND child = NULL;
114 EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child));
115
116 RECT region_before, region_after;
117 int result = GetWindowRgnBox(child, &region_before);
118 ASSERT_EQ(result, SIMPLEREGION);
119
120 // Now print preview.
121 Print();
122
123 result = GetWindowRgnBox(child, &region_after);
124 if (result == NULLREGION) {
125 // Depending on the browser window size, the plugin could be full covered.
126 return;
127 }
128
129 ASSERT_EQ(result, SIMPLEREGION);
130 bool rects_equal =
131 region_before.left == region_after.left &&
132 region_before.top == region_after.top &&
133 region_before.right == region_after.right &&
134 region_before.bottom == region_after.bottom;
135 ASSERT_FALSE(rects_equal);
136 }
137 #endif
138
68 } // namespace 139 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/printing/npapi_plugin.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698