Commit 22a07738 authored by garykac's avatar garykac Committed by Commit bot

Add unittests to check that null/empty window shapes work.

Followup to https://codereview.chromium.org/602013002/, which fixes a bug with empty window shapes not being handled properly on CrOS.

BUG=417014

Review URL: https://codereview.chromium.org/607623002

Cr-Commit-Position: refs/heads/master@{#297337}
parent 971cb69e
...@@ -72,6 +72,30 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestBasic) { ...@@ -72,6 +72,30 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestBasic) {
} }
scoped_ptr<SkRegion> region(new SkRegion); scoped_ptr<SkRegion> region(new SkRegion);
region->op(SkIRect::MakeXYWH(0, 0, 0, 0), SkRegion::kUnion_Op);
app_window()->UpdateShape(region.Pass());
{
// With an empty custom shape, all events within the window should fall
// through to the root window.
ui::MouseEvent move(ui::ET_MOUSE_MOVED,
gfx::Point(40, 40), gfx::Point(40, 40),
ui::EF_NONE, ui::EF_NONE);
ui::EventDispatchDetails details =
event_processor()->OnEventFromSource(&move);
ASSERT_FALSE(details.dispatcher_destroyed);
EXPECT_EQ(root_window(), move.target());
}
// Window shape (global coordinates)
// 30 70 90 130
// 30 + +-----+
// . | | <- mouse move (40,40)
// 70 +--------+ +---------+
// | . | <- mouse move (80,80)
// 90 +--------+ +---------+
// | |
// 130 +-----+
region.reset(new SkRegion);
region->op(SkIRect::MakeXYWH(40, 0, 20, 100), SkRegion::kUnion_Op); region->op(SkIRect::MakeXYWH(40, 0, 20, 100), SkRegion::kUnion_Op);
region->op(SkIRect::MakeXYWH(0, 40, 100, 20), SkRegion::kUnion_Op); region->op(SkIRect::MakeXYWH(0, 40, 100, 20), SkRegion::kUnion_Op);
app_window()->UpdateShape(region.Pass()); app_window()->UpdateShape(region.Pass());
......
...@@ -356,6 +356,51 @@ TEST_F(X11TopmostWindowFinderTest, NonRectangular) { ...@@ -356,6 +356,51 @@ TEST_F(X11TopmostWindowFinderTest, NonRectangular) {
XDestroyWindow(xdisplay(), xid2); XDestroyWindow(xdisplay(), xid2);
} }
// Test that a window with an empty shape are properly handled.
TEST_F(X11TopmostWindowFinderTest, NonRectangularEmptyShape) {
if (!ui::IsShapeExtensionAvailable())
return;
scoped_ptr<Widget> widget1(
CreateAndShowWidget(gfx::Rect(100, 100, 100, 100)));
XID xid1 = widget1->GetNativeWindow()->GetHost()->GetAcceleratedWidget();
SkRegion* skregion1 = new SkRegion;
skregion1->op(SkIRect::MakeXYWH(0, 0, 0, 0), SkRegion::kUnion_Op);
// Widget takes ownership of |skregion1|.
widget1->SetShape(skregion1);
XID xids[] = { xid1 };
StackingClientListWaiter stack_waiter(xids, arraysize(xids));
stack_waiter.Wait();
ui::X11EventSource::GetInstance()->DispatchXEvents();
EXPECT_NE(xid1, FindTopmostXWindowAt(105, 105));
}
// Test that setting a Null shape removes the shape.
TEST_F(X11TopmostWindowFinderTest, NonRectangularNullShape) {
if (!ui::IsShapeExtensionAvailable())
return;
scoped_ptr<Widget> widget1(
CreateAndShowWidget(gfx::Rect(100, 100, 100, 100)));
XID xid1 = widget1->GetNativeWindow()->GetHost()->GetAcceleratedWidget();
SkRegion* skregion1 = new SkRegion;
skregion1->op(SkIRect::MakeXYWH(0, 0, 0, 0), SkRegion::kUnion_Op);
// Widget takes ownership of |skregion1|.
widget1->SetShape(skregion1);
// Remove the shape - this is now just a normal window.
widget1->SetShape(NULL);
XID xids[] = { xid1 };
StackingClientListWaiter stack_waiter(xids, arraysize(xids));
stack_waiter.Wait();
ui::X11EventSource::GetInstance()->DispatchXEvents();
EXPECT_EQ(xid1, FindTopmostXWindowAt(105, 105));
}
// Test that the TopmostWindowFinder finds windows which belong to menus // Test that the TopmostWindowFinder finds windows which belong to menus
// (which may or may not belong to Chrome). // (which may or may not belong to Chrome).
TEST_F(X11TopmostWindowFinderTest, Menu) { TEST_F(X11TopmostWindowFinderTest, Menu) {
......
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