#include "content/browser/renderer_host/render_widget_host_view_aura.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/sanitizer_buildflags.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/null_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_timeouts.h"
#include "base/test/with_feature_override.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "cc/trees/render_frame_metadata.h"
#include "components/input/input_router.h"
#include "components/input/mouse_wheel_event_queue.h"
#include "components/viz/common/features.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
#include "components/viz/common/surfaces/child_local_surface_id_allocator.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "components/viz/test/begin_frame_args_test.h"
#include "components/viz/test/fake_external_begin_frame_source.h"
#include "components/viz/test/fake_surface_observer.h"
#include "components/viz/test/test_latest_local_surface_id_lookup_delegate.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/browser/renderer_host/delegated_frame_host.h"
#include "content/browser/renderer_host/delegated_frame_host_client_aura.h"
#include "content/browser/renderer_host/frame_token_message_queue.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/overscroll_controller.h"
#include "content/browser/renderer_host/overscroll_controller_delegate.h"
#include "content/browser/renderer_host/render_frame_metadata_provider_impl.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_event_handler.h"
#include "content/browser/renderer_host/text_input_manager.h"
#include "content/browser/site_instance_group.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_contents/web_contents_view_aura.h"
#include "content/common/features.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view_delegate.h"
#include "content/public/test/fake_frame_widget.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_image_transport_factory.h"
#include "content/test/mock_render_input_router.h"
#include "content/test/mock_render_widget_host_delegate.h"
#include "content/test/mock_widget.h"
#include "content/test/mock_widget_input_handler.h"
#include "content/test/test_overscroll_delegate.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_test_sink.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/input/synthetic_web_input_event_builders.h"
#include "third_party/blink/public/mojom/input/touch_event.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_parenting_client.h"
#include "ui/aura/env.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/scoped_keyboard_hook.h"
#include "ui/aura/test/aura_test_helper.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/test/test_cursor_client.h"
#include "ui/aura/test/test_screen.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/ime/init/input_method_factory.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/mock_input_method.h"
#include "ui/base/ime/mojom/text_input_state.mojom.h"
#include "ui/base/ime/virtual_keyboard_controller.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/ui_base_switches.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/compositor/test/draw_waiter_for_test.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/blink/blink_event_util.h"
#include "ui/events/blink/blink_features.h"
#include "ui/events/blink/web_input_event_traits.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/events/gestures/motion_event_aura.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/selection_bound.h"
#include "ui/wm/core/window_util.h"
#if BUILDFLAG(IS_WIN)
#include "content/browser/renderer_host/legacy_render_widget_host_win.h"
#include "ui/base/view_prop.h"
#include "ui/base/win/window_event_target.h"
#endif
_;
WebGestureEvent;
WebInputEvent;
WebMouseEvent;
WebMouseWheelEvent;
WebTouchEvent;
WebTouchPoint;
WebInputEventTraits;
FrameEvictionManager;
#define EXPECT_EVICTED(view) …
#define EXPECT_HAS_FRAME(view) …
namespace content {
void ParentHostView(RenderWidgetHostView* host_view,
RenderWidgetHostView* parent_host_view,
const gfx::Rect& bounds = gfx::Rect()) { … }
void InstallDelegatedFrameHostClient(
RenderWidgetHostViewAura* render_widget_host_view);
const viz::LocalSurfaceId kArbitraryLocalSurfaceId(
1,
base::UnguessableToken::CreateForTesting(2, 3));
std::string GetMessageNames(
const MockWidgetInputHandler::MessageVector& events) { … }
class TestWindowObserver : public aura::WindowObserver { … };
class FakeWindowEventDispatcher : public aura::WindowEventDispatcher { … };
class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura { … };
class FullscreenLayoutManager : public aura::LayoutManager { … };
class MockRenderWidgetHostImpl : public RenderWidgetHostImpl { … };
class TestScopedKeyboardHook : public aura::ScopedKeyboardHook { … };
TestScopedKeyboardHook::TestScopedKeyboardHook() = default;
TestScopedKeyboardHook::~TestScopedKeyboardHook() = default;
bool TestScopedKeyboardHook::IsKeyLocked(ui::DomCode dom_code) { … }
void TestScopedKeyboardHook::LockAllKeys() { … }
void TestScopedKeyboardHook::LockSpecificKey(ui::DomCode dom_code) { … }
class RenderWidgetHostViewAuraTest : public testing::Test { … };
void InstallDelegatedFrameHostClient(
RenderWidgetHostViewAura* render_widget_host_view) { … }
class RenderWidgetHostViewAuraOverscrollTest
: public RenderWidgetHostViewAuraTest { … };
class RenderWidgetHostViewAuraShutdownTest
: public RenderWidgetHostViewAuraTest { … };
TEST_F(RenderWidgetHostViewAuraTest, PositionChildPopup) { … }
TEST_F(RenderWidgetHostViewAuraTest, ParentMovementUpdatesScreenRect) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(RenderWidgetHostViewAuraTest, DestroyPopupClickOutsidePopup) {
parent_view_->SetBounds(gfx::Rect(10, 10, 400, 400));
parent_view_->Focus();
EXPECT_TRUE(parent_view_->HasFocus());
InitViewForPopup(parent_view_, gfx::Rect(10, 10, 100, 100));
aura::Window* window = view_->GetNativeView();
ASSERT_TRUE(window != nullptr);
gfx::Point click_point(0, 0);
EXPECT_FALSE(window->GetBoundsInRootWindow().Contains(click_point));
aura::Window* parent_window = parent_view_->GetNativeView();
EXPECT_FALSE(parent_window->GetBoundsInRootWindow().Contains(click_point));
TestWindowObserver observer(window);
ui::test::EventGenerator generator(window->GetRootWindow(), click_point);
widget_host_ = nullptr;
view_ = nullptr;
generator.ClickLeftButton();
ASSERT_TRUE(parent_view_->HasFocus());
ASSERT_TRUE(observer.destroyed());
}
TEST_F(RenderWidgetHostViewAuraTest, DestroyPopupTapOutsidePopup) {
parent_view_->SetBounds(gfx::Rect(10, 10, 400, 400));
parent_view_->Focus();
EXPECT_TRUE(parent_view_->HasFocus());
InitViewForPopup(parent_view_, gfx::Rect(10, 10, 100, 100));
aura::Window* window = view_->GetNativeView();
ASSERT_TRUE(window != nullptr);
gfx::Point tap_point(0, 0);
EXPECT_FALSE(window->GetBoundsInRootWindow().Contains(tap_point));
aura::Window* parent_window = parent_view_->GetNativeView();
EXPECT_FALSE(parent_window->GetBoundsInRootWindow().Contains(tap_point));
TestWindowObserver observer(window);
ui::test::EventGenerator generator(window->GetRootWindow(), tap_point);
widget_host_ = nullptr;
view_ = nullptr;
generator.GestureTapAt(tap_point);
ASSERT_TRUE(parent_view_->HasFocus());
ASSERT_TRUE(observer.destroyed());
}
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
TEST_F(RenderWidgetHostViewAuraTest, PopupRetainsCaptureAfterMouseRelease) { … }
#endif
TEST_F(RenderWidgetHostViewAuraTest, PopupClosesWhenParentLosesFocus) { … }
TEST_F(RenderWidgetHostViewAuraTest, SetCompositionText) { … }
TEST_F(RenderWidgetHostViewAuraTest, FocusedNodeChanged) { … }
TEST_F(RenderWidgetHostViewAuraTest, FinishCompositionByMouse) { … }
TEST_F(RenderWidgetHostViewAuraTest, WasOccluded) { … }
TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { … }
TEST_F(RenderWidgetHostViewAuraTest,
KeyEventRoutingWithKeyboardLockActiveForOneKey) { … }
TEST_F(RenderWidgetHostViewAuraTest,
KeyEventRoutingWithKeyboardLockActiveForEscKey) { … }
TEST_F(RenderWidgetHostViewAuraTest,
KeyEventRoutingWithKeyboardLockActiveForAllKeys) { … }
TEST_F(RenderWidgetHostViewAuraTest,
KeyEventRoutingKeyboardLockAndChildPopupWithInputGrab) { … }
TEST_F(RenderWidgetHostViewAuraTest, TimerBasedWheelEventPhaseInfo) { … }
TEST_F(RenderWidgetHostViewAuraTest,
TimerBasedWheelEventPhaseInfoWithPercentBasedScrolling) { … }
void RenderWidgetHostViewAuraTest::RunTimerBasedWheelEventPhaseInfoTest(
bool percent_based_scrolling_enabled) { … }
TEST_F(RenderWidgetHostViewAuraTest, TimerBasedLatchingBreaksWithMouseMove) { … }
TEST_F(RenderWidgetHostViewAuraTest,
TimerBasedLatchingBreaksWithModifiersChange) { … }
TEST_F(RenderWidgetHostViewAuraTest,
TimerBasedLatchingBreaksWithDirectionChange) { … }
TEST_F(RenderWidgetHostViewAuraTest,
TimerBasedLatchingBreaksWithAutoscrollStart) { … }
TEST_F(RenderWidgetHostViewAuraTest, TouchpadFlingStartResetsWheelPhaseState) { … }
TEST_F(RenderWidgetHostViewAuraTest, MouseWheelScrollingAfterGFCWithoutGFS) { … }
TEST_F(RenderWidgetHostViewAuraTest,
ScrollingWithExternalMouseBreaksTouchpadScrollLatching) { … }
TEST_F(RenderWidgetHostViewAuraTest,
GSBWithTouchSourceStopsWheelScrollSequence) { … }
TEST_F(RenderWidgetHostViewAuraTest,
SyntheticFlingCancelAtTouchpadScrollBegin) { … }
TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { … }
TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { … }
TEST_F(RenderWidgetHostViewAuraTest, CompositorViewportPixelSizeWithScale) { … }
TEST_F(RenderWidgetHostViewAuraTest, AutoResizeWithScale) { … }
TEST_F(RenderWidgetHostViewAuraTest,
VerifyVisualPropertiesWhenDisablingAutoResize) { … }
TEST_F(RenderWidgetHostViewAuraTest, AutoResizeWithBrowserInitiatedResize) { … }
TEST_F(RenderWidgetHostViewAuraTest, ChildAllocationAcceptedInParent) { … }
TEST_F(RenderWidgetHostViewAuraTest,
ChildAllocationAcceptedInParentWhileHidden) { … }
TEST_F(RenderWidgetHostViewAuraTest, ConflictingAllocationsResolve) { … }
TEST_F(RenderWidgetHostViewAuraTest, CursorVisibilityChange) { … }
TEST_F(RenderWidgetHostViewAuraTest, UpdateCursorIfOverSelf) { … }
TEST_F(RenderWidgetHostViewAuraTest, ZeroSizeStillGetsLocalSurfaceId) { … }
TEST_F(RenderWidgetHostViewAuraTest, BackgroundColorMatchesCompositorFrame) { … }
TEST_F(RenderWidgetHostViewAuraTest, BackgroundColorOrder) { … }
TEST_F(RenderWidgetHostViewAuraTest, Resize) { … }
TEST_F(RenderWidgetHostViewAuraTest, SurfaceChanges) { … }
TEST_F(RenderWidgetHostViewAuraTest, DeviceScaleFactorChanges) { … }
TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { … }
TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithMemoryPressure) { … }
TEST_F(RenderWidgetHostViewAuraTest, VisibleViewportTest) { … }
TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelNotPreciseScrollEvent) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollEventOverscrolls) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
WheelScrollConsumedDoNotOverscroll) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollOverscrollToggle) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
ScrollEventsOverscrollWithFling) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
ScrollEventsOverscrollWithZeroFling) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN)
#define MAYBE_ReverseFlingCancelsOverscroll …
#else
#define MAYBE_ReverseFlingCancelsOverscroll …
#endif
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
MAYBE_ReverseFlingCancelsOverscroll) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, GestureScrollOverscrolls) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDeltaCap) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, GestureScrollConsumed) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
GestureScrollDebounceOverscrolls) { … }
#if BUILDFLAG(USING_SANITIZER)
#define MAYBE_GestureScrollDebounceTimerOverscroll …
#else
#define MAYBE_GestureScrollDebounceTimerOverscroll …
#endif
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
MAYBE_GestureScrollDebounceTimerOverscroll) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
TouchGestureEndDispatchedAfterOverscrollComplete) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
CompleteOverscrollOnGestureScrollEndAck) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
InterleavedScrollUpdateAckAndScrollEnd) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
OverscrollDirectionChangeMouseWheel) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollMouseMoveCompletion) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest,
OverscrollStateResetsAfterScroll) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(RenderWidgetHostViewAuraTest, VirtualKeyboardFocusEnsureCaretInRect) {
InitViewForFrame(nullptr);
aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow();
aura::client::ParentWindowWithContext(view_->GetNativeView(), root_window,
gfx::Rect(),
display::kInvalidDisplayId);
const gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200);
const gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200);
const gfx::Rect root_bounds = root_window->bounds();
const int keyboard_height = 200;
const gfx::Rect keyboard_view_bounds =
gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(),
keyboard_height);
ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod();
view_->SetBounds(orig_view_bounds);
input_method->SetFocusedTextInputClient(view_);
EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
input_method->SetVirtualKeyboardBounds(keyboard_view_bounds);
EXPECT_EQ(view_->GetNativeView()->bounds(), shifted_view_bounds);
view_->DetachFromInputMethod(false);
EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
}
TEST_F(RenderWidgetHostViewAuraTest, UpdateInsetsWithVirtualKeyboardEnabled) {
InitViewForFrame(nullptr);
aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow();
aura::client::ParentWindowWithContext(view_->GetNativeView(), root_window,
gfx::Rect(),
display::kInvalidDisplayId);
const gfx::Rect orig_view_bounds = gfx::Rect(0, 300, 400, 200);
const gfx::Rect shifted_view_bounds = gfx::Rect(0, 200, 400, 200);
const gfx::Rect moved_view_bounds = gfx::Rect(100, 250, 400, 200);
const gfx::Rect resized_view_bounds = gfx::Rect(100, 250, 300, 175);
const auto origin_view_insets = gfx::Insets::TLBR(0, 0, 100, 0);
const auto shifted_view_insets = gfx::Insets();
const auto moved_view_insets = gfx::Insets::TLBR(0, 0, 50, 0);
const auto resized_view_insets = gfx::Insets::TLBR(0, 0, 25, 0);
const gfx::Rect root_bounds = root_window->bounds();
const int keyboard_height = 200;
const gfx::Rect keyboard_view_bounds =
gfx::Rect(0, root_bounds.height() - keyboard_height, root_bounds.width(),
keyboard_height);
ui::InputMethod* input_method = root_window->GetHost()->GetInputMethod();
view_->SetBounds(orig_view_bounds);
input_method->SetFocusedTextInputClient(view_);
EXPECT_EQ(view_->GetNativeView()->bounds(), orig_view_bounds);
view_->SetInsets(gfx::Insets::TLBR(
0, 0,
gfx::IntersectRects(orig_view_bounds, keyboard_view_bounds).height(), 0));
EXPECT_EQ(view_->insets_, origin_view_insets);
input_method->SetVirtualKeyboardBounds(keyboard_view_bounds);
EXPECT_EQ(view_->GetNativeView()->bounds(), shifted_view_bounds);
EXPECT_EQ(view_->insets_, shifted_view_insets);
view_->SetBounds(moved_view_bounds);
EXPECT_EQ(view_->insets_, moved_view_insets);
view_->SetBounds(resized_view_bounds);
EXPECT_EQ(view_->insets_, resized_view_insets);
}
#endif
TEST_F(RenderWidgetHostViewAuraTest,
InvalidEventsHaveSyncHandlingDisabled) { … }
TEST_F(RenderWidgetHostViewAuraTest, KeyEvent) { … }
TEST_F(RenderWidgetHostViewAuraTest, KeyEventsHandled) { … }
TEST_F(RenderWidgetHostViewAuraTest, SetCanScrollForWebMouseWheelEvent) { … }
TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) { … }
TEST_F(RenderWidgetHostViewAuraOverscrollTest, ScrollDeltasResetOnEnd) { … }
TEST_F(RenderWidgetHostViewAuraTest, ForwardMouseEvent) { … }
#if BUILDFLAG(IS_WIN)
class MockWindowEventTarget : public ui::WindowEventTarget {
public:
MockWindowEventTarget() = default;
MockWindowEventTarget(const MockWindowEventTarget&) = delete;
MockWindowEventTarget& operator=(const MockWindowEventTarget&) = delete;
LRESULT HandleMouseMessage(unsigned int message,
WPARAM w_param,
LPARAM l_param,
bool* handled) override {
return S_OK;
}
LRESULT HandlePointerMessage(unsigned int message,
WPARAM w_param,
LPARAM l_param,
bool* handled) override {
return S_OK;
}
LRESULT HandleKeyboardMessage(unsigned int message,
WPARAM w_param,
LPARAM l_param,
bool* handled) override {
return S_OK;
}
LRESULT HandleTouchMessage(unsigned int message,
WPARAM w_param,
LPARAM l_param,
bool* handled) override {
return S_OK;
}
LRESULT HandleInputMessage(unsigned int message,
WPARAM w_param,
LPARAM l_param,
bool* handled) override {
return S_OK;
}
LRESULT HandleScrollMessage(unsigned int message,
WPARAM w_param,
LPARAM l_param,
bool* handled) override {
return S_OK;
}
LRESULT HandleNcHitTestMessage(unsigned int message,
WPARAM w_param,
LPARAM l_param,
bool* handled) override {
return S_OK;
}
void HandleParentChanged() override {}
void ApplyPinchZoomScale(float scale) override {}
void ApplyPinchZoomBegin() override {}
void ApplyPinchZoomEnd() override {}
void ApplyPanGestureScroll(int scroll_x, int scroll_y) override {}
void ApplyPanGestureFling(int scroll_x, int scroll_y) override {}
void ApplyPanGestureScrollBegin(int scroll_x, int scroll_y) override {}
void ApplyPanGestureFlingBegin() override {}
void ApplyPanGestureFlingEnd() override {}
void ApplyPanGestureScrollEnd(bool tranisitioning_to_pinch) override {}
};
TEST_F(RenderWidgetHostViewAuraTest, OcclusionHidesTooltip) {
MockWindowEventTarget event_target;
auto prop_window_target = std::make_unique<ui::ViewProp>(
parent_view_->GetHostWindowHWND(),
ui::WindowEventTarget::kWin32InputEventTarget,
static_cast<ui::WindowEventTarget*>(&event_target));
InitViewForFrame(nullptr);
ParentHostView(view_, parent_view_);
view_->Show();
EXPECT_TRUE(legacy_render_widget_host_HWND());
std::u16string tooltip_text(u"The tooltip!");
view_->UpdateTooltipUnderCursor(tooltip_text);
EXPECT_FALSE(widget_host_->is_hidden());
EXPECT_EQ(tooltip_text, view_->tooltip_);
view_->WasOccluded();
EXPECT_TRUE(widget_host_->is_hidden());
EXPECT_EQ(std::u16string(), view_->tooltip_);
}
TEST_F(RenderWidgetHostViewAuraTest, LegacyRenderWidgetHostHWNDAuraLookup) {
MockWindowEventTarget event_target;
auto prop_window_target = std::make_unique<ui::ViewProp>(
parent_view_->GetHostWindowHWND(),
ui::WindowEventTarget::kWin32InputEventTarget,
static_cast<ui::WindowEventTarget*>(&event_target));
InitViewForFrame(nullptr);
ParentHostView(view_, parent_view_);
view_->Show();
ASSERT_TRUE(legacy_render_widget_host_HWND());
HWND hwnd = legacy_render_widget_host_HWND()->hwnd();
EXPECT_TRUE(hwnd);
auto* window_tree_host = aura::WindowTreeHost::GetForAcceleratedWidget(hwnd);
EXPECT_TRUE(window_tree_host);
EXPECT_EQ(view_->GetNativeView()->GetHost(), window_tree_host);
}
#endif
TEST_F(RenderWidgetHostViewAuraTest, ElideEmptyTouchpadPinchSequence) { … }
TEST_F(RenderWidgetHostViewAuraTest,
TouchpadScrollThenPinchFiresImmediateScrollEnd) { … }
TEST_F(RenderWidgetHostViewAuraTest, GestureTapFromStylusHasPointerType) { … }
#if BUILDFLAG(IS_LINUX)
#define MAYBE_NewContentRenderingTimeout …
#else
#define MAYBE_NewContentRenderingTimeout …
#endif
TEST_F(RenderWidgetHostViewAuraTest, MAYBE_NewContentRenderingTimeout) { … }
TEST_F(RenderWidgetHostViewAuraTest, AllocateLocalSurfaceIdOnEviction) { … }
TEST_F(RenderWidgetHostViewAuraTest, DropFallbackIfResizedWhileHidden) { … }
TEST_F(RenderWidgetHostViewAuraTest, DontDropFallbackIfNotResizedWhileHidden) { … }
TEST_F(RenderWidgetHostViewAuraTest, TakeFallbackContent) { … }
TEST_F(RenderWidgetHostViewAuraTest, TakeFallbackContentForPrerender) { … }
class RenderWidgetHostViewAuraWithViewHarnessTest
: public RenderViewHostImplTestHarness { … };
class MockWebContentsViewDelegate : public WebContentsViewDelegate { … };
TEST_F(RenderWidgetHostViewAuraWithViewHarnessTest,
ContextMenuTest) { … }
class InputMethodAuraTestBase : public RenderWidgetHostViewAuraTest { … };
class InputMethodResultAuraTest : public InputMethodAuraTestBase { … };
TEST_F(InputMethodResultAuraTest, SetCompositionText) { … }
TEST_F(InputMethodResultAuraTest, ConfirmCompositionText) { … }
TEST_F(InputMethodResultAuraTest, ClearCompositionText) { … }
TEST_F(InputMethodResultAuraTest, InsertEmptyText) { … }
TEST_F(InputMethodResultAuraTest, CommitText) { … }
TEST_F(InputMethodResultAuraTest, CommitTextWithEmptyText) { … }
TEST_F(InputMethodResultAuraTest, CommitTextBeforeCursor) { … }
TEST_F(InputMethodResultAuraTest, FinishImeCompositionSession) { … }
TEST_F(InputMethodResultAuraTest, ChangeTextDirectionAndLayoutAlignment) { … }
class InputMethodStateAuraTest : public InputMethodAuraTestBase { … };
TEST_F(InputMethodStateAuraTest, GetCaretBounds) { … }
TEST_F(InputMethodStateAuraTest, GetCompositionCharacterBounds) { … }
TEST_F(InputMethodStateAuraTest, GetSelectedText) { … }
TEST_F(InputMethodStateAuraTest, GetTextRange) { … }
TEST_F(InputMethodStateAuraTest, GetCompositionTextRange) { … }
TEST_F(InputMethodStateAuraTest, GetEditableSelectionRange) { … }
TEST_F(InputMethodStateAuraTest, GetTextFromRange) { … }
TEST_F(InputMethodStateAuraTest, SelectedTextCopiedToClipboard) { … }
TEST_F(InputMethodStateAuraTest, ImeCancelCompositionForAllViews) { … }
TEST_F(InputMethodStateAuraTest, ImeFocusedNodeChanged) { … }
TEST_F(RenderWidgetHostViewAuraTest, FocusReasonNotFocused) { … }
TEST_F(RenderWidgetHostViewAuraTest, FocusReasonMouse) { … }
TEST_F(RenderWidgetHostViewAuraTest, FocusReasonTouch) { … }
TEST_F(RenderWidgetHostViewAuraTest, FocusReasonPen) { … }
TEST_F(RenderWidgetHostViewAuraTest, FocusReasonMultipleEventsOnSameNode) { … }
class RenderWidgetHostViewAuraInputMethodTest
: public RenderWidgetHostViewAuraTest,
public ui::InputMethodObserver { … };
TEST_F(RenderWidgetHostViewAuraInputMethodTest, OnCaretBoundsChanged) { … }
TEST_F(RenderWidgetHostViewAuraInputMethodTest,
OnCaretBoundsChangedInputModeNone) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS)
class MockVirtualKeyboardController final
: public ui::VirtualKeyboardController {
public:
MockVirtualKeyboardController() = default;
MockVirtualKeyboardController(const MockVirtualKeyboardController&) = delete;
MockVirtualKeyboardController& operator=(
const MockVirtualKeyboardController&) = delete;
bool DisplayVirtualKeyboard() override {
virtual_keyboard_requested_ = true;
return virtual_keyboard_requested_;
}
void DismissVirtualKeyboard() override {
virtual_keyboard_requested_ = false;
}
void AddObserver(ui::VirtualKeyboardControllerObserver* observer) override {
observer_count_++;
}
void RemoveObserver(
ui::VirtualKeyboardControllerObserver* observer) override {
observer_count_--;
}
bool IsKeyboardVisible() override { return virtual_keyboard_requested_; }
size_t observer_count() const { return observer_count_; }
private:
size_t observer_count_ = 0;
bool virtual_keyboard_requested_ = false;
};
class RenderWidgetHostViewAuraKeyboardMockInputMethod
: public ui::MockInputMethod {
public:
RenderWidgetHostViewAuraKeyboardMockInputMethod()
: MockInputMethod(nullptr) {}
RenderWidgetHostViewAuraKeyboardMockInputMethod(
const RenderWidgetHostViewAuraKeyboardMockInputMethod&) = delete;
RenderWidgetHostViewAuraKeyboardMockInputMethod& operator=(
const RenderWidgetHostViewAuraKeyboardMockInputMethod&) = delete;
ui::VirtualKeyboardController* GetVirtualKeyboardController() override {
return &keyboard_controller_;
}
size_t keyboard_controller_observer_count() const {
return keyboard_controller_.observer_count();
}
void SetVirtualKeyboardVisibilityIfEnabled(bool should_show) override {
if (should_show) {
keyboard_controller_.DisplayVirtualKeyboard();
} else {
keyboard_controller_.DismissVirtualKeyboard();
}
}
bool IsKeyboardVisible() { return keyboard_controller_.IsKeyboardVisible(); }
private:
MockVirtualKeyboardController keyboard_controller_;
};
class RenderWidgetHostViewAuraKeyboardTest
: public RenderWidgetHostViewAuraTest {
public:
RenderWidgetHostViewAuraKeyboardTest() = default;
RenderWidgetHostViewAuraKeyboardTest(
const RenderWidgetHostViewAuraKeyboardTest&) = delete;
RenderWidgetHostViewAuraKeyboardTest& operator=(
const RenderWidgetHostViewAuraKeyboardTest&) = delete;
~RenderWidgetHostViewAuraKeyboardTest() override {}
void SetUp() override {
ui::SetUpInputMethodForTesting(
new RenderWidgetHostViewAuraKeyboardMockInputMethod());
SetUpEnvironment();
}
RenderWidgetHostViewAuraKeyboardMockInputMethod* GetMockInputMethod() const {
return static_cast<RenderWidgetHostViewAuraKeyboardMockInputMethod*>(
GetInputMethod());
}
size_t keyboard_controller_observer_count() const {
return GetMockInputMethod()->keyboard_controller_observer_count();
}
bool IsKeyboardVisible() const {
return GetMockInputMethod()->IsKeyboardVisible();
}
};
#endif
#if BUILDFLAG(IS_CHROMEOS)
TEST_F(RenderWidgetHostViewAuraKeyboardTest,
UpdateTextInputStateUpdatesVirtualKeyboardState) {
ActivateViewForTextInputManager(parent_view_, ui::TEXT_INPUT_TYPE_TEXT);
ui::mojom::TextInputState state;
state.type = ui::TEXT_INPUT_TYPE_TEXT;
state.mode = ui::TEXT_INPUT_MODE_NONE;
state.last_vk_visibility_request =
ui::mojom::VirtualKeyboardVisibilityRequest::SHOW;
EXPECT_EQ(IsKeyboardVisible(), false);
GetTextInputManager(parent_view_)->UpdateTextInputState(parent_view_, state);
EXPECT_EQ(IsKeyboardVisible(), true);
state.last_vk_visibility_request =
ui::mojom::VirtualKeyboardVisibilityRequest::HIDE;
GetTextInputManager(parent_view_)->UpdateTextInputState(parent_view_, state);
EXPECT_EQ(IsKeyboardVisible(), false);
}
#endif
#if BUILDFLAG(IS_WIN)
TEST_F(RenderWidgetHostViewAuraKeyboardTest, KeyboardObserverDestroyed) {
parent_view_->SetLastPointerType(ui::EventPointerType::kTouch);
ActivateViewForTextInputManager(parent_view_, ui::TEXT_INPUT_TYPE_TEXT);
EXPECT_NE(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 1u);
EXPECT_EQ(IsKeyboardVisible(), true);
parent_view_->DetachFromInputMethod(true);
EXPECT_EQ(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 0u);
}
TEST_F(RenderWidgetHostViewAuraKeyboardTest, NoKeyboardObserverForMouseInput) {
parent_view_->SetLastPointerType(ui::EventPointerType::kMouse);
ActivateViewForTextInputManager(parent_view_, ui::TEXT_INPUT_TYPE_TEXT);
EXPECT_EQ(keyboard_controller_observer_count(), 0u);
EXPECT_EQ(IsKeyboardVisible(), false);
}
TEST_F(RenderWidgetHostViewAuraKeyboardTest,
KeyboardObserverForOnlyTouchInput) {
parent_view_->SetLastPointerType(ui::EventPointerType::kTouch);
ActivateViewForTextInputManager(parent_view_, ui::TEXT_INPUT_TYPE_TEXT);
EXPECT_NE(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 1u);
EXPECT_EQ(IsKeyboardVisible(), true);
}
TEST_F(RenderWidgetHostViewAuraKeyboardTest,
KeyboardObserverForFocusedNodeChanged) {
parent_view_->SetLastPointerType(ui::EventPointerType::kTouch);
ActivateViewForTextInputManager(parent_view_, ui::TEXT_INPUT_TYPE_TEXT);
EXPECT_EQ(IsKeyboardVisible(), true);
EXPECT_NE(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 1u);
parent_view_->FocusedNodeChanged(false, gfx::Rect());
EXPECT_NE(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 1u);
EXPECT_EQ(IsKeyboardVisible(), false);
parent_view_->DetachFromInputMethod(true);
EXPECT_EQ(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 0u);
}
TEST_F(RenderWidgetHostViewAuraKeyboardTest, KeyboardObserverForPenInput) {
parent_view_->SetLastPointerType(ui::EventPointerType::kPen);
ActivateViewForTextInputManager(parent_view_, ui::TEXT_INPUT_TYPE_TEXT);
EXPECT_NE(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 1u);
}
TEST_F(RenderWidgetHostViewAuraKeyboardTest,
KeyboardObserverDetachDuringWindowDestroy) {
parent_view_->SetLastPointerType(ui::EventPointerType::kTouch);
ActivateViewForTextInputManager(parent_view_, ui::TEXT_INPUT_TYPE_TEXT);
EXPECT_NE(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 1u);
EXPECT_EQ(IsKeyboardVisible(), true);
parent_view_->DetachFromInputMethod(false);
EXPECT_EQ(IsKeyboardVisible(), false);
EXPECT_NE(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 1u);
parent_view_->DetachFromInputMethod(true);
EXPECT_EQ(parent_view_->virtual_keyboard_controller_win_.get(), nullptr);
EXPECT_EQ(keyboard_controller_observer_count(), 0u);
}
#endif
}