Index: chrome/browser/ui/views/location_bar/star_view_browsertest.cc |
=================================================================== |
--- chrome/browser/ui/views/location_bar/star_view_browsertest.cc (revision 234230) |
+++ chrome/browser/ui/views/location_bar/star_view_browsertest.cc (working copy) |
@@ -4,11 +4,24 @@ |
#include "chrome/browser/ui/views/location_bar/star_view.h" |
+#include "base/command_line.h" |
+#include "base/prefs/pref_service.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
#include "chrome/browser/ui/views/frame/browser_view.h" |
#include "chrome/browser/ui/views/toolbar_view.h" |
+#include "chrome/common/pref_names.h" |
#include "chrome/test/base/in_process_browser_test.h" |
+#include "chrome/test/base/ui_test_utils.h" |
+#include "content/public/test/browser_test_utils.h" |
+#include "ui/base/ui_base_switches.h" |
+#if defined(OS_WIN) && defined(USE_AURA) |
+#include "content/public/browser/web_contents_view.h" |
+#include "ui/aura/root_window.h" |
+#endif |
+ |
namespace { |
typedef InProcessBrowserTest StarViewTest; |
@@ -49,4 +62,91 @@ |
EXPECT_FALSE(BookmarkBubbleView::IsShowing()); |
} |
+#if defined(OS_WIN) && defined(USE_AURA) |
+ |
+class StarViewTestNoDWM : public InProcessBrowserTest { |
+ public: |
+ StarViewTestNoDWM() {} |
+ |
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
+ command_line->AppendSwitch(switches::kDisableDwmComposition); |
+ } |
+}; |
+ |
+BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) { |
+ HWND* child = reinterpret_cast<HWND*>(l_param); |
+ *child = hwnd; |
+ // The first child window is the plugin, then its children. So stop |
+ // enumerating after the first callback. |
+ return FALSE; |
+} |
+ |
+// Ensure that UIs like the star window, user profiler picker, omnibox |
+// popup and bookmark editor are always over a windowed NPAPI plugin even if |
+// kDisableDwmComposition is used. |
+IN_PROC_BROWSER_TEST_F(StarViewTestNoDWM, WindowedNPAPIPluginHidden) { |
+ browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, |
+ true); |
+ |
+ // First load the page and wait for the NPAPI plugin's window to display. |
+ string16 expected_title(ASCIIToUTF16("ready")); |
+ content::WebContents* tab = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::TitleWatcher title_watcher(tab, expected_title); |
+ |
+ GURL url = ui_test_utils::GetTestUrl( |
+ base::FilePath().AppendASCII("printing"), |
+ base::FilePath().AppendASCII("npapi_plugin.html")); |
+ ui_test_utils::NavigateToURL(browser(), url); |
+ |
+ EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
+ |
+ // Now get the region of the plugin before the star view is shown. |
+ HWND hwnd = |
+ tab->GetView()->GetNativeView()->GetDispatcher()->GetAcceleratedWidget(); |
+ HWND child = NULL; |
+ EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child)); |
+ |
+ RECT region_before, region_after; |
+ int result = GetWindowRgnBox(child, ®ion_before); |
+ ASSERT_EQ(result, SIMPLEREGION); |
+ |
+ // Now show the star view |
+ BrowserView* browser_view = reinterpret_cast<BrowserView*>( |
+ browser()->window()); |
+ views::ImageView* star_view = |
+ browser_view->GetToolbarView()->location_bar()->star_view(); |
+ |
+ ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), |
+ ui::EF_LEFT_MOUSE_BUTTON); |
+ ui::MouseEvent released_event(ui::ET_MOUSE_RELEASED, gfx::Point(), |
+ gfx::Point(), ui::EF_LEFT_MOUSE_BUTTON); |
+ |
+ // Verify that clicking once shows the bookmark bubble. |
+ 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
|
+ star_view->OnMouseReleased(released_event); |
+ EXPECT_TRUE(BookmarkBubbleView::IsShowing()); |
+ |
+ result = GetWindowRgnBox(child, ®ion_after); |
+ if (result == NULLREGION) { |
+ // Depending on the browser window size, the plugin could be full covered. |
+ return; |
+ } |
+ |
+ if (result == COMPLEXREGION) { |
+ // Complex region, by definition not equal to the initial region. |
+ return; |
+ } |
+ |
+ ASSERT_EQ(result, SIMPLEREGION); |
+ bool rects_equal = |
+ region_before.left == region_after.left && |
+ region_before.top == region_after.top && |
+ region_before.right == region_after.right && |
+ region_before.bottom == region_after.bottom; |
+ ASSERT_FALSE(rects_equal); |
+} |
+ |
+#endif |
+ |
} // namespace |