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

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: fixes 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/interactive_ui_tests.isolate » ('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"
15 #include "chrome/test/base/interactive_test_utils.h"
10 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/public/test/browser_test_utils.h"
19 #include "content/public/test/test_utils.h"
20 #include "ui/base/ui_base_switches.h"
21
22 #if defined(OS_WIN) && defined(USE_AURA)
23 #include "content/public/browser/web_contents_view.h"
24 #include "ui/aura/root_window.h"
25 #include "ui/aura/window.h"
26 #endif
11 27
12 namespace { 28 namespace {
13 29
14 typedef InProcessBrowserTest StarViewTest; 30 typedef InProcessBrowserTest StarViewTest;
15 31
16 // Verify that clicking the bookmark star a second time hides the bookmark 32 // Verify that clicking the bookmark star a second time hides the bookmark
17 // bubble. 33 // bubble.
18 #if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS) 34 #if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)
19 #define MAYBE_HideOnSecondClick DISABLED_HideOnSecondClick 35 #define MAYBE_HideOnSecondClick DISABLED_HideOnSecondClick
20 #else 36 #else
(...skipping 21 matching lines...) Expand all
42 star_view->OnMousePressed(pressed_event); 58 star_view->OnMousePressed(pressed_event);
43 // Hide the bubble manually. In the browser this would normally happen during 59 // Hide the bubble manually. In the browser this would normally happen during
44 // the event processing. 60 // the event processing.
45 BookmarkBubbleView::Hide(); 61 BookmarkBubbleView::Hide();
46 base::MessageLoop::current()->RunUntilIdle(); 62 base::MessageLoop::current()->RunUntilIdle();
47 EXPECT_FALSE(BookmarkBubbleView::IsShowing()); 63 EXPECT_FALSE(BookmarkBubbleView::IsShowing());
48 star_view->OnMouseReleased(released_event); 64 star_view->OnMouseReleased(released_event);
49 EXPECT_FALSE(BookmarkBubbleView::IsShowing()); 65 EXPECT_FALSE(BookmarkBubbleView::IsShowing());
50 } 66 }
51 67
68 #if defined(OS_WIN) && defined(USE_AURA)
69
70 class StarViewTestNoDWM : public InProcessBrowserTest {
71 public:
72 StarViewTestNoDWM() {}
73
74 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
75 command_line->AppendSwitch(switches::kDisableDwmComposition);
76 }
77 };
78
79 BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) {
80 HWND* child = reinterpret_cast<HWND*>(l_param);
81 *child = hwnd;
82 // The first child window is the plugin, then its children. So stop
83 // enumerating after the first callback.
84 return FALSE;
85 }
86
87 // Ensure that UIs like the star window, user profiler picker, omnibox
88 // popup and bookmark editor are always over a windowed NPAPI plugin even if
89 // kDisableDwmComposition is used.
90 IN_PROC_BROWSER_TEST_F(StarViewTestNoDWM, WindowedNPAPIPluginHidden) {
91 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize,
92 true);
93 LOG(ERROR) << "1";
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 LOG(ERROR) << "2";
105 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
106 LOG(ERROR) << "3";
107
108 // Now get the region of the plugin before the star view is shown.
109 HWND hwnd =
110 tab->GetView()->GetNativeView()->GetDispatcher()->GetAcceleratedWidget();
111 HWND child = NULL;
112 EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child));
113 LOG(ERROR) << "4";
114
115 RECT region_before, region_after;
116 int result = GetWindowRgnBox(child, &region_before);
117 ASSERT_EQ(result, SIMPLEREGION);
118
119 // Now show the star view
120 BrowserView* browser_view = reinterpret_cast<BrowserView*>(
121 browser()->window());
122 views::ImageView* star_view =
123 browser_view->GetToolbarView()->location_bar()->star_view();
124
125 scoped_refptr<content::MessageLoopRunner> runner =
126 new content::MessageLoopRunner;
127 LOG(ERROR) << "5";
128 // Verify that clicking once shows the bookmark bubble.
129 ui_test_utils::MoveMouseToCenterAndPress(
130 star_view,
131 ui_controls::LEFT,
132 ui_controls::DOWN | ui_controls::UP,
133 runner->QuitClosure());
134 LOG(ERROR) << "6";
135 runner->Run();
136 LOG(ERROR) << "7";
137
138 EXPECT_TRUE(BookmarkBubbleView::IsShowing());
139
140 result = GetWindowRgnBox(child, &region_after);
141 if (result == NULLREGION) {
142 // Depending on the browser window size, the plugin could be full covered.
143 return;
144 }
145
146 if (result == COMPLEXREGION) {
147 // Complex region, by definition not equal to the initial region.
148 return;
149 }
150
151 ASSERT_EQ(result, SIMPLEREGION);
152 bool rects_equal =
153 region_before.left == region_after.left &&
154 region_before.top == region_after.top &&
155 region_before.right == region_after.right &&
156 region_before.bottom == region_after.bottom;
157 ASSERT_FALSE(rects_equal);
158 }
159
160 #endif
161
52 } // namespace 162 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/interactive_ui_tests.isolate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698