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

Side by Side Diff: chrome/browser/ui/views/location_bar/star_view_browsertest.cc

Issue 69833002: When DWM compositing is disabled (i.e. XP, RDP) ensure that windowed NPAPI plugins don't cover UI d… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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 | content/browser/renderer_host/render_widget_host_view_aura.cc » ('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 "chrome/browser/ui/views/location_bar/star_view.h" 5 #include "chrome/browser/ui/views/location_bar/star_view.h"
6 6
7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
7 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" 11 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
8 #include "chrome/browser/ui/views/frame/browser_view.h" 12 #include "chrome/browser/ui/views/frame/browser_view.h"
9 #include "chrome/browser/ui/views/toolbar_view.h" 13 #include "chrome/browser/ui/views/toolbar_view.h"
14 #include "chrome/common/pref_names.h"
10 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/test/browser_test_utils.h"
18 #include "ui/base/ui_base_switches.h"
19
20 #if defined(OS_WIN) && defined(USE_AURA)
21 #include "content/public/browser/web_contents_view.h"
22 #include "ui/aura/root_window.h"
23 #endif
11 24
12 namespace { 25 namespace {
13 26
14 typedef InProcessBrowserTest StarViewTest; 27 typedef InProcessBrowserTest StarViewTest;
15 28
16 // Verify that clicking the bookmark star a second time hides the bookmark 29 // Verify that clicking the bookmark star a second time hides the bookmark
17 // bubble. 30 // bubble.
18 #if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS) 31 #if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)
19 #define MAYBE_HideOnSecondClick DISABLED_HideOnSecondClick 32 #define MAYBE_HideOnSecondClick DISABLED_HideOnSecondClick
20 #else 33 #else
(...skipping 21 matching lines...) Expand all
42 star_view->OnMousePressed(pressed_event); 55 star_view->OnMousePressed(pressed_event);
43 // Hide the bubble manually. In the browser this would normally happen during 56 // Hide the bubble manually. In the browser this would normally happen during
44 // the event processing. 57 // the event processing.
45 BookmarkBubbleView::Hide(); 58 BookmarkBubbleView::Hide();
46 base::MessageLoop::current()->RunUntilIdle(); 59 base::MessageLoop::current()->RunUntilIdle();
47 EXPECT_FALSE(BookmarkBubbleView::IsShowing()); 60 EXPECT_FALSE(BookmarkBubbleView::IsShowing());
48 star_view->OnMouseReleased(released_event); 61 star_view->OnMouseReleased(released_event);
49 EXPECT_FALSE(BookmarkBubbleView::IsShowing()); 62 EXPECT_FALSE(BookmarkBubbleView::IsShowing());
50 } 63 }
51 64
65 #if defined(OS_WIN) && defined(USE_AURA)
66
67 class StarViewTestNoDWM : public InProcessBrowserTest {
68 public:
69 StarViewTestNoDWM() {}
70
71 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
72 command_line->AppendSwitch(switches::kDisableDwmComposition);
73 }
74 };
75
76 BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) {
77 HWND* child = reinterpret_cast<HWND*>(l_param);
78 *child = hwnd;
79 // The first child window is the plugin, then its children. So stop
80 // enumerating after the first callback.
81 return FALSE;
82 }
83
84 // Ensure that UIs like the star window, user profiler picker, omnibox
85 // popup and bookmark editor are always over a windowed NPAPI plugin even if
86 // kDisableDwmComposition is used.
87 IN_PROC_BROWSER_TEST_F(StarViewTestNoDWM, WindowedNPAPIPluginHidden) {
88 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize,
89 true);
90
91 // First load the page and wait for the NPAPI plugin's window to display.
92 string16 expected_title(ASCIIToUTF16("ready"));
93 content::WebContents* tab =
94 browser()->tab_strip_model()->GetActiveWebContents();
95 content::TitleWatcher title_watcher(tab, expected_title);
96
97 GURL url = ui_test_utils::GetTestUrl(
98 base::FilePath().AppendASCII("printing"),
99 base::FilePath().AppendASCII("npapi_plugin.html"));
100 ui_test_utils::NavigateToURL(browser(), url);
101
102 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
103
104 // Now get the region of the plugin before the star view is shown.
105 HWND hwnd =
106 tab->GetView()->GetNativeView()->GetDispatcher()->GetAcceleratedWidget();
107 HWND child = NULL;
108 EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child));
109
110 RECT region_before, region_after;
111 int result = GetWindowRgnBox(child, &region_before);
112 ASSERT_EQ(result, SIMPLEREGION);
113
114 // Now show the star view
115 BrowserView* browser_view = reinterpret_cast<BrowserView*>(
116 browser()->window());
117 views::ImageView* star_view =
118 browser_view->GetToolbarView()->location_bar()->star_view();
119
120 ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
121 ui::EF_LEFT_MOUSE_BUTTON);
122 ui::MouseEvent released_event(ui::ET_MOUSE_RELEASED, gfx::Point(),
123 gfx::Point(), ui::EF_LEFT_MOUSE_BUTTON);
124
125 // Verify that clicking once shows the bookmark bubble.
126 star_view->OnMousePressed(pressed_event);
Ben Goodger (Google) 2013/11/12 02:41:44 I know it may be tempting just to do this, but it
jam 2013/11/12 02:53:58 I just copied this from the above test. I could ch
127 star_view->OnMouseReleased(released_event);
128 EXPECT_TRUE(BookmarkBubbleView::IsShowing());
129
130 result = GetWindowRgnBox(child, &region_after);
131 if (result == NULLREGION) {
132 // Depending on the browser window size, the plugin could be full covered.
133 return;
134 }
135
136 if (result == COMPLEXREGION) {
137 // Complex region, by definition not equal to the initial region.
138 return;
139 }
140
141 ASSERT_EQ(result, SIMPLEREGION);
142 bool rects_equal =
143 region_before.left == region_after.left &&
144 region_before.top == region_after.top &&
145 region_before.right == region_after.right &&
146 region_before.bottom == region_after.bottom;
147 ASSERT_FALSE(rects_equal);
148 }
149
150 #endif
151
52 } // namespace 152 } // namespace
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698