This source file includes following definitions.
- IN_PROC_BROWSER_TEST_F
- SetUpCommandLine
- EnumerateChildren
- IN_PROC_BROWSER_TEST_F
#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/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)
#include "content/public/browser/web_contents_view.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#endif
namespace {
typedef InProcessBrowserTest StarViewTest;
#if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)
#define MAYBE_HideOnSecondClick DISABLED_HideOnSecondClick
#else
#define MAYBE_HideOnSecondClick HideOnSecondClick
#endif
IN_PROC_BROWSER_TEST_F(StarViewTest, MAYBE_HideOnSecondClick) {
BrowserView* browser_view = reinterpret_cast<BrowserView*>(
browser()->window());
views::View* 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::EF_LEFT_MOUSE_BUTTON);
ui::MouseEvent released_event(ui::ET_MOUSE_RELEASED, gfx::Point(),
gfx::Point(), ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);
EXPECT_FALSE(BookmarkBubbleView::IsShowing());
star_view->OnMousePressed(pressed_event);
EXPECT_FALSE(BookmarkBubbleView::IsShowing());
star_view->OnMouseReleased(released_event);
EXPECT_TRUE(BookmarkBubbleView::IsShowing());
star_view->OnMousePressed(pressed_event);
BookmarkBubbleView::Hide();
base::MessageLoop::current()->RunUntilIdle();
EXPECT_FALSE(BookmarkBubbleView::IsShowing());
star_view->OnMouseReleased(released_event);
EXPECT_FALSE(BookmarkBubbleView::IsShowing());
}
#if defined(OS_WIN)
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;
return FALSE;
}
IN_PROC_BROWSER_TEST_F(StarViewTestNoDWM, WindowedNPAPIPluginHidden) {
browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize,
true);
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL("about:blank"), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
browser()->tab_strip_model()->ActivateTabAt(0, true);
base::string16 expected_title(base::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());
HWND hwnd = tab->GetView()->GetNativeView()->GetHost()->
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);
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;
ui_test_utils::MoveMouseToCenterAndPress(
star_view,
ui_controls::LEFT,
ui_controls::DOWN | ui_controls::UP,
runner->QuitClosure());
runner->Run();
EXPECT_TRUE(BookmarkBubbleView::IsShowing());
result = GetWindowRgnBox(child, ®ion_after);
if (result == NULLREGION) {
return;
}
if (result == COMPLEXREGION) {
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
}