chromium/ui/views/widget/native_widget_aura_unittest.cc

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

#include "ui/views/widget/native_widget_aura.h"

#include <memory>
#include <set>
#include <utility>

#include "base/command_line.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/uuid.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/unique_widget_ptr.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/wm/core/base_focus_rules.h"
#include "ui/wm/core/default_activation_client.h"
#include "ui/wm/core/focus_controller.h"
#include "ui/wm/core/transient_window_manager.h"

namespace views {
namespace {

NativeWidgetAura* Init(aura::Window* parent, Widget* widget) {}

// TestFocusRules is intended to provide a way to manually set a window's
// activatability so that the focus rules can be tested.
class TestFocusRules : public wm::BaseFocusRules {};

class NativeWidgetAuraTest : public ViewsTestBase {};

TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) {}

TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) {}

// Verifies CenterWindow() constrains to parent size.
TEST_F(NativeWidgetAuraTest, CenterWindowSmallParentNotAtOrigin) {}

// View which handles both mouse and gesture events.
class EventHandlingView : public View {};

BEGIN_METADATA()

// Verifies that when the mouse click interrupts the gesture scroll, the view
// where the gesture scroll starts should receive the scroll end event.
TEST_F(NativeWidgetAuraTest, MouseClickInterruptsGestureScroll) {}

TEST_F(NativeWidgetAuraTest, CreateMinimized) {}

// Tests that GetRestoreBounds returns the window bounds even if the window is
// transformed.
TEST_F(NativeWidgetAuraTest, RestoreBounds) {}

TEST_F(NativeWidgetAuraTest, GetWorkspace) {}

// A WindowObserver that counts kShowStateKey property changes.
class TestWindowObserver : public aura::WindowObserver {};

// Tests that window transitions from normal to minimized and back do not
// involve extra show state transitions.
TEST_F(NativeWidgetAuraTest, ToggleState) {}

class TestLayoutManagerBase : public aura::LayoutManager {};

// Used by ShowMaximizedDoesntBounceAround. See it for details.
class MaximizeLayoutManager : public TestLayoutManagerBase {};

// This simulates BrowserView, which creates a custom RootView so that
// OnNativeWidgetSizeChanged that is invoked during Init matters.
class TestWidget : public Widget {};

// Verifies the size of the widget doesn't change more than once during Init if
// the window ends up maximized. This is important as otherwise
// RenderWidgetHostViewAura ends up getting resized during construction, which
// leads to noticable flashes.
TEST_F(NativeWidgetAuraTest, ShowMaximizedDoesntBounceAround) {}

class PropertyTestLayoutManager : public TestLayoutManagerBase {};

// Verifies the resize behavior when added to the layout manager.
TEST_F(NativeWidgetAuraTest, TestPropertiesWhenAddedToLayout) {}

TEST_F(NativeWidgetAuraTest, GetClientAreaScreenBounds) {}

// View subclass that tracks whether it has gotten a gesture event.
class GestureTrackingView : public View {};

BEGIN_METADATA()

// Verifies a capture isn't set on touch press and that the view that gets
// the press gets the release.
TEST_F(NativeWidgetAuraTest, DontCaptureOnGesture) {}

// Verifies views with layers are targeted for events properly.
TEST_F(NativeWidgetAuraTest, PreferViewLayersToChildWindows) {}

// Verifies views with layers are targeted for events properly.
TEST_F(NativeWidgetAuraTest,
       ShouldDescendIntoChildForEventHandlingChecksVisibleBounds) {}

// Verifies views with layers that have SetCanProcessEventWithinSubtree(false)
// set are ignored for event targeting (i.e. the underlying child window can
// still be the target of those events).
TEST_F(
    NativeWidgetAuraTest,
    ShouldDescendIntoChildForEventHandlingIgnoresViewsThatDoNotProcessEvents) {}

// Verifies that widget->FlashFrame() sets aura::client::kDrawAttentionKey,
// and activating the window clears it.
TEST_F(NativeWidgetAuraTest, FlashFrame) {}

// Used to track calls to WidgetDelegate::OnWidgetMove().
class MoveTestWidgetDelegate : public WidgetDelegateView {};

// This test simulates what happens when a window is normally maximized. That
// is, it's layer is acquired for animation then the window is maximized.
// Acquiring the layer resets the bounds of the window. This test verifies the
// Widget is still notified correctly of a move in this case.
TEST_F(NativeWidgetAuraTest, OnWidgetMovedInvokedAfterAcquireLayer) {}

// Tests that if a widget has a view which should be initially focused when the
// widget is shown, this view should not get focused if the associated window
// can not be activated.
TEST_F(NativeWidgetAuraTest, PreventFocusOnNonActivableWindow) {}

// Tests that the transient child bubble window is only visible if the parent is
// visible.
TEST_F(NativeWidgetAuraTest, VisibilityOfChildBubbleWindow) {}

// Tests that for a child transient window, if its modal type is
// ui::mojom::ModalType::kWindow, then its visibility is controlled by its
// transient parent's visibility.
TEST_F(NativeWidgetAuraTest, TransientChildModalWindowVisibility) {}

// Tests that widgets that are created minimized have the correct restore
// bounds.
TEST_F(NativeWidgetAuraTest, MinimizedWidgetRestoreBounds) {}

// Tests that the `kDeskUuidKey` is set if the `workspace` parameter is
// a uuid, and that the `kWindowWorkspaceKey` is set if it's a string
// representation of an integer.
TEST_F(NativeWidgetAuraTest, WorkspaceUuid) {}

// Series of tests that verifies having a null NativeWidgetDelegate doesn't
// crash.
class NativeWidgetAuraWithNoDelegateTest : public NativeWidgetAuraTest {};

TEST_F(NativeWidgetAuraWithNoDelegateTest, GetHitTestMaskTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, GetMaximumSizeTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, GetMinimumSizeTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, GetNonClientComponentTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, GetWidgetTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, HasHitTestMaskTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnBoundsChangedTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnCaptureLostTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnGestureEventTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnKeyEventTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnMouseEventTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnPaintTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnResizeLoopEndedTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnResizeLoopStartedTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnScrollEventTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnTransientParentChangedTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnWindowAddedToRootWindowTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnWindowPropertyChangedTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnWindowRemovingFromRootWindowTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest,
       OnWindowTargetVisibilityChangedTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnWindowActivatedTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, OnWindowFocusedTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, ShouldActivateTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest,
       ShouldDescendIntoChildForEventHandlingTest) {}

TEST_F(NativeWidgetAuraWithNoDelegateTest, UpdateVisualStateTest) {}

}  // namespace
}  // namespace views