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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « components/exo/shell_surface.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/aura/wm_window_aura.h" 5 #include "ash/aura/wm_window_aura.h"
6 #include "ash/common/accessibility_delegate.h" 6 #include "ash/common/accessibility_delegate.h"
7 #include "ash/common/wm/window_state.h" 7 #include "ash/common/wm/window_state.h"
8 #include "ash/common/wm/wm_event.h" 8 #include "ash/common/wm/wm_event.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 437 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
438 438
439 // Only SetSystemModal changes modality. 439 // Only SetSystemModal changes modality.
440 shell_surface->SetSystemModal(true); 440 shell_surface->SetSystemModal(true);
441 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 441 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen());
442 442
443 shell_surface->SetSystemModal(false); 443 shell_surface->SetSystemModal(false);
444 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 444 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
445 } 445 }
446 446
447 TEST_F(ShellSurfaceTest, PopupWindow) {
448 Surface parent_surface;
449 ShellSurface parent(&parent_surface);
450 const gfx::Rect parent_bounds(100, 100, 300, 300);
451
452 Buffer parent_buffer(
453 exo_test_helper()->CreateGpuMemoryBuffer(parent_bounds.size()));
454 parent_surface.Attach(&parent_buffer);
455 parent_surface.Commit();
456
457 parent.GetWidget()->SetBounds(parent_bounds);
458
459 Display display;
460 Surface popup_surface;
461 const gfx::Rect popup_bounds(10, 10, 100, 100);
462 std::unique_ptr<ShellSurface> popup = display.CreatePopupShellSurface(
463 &popup_surface, &parent, popup_bounds.origin());
464
465 Buffer popup_buffer(
466 exo_test_helper()->CreateGpuMemoryBuffer(popup_bounds.size()));
467 popup_surface.Attach(&popup_buffer);
468 popup_surface.Commit();
469
470 // Popup bounds are relative to parent.
471 EXPECT_EQ(gfx::Rect(parent_bounds.origin() + popup_bounds.OffsetFromOrigin(),
472 popup_bounds.size()),
473 popup->GetWidget()->GetWindowBoundsInScreen());
474
475 const gfx::Rect geometry(5, 5, 90, 90);
476 popup->SetGeometry(geometry);
477 popup_surface.Commit();
478
479 // Popup position is fixed, and geometry is relative to it.
480 EXPECT_EQ(gfx::Rect(parent_bounds.origin() +
481 popup_bounds.OffsetFromOrigin() +
482 geometry.OffsetFromOrigin(),
483 geometry.size()),
484 popup->GetWidget()->GetWindowBoundsInScreen());
485 }
486
447 TEST_F(ShellSurfaceTest, Shadow) { 487 TEST_F(ShellSurfaceTest, Shadow) {
448 std::unique_ptr<Surface> surface(new Surface); 488 std::unique_ptr<Surface> surface(new Surface);
449 std::unique_ptr<ShellSurface> shell_surface( 489 std::unique_ptr<ShellSurface> shell_surface(
450 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true, 490 new ShellSurface(surface.get(), nullptr, gfx::Rect(), true,
451 ash::kShellWindowId_DefaultContainer)); 491 ash::kShellWindowId_DefaultContainer));
452 surface->Commit(); 492 surface->Commit();
453 493
454 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow(); 494 aura::Window* window = shell_surface->GetWidget()->GetNativeWindow();
455 495
456 // 1) Initial state, no shadow. 496 // 1) Initial state, no shadow.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 shell_surface.OnAccessibilityModeChanged(); 805 shell_surface.OnAccessibilityModeChanged();
766 shell_surface2.OnAccessibilityModeChanged(); 806 shell_surface2.OnAccessibilityModeChanged();
767 807
768 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible()); 808 EXPECT_TRUE(shell_surface.shadow_underlay()->IsVisible());
769 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds()); 809 EXPECT_EQ(shadow_bounds, shell_surface.shadow_underlay()->bounds());
770 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds()); 810 EXPECT_EQ(shadow_bounds, shell_surface2.shadow_underlay()->bounds());
771 } 811 }
772 812
773 } // namespace 813 } // namespace
774 } // namespace exo 814 } // namespace exo
OLDNEW
« 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