Commit 00297e0b authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

macviews: remove NativeWidget damage rect propagation tests

These tests were asserting that, when Views damages a specific rect
within the BridgedContentView, AppKit was propagating the damaged
rect all the way back to [BridgedContentView drawRect:]. There are
two issues with this:

1) BridgedContentView does not implement drawRect:, and
2) Since BridgedContentView is layer-hosted AppKit is not supposed
   to track damage to it and is *supposed* to always call drawRect:
   on the entire thing

It appears that AppKit in <= 10.15 did bother to track the damage
and invoke drawRect: only on the damaged area even for layer-hosted
views, presumably as an optimization for misguided code that was
improperly using layers. As of 11 AppKit does not do this, so the test
(which was asserting behavior that was both incorrect and irrelevant
to us) is broken.

This change deletes these tests.

Bug: 1114240
Change-Id: I22ede812cdf98707cc22bca1238f59856a371d36
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352431
Commit-Queue: Robert Liao <robliao@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797329}
parent 04cd36d0
......@@ -1937,98 +1937,6 @@ TEST_F(NativeWidgetMacTest, ChangeOpacity) {
widget->CloseNow();
}
// Test that NativeWidgetMac::SchedulePaintInRect correctly passes the dirtyRect
// parameter to BridgedContentView::drawRect, for a titled window (window with a
// toolbar).
TEST_F(NativeWidgetMacTest, SchedulePaintInRect_Titled) {
Widget* widget = CreateTopLevelPlatformWidget();
gfx::Rect screen_rect(50, 50, 100, 100);
widget->SetBounds(screen_rect);
// Setup the mock content view for the NSWindow, so that we can intercept
// drawRect.
NSWindow* window = widget->GetNativeWindow().GetNativeNSWindow();
base::scoped_nsobject<MockBridgedView> mock_bridged_view(
[[MockBridgedView alloc] init]);
// Reset drawRect count.
[mock_bridged_view setDrawRectCount:0];
[window setContentView:mock_bridged_view];
// Ensure the initial draw of the window is done.
while ([mock_bridged_view drawRectCount] == 0)
base::RunLoop().RunUntilIdle();
// Add a dummy view to the widget. This will cause SchedulePaint to be called
// on the dummy view.
View* dummy_view = new View();
gfx::Rect dummy_bounds(25, 30, 10, 15);
dummy_view->SetBoundsRect(dummy_bounds);
// Reset drawRect count.
[mock_bridged_view setDrawRectCount:0];
widget->GetContentsView()->AddChildView(dummy_view);
// SchedulePaint is asyncronous. Wait for drawRect: to be called.
while ([mock_bridged_view drawRectCount] == 0)
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1u, [mock_bridged_view drawRectCount]);
int client_area_height = widget->GetClientAreaBoundsInScreen().height();
// These are expected dummy_view bounds in AppKit coordinate system. The y
// coordinate of rect origin is calculated as:
// client_area_height - 30 (dummy_view's y coordinate) - 15 (dummy view's
// height).
gfx::Rect expected_appkit_bounds(25, client_area_height - 45, 10, 15);
EXPECT_NSEQ(expected_appkit_bounds.ToCGRect(),
[mock_bridged_view lastDirtyRect]);
widget->CloseNow();
}
// Test that NativeWidgetMac::SchedulePaintInRect correctly passes the dirtyRect
// parameter to BridgedContentView::drawRect, for a borderless window.
TEST_F(NativeWidgetMacTest, SchedulePaintInRect_Borderless) {
Widget* widget = CreateTopLevelFramelessPlatformWidget();
gfx::Rect screen_rect(50, 50, 100, 100);
widget->SetBounds(screen_rect);
// Setup the mock content view for the NSWindow, so that we can intercept
// drawRect.
NSWindow* window = widget->GetNativeWindow().GetNativeNSWindow();
base::scoped_nsobject<MockBridgedView> mock_bridged_view(
[[MockBridgedView alloc] init]);
// Reset drawRect count.
[mock_bridged_view setDrawRectCount:0];
[window setContentView:mock_bridged_view];
// Ensure the initial draw of the window is done.
while ([mock_bridged_view drawRectCount] == 0)
base::RunLoop().RunUntilIdle();
// Add a dummy view to the widget. This will cause SchedulePaint to be called
// on the dummy view.
View* dummy_view = new View();
gfx::Rect dummy_bounds(25, 30, 10, 15);
dummy_view->SetBoundsRect(dummy_bounds);
// Reset drawRect count.
[mock_bridged_view setDrawRectCount:0];
widget->GetRootView()->AddChildView(dummy_view);
// SchedulePaint is asyncronous. Wait for drawRect: to be called.
while ([mock_bridged_view drawRectCount] == 0)
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1u, [mock_bridged_view drawRectCount]);
// These are expected dummy_view bounds in AppKit coordinate system. The y
// coordinate of rect origin is calculated as:
// 100(client area height) - 30 (dummy_view's y coordinate) - 15 (dummy view's
// height).
gfx::Rect expected_appkit_bounds(25, 55, 10, 15);
EXPECT_NSEQ(expected_appkit_bounds.ToCGRect(),
[mock_bridged_view lastDirtyRect]);
widget->CloseNow();
}
// Ensure traversing NSView focus correctly updates the views::FocusManager.
TEST_F(NativeWidgetMacTest, ChangeFocusOnChangeFirstResponder) {
Widget* widget = CreateTopLevelPlatformWidget();
......
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