This source file includes following definitions.
- MouseLeaveTestCommon
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "base/files/file_path.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/test/browser_test_utils.h"
#include "ui/base/test/ui_controls.h"
namespace {
class MouseLeaveTest : public InProcessBrowserTest {
public:
MouseLeaveTest() {}
void MouseLeaveTestCommon() {
GURL test_url = ui_test_utils::GetTestUrl(
base::FilePath(), base::FilePath(FILE_PATH_LITERAL("mouseleave.html")));
content::WebContents* tab =
browser()->tab_strip_model()->GetActiveWebContents();
gfx::Rect tab_view_bounds;
tab->GetView()->GetContainerBounds(&tab_view_bounds);
gfx::Point in_content_point(
tab_view_bounds.x() + tab_view_bounds.width() / 2,
tab_view_bounds.y() + 10);
gfx::Point above_content_point(
tab_view_bounds.x() + tab_view_bounds.width() / 2,
tab_view_bounds.y() - 2);
ui_controls::SendMouseMove(above_content_point.x(),
above_content_point.y());
base::string16 load_expected_title(base::ASCIIToUTF16("onload"));
content::TitleWatcher load_title_watcher(tab, load_expected_title);
ui_test_utils::NavigateToURL(browser(), test_url);
EXPECT_EQ(load_expected_title, load_title_watcher.WaitAndGetTitle());
ui_controls::SendMouseMove(in_content_point.x(), in_content_point.y());
base::string16 entered_expected_title(base::ASCIIToUTF16("entered"));
content::TitleWatcher entered_title_watcher(tab, entered_expected_title);
EXPECT_EQ(entered_expected_title, entered_title_watcher.WaitAndGetTitle());
ui_controls::SendMouseMove(above_content_point.x(),
above_content_point.y());
base::string16 left_expected_title(base::ASCIIToUTF16("left"));
content::TitleWatcher left_title_watcher(tab, left_expected_title);
EXPECT_EQ(left_expected_title, left_title_watcher.WaitAndGetTitle());
}
DISALLOW_COPY_AND_ASSIGN(MouseLeaveTest);
};
#if defined(OS_MACOSX)
#define MAYBE_TestOnMouseOut DISABLED_TestOnMouseOut
#elif defined(OS_LINUX)
#define MAYBE_TestOnMouseOut DISABLED_TestOnMouseOut
#else
#define MAYBE_TestOnMouseOut TestOnMouseOut
#endif
IN_PROC_BROWSER_TEST_F(MouseLeaveTest, MAYBE_TestOnMouseOut) {
MouseLeaveTestCommon();
}
#if defined(OS_WIN)
IN_PROC_BROWSER_TEST_F(MouseLeaveTest, MouseDownOnBrowserCaption) {
gfx::Rect browser_bounds = browser()->window()->GetBounds();
ui_controls::SendMouseMove(browser_bounds.x() + 200,
browser_bounds.y() + 10);
ui_controls::SendMouseClick(ui_controls::LEFT);
MouseLeaveTestCommon();
}
#endif
}