| Index: chrome/browser/ui/views/location_bar/star_view_browsertest.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/location_bar/star_view_browsertest.cc (revision 234770)
|
| +++ chrome/browser/ui/views/location_bar/star_view_browsertest.cc (working copy)
|
| @@ -4,11 +4,27 @@
|
|
|
| #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/interactive_test_utils.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 "content/public/test/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"
|
| +#include "ui/aura/window.h"
|
| +#endif
|
| +
|
| namespace {
|
|
|
| typedef InProcessBrowserTest StarViewTest;
|
| @@ -49,4 +65,98 @@
|
| 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);
|
| + LOG(ERROR) << "1";
|
| + // 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);
|
| + LOG(ERROR) << "2";
|
| + EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
|
| + LOG(ERROR) << "3";
|
| +
|
| + // 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));
|
| + LOG(ERROR) << "4";
|
| +
|
| + 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();
|
| +
|
| + scoped_refptr<content::MessageLoopRunner> runner =
|
| + new content::MessageLoopRunner;
|
| + LOG(ERROR) << "5";
|
| + // Verify that clicking once shows the bookmark bubble.
|
| + ui_test_utils::MoveMouseToCenterAndPress(
|
| + star_view,
|
| + ui_controls::LEFT,
|
| + ui_controls::DOWN | ui_controls::UP,
|
| + runner->QuitClosure());
|
| + LOG(ERROR) << "6";
|
| + runner->Run();
|
| + LOG(ERROR) << "7";
|
| +
|
| + 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
|
|
|