#include <memory>
#include <optional>
#include <set>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/test/gtest_util.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h"
#include "ui/base/hit_test.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/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/color/color_provider_key.h"
#include "ui/color/color_provider_manager.h"
#include "ui/color/color_recipe.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/compositor/test/draw_waiter_for_test.h"
#include "ui/events/event_observer.h"
#include "ui/events/event_utils.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/native_theme/native_theme.h"
#include "ui/native_theme/test_native_theme.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/buildflags.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/event_monitor.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/test/mock_drag_controller.h"
#include "ui/views/test/mock_native_widget.h"
#include "ui/views/test/native_widget_factory.h"
#include "ui/views/test/test_views.h"
#include "ui/views/test/test_widget_observer.h"
#include "ui/views/test/views_test_utils.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/view_test_api.h"
#include "ui/views/views_test_suite.h"
#include "ui/views/widget/native_widget_delegate.h"
#include "ui/views/widget/native_widget_private.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/views/widget/widget_deletion_observer.h"
#include "ui/views/widget/widget_interactive_uitest_utils.h"
#include "ui/views/widget/widget_removals_observer.h"
#include "ui/views/widget/widget_utils.h"
#include "ui/views/window/dialog_delegate.h"
#include "ui/views/window/native_frame_view.h"
#if defined(USE_AURA)
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/view_prop.h"
#include "ui/views/test/test_platform_native_widget.h"
#include "ui/views/widget/native_widget_aura.h"
#include "ui/wm/core/base_focus_rules.h"
#include "ui/wm/core/focus_controller.h"
#include "ui/wm/core/shadow_controller.h"
#include "ui/wm/core/shadow_controller_delegate.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "ui/base/win/window_event_target.h"
#include "ui/views/win/hwnd_util.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "base/mac/mac_util.h"
#endif
#if BUILDFLAG(ENABLE_DESKTOP_AURA)
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#endif
namespace views::test {
namespace {
_;
IsEmpty;
Not;
gfx::Point ConvertPointFromWidgetToView(View* view, const gfx::Point& p) { … }
std::unique_ptr<ui::test::EventGenerator> CreateEventGenerator(
gfx::NativeWindow root_window,
gfx::NativeWindow target_window) { … }
class TestBubbleDialogDelegateView : public BubbleDialogDelegateView { … };
BEGIN_METADATA(…)
ui::GestureEvent CreateTestGestureEvent(ui::EventType type, int x, int y) { … }
ui::GestureEvent CreateTestGestureEvent(const ui::GestureEventDetails& details,
int x,
int y) { … }
class TestWidgetRemovalsObserver : public WidgetRemovalsObserver { … };
}
class ScrollableEventCountView : public EventCountView { … };
BEGIN_METADATA(…)
class MinimumSizeFrameView : public NativeFrameView { … };
BEGIN_METADATA(…)
class EventCountHandler : public ui::EventHandler { … };
TEST_F(WidgetTest, WidgetInitParams) { … }
class WidgetWithCustomParamsTest : public WidgetTest { … };
TEST_F(WidgetWithCustomParamsTest, NamePropagatedFromParams) { … }
TEST_F(WidgetWithCustomParamsTest, NamePropagatedFromDelegate) { … }
TEST_F(WidgetWithCustomParamsTest, Autosize) { … }
namespace {
class ViewWithClassName : public View { … };
BEGIN_METADATA(…)
}
TEST_F(WidgetWithCustomParamsTest, NamePropagatedFromContentsViewClassName) { … }
namespace {
class TestView : public View { … };
BEGIN_METADATA(…)
}
TEST_F(WidgetWithCustomParamsTest, InitWithNativeTheme) { … }
class WidgetColorModeTest : public WidgetTest { … };
TEST_F(WidgetColorModeTest, ColorModeOverride_NoOverride) { … }
TEST_F(WidgetColorModeTest, ColorModeOverride_DarkOverride) { … }
TEST_F(WidgetColorModeTest, ColorModeOverride_LightOverride) { … }
TEST_F(WidgetColorModeTest, ChildInheritsColorMode_NoOverrides) { … }
TEST_F(WidgetColorModeTest, ChildInheritsColorMode_Overrides) { … }
TEST_F(WidgetTest, NativeWindowProperty) { … }
TEST_F(WidgetTest, GetParent) { … }
TEST_F(WidgetTest, ArrowKeyFocusTraversalOffByDefault) { … }
TEST_F(WidgetTest, ArrowKeyTraversalMovesFocusBetweenViews) { … }
TEST_F(WidgetTest, ArrowKeyTraversalNotInheritedByChildWidgets) { … }
TEST_F(WidgetTest, ArrowKeyTraversalMayBeExplicitlyEnabledByChildWidgets) { … }
TEST_F(WidgetTest, GetTopLevelWidget_Native) { … }
TEST_F(WidgetTest, ChangeActivation) { … }
TEST_F(WidgetTest, Visibility) { … }
TEST_F(WidgetTest, ChildBoundsRelativeToParent) { … }
struct OwnershipTestState { … };
class WidgetOwnershipTest : public WidgetTest { … };
class OwnershipTestWidget : public Widget { … };
class NativeWidgetDestroyedWaiter { … };
NativeWidgetOwnsWidgetTest;
TEST_F(NativeWidgetOwnsWidgetTest, NonDesktopWidget_CloseNow) { … }
TEST_F(NativeWidgetOwnsWidgetTest, NonDesktopWidget_Close) { … }
#if BUILDFLAG(ENABLE_DESKTOP_AURA)
TEST_F(NativeWidgetOwnsWidgetTest, DesktopWidget_Close) { … }
#endif
#if BUILDFLAG(ENABLE_DESKTOP_AURA)
TEST_F(NativeWidgetOwnsWidgetTest, DesktopWidget_CloseNow) { … }
#endif
TEST_F(NativeWidgetOwnsWidgetTest, NonDestkopWidget_CloseNowParent) { … }
#if BUILDFLAG(ENABLE_DESKTOP_AURA)
TEST_F(NativeWidgetOwnsWidgetTest, DestkopWidget_CloseNowParent) { … }
#endif
TEST_F(NativeWidgetOwnsWidgetTest, NonDesktopWidget_NativeDestroy) { … }
#if BUILDFLAG(ENABLE_DESKTOP_AURA)
TEST_F(NativeWidgetOwnsWidgetTest, DesktopWidget_NativeDestroy) { … }
#endif
WidgetOwnsNativeWidgetTest;
TEST_F(WidgetOwnsNativeWidgetTest, Ownership) { … }
TEST_F(WidgetOwnsNativeWidgetTest, DestroyParentView) { … }
TEST_F(WidgetOwnsNativeWidgetTest, WidgetDelegateView) { … }
TEST_F(WidgetOwnsNativeWidgetTest, IdempotentCloseNow) { … }
TEST_F(WidgetOwnsNativeWidgetTest, IdempotentClose) { … }
ClientOwnsWidgetTest;
TEST_F(ClientOwnsWidgetTest, Ownership) { … }
TEST_F(ClientOwnsWidgetTest, DestructWithAsyncCloseFirst) { … }
TEST_F(ClientOwnsWidgetTest, DestructWithoutExplicitClose) { … }
class WidgetDestroyCounter : public WidgetObserver { … };
TEST_F(ClientOwnsWidgetTest, NotificationsTest) { … }
class WidgetWithDestroyedNativeViewOrNativeWidgetTest
: public ViewsTestBase,
public testing::WithParamInterface<
std::tuple<ViewsTestBase::NativeWidgetType,
Widget::InitParams::Ownership>> { … };
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Activate) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, AddAndRemoveObserver) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
AddAndRemoveRemovalsObserver) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, AsWidget) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, CanActivate) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, CenterWindow) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ClearNativeFocus) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ClientView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Close) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
CloseAllSecondaryWidgets) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, CloseNow) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ClosedReason) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, CloseWithReason) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
CreateNonClientFrameView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Deactivate) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, DraggedView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, EndMoveLoop) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ExecuteCommand) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, FlashFrame) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, FrameType) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, FrameTypeChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetAccelerator) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetAllChildWidgets) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetAllOwnedWidgets) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetAndSetZOrderLevel) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
GetClientAreaBoundsInScreen) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetColorProvider) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetCompositor) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetContentsView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetCustomTheme) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetEventSink) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetFocusSearch) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetFocusManager) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetFocusTraversable) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetGestureConsumer) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetGestureRecognizer) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetHitTestMask) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetInputMethod) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetLayer) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetMinimumSize) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetMaximumSize) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetName) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetNativeTheme) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetNativeView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetNativeWindow) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
GetNativeWindowProperty) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetNonClientComponent) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
GetPrimaryWindowWidget) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetRestoredBounds) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetRootView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetSublevelManager) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetThemeProvider) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetTooltipManager) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetTopLevelWidget) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
GetTopLevelWidgetForNativeView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetWeakPtr) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
GetWidgetForNativeView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
GetWidgetForNativeWindow) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
GetWindowBoundsInScreen) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
GetWorkAreaBoundsInScreen) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetWorkspace) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, GetZOrderSublevel) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, HasCapture) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, HasFocusManager) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, HasHitTestMask) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, HasObserver) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, HasRemovalsObserver) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Hide) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Init) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, is_secondary_widget) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsActive) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsClosed) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsDialogBox) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsFullscreen) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsMaximized) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsMinimized) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsModal) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsMouseEventsEnabled) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsMoveLoopSupported) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
IsNativeWidgetInitialized) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsStackedAbove) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, IsVisible) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
IsVisibleOnAllWorkspaces) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnGestureEvent) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnKeyEvent) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnMouseCaptureLost) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnMouseEvent) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnNativeBlur) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnNativeFocus) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnNativeThemeUpdated) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetActivationChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetAddedToCompositor) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetBeginUserBoundsChange) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnNativeWidgetCreated) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetDestroyed) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetDestroying) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetEndUserBoundsChange) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnNativeWidgetMove) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnNativeWidgetPaint) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetParentChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetRemovingFromCompositor) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetSizeChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetVisibilityChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetWindowShowStateChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnNativeWidgetWorkspaceChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnOwnerClosing) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnParentShouldPaintAsActiveChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, OnScrollEvent) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
OnSizeConstraintsChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, LayerTreeChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
LayoutRootViewIfNecessary) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, LockPaintAsActive) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Maximize) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Minimize) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, movement_disabled) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, native_widget_private) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, native_widget) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, non_client_view) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
NotifyNativeViewHierarchyChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
NotifyNativeViewHierarchyWillChange) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, NotifyWillRemoveView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, parent) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
RegisterPaintAsActiveChangedCallback) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ReleaseCapture) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ReorderNativeViews) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ReparentNativeView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Restore) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, RunMoveLoop) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, RunShellDrag) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ScheduleLayout) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SchedulePaintInRect) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetAspectRatio) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetBounds) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetBoundsConstrained) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
SetCanAppearInExistingFullscreenSpaces) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetCapture) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetContentsView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetCursor) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
SetFocusTraversableParent) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
SetFocusTraversableParentView) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetFullscreen) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetInitialFocus) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
SetNativeWindowProperty) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetOpacity) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetShape) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetSize) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
SetVisibilityChangedAnimationsEnabled) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
SetVisibilityAnimationDuration) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
SetVisibilityAnimationTransition) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, SetVisible) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
SetVisibleOnAllWorkspaces) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
ShouldDescendIntoChildForEventHandling) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
ShouldHandleNativeWidgetActivationChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ShouldPaintAsActive) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ShouldUseNativeFrame) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
ShouldWindowContentsBeTransparent) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Show) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ShowEmojiPanel) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ShowInactive) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, StackAbove) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, StackAboveWidget) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, StackAtTop) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest,
SynthesizeMouseMoveEvent) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ThemeChanged) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, UnlockPaintAsActive) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, UpdateWindowIcon) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, UpdateWindowTitle) { … }
TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, ViewHierarchyChanged) { … }
INSTANTIATE_TEST_SUITE_P(…);
class WidgetObserverTest : public WidgetTest, public WidgetObserver { … };
#if BUILDFLAG(IS_MAC)
#define MAYBE_ActivationChange …
#else
#define MAYBE_ActivationChange …
#endif
TEST_F(WidgetObserverTest, MAYBE_ActivationChange) { … }
namespace {
class WidgetActivationForwarder : public TestWidgetObserver { … };
class WidgetCloseCounter : public TestWidgetObserver { … };
}
TEST_F(WidgetObserverTest, CloseReentrancy) { … }
TEST_F(WidgetObserverTest, VisibilityChange) { … }
TEST_F(WidgetObserverTest, DestroyBubble) { … }
TEST_F(WidgetObserverTest, WidgetBoundsChanged) { … }
TEST_F(WidgetObserverTest, WidgetBoundsChangedNative) { … }
namespace {
class MoveTrackingTestDesktopWidgetDelegate : public TestDesktopWidgetDelegate { … };
}
class DesktopWidgetObserverTest : public WidgetObserverTest { … };
TEST_F(DesktopWidgetObserverTest, OnWidgetMovedWhenOriginChangesNative) { … }
TEST_F(WidgetObserverTest, ClosingOnHiddenParent) { … }
#if BUILDFLAG(IS_LINUX)
TEST_F(WidgetTest, GetWindowPlacement) { … }
TEST_F(DesktopWidgetTest, MinimumSizeConstraints) { … }
#if BUILDFLAG(ENABLE_DESKTOP_AURA)
TEST_F(DesktopWidgetTest, GetPossiblyDestroyedParent) { … }
#endif
TEST_F(WidgetTest, GetWindowBoundsInScreen) { … }
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)
#define MAYBE_GetRestoredBounds …
#else
#define MAYBE_GetRestoredBounds …
#endif
TEST_F(DesktopWidgetTest, MAYBE_GetRestoredBounds) { … }
TEST_F(WidgetTest, KeyboardInputEvent) { … }
TEST_F(WidgetTest, BubbleControlsResetOnInit) { … }
#if BUILDFLAG(IS_WIN)
TEST_F(DesktopWidgetTest, TestViewWidthAfterMinimizingWidget) {
std::unique_ptr<Widget> widget =
CreateTestWidget(Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET,
Widget::InitParams::TYPE_WINDOW);
NonClientView* non_client_view = widget->non_client_view();
non_client_view->SetFrameView(
std::make_unique<MinimumSizeFrameView>(widget.get()));
non_client_view->InvalidateLayout();
views::test::RunScheduledLayout(non_client_view);
widget->Show();
EXPECT_NE(0, non_client_view->frame_view()->width());
widget->Minimize();
EXPECT_EQ(0, non_client_view->frame_view()->width());
}
#endif
class DesktopAuraTestValidPaintWidget : public Widget, public WidgetObserver { … };
namespace {
class ContentsView : public View { … };
BEGIN_METADATA(…)
}
class DesktopAuraPaintWidgetTest : public DesktopWidgetTest { … };
TEST_F(DesktopAuraPaintWidgetTest, DesktopNativeWidgetNoPaintAfterCloseTest) { … }
TEST_F(DesktopAuraPaintWidgetTest, DesktopNativeWidgetNoPaintAfterHideTest) { … }
TEST_F(DesktopWidgetTest, TestWindowVisibilityAfterHide) { … }
TEST_F(WidgetTest, WheelEventsFromScrollEventTarget) { … }
TEST_F(WidgetTest, GestureScrollEventDispatching) { … }
TEST_F(WidgetTest, EventHandlersOnRootView) { … }
TEST_F(WidgetTest, SynthesizeMouseMoveEvent) { … }
namespace {
class MousePressEventConsumer : public ui::EventHandler { … };
}
#if !BUILDFLAG(IS_MAC) || defined(USE_AURA)
TEST_F(WidgetTest, MouseEventDispatchWhileTouchIsDown) { … }
#endif
TEST_F(WidgetTest, MousePressCausesCapture) { … }
namespace {
class CaptureEventConsumer : public ui::EventHandler { … };
}
TEST_F(WidgetTest, CaptureDuringMousePressNotOverridden) { … }
class ClosingEventObserver : public ui::EventObserver { … };
class ClosingView : public View { … };
BEGIN_METADATA(…)
TEST_F(WidgetTest, DestroyedWithCaptureViaEventMonitor) { … }
TEST_F(WidgetTest, LockPaintAsActive) { … }
TEST_F(WidgetTest, LockPaintAsActive_AlreadyActive) { … }
TEST_F(WidgetTest, LockPaintAsActive_BecomesActive) { … }
class PaintAsActiveCallbackCounter { … };
TEST_F(WidgetTest, LockParentPaintAsActive) { … }
TEST_F(DesktopWidgetTest,
ClosingActiveChildDoesNotPrematurelyPaintParentInactive) { … }
TEST_F(DesktopWidgetTest, LockPaintAsActiveAndCloseParent) { … }
class TestNativeWidgetDestroyedWidget : public Widget { … };
void TestNativeWidgetDestroyedWidget::OnNativeWidgetDestroyed() { … }
TEST_F(DesktopWidgetTest, WidgetDestroyedItselfDoesNotCrash) { … }
TEST_F(DesktopWidgetTest, SingleWindowClosing) { … }
TEST_F(DesktopWidgetTest, CloseRequested_AllowsClose) { … }
TEST_F(DesktopWidgetTest, CloseRequested_DisallowClose) { … }
TEST_F(DesktopWidgetTest, CloseRequested_SecondCloseIgnored) { … }
class WidgetWindowTitleTest : public DesktopWidgetTest { … };
TEST_F(WidgetWindowTitleTest, SetWindowTitleChanged_NativeWidget) { … }
TEST_F(WidgetWindowTitleTest, SetWindowTitleChanged_DesktopNativeWidget) { … }
TEST_F(WidgetTest, WidgetDeleted_InOnMousePressed) { … }
#if !BUILDFLAG(IS_MAC) || defined(USE_AURA)
TEST_F(WidgetTest, WidgetDeleted_InDispatchGestureEvent) { … }
#endif
class GetNativeThemeFromDestructorView : public WidgetDelegateView { … };
bool RunGetNativeThemeFromDestructor(Widget::InitParams params,
bool is_first_run) { … }
TEST_F(DesktopWidgetTest, DISABLED_GetNativeThemeFromDestructor) { … }
class CloseDestroysWidget : public Widget { … };
class AnimationEndObserver : public ui::ImplicitAnimationObserver { … };
class WidgetBoundsObserver : public WidgetObserver { … };
TEST_F(DesktopWidgetTest, CloseDestroys) { … }
TEST_F(WidgetTest, CloseWidgetWhileAnimating) { … }
#if BUILDFLAG(ENABLE_DESKTOP_AURA) || BUILDFLAG(IS_MAC)
TEST_F(DesktopWidgetTest, CloseAllSecondaryWidgets) { … }
#endif
TEST_F(DesktopWidgetTest, ValidDuringOnNativeWidgetDestroyingFromCloseNow) { … }
TEST_F(DesktopWidgetTest, ValidDuringOnNativeWidgetDestroyingFromClose) { … }
TEST_F(WidgetTest, NoCrashOnWidgetDelete) { … }
TEST_F(WidgetTest, NoCrashOnResizeConstraintsWindowTitleOnPopup) { … }
TEST_F(WidgetTest, NoCrashOnWidgetDeleteWithPendingEvents) { … }
class RootViewTestView : public View { … };
BEGIN_METADATA(…)
#if BUILDFLAG(IS_WIN)
#define MAYBE_DisableTestRootViewHandlersWhenHidden …
#else
#define MAYBE_DisableTestRootViewHandlersWhenHidden …
#endif
TEST_F(WidgetTest, MAYBE_DisableTestRootViewHandlersWhenHidden) { … }
TEST_F(WidgetTest, GestureEndEvents) { … }
TEST_F(WidgetTest, GestureEventsNotProcessed) { … }
TEST_F(WidgetTest, GestureEventDispatch) { … }
TEST_F(WidgetTest, ScrollGestureEventDispatch) { … }
#if !BUILDFLAG(IS_MAC)
TEST_F(WidgetTest, NotifyDragControllerWhenDragWillStart) { … }
#endif
class GestureLocationView : public EventCountView { … };
BEGIN_METADATA(…)
TEST_F(WidgetTest, GestureEventLocationWhileBubbling) { … }
TEST_F(WidgetTest, GetAllChildWidgets) { … }
class DestroyedTrackingView : public View { … };
BEGIN_METADATA(…)
class WidgetChildDestructionTest : public DesktopWidgetTest { … };
TEST_F(WidgetChildDestructionTest,
DestroyChildWidgetsInOrderWithDesktopNativeWidget) { … }
TEST_F(WidgetChildDestructionTest,
DestroyChildWidgetsInOrderWithDesktopNativeWidgetForBoth) { … }
TEST_F(WidgetChildDestructionTest, DestroyChildWidgetsInOrder) { … }
TEST_F(WidgetTest, FullscreenStatePropagated) { … }
TEST_F(DesktopWidgetTest, FullscreenStatePropagated_DesktopWidget) { … }
class DestroyingWidgetBoundsObserver : public WidgetObserver { … };
#if BUILDFLAG(IS_MAC)
#define MAYBE_DeleteInSetFullscreen …
#else
#define MAYBE_DeleteInSetFullscreen …
#endif
TEST_F(DesktopWidgetTest, MAYBE_DeleteInSetFullscreen) { … }
namespace {
class FullscreenAwareFrame : public views::NonClientFrameView { … };
BEGIN_METADATA(…)
}
TEST_F(WidgetTest, FullscreenFrameLayout) { … }
namespace {
class IsActiveFromDestroyObserver : public WidgetObserver { … };
}
class ChildDesktopWidgetTest : public DesktopWidgetTest { … };
TEST_F(ChildDesktopWidgetTest, IsActiveFromDestroy) { … }
TEST_F(WidgetTest, MouseEventTypesViaGenerator) { … }
TEST_F(WidgetTest, NonClientWindowValidAfterInit) { … }
#if BUILDFLAG(IS_WIN)
class SubclassWindowHelper {
public:
explicit SubclassWindowHelper(HWND window)
: window_(window), message_to_destroy_on_(0) {
EXPECT_EQ(instance_, nullptr);
instance_ = this;
EXPECT_TRUE(Subclass());
}
SubclassWindowHelper(const SubclassWindowHelper&) = delete;
SubclassWindowHelper& operator=(const SubclassWindowHelper&) = delete;
~SubclassWindowHelper() {
Unsubclass();
instance_ = nullptr;
}
bool received_message(unsigned int message) {
return (messages_.find(message) != messages_.end());
}
void Clear() { messages_.clear(); }
void set_message_to_destroy_on(unsigned int message) {
message_to_destroy_on_ = message;
}
private:
bool Subclass() {
old_proc_ = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(
window_, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(WndProc)));
return old_proc_ != nullptr;
}
void Unsubclass() {
::SetWindowLongPtr(window_, GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(old_proc_));
}
static LRESULT CALLBACK WndProc(HWND window,
unsigned int message,
WPARAM w_param,
LPARAM l_param) {
EXPECT_NE(instance_, nullptr);
EXPECT_EQ(window, instance_->window_);
instance_->messages_.insert(message);
LRESULT ret = ::CallWindowProc(instance_->old_proc_, window, message,
w_param, l_param);
if (message == instance_->message_to_destroy_on_) {
instance_->Unsubclass();
::DestroyWindow(window);
}
return ret;
}
WNDPROC old_proc_;
HWND window_;
static SubclassWindowHelper* instance_;
std::set<unsigned int> messages_;
unsigned int message_to_destroy_on_;
};
SubclassWindowHelper* SubclassWindowHelper::instance_ = nullptr;
TEST_F(DesktopWidgetTest,
DISABLED_SysCommandMoveOnNCLButtonDownOnCaptionAndMoveTest) {
std::unique_ptr<Widget> widget =
CreateTestWidget(Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET,
Widget::InitParams::TYPE_WINDOW);
widget->Show();
::SetCursorPos(500, 500);
HWND window = widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget();
SubclassWindowHelper subclass_helper(window);
::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100));
RunPendingMessages();
EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN));
EXPECT_FALSE(subclass_helper.received_message(WM_SYSCOMMAND));
subclass_helper.Clear();
::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100));
::PostMessage(window, WM_NCMOUSEMOVE, HTCAPTION, MAKELPARAM(100, 100));
RunPendingMessages();
EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN));
EXPECT_TRUE(subclass_helper.received_message(WM_NCMOUSEMOVE));
EXPECT_FALSE(subclass_helper.received_message(WM_SYSCOMMAND));
subclass_helper.Clear();
::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100));
::PostMessage(window, WM_NCMOUSEMOVE, HTCAPTION, MAKELPARAM(110, 110));
RunPendingMessages();
EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN));
EXPECT_TRUE(subclass_helper.received_message(WM_NCMOUSEMOVE));
EXPECT_TRUE(subclass_helper.received_message(WM_SYSCOMMAND));
subclass_helper.Clear();
::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100));
::PostMessage(window, WM_NCMOUSEMOVE, HTTOP, MAKELPARAM(110, 102));
RunPendingMessages();
EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN));
EXPECT_TRUE(subclass_helper.received_message(WM_NCMOUSEMOVE));
EXPECT_TRUE(subclass_helper.received_message(WM_SYSCOMMAND));
subclass_helper.Clear();
::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100));
::PostMessage(window, WM_MOUSEMOVE, HTCLIENT, MAKELPARAM(110, 110));
RunPendingMessages();
EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN));
EXPECT_TRUE(subclass_helper.received_message(WM_MOUSEMOVE));
EXPECT_TRUE(subclass_helper.received_message(WM_SYSCOMMAND));
}
TEST_F(DesktopWidgetTest, DISABLED_DestroyInSysCommandNCLButtonDownOnCaption) {
std::unique_ptr<Widget> widget =
CreateTestWidget(Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET,
Widget::InitParams::TYPE_WINDOW);
widget->Show();
::SetCursorPos(500, 500);
HWND window = widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget();
SubclassWindowHelper subclass_helper(window);
subclass_helper.set_message_to_destroy_on(WM_SYSCOMMAND);
::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100));
::PostMessage(window, WM_NCMOUSEMOVE, HTCAPTION, MAKELPARAM(110, 110));
RunPendingMessages();
EXPECT_TRUE(subclass_helper.received_message(WM_NCLBUTTONDOWN));
EXPECT_TRUE(subclass_helper.received_message(WM_SYSCOMMAND));
}
#endif
TEST_F(WidgetTest, ZOrderLevel) { … }
namespace {
class ScaleFactorView : public View { … };
BEGIN_METADATA(…)
}
TEST_F(WidgetTest, OnDeviceScaleFactorChanged) { … }
TEST_F(WidgetTest, WidgetRemovalsObserverCalled) { … }
TEST_F(WidgetTest, WidgetRemovalsObserverCalledWhenRemovingRootView) { … }
TEST_F(WidgetTest, WidgetRemovalsObserverCalledWhenMovingBetweenWidgets) { … }
TEST_F(WidgetTest, MouseWheelEvent) { … }
TEST_F(WidgetTest, MouseEnteredWithoutMoved) { … }
TEST_F(WidgetTest, MouseMovedAfterEnteredDoesntCauseEntered) { … }
class CloseFromClosingObserver : public WidgetObserver { … };
TEST_F(WidgetTest, CloseNowFollowedByCloseDoesntCallOnWidgetClosingTwice) { … }
namespace {
class TestSaveWindowPlacementWidgetDelegate : public TestDesktopWidgetDelegate { … };
}
TEST_F(WidgetTest, ShouldSaveWindowPlacement) { … }
TEST_F(WidgetTest, RootViewAccessibilityCacheInitialized) { … }
TEST_F(WidgetTest, ClientViewAccessibilityProperties) { … }
TEST_F(WidgetTest, NonClientViewAccessibilityProperties) { … }
class WidgetSetAspectRatioTest
: public ViewsTestBase,
public testing::WithParamInterface<gfx::Size > { … };
TEST_P(WidgetSetAspectRatioTest, SetAspectRatioIncludesMargin) { … }
INSTANTIATE_TEST_SUITE_P(…);
class WidgetShadowTest : public WidgetTest { … };
#if BUILDFLAG(IS_MAC)
#define MAYBE_ShadowsInRootWindow …
#else
#define MAYBE_ShadowsInRootWindow …
#endif
TEST_F(WidgetShadowTest, MAYBE_ShadowsInRootWindow) { … }
#if BUILDFLAG(IS_WIN)
TEST_F(DesktopWidgetTest, WindowModalOwnerDestroyedEnabledTest) {
std::unique_ptr<Widget> top_level_widget =
CreateTestWidget(Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET);
top_level_widget->Show();
const auto create_params = [this](Widget* widget, gfx::NativeView parent) {
Widget::InitParams init_params =
CreateParamsForTestWidget(Widget::InitParams::TYPE_WINDOW);
init_params.delegate = new WidgetDelegate();
init_params.delegate->SetModalType(ui::mojom::ModalType::kWindow);
init_params.parent = parent;
init_params.native_widget =
new test::TestPlatformNativeWidget<DesktopNativeWidgetAura>(
widget, false, nullptr);
return init_params;
};
Widget owner_dialog_widget;
owner_dialog_widget.Init(
create_params(&owner_dialog_widget, top_level_widget->GetNativeView()));
owner_dialog_widget.Show();
HWND owner_hwnd = HWNDForWidget(&owner_dialog_widget);
Widget owned_dialog_widget;
owned_dialog_widget.Init(
create_params(&owned_dialog_widget, owner_dialog_widget.GetNativeView()));
owned_dialog_widget.Show();
HWND owned_hwnd = HWNDForWidget(&owned_dialog_widget);
RunPendingMessages();
HWND top_hwnd = HWNDForWidget(top_level_widget.get());
EXPECT_FALSE(!!IsWindowEnabled(owner_hwnd));
EXPECT_FALSE(!!IsWindowEnabled(top_hwnd));
EXPECT_TRUE(!!IsWindowEnabled(owned_hwnd));
owner_dialog_widget.CloseNow();
RunPendingMessages();
EXPECT_FALSE(!!IsWindow(owner_hwnd));
EXPECT_FALSE(!!IsWindow(owned_hwnd));
EXPECT_TRUE(!!IsWindowEnabled(top_hwnd));
top_level_widget->CloseNow();
}
TEST_F(DesktopWidgetTest, StackAboveTest) {
WidgetAutoclosePtr root_one(CreateTopLevelNativeWidget());
WidgetAutoclosePtr root_two(CreateTopLevelNativeWidget());
Widget* child_one = CreateChildNativeWidgetWithParent(root_one->AsWidget());
Widget* child_one_b = CreateChildNativeWidgetWithParent(root_one->AsWidget());
Widget* child_two = CreateChildNativeWidgetWithParent(root_two->AsWidget());
Widget* grandchild_one =
CreateChildNativeWidgetWithParent(child_one->AsWidget());
Widget* grandchild_two =
CreateChildNativeWidgetWithParent(child_two->AsWidget());
root_one->ShowInactive();
child_one->ShowInactive();
child_one_b->ShowInactive();
grandchild_one->ShowInactive();
root_two->ShowInactive();
child_two->ShowInactive();
grandchild_two->ShowInactive();
EXPECT_TRUE(child_one->IsStackedAbove(root_one->GetNativeView()));
EXPECT_TRUE(child_one_b->IsStackedAbove(root_one->GetNativeView()));
EXPECT_TRUE(grandchild_one->IsStackedAbove(child_one->GetNativeView()));
EXPECT_TRUE(grandchild_two->IsStackedAbove(root_two->GetNativeView()));
EXPECT_TRUE(child_one->IsStackedAbove(child_one_b->GetNativeView()));
EXPECT_TRUE(grandchild_one->IsStackedAbove(child_one_b->GetNativeView()));
EXPECT_TRUE(root_two->IsStackedAbove(root_one->GetNativeView()));
EXPECT_TRUE(root_two->IsStackedAbove(child_one_b->GetNativeView()));
EXPECT_TRUE(child_two->IsStackedAbove(child_one_b->GetNativeView()));
EXPECT_TRUE(child_two->IsStackedAbove(grandchild_one->GetNativeView()));
EXPECT_TRUE(grandchild_two->IsStackedAbove(child_one->GetNativeView()));
EXPECT_TRUE(grandchild_two->IsStackedAbove(root_one->GetNativeView()));
EXPECT_FALSE(root_one->IsStackedAbove(grandchild_two->GetNativeView()));
EXPECT_FALSE(root_one->IsStackedAbove(grandchild_one->GetNativeView()));
EXPECT_FALSE(child_two->IsStackedAbove(grandchild_two->GetNativeView()));
EXPECT_FALSE(child_one->IsStackedAbove(grandchild_two->GetNativeView()));
EXPECT_FALSE(child_one_b->IsStackedAbove(child_two->GetNativeView()));
EXPECT_FALSE(grandchild_one->IsStackedAbove(grandchild_two->GetNativeView()));
EXPECT_FALSE(grandchild_one->IsStackedAbove(root_two->GetNativeView()));
EXPECT_FALSE(child_one_b->IsStackedAbove(grandchild_one->GetNativeView()));
}
#endif
#if BUILDFLAG(ENABLE_DESKTOP_AURA) || BUILDFLAG(IS_MAC)
namespace {
class CompositingWidgetTest : public DesktopWidgetTest { … };
}
TEST_F(CompositingWidgetTest, Transparency_DesktopWidgetOpaque) { … }
TEST_F(CompositingWidgetTest, Transparency_DesktopWidgetTranslucent) { … }
namespace {
class ScreenshotWidgetTest : public ViewsTestBase { … };
}
TEST_F(ScreenshotWidgetTest, CallsNativeWidget) { … }
#endif
}