Commit 39db8cc4 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

macviews: account for Big Sur sheet visual effect window in tests

To create the dimming visual effect when showing a sheet in Big Sur,
AppKit installs a new child window of the window with the sheet,
which breaks NativeWidgetMacTest.WindowModalSheet.

Bug: 1114245
Change-Id: Ib7185441e1c52e0990caa1c92f5f773431d66775
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2357633
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798292}
parent 976638b8
...@@ -1312,6 +1312,19 @@ TEST_F(NativeWidgetMacTest, ShowAnimationControl) { ...@@ -1312,6 +1312,19 @@ TEST_F(NativeWidgetMacTest, ShowAnimationControl) {
EXPECT_FALSE([retained_animation isAnimating]); EXPECT_FALSE([retained_animation isAnimating]);
} }
// Expect that |children|, the list of child windows of a window that has a
// sheet open, is logically empty. "Logically empty" accounts for the
// AppKit-created visual effect window that shows atop windows with open sheets
// on macOS 11.
void AssertNoChildrenForWindowWithSheet(NSArray<NSWindow*>* children) {
if (base::mac::IsAtLeastOS11()) {
ASSERT_EQ(1u, children.count);
EXPECT_NSEQ(@"NSSheetEffectDimmingWindow", children[0].className);
} else {
ASSERT_EQ(0u, children.count);
}
}
// Tests behavior of window-modal dialogs, displayed as sheets. // Tests behavior of window-modal dialogs, displayed as sheets.
TEST_F(NativeWidgetMacTest, WindowModalSheet) { TEST_F(NativeWidgetMacTest, WindowModalSheet) {
NSWindow* native_parent = MakeClosableTitledNativeParent(); NSWindow* native_parent = MakeClosableTitledNativeParent();
...@@ -1369,8 +1382,7 @@ TEST_F(NativeWidgetMacTest, WindowModalSheet) { ...@@ -1369,8 +1382,7 @@ TEST_F(NativeWidgetMacTest, WindowModalSheet) {
ASSERT_EQ(2u, children.size()); ASSERT_EQ(2u, children.size());
EXPECT_TRUE(children.count(sheet_widget)); EXPECT_TRUE(children.count(sheet_widget));
// Sheets are not child windows of their parent NSWindow, though. AssertNoChildrenForWindowWithSheet(native_parent.childWindows);
ASSERT_EQ(0u, [native_parent childWindows].count);
// Modal, so the close button in the parent window should get disabled. // Modal, so the close button in the parent window should get disabled.
EXPECT_FALSE([parent_close_button isEnabled]); EXPECT_FALSE([parent_close_button isEnabled]);
...@@ -1393,7 +1405,7 @@ TEST_F(NativeWidgetMacTest, WindowModalSheet) { ...@@ -1393,7 +1405,7 @@ TEST_F(NativeWidgetMacTest, WindowModalSheet) {
widget_observer.WaitForVisibleCounts(1, 1); widget_observer.WaitForVisibleCounts(1, 1);
EXPECT_FALSE(sheet_widget->IsVisible()); EXPECT_FALSE(sheet_widget->IsVisible());
[native_parent makeKeyAndOrderFront:nil]; [native_parent makeKeyAndOrderFront:nil];
ASSERT_EQ(0u, [native_parent childWindows].count); AssertNoChildrenForWindowWithSheet(native_parent.childWindows);
widget_observer.WaitForVisibleCounts(2, 1); widget_observer.WaitForVisibleCounts(2, 1);
EXPECT_TRUE(sheet_widget->IsVisible()); EXPECT_TRUE(sheet_widget->IsVisible());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment