chromium/chrome/browser/mouse_events_interactive_uitest.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/files/file_path.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.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/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "ui/base/test/ui_controls.h"

namespace {

// Integration test of browser event forwarding and web content event handling.
class MouseEventsTest : public InProcessBrowserTest {};

#if BUILDFLAG(IS_MAC)
// Flaky; http://crbug.com/133361.
#define MAYBE_MouseOver
#else
#define MAYBE_MouseOver
#endif

IN_PROC_BROWSER_TEST_F(MouseEventsTest, MAYBE_MouseOver) {}

#if BUILDFLAG(IS_MAC)
// Flaky; http://crbug.com/133361.
#define MAYBE_ClickAndDoubleClick
#else
#define MAYBE_ClickAndDoubleClick
#endif

IN_PROC_BROWSER_TEST_F(MouseEventsTest, MAYBE_ClickAndDoubleClick) {}

#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
    BUILDFLAG(IS_WIN)
// Flaky; http://crbug.com/133361.
#define MAYBE_TestOnMouseOut
#else
#define MAYBE_TestOnMouseOut
#endif

IN_PROC_BROWSER_TEST_F(MouseEventsTest, MAYBE_TestOnMouseOut) {}

#if BUILDFLAG(IS_WIN)
// Mac/Linux are flaky; http://crbug.com/133361.
IN_PROC_BROWSER_TEST_F(MouseEventsTest, 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);

  NavigateAndWaitForMouseOverThenMouseOut();
}
#endif

#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_OZONE)
// Test that a mouseleave is not triggered when showing the context menu.
// If the test is failed, it means that Blink gets the mouseleave event
// when showing the context menu and it could make the unexpecting
// content behavior such as clearing the hover status.
// Please refer to the below issue for understanding what happens .
// Flaky; See http://crbug.com/656101.
#define MAYBE_ContextMenu
#else
#define MAYBE_ContextMenu
#endif

IN_PROC_BROWSER_TEST_F(MouseEventsTest, MAYBE_ContextMenu) {}

#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \
    BUILDFLAG(IS_CHROMEOS)
// Test that a mouseleave is not triggered when showing a modal dialog.
// Sample regression: crbug.com/394672
// Flaky; http://crbug.com/838120
#define MAYBE_ModalDialog
#else
#define MAYBE_ModalDialog
#endif

IN_PROC_BROWSER_TEST_F(MouseEventsTest, MAYBE_ModalDialog) {}

}  // namespace