Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Unified Diff: components/exo/shell_surface_unittest.cc

Issue 2467173002: exo: Fix widget positioning for pop-ups (Closed)
Patch Set: Add unit test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/exo/shell_surface.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/shell_surface_unittest.cc
diff --git a/components/exo/shell_surface_unittest.cc b/components/exo/shell_surface_unittest.cc
index fc705357235b4d1f24f16594d428d3838efa928d..1ba2412c316d2ad9e7bef8fa30d56b30f17d7262 100644
--- a/components/exo/shell_surface_unittest.cc
+++ b/components/exo/shell_surface_unittest.cc
@@ -444,6 +444,46 @@ TEST_F(ShellSurfaceTest, ModalWindow) {
EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
}
+TEST_F(ShellSurfaceTest, PopupWindow) {
+ Surface parent_surface;
+ ShellSurface parent(&parent_surface);
+ const gfx::Rect parent_bounds(100, 100, 300, 300);
+
+ Buffer parent_buffer(
+ exo_test_helper()->CreateGpuMemoryBuffer(parent_bounds.size()));
+ parent_surface.Attach(&parent_buffer);
+ parent_surface.Commit();
+
+ parent.GetWidget()->SetBounds(parent_bounds);
+
+ Display display;
+ Surface popup_surface;
+ const gfx::Rect popup_bounds(10, 10, 100, 100);
+ std::unique_ptr<ShellSurface> popup = display.CreatePopupShellSurface(
+ &popup_surface, &parent, popup_bounds.origin());
+
+ Buffer popup_buffer(
+ exo_test_helper()->CreateGpuMemoryBuffer(popup_bounds.size()));
+ popup_surface.Attach(&popup_buffer);
+ popup_surface.Commit();
+
+ // Popup bounds are relative to parent.
+ EXPECT_EQ(gfx::Rect(parent_bounds.origin() + popup_bounds.OffsetFromOrigin(),
+ popup_bounds.size()),
+ popup->GetWidget()->GetWindowBoundsInScreen());
+
+ const gfx::Rect geometry(5, 5, 90, 90);
+ popup->SetGeometry(geometry);
+ popup_surface.Commit();
+
+ // Popup position is fixed, and geometry is relative to it.
+ EXPECT_EQ(gfx::Rect(parent_bounds.origin() +
+ popup_bounds.OffsetFromOrigin() +
+ geometry.OffsetFromOrigin(),
+ geometry.size()),
+ popup->GetWidget()->GetWindowBoundsInScreen());
+}
+
TEST_F(ShellSurfaceTest, Shadow) {
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<ShellSurface> shell_surface(
« no previous file with comments | « components/exo/shell_surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698