chromium/chrome/browser/ui/renderer_event_injection_browsertest.cc

// Copyright 2019 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/command_line.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "build/chromeos_buildflags.h"
#include "cc/base/switches.h"
#include "chrome/browser/ui/browser.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/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/input/web_touch_event.h"
#include "ui/display/display_switches.h"

namespace {

// This test verifies renderer event injection works. That is, it verifies
// a renderer can inject events and that they're received by content. It's in
// the Chrome side (not content) so that it can verify events work correctly
// when all of Chrome is brought up. This is especially important for ChromeOS,
// as content tests do not bring up the ChromeOS window-manager (ash).
//
// The parameter is how the display is configured, and is only applicable to
// ChromeOS.
class RendererEventInjectionTest
    : public InProcessBrowserTest,
      public ::testing::WithParamInterface<const char*> {};

// Detects when a touch press is received.
class TouchEventObserver
    : public content::RenderWidgetHost::InputEventObserver {};

IN_PROC_BROWSER_TEST_P(RendererEventInjectionTest, TestRootTransform) {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
// This configures the display in various interesting ways for ChromeOS. In
// particular, it tests rotation "/r" and a scale factor of 2 "*2".
INSTANTIATE_TEST_SUITE_P(
    All,
    RendererEventInjectionTest,
    ::testing::Values("1200x800", "1200x800/r", "1200x800*2", "1200x800*2/r"));
#else
INSTANTIATE_TEST_SUITE_P();
#endif

}  // namespace