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

Unified Diff: ash/wm/workspace/workspace_layout_manager_unittest.cc

Issue 2847283002: chromeos: convert remaining AshTest usage to AshTestBase (Closed)
Patch Set: Created 3 years, 8 months 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
Index: ash/wm/workspace/workspace_layout_manager_unittest.cc
diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc
index 539cd2c358ebc30e2119d8037459d9049a78d40e..572ac81824026dcab0990264233e49898e84b32a 100644
--- a/ash/wm/workspace/workspace_layout_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc
@@ -10,6 +10,7 @@
#include "ash/public/cpp/config.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h"
+#include "ash/screen_util.h"
#include "ash/session/session_controller.h"
#include "ash/shelf/shelf_constants.h"
#include "ash/shelf/shelf_layout_manager.h"
@@ -17,9 +18,9 @@
#include "ash/shell.h"
#include "ash/shell_observer.h"
#include "ash/shell_port.h"
-#include "ash/test/ash_test.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/test_session_controller_client.h"
+#include "ash/test/wm_window_test_api.h"
#include "ash/wm/fullscreen_window_finder.h"
#include "ash/wm/maximize_mode/workspace_backdrop_delegate.h"
#include "ash/wm/window_state.h"
@@ -31,16 +32,21 @@
#include "ash/wm_window.h"
#include "base/command_line.h"
#include "base/run_loop.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/focus_client.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_switches.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/layer_type.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/display/display.h"
+#include "ui/display/manager/display_manager.h"
#include "ui/display/screen.h"
+#include "ui/display/test/display_manager_test_api.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
+#include "ui/wm/core/window_util.h"
namespace ash {
namespace {
@@ -90,32 +96,35 @@ class TestShellObserver : public ShellObserver {
DISALLOW_COPY_AND_ASSIGN(TestShellObserver);
};
+display::Display GetDisplayNearestWindow(aura::Window* window) {
+ return display::Screen::GetScreen()->GetDisplayNearestWindow(window);
+}
+
} // namespace
-using WorkspaceLayoutManagerTest = AshTest;
+using WorkspaceLayoutManagerTest = test::AshTestBase;
// Verifies that a window containing a restore coordinate will be restored to
// to the size prior to minimize, keeping the restore rectangle in tact (if
// there is one).
TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
- std::unique_ptr<WindowOwner> window_owner(
- CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
- WmWindow* window = window_owner->window();
+ WmWindowTestApi::GlobalMinimumSizeLock min_size_lock;
+ std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
gfx::Rect bounds(10, 15, 25, 35);
window->SetBounds(bounds);
- wm::WindowState* window_state = window->GetWindowState();
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
// This will not be used for un-minimizing window.
window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100));
window_state->Minimize();
window_state->Restore();
EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString());
- EXPECT_EQ("10,15 25x35", window->GetBounds().ToString());
+ EXPECT_EQ("10,15 25x35", window->bounds().ToString());
UpdateDisplay("400x300,500x400");
window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay());
- EXPECT_EQ(ShellPort::Get()->GetAllRootWindows()[1], window->GetRootWindow());
+ EXPECT_EQ(Shell::Get()->GetAllRootWindows()[1], window->GetRootWindow());
window_state->Minimize();
// This will not be used for un-minimizing window.
window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100));
@@ -127,30 +136,34 @@ TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
window_state->Minimize();
UpdateDisplay("400x300");
window_state->Restore();
- EXPECT_EQ(ShellPort::Get()->GetPrimaryRootWindow(), window->GetRootWindow());
- EXPECT_TRUE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
- window->GetBounds()));
+ EXPECT_EQ(Shell::GetPrimaryRootWindow(), window->GetRootWindow());
+ EXPECT_TRUE(
+ Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
}
TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) {
UpdateDisplay("300x400,400x500");
- WmWindow::Windows root_windows = ShellPort::Get()->GetAllRootWindows();
+ aura::Window::Windows root_windows = Shell::Get()->GetAllRootWindows();
- if (!SetSecondaryDisplayPlacement(display::DisplayPlacement::TOP, 0))
+ if (Shell::GetAshConfig() != Config::CLASSIC) {
+ // TODO(sky): should work for mus/mash once http://crbug.com/706589 is
+ // fixed.
return;
+ }
+ Shell::Get()->display_manager()->SetLayoutForCurrentDisplays(
+ display::test::CreateDisplayLayout(Shell::Get()->display_manager(),
+ display::DisplayPlacement::TOP, 0));
EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString());
- std::unique_ptr<WindowOwner> window1_owner(
+ std::unique_ptr<aura::Window> window1(
CreateTestWindow(gfx::Rect(10, -400, 200, 200)));
- EXPECT_EQ("10,-400 200x200",
- window1_owner->window()->GetBoundsInScreen().ToString());
+ EXPECT_EQ("10,-400 200x200", window1->GetBoundsInScreen().ToString());
// Make sure the caption is visible.
- std::unique_ptr<WindowOwner> window2_owner(
+ std::unique_ptr<aura::Window> window2(
CreateTestWindow(gfx::Rect(10, -600, 200, 200)));
- EXPECT_EQ("10,-500 200x200",
- window2_owner->window()->GetBoundsInScreen().ToString());
+ EXPECT_EQ("10,-500 200x200", window2->GetBoundsInScreen().ToString());
}
TEST_F(WorkspaceLayoutManagerTest, NoMinimumVisibilityForPopupWindows) {
@@ -158,63 +171,61 @@ TEST_F(WorkspaceLayoutManagerTest, NoMinimumVisibilityForPopupWindows) {
// Create a popup window out of display boundaries and make sure it is not
// moved to have minimum visibility.
- std::unique_ptr<WindowOwner> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindow(gfx::Rect(400, 100, 50, 50), ui::wm::WINDOW_TYPE_POPUP));
- EXPECT_EQ("400,100 50x50",
- window_owner->window()->GetBoundsInScreen().ToString());
+ EXPECT_EQ("400,100 50x50", window->GetBoundsInScreen().ToString());
}
TEST_F(WorkspaceLayoutManagerTest, KeepRestoredWindowInDisplay) {
- std::unique_ptr<WindowOwner> window_owner(
+ WmWindowTestApi::GlobalMinimumSizeLock min_size_lock;
+ std::unique_ptr<aura::Window> window(
CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
- WmWindow* window = window_owner->window();
- wm::WindowState* window_state = window->GetWindowState();
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
// Maximized -> Normal transition.
window_state->Maximize();
window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40));
window_state->Restore();
- EXPECT_TRUE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
- window->GetBounds()));
+ EXPECT_TRUE(
+ Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
// Y bounds should not be negative.
- EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString());
+ EXPECT_EQ("-5,0 30x40", window->bounds().ToString());
// Minimized -> Normal transition.
window->SetBounds(gfx::Rect(-100, -100, 30, 40));
window_state->Minimize();
- EXPECT_FALSE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
- window->GetBounds()));
- EXPECT_EQ("-100,-100 30x40", window->GetBounds().ToString());
+ EXPECT_FALSE(
+ Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
+ EXPECT_EQ("-100,-100 30x40", window->bounds().ToString());
window->Show();
- EXPECT_TRUE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
- window->GetBounds()));
+ EXPECT_TRUE(
+ Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
// Y bounds should not be negative.
- EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString());
+ EXPECT_EQ("-5,0 30x40", window->bounds().ToString());
// Fullscreen -> Normal transition.
window->SetBounds(gfx::Rect(0, 0, 30, 40)); // reset bounds.
- ASSERT_EQ("0,0 30x40", window->GetBounds().ToString());
- window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
- EXPECT_EQ(window->GetBounds(), window->GetRootWindow()->GetBounds());
+ ASSERT_EQ("0,0 30x40", window->bounds().ToString());
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
+ EXPECT_EQ(window->bounds(), window->GetRootWindow()->bounds());
window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40));
window_state->Restore();
- EXPECT_TRUE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
- window->GetBounds()));
+ EXPECT_TRUE(
+ Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
// Y bounds should not be negative.
- EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString());
+ EXPECT_EQ("-5,0 30x40", window->bounds().ToString());
}
TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) {
UpdateDisplay("300x400,400x500");
- WmWindow::Windows root_windows = ShellPort::Get()->GetAllRootWindows();
+ aura::Window::Windows root_windows = Shell::Get()->GetAllRootWindows();
- std::unique_ptr<WindowOwner> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
- WmWindow* window = window_owner->window();
EXPECT_EQ(root_windows[0], window->GetRootWindow());
- wm::WindowState* window_state = window->GetWindowState();
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40));
// Maximize the window in 2nd display as the restore bounds
// is inside 2nd display.
@@ -244,37 +255,43 @@ TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) {
views::Widget::InitParams params;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.delegate = new MaximizeDelegateView(gfx::Rect(400, 0, 30, 40));
+ params.context = root_windows[0];
+ // XXX
+ /*
+WAS THIS!
ConfigureWidgetInitParamsForDisplay(root_windows[0], &params);
+
+Included this!
+ params.mus_properties[ui::mojom::WindowManager::kDisplayId_InitProperty] =
+ mojo::ConvertTo<std::vector<uint8_t>>(
+ root_windows[0]->GetDisplayNearestWindow().id());
+ */
w1->Init(params);
- EXPECT_EQ(root_windows[0],
- WmWindow::Get(w1->GetNativeWindow())->GetRootWindow());
+ EXPECT_EQ(root_windows[0], w1->GetNativeWindow()->GetRootWindow());
w1->Show();
EXPECT_TRUE(w1->IsMaximized());
- EXPECT_EQ(root_windows[1],
- WmWindow::Get(w1->GetNativeWindow())->GetRootWindow());
+ EXPECT_EQ(root_windows[1], w1->GetNativeWindow()->GetRootWindow());
EXPECT_EQ(gfx::Rect(300, 0, 400, 500 - kShelfSize).ToString(),
w1->GetWindowBoundsInScreen().ToString());
w1->Restore();
- EXPECT_EQ(root_windows[1],
- WmWindow::Get(w1->GetNativeWindow())->GetRootWindow());
+ EXPECT_EQ(root_windows[1], w1->GetNativeWindow()->GetRootWindow());
EXPECT_EQ("400,0 30x40", w1->GetWindowBoundsInScreen().ToString());
}
TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) {
UpdateDisplay("300x400,400x500");
- WmWindow::Windows root_windows = ShellPort::Get()->GetAllRootWindows();
+ aura::Window::Windows root_windows = Shell::Get()->GetAllRootWindows();
- std::unique_ptr<WindowOwner> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
- WmWindow* window = window_owner->window();
EXPECT_EQ(root_windows[0], window->GetRootWindow());
- wm::WindowState* window_state = window->GetWindowState();
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40));
// Maximize the window in 2nd display as the restore bounds
// is inside 2nd display.
- window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString());
@@ -285,7 +302,7 @@ TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) {
// If the restore bounds intersects with the current display,
// don't move.
window_state->SetRestoreBoundsInScreen(gfx::Rect(295, 0, 30, 40));
- window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
EXPECT_EQ(root_windows[1], window->GetRootWindow());
EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString());
@@ -303,7 +320,7 @@ class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver {
public:
DontClobberRestoreBoundsWindowObserver() : window_(nullptr) {}
- void set_window(WmWindow* window) { window_ = window; }
+ void set_window(aura::Window* window) { window_ = window; }
// aura::WindowObserver:
void OnWindowPropertyChanged(aura::Window* window,
@@ -313,18 +330,19 @@ class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver {
return;
if (wm::GetWindowState(window)->IsMaximized()) {
- WmWindow* w = window_;
+ aura::Window* w = window_;
window_ = nullptr;
- gfx::Rect shelf_bounds(AshTest::GetPrimaryShelf()->GetIdealBounds());
- const gfx::Rect& window_bounds(w->GetBounds());
+ gfx::Rect shelf_bounds(
+ test::AshTestBase::GetPrimaryShelf()->GetIdealBounds());
+ const gfx::Rect& window_bounds(w->bounds());
w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1,
window_bounds.width(), window_bounds.height()));
}
}
private:
- WmWindow* window_;
+ aura::Window* window_;
DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver);
};
@@ -341,19 +359,18 @@ TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) {
// NOTE: for this test to exercise the failure the observer needs to be added
// before the parent set. This mimics what BrowserFrameAsh does.
window->AddObserver(&window_observer);
- ParentWindowInPrimaryRootWindow(WmWindow::Get(window.get()));
+ ParentWindowInPrimaryRootWindow(window.get());
window->Show();
wm::WindowState* window_state = wm::GetWindowState(window.get());
window_state->Activate();
- std::unique_ptr<WindowOwner> window2_owner(
+ std::unique_ptr<aura::Window> window2(
CreateTestWindow(gfx::Rect(12, 20, 30, 40)));
- WmWindow* window2 = window2_owner->window();
- AddTransientChild(WmWindow::Get(window.get()), window2);
+ ::wm::AddTransientChild(window.get(), window2.get());
window2->Show();
- window_observer.set_window(window2);
+ window_observer.set_window(window2.get());
window_state->Maximize();
EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInScreen().ToString());
window->RemoveObserver(&window_observer);
@@ -361,17 +378,15 @@ TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) {
// Verifies when a window is maximized all descendant windows have a size.
TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) {
- std::unique_ptr<WindowOwner> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindow(gfx::Rect(10, 20, 30, 40)));
- WmWindow* window = window_owner->window();
window->Show();
- wm::WindowState* window_state = window->GetWindowState();
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
window_state->Activate();
- std::unique_ptr<WindowOwner> child_window_owner(
- CreateChildWindow(window, gfx::Rect(5, 6, 7, 8)));
- WmWindow* child_window = child_window_owner->window();
+ std::unique_ptr<aura::Window> child_window(
+ CreateChildWindow(window.get(), gfx::Rect(5, 6, 7, 8)));
window_state->Maximize();
- EXPECT_EQ("5,6 7x8", child_window->GetBounds().ToString());
+ EXPECT_EQ("5,6 7x8", child_window->bounds().ToString());
}
// Verifies a window created with maximized state has the maximized
@@ -382,7 +397,7 @@ TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) {
window->Init(ui::LAYER_TEXTURED);
wm::GetWindowState(window.get())->Maximize();
WmWindow* default_container =
- ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer(
+ Shell::GetPrimaryRootWindowController()->GetWmContainer(
kShellWindowId_DefaultContainer);
default_container->aura_window()->AddChild(window.get());
window->Show();
@@ -400,34 +415,30 @@ TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) {
// Normal window bounds shouldn't be changed.
gfx::Rect window_bounds(100, 100, 200, 200);
- std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds));
- WmWindow* window = window_owner->window();
- EXPECT_EQ(window_bounds, window->GetBounds());
+ std::unique_ptr<aura::Window> window(CreateTestWindow(window_bounds));
+ EXPECT_EQ(window_bounds, window->bounds());
// If the window is out of the workspace, it would be moved on screen.
- gfx::Rect root_window_bounds =
- ShellPort::Get()->GetPrimaryRootWindow()->GetBounds();
+ gfx::Rect root_window_bounds = Shell::GetPrimaryRootWindow()->bounds();
window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height());
ASSERT_FALSE(window_bounds.Intersects(root_window_bounds));
- std::unique_ptr<WindowOwner> out_window_owner(
- CreateTestWindow(window_bounds));
- WmWindow* out_window = out_window_owner->window();
- EXPECT_EQ(window_bounds.size(), out_window->GetBounds().size());
- gfx::Rect bounds = out_window->GetBounds();
+ std::unique_ptr<aura::Window> out_window(CreateTestWindow(window_bounds));
+ EXPECT_EQ(window_bounds.size(), out_window->bounds().size());
+ gfx::Rect bounds = out_window->bounds();
bounds.Intersect(root_window_bounds);
// 30% of the window edge must be visible.
- EXPECT_GT(bounds.width(), out_window->GetBounds().width() * 0.29);
- EXPECT_GT(bounds.height(), out_window->GetBounds().height() * 0.29);
+ EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
+ EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
- WmWindow* parent = out_window->GetParent();
- parent->RemoveChild(out_window);
+ aura::Window* parent = out_window->parent();
+ parent->RemoveChild(out_window.get());
out_window->SetBounds(gfx::Rect(-200, -200, 200, 200));
// UserHasChangedWindowPositionOrSize flag shouldn't turn off this behavior.
- window->GetWindowState()->set_bounds_changed_by_user(true);
- parent->AddChild(out_window);
- EXPECT_GT(bounds.width(), out_window->GetBounds().width() * 0.29);
- EXPECT_GT(bounds.height(), out_window->GetBounds().height() * 0.29);
+ wm::GetWindowState(window.get())->set_bounds_changed_by_user(true);
+ parent->AddChild(out_window.get());
+ EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
+ EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
// Make sure we always make more than 1/3 of the window edge visible even
// if the initial bounds intersects with display.
@@ -437,35 +448,32 @@ TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) {
// Make sure that the initial bounds' visible area is less than 26%
// so that the auto adjustment logic kicks in.
- ASSERT_LT(bounds.width(), out_window->GetBounds().width() * 0.26);
- ASSERT_LT(bounds.height(), out_window->GetBounds().height() * 0.26);
+ ASSERT_LT(bounds.width(), out_window->bounds().width() * 0.26);
+ ASSERT_LT(bounds.height(), out_window->bounds().height() * 0.26);
ASSERT_TRUE(window_bounds.Intersects(root_window_bounds));
- std::unique_ptr<WindowOwner> partially_out_window_owner(
+ std::unique_ptr<aura::Window> partially_out_window(
CreateTestWindow(window_bounds));
- WmWindow* partially_out_window = partially_out_window_owner->window();
- EXPECT_EQ(window_bounds.size(), partially_out_window->GetBounds().size());
- bounds = partially_out_window->GetBounds();
+ EXPECT_EQ(window_bounds.size(), partially_out_window->bounds().size());
+ bounds = partially_out_window->bounds();
bounds.Intersect(root_window_bounds);
- EXPECT_GT(bounds.width(), out_window->GetBounds().width() * 0.29);
- EXPECT_GT(bounds.height(), out_window->GetBounds().height() * 0.29);
+ EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
+ EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
// Make sure the window whose 30% width/height is bigger than display
// will be placed correctly.
window_bounds.SetRect(-1900, -1900, 3000, 3000);
- std::unique_ptr<WindowOwner> window_bigger_than_display_owner(
+ std::unique_ptr<aura::Window> window_bigger_than_display(
CreateTestWindow(window_bounds));
- WmWindow* window_bigger_than_display =
- window_bigger_than_display_owner->window();
EXPECT_GE(root_window_bounds.width(),
- window_bigger_than_display->GetBounds().width());
+ window_bigger_than_display->bounds().width());
EXPECT_GE(root_window_bounds.height(),
- window_bigger_than_display->GetBounds().height());
+ window_bigger_than_display->bounds().height());
- bounds = window_bigger_than_display->GetBounds();
+ bounds = window_bigger_than_display->bounds();
bounds.Intersect(root_window_bounds);
- EXPECT_GT(bounds.width(), out_window->GetBounds().width() * 0.29);
- EXPECT_GT(bounds.height(), out_window->GetBounds().height() * 0.29);
+ EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
+ EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
}
// Verifies the size of a window is enforced to be smaller than the work area.
@@ -475,33 +483,30 @@ TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) {
display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size());
const gfx::Rect window_bounds(100, 101, work_area.width() + 1,
work_area.height() + 2);
- std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds));
- WmWindow* window = window_owner->window();
+ std::unique_ptr<aura::Window> window(CreateTestWindow(window_bounds));
// TODO: fix. This test verifies that when a window is added the bounds are
// adjusted. CreateTestWindow() for mus adds, then sets the bounds (this comes
// from NativeWidgetAura), which means this test now fails for aura-mus.
if (Shell::GetAshConfig() == Config::CLASSIC) {
EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
- window->GetBounds().ToString());
+ window->bounds().ToString());
}
// Directly setting the bounds triggers a slightly different code path. Verify
// that too.
window->SetBounds(window_bounds);
EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
- window->GetBounds().ToString());
+ window->bounds().ToString());
}
TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) {
TestShellObserver observer;
- std::unique_ptr<WindowOwner> window1_owner(
+ std::unique_ptr<aura::Window> window1(
CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
- WmWindow* window1 = window1_owner->window();
- std::unique_ptr<WindowOwner> window2_owner(
+ std::unique_ptr<aura::Window> window2(
CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
- WmWindow* window2 = window2_owner->window();
- wm::WindowState* window_state1 = window1->GetWindowState();
- wm::WindowState* window_state2 = window2->GetWindowState();
+ wm::WindowState* window_state1 = wm::GetWindowState(window1.get());
+ wm::WindowState* window_state2 = wm::GetWindowState(window2.get());
window_state2->Activate();
const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
@@ -528,7 +533,7 @@ TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) {
EXPECT_TRUE(observer.is_fullscreen());
// Closing the window should change the fullscreen state.
- window2_owner.reset();
+ window2.reset();
EXPECT_EQ(6, observer.call_count());
EXPECT_FALSE(observer.is_fullscreen());
}
@@ -539,12 +544,12 @@ TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) {
TEST_F(WorkspaceLayoutManagerTest,
SnappedWindowMayNotAdjustBoundsOnWorkAreaChanged) {
UpdateDisplay("300x400");
- std::unique_ptr<WindowOwner> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindow(gfx::Rect(10, 20, 100, 200)));
- WmWindow* window = window_owner->window();
- wm::WindowState* window_state = window->GetWindowState();
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
gfx::Insets insets(0, 0, 50, 0);
- ShellPort::Get()->SetDisplayWorkAreaInsets(window, insets);
+ ShellPort::Get()->SetDisplayWorkAreaInsets(WmWindow::Get(window.get()),
+ insets);
const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT);
window_state->OnWMEvent(&snap_left);
EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType());
@@ -553,20 +558,22 @@ TEST_F(WorkspaceLayoutManagerTest,
gfx::Rect expected_bounds =
gfx::Rect(kWorkAreaBounds.x(), kWorkAreaBounds.y(),
kWorkAreaBounds.width() / 2, kWorkAreaBounds.height());
- EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString());
ui::ScopedAnimationDurationScaleMode test_duration_mode(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
// The following two SetDisplayWorkAreaInsets calls simulate the case of
// crbug.com/673803 that work area first becomes fullscreen and then returns
// to the original state.
- ShellPort::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets(0, 0, 0, 0));
- ui::LayerAnimator* animator = window->GetLayer()->GetAnimator();
+ ShellPort::Get()->SetDisplayWorkAreaInsets(WmWindow::Get(window.get()),
+ gfx::Insets(0, 0, 0, 0));
+ ui::LayerAnimator* animator = window->layer()->GetAnimator();
EXPECT_TRUE(animator->is_animating());
- ShellPort::Get()->SetDisplayWorkAreaInsets(window, insets);
+ ShellPort::Get()->SetDisplayWorkAreaInsets(WmWindow::Get(window.get()),
+ insets);
animator->StopAnimating();
EXPECT_FALSE(animator->is_animating());
- EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString());
}
// Do not adjust window bounds to ensure minimum visibility for transient
@@ -578,19 +585,18 @@ TEST_F(WorkspaceLayoutManagerTest,
base::MakeUnique<aura::Window>(nullptr, ui::wm::WINDOW_TYPE_NORMAL));
window->Init(ui::LAYER_TEXTURED);
window->SetBounds(gfx::Rect(10, 0, 100, 200));
- ParentWindowInPrimaryRootWindow(WmWindow::Get(window.get()));
+ ParentWindowInPrimaryRootWindow(window.get());
window->Show();
- std::unique_ptr<WindowOwner> window2_owner(
+ std::unique_ptr<aura::Window> window2(
CreateTestWindow(gfx::Rect(10, 0, 40, 20)));
- WmWindow* window2 = window2_owner->window();
- AddTransientChild(WmWindow::Get(window.get()), window2);
+ ::wm::AddTransientChild(window.get(), window2.get());
window2->Show();
- gfx::Rect expected_bounds = window2->GetBounds();
+ gfx::Rect expected_bounds = window2->bounds();
ShellPort::Get()->SetDisplayWorkAreaInsets(WmWindow::Get(window.get()),
gfx::Insets(50, 0, 0, 0));
- EXPECT_EQ(expected_bounds.ToString(), window2->GetBounds().ToString());
+ EXPECT_EQ(expected_bounds.ToString(), window2->bounds().ToString());
}
// Following "Solo" tests were originally written for BaseLayoutManager.
@@ -599,31 +605,30 @@ using WorkspaceLayoutManagerSoloTest = test::AshTestBase;
// Tests normal->maximize->normal.
TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) {
gfx::Rect bounds(100, 100, 200, 200);
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* window = WmWindow::Get(window_owner.get());
- window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
// Maximized window fills the work area, not the whole display.
- EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
- window->GetBounds().ToString());
- window->SetShowState(ui::SHOW_STATE_NORMAL);
- EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(
+ ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
+ window->bounds().ToString());
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
+ EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
}
// Tests normal->minimize->normal.
TEST_F(WorkspaceLayoutManagerSoloTest, Minimize) {
gfx::Rect bounds(100, 100, 200, 200);
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* window = WmWindow::Get(window_owner.get());
- window->SetShowState(ui::SHOW_STATE_MINIMIZED);
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
EXPECT_FALSE(window->IsVisible());
- EXPECT_TRUE(window->GetWindowState()->IsMinimized());
- EXPECT_EQ(bounds, window->GetBounds());
- window->SetShowState(ui::SHOW_STATE_NORMAL);
+ EXPECT_TRUE(wm::GetWindowState(window.get())->IsMinimized());
+ EXPECT_EQ(bounds, window->bounds());
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
EXPECT_TRUE(window->IsVisible());
- EXPECT_FALSE(window->GetWindowState()->IsMinimized());
- EXPECT_EQ(bounds, window->GetBounds());
+ EXPECT_FALSE(wm::GetWindowState(window.get())->IsMinimized());
+ EXPECT_EQ(bounds, window->bounds());
}
// A aura::WindowObserver which sets the focus when the window becomes visible.
@@ -633,20 +638,20 @@ class FocusDuringUnminimizeWindowObserver : public aura::WindowObserver {
: window_(nullptr), show_state_(ui::SHOW_STATE_END) {}
~FocusDuringUnminimizeWindowObserver() override { SetWindow(nullptr); }
- void SetWindow(WmWindow* window) {
+ void SetWindow(aura::Window* window) {
if (window_)
- window_->aura_window()->RemoveObserver(this);
+ window_->RemoveObserver(this);
window_ = window;
if (window_)
- window_->aura_window()->AddObserver(this);
+ window_->AddObserver(this);
}
// aura::WindowObserver:
void OnWindowVisibilityChanged(aura::Window* window, bool visible) override {
if (window_) {
if (visible)
- window_->SetFocused();
- show_state_ = window_->GetShowState();
+ aura::client::GetFocusClient(window_)->FocusWindow(window_);
+ show_state_ = window_->GetProperty(aura::client::kShowStateKey);
}
}
@@ -657,7 +662,7 @@ class FocusDuringUnminimizeWindowObserver : public aura::WindowObserver {
}
private:
- WmWindow* window_;
+ aura::Window* window_;
ui::WindowShowState show_state_;
DISALLOW_COPY_AND_ASSIGN(FocusDuringUnminimizeWindowObserver);
@@ -668,11 +673,10 @@ class FocusDuringUnminimizeWindowObserver : public aura::WindowObserver {
// callback doesn't cause DCHECK error. See crbug.com/168383.
TEST_F(WorkspaceLayoutManagerSoloTest, FocusDuringUnminimize) {
FocusDuringUnminimizeWindowObserver observer;
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
- WmWindow* window = WmWindow::Get(window_owner.get());
- observer.SetWindow(window);
- window->SetShowState(ui::SHOW_STATE_MINIMIZED);
+ observer.SetWindow(window.get());
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
EXPECT_FALSE(window->IsVisible());
EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, observer.GetShowStateAndReset());
window->Show();
@@ -684,188 +688,185 @@ TEST_F(WorkspaceLayoutManagerSoloTest, FocusDuringUnminimize) {
// Tests maximized window size during root window resize.
TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeRootWindowResize) {
gfx::Rect bounds(100, 100, 200, 200);
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* window = WmWindow::Get(window_owner.get());
- window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
gfx::Rect initial_work_area_bounds =
- wm::GetMaximizedWindowBoundsInParent(window);
- EXPECT_EQ(initial_work_area_bounds.ToString(),
- window->GetBounds().ToString());
+ ScreenUtil::GetMaximizedWindowBoundsInParent(window.get());
+ EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString());
// Enlarge the root window. We should still match the work area size.
UpdateDisplay("900x700");
- EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
- window->GetBounds().ToString());
- EXPECT_NE(initial_work_area_bounds.ToString(),
- wm::GetMaximizedWindowBoundsInParent(window).ToString());
+ EXPECT_EQ(
+ ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
+ window->bounds().ToString());
+ EXPECT_NE(
+ initial_work_area_bounds.ToString(),
+ ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString());
}
// Tests normal->fullscreen->normal.
TEST_F(WorkspaceLayoutManagerSoloTest, Fullscreen) {
gfx::Rect bounds(100, 100, 200, 200);
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* window = WmWindow::Get(window_owner.get());
- window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
// Fullscreen window fills the whole display.
- EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(),
- window->GetBounds().ToString());
- window->SetShowState(ui::SHOW_STATE_NORMAL);
- EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(GetDisplayNearestWindow(window.get()).bounds().ToString(),
+ window->bounds().ToString());
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
+ EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
}
// Tests that fullscreen window causes always_on_top windows to stack below.
TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenSuspendsAlwaysOnTop) {
gfx::Rect bounds(100, 100, 200, 200);
- std::unique_ptr<aura::Window> fullscreen_window_owner(
+ std::unique_ptr<aura::Window> fullscreen_window(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* fullscreen_window = WmWindow::Get(fullscreen_window_owner.get());
- std::unique_ptr<aura::Window> always_on_top_window1_owner(
+ std::unique_ptr<aura::Window> always_on_top_window1(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* always_on_top_window1 =
- WmWindow::Get(always_on_top_window1_owner.get());
- std::unique_ptr<aura::Window> always_on_top_window2_owner(
+ std::unique_ptr<aura::Window> always_on_top_window2(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* always_on_top_window2 =
- WmWindow::Get(always_on_top_window2_owner.get());
- always_on_top_window1->SetAlwaysOnTop(true);
- always_on_top_window2->SetAlwaysOnTop(true);
+ always_on_top_window1->SetProperty(aura::client::kAlwaysOnTopKey, true);
+ always_on_top_window2->SetProperty(aura::client::kAlwaysOnTopKey, true);
// Making a window fullscreen temporarily suspends always on top state.
- fullscreen_window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
- EXPECT_FALSE(always_on_top_window1->IsAlwaysOnTop());
- EXPECT_FALSE(always_on_top_window2->IsAlwaysOnTop());
- EXPECT_NE(nullptr, wm::GetWindowForFullscreenMode(fullscreen_window));
+ fullscreen_window->SetProperty(aura::client::kShowStateKey,
+ ui::SHOW_STATE_FULLSCREEN);
+ EXPECT_FALSE(
+ always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey));
+ EXPECT_FALSE(
+ always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey));
+ EXPECT_NE(nullptr, wm::GetWindowForFullscreenMode(
+ WmWindow::Get(fullscreen_window.get())));
// Adding a new always-on-top window is not affected by fullscreen.
- std::unique_ptr<aura::Window> always_on_top_window3_owner(
+ std::unique_ptr<aura::Window> always_on_top_window3(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* always_on_top_window3 =
- WmWindow::Get(always_on_top_window3_owner.get());
- always_on_top_window3->SetAlwaysOnTop(true);
- EXPECT_TRUE(always_on_top_window3->IsAlwaysOnTop());
+ always_on_top_window3->SetProperty(aura::client::kAlwaysOnTopKey, true);
+ EXPECT_TRUE(
+ always_on_top_window3->GetProperty(aura::client::kAlwaysOnTopKey));
// Making fullscreen window normal restores always on top windows.
- fullscreen_window->SetShowState(ui::SHOW_STATE_NORMAL);
- EXPECT_TRUE(always_on_top_window1->IsAlwaysOnTop());
- EXPECT_TRUE(always_on_top_window2->IsAlwaysOnTop());
- EXPECT_TRUE(always_on_top_window3->IsAlwaysOnTop());
- EXPECT_EQ(nullptr, wm::GetWindowForFullscreenMode(fullscreen_window));
+ fullscreen_window->SetProperty(aura::client::kShowStateKey,
+ ui::SHOW_STATE_NORMAL);
+ EXPECT_TRUE(
+ always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey));
+ EXPECT_TRUE(
+ always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey));
+ EXPECT_TRUE(
+ always_on_top_window3->GetProperty(aura::client::kAlwaysOnTopKey));
+ EXPECT_EQ(nullptr, wm::GetWindowForFullscreenMode(
+ WmWindow::Get(fullscreen_window.get())));
}
// Similary, pinned window causes always_on_top_ windows to stack below.
TEST_F(WorkspaceLayoutManagerSoloTest, PinnedSuspendsAlwaysOnTop) {
gfx::Rect bounds(100, 100, 200, 200);
- std::unique_ptr<aura::Window> pinned_window_owner(
+ std::unique_ptr<aura::Window> pinned_window(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* pinned_window = WmWindow::Get(pinned_window_owner.get());
- std::unique_ptr<aura::Window> always_on_top_window1_owner(
+ std::unique_ptr<aura::Window> always_on_top_window1(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* always_on_top_window1 =
- WmWindow::Get(always_on_top_window1_owner.get());
- std::unique_ptr<aura::Window> always_on_top_window2_owner(
+ std::unique_ptr<aura::Window> always_on_top_window2(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* always_on_top_window2 =
- WmWindow::Get(always_on_top_window2_owner.get());
- always_on_top_window1->SetAlwaysOnTop(true);
- always_on_top_window2->SetAlwaysOnTop(true);
+ always_on_top_window1->SetProperty(aura::client::kAlwaysOnTopKey, true);
+ always_on_top_window2->SetProperty(aura::client::kAlwaysOnTopKey, true);
// Making a window pinned temporarily suspends always on top state.
const bool trusted = false;
- wm::PinWindow(pinned_window->aura_window(), trusted);
- EXPECT_FALSE(always_on_top_window1->IsAlwaysOnTop());
- EXPECT_FALSE(always_on_top_window2->IsAlwaysOnTop());
+ wm::PinWindow(pinned_window.get(), trusted);
+ EXPECT_FALSE(
+ always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey));
+ EXPECT_FALSE(
+ always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey));
// Adding a new always-on-top window also is affected by pinned mode.
- std::unique_ptr<aura::Window> always_on_top_window3_owner(
+ std::unique_ptr<aura::Window> always_on_top_window3(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* always_on_top_window3 =
- WmWindow::Get(always_on_top_window3_owner.get());
- always_on_top_window3->SetAlwaysOnTop(true);
- EXPECT_FALSE(always_on_top_window3->IsAlwaysOnTop());
+ always_on_top_window3->SetProperty(aura::client::kAlwaysOnTopKey, true);
+ EXPECT_FALSE(
+ always_on_top_window3->GetProperty(aura::client::kAlwaysOnTopKey));
// Making pinned window normal restores always on top windows.
- pinned_window->GetWindowState()->Restore();
- EXPECT_TRUE(always_on_top_window1->IsAlwaysOnTop());
- EXPECT_TRUE(always_on_top_window2->IsAlwaysOnTop());
- EXPECT_TRUE(always_on_top_window3->IsAlwaysOnTop());
+ wm::GetWindowState(pinned_window.get())->Restore();
+ EXPECT_TRUE(
+ always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey));
+ EXPECT_TRUE(
+ always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey));
+ EXPECT_TRUE(
+ always_on_top_window3->GetProperty(aura::client::kAlwaysOnTopKey));
}
// Tests fullscreen window size during root window resize.
TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenRootWindowResize) {
gfx::Rect bounds(100, 100, 200, 200);
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(bounds));
- WmWindow* window = WmWindow::Get(window_owner.get());
// Fullscreen window fills the whole display.
- window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
- EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(),
- window->GetBounds().ToString());
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
+ EXPECT_EQ(GetDisplayNearestWindow(window.get()).bounds().ToString(),
+ window->bounds().ToString());
// Enlarge the root window. We should still match the display size.
UpdateDisplay("800x600");
- EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(),
- window->GetBounds().ToString());
+ EXPECT_EQ(GetDisplayNearestWindow(window.get()).bounds().ToString(),
+ window->bounds().ToString());
}
// Tests that when the screen gets smaller the windows aren't bigger than
// the screen.
TEST_F(WorkspaceLayoutManagerSoloTest, RootWindowResizeShrinksWindows) {
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(10, 20, 500, 400)));
- WmWindow* window = WmWindow::Get(window_owner.get());
- gfx::Rect work_area = window->GetDisplayNearestWindow().work_area();
+ gfx::Rect work_area = GetDisplayNearestWindow(window.get()).work_area();
// Invariant: Window is smaller than work area.
- EXPECT_LE(window->GetBounds().width(), work_area.width());
- EXPECT_LE(window->GetBounds().height(), work_area.height());
+ EXPECT_LE(window->bounds().width(), work_area.width());
+ EXPECT_LE(window->bounds().height(), work_area.height());
// Make the root window narrower than our window.
UpdateDisplay("300x400");
- work_area = window->GetDisplayNearestWindow().work_area();
- EXPECT_LE(window->GetBounds().width(), work_area.width());
- EXPECT_LE(window->GetBounds().height(), work_area.height());
+ work_area = GetDisplayNearestWindow(window.get()).work_area();
+ EXPECT_LE(window->bounds().width(), work_area.width());
+ EXPECT_LE(window->bounds().height(), work_area.height());
// Make the root window shorter than our window.
UpdateDisplay("300x200");
- work_area = window->GetDisplayNearestWindow().work_area();
- EXPECT_LE(window->GetBounds().width(), work_area.width());
- EXPECT_LE(window->GetBounds().height(), work_area.height());
+ work_area = GetDisplayNearestWindow(window.get()).work_area();
+ EXPECT_LE(window->bounds().width(), work_area.width());
+ EXPECT_LE(window->bounds().height(), work_area.height());
// Enlarging the root window does not change the window bounds.
- gfx::Rect old_bounds = window->GetBounds();
+ gfx::Rect old_bounds = window->bounds();
UpdateDisplay("800x600");
- EXPECT_EQ(old_bounds.width(), window->GetBounds().width());
- EXPECT_EQ(old_bounds.height(), window->GetBounds().height());
+ EXPECT_EQ(old_bounds.width(), window->bounds().width());
+ EXPECT_EQ(old_bounds.height(), window->bounds().height());
}
// Verifies maximizing sets the restore bounds, and restoring
// restores the bounds.
TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeSetsRestoreBounds) {
const gfx::Rect initial_bounds(10, 20, 30, 40);
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(initial_bounds));
- WmWindow* window = WmWindow::Get(window_owner.get());
- EXPECT_EQ(initial_bounds, window->GetBounds());
- wm::WindowState* window_state = window->GetWindowState();
+ EXPECT_EQ(initial_bounds, window->bounds());
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
// Maximize it, which will keep the previous restore bounds.
- window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInParent().ToString());
// Restore it, which should restore bounds and reset restore bounds.
- window->SetShowState(ui::SHOW_STATE_NORMAL);
- EXPECT_EQ("10,20 30x40", window->GetBounds().ToString());
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
+ EXPECT_EQ("10,20 30x40", window->bounds().ToString());
EXPECT_FALSE(window_state->HasRestoreBounds());
}
// Verifies maximizing keeps the restore bounds if set.
TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeResetsRestoreBounds) {
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
- WmWindow* window = WmWindow::Get(window_owner.get());
- wm::WindowState* window_state = window->GetWindowState();
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
window_state->SetRestoreBoundsInParent(gfx::Rect(10, 11, 12, 13));
// Maximize it, which will keep the previous restore bounds.
- window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
EXPECT_EQ("10,11 12x13", window_state->GetRestoreBoundsInParent().ToString());
}
@@ -873,13 +874,12 @@ TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeResetsRestoreBounds) {
// maximzied state from a minimized state.
TEST_F(WorkspaceLayoutManagerSoloTest,
BoundsAfterRestoringToMaximizeFromMinimize) {
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
- WmWindow* window = WmWindow::Get(window_owner.get());
gfx::Rect bounds(10, 15, 25, 35);
window->SetBounds(bounds);
- wm::WindowState* window_state = window->GetWindowState();
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
// Maximize it, which should reset restore bounds.
window_state->Maximize();
EXPECT_EQ(bounds.ToString(),
@@ -897,67 +897,70 @@ TEST_F(WorkspaceLayoutManagerSoloTest,
EXPECT_TRUE(window_state->IsMaximized());
window_state->Restore();
- EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
}
// Verify if the window is not resized during screen lock. See: crbug.com/173127
TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) {
SetCanLockScreen(true);
- std::unique_ptr<aura::Window> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
- WmWindow* window = WmWindow::Get(window_owner.get());
// window with AlwaysOnTop will be managed by BaseLayoutManager.
- window->SetAlwaysOnTop(true);
+ window->SetProperty(aura::client::kAlwaysOnTopKey, true);
window->Show();
WmShelf* shelf = GetPrimaryShelf();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- window->SetBounds(wm::GetMaximizedWindowBoundsInParent(window));
- gfx::Rect window_bounds = window->GetBounds();
- EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
- window_bounds.ToString());
+ window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()));
+ gfx::Rect window_bounds = window->bounds();
+ EXPECT_EQ(
+ ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
+ window_bounds.ToString());
// The window size should not get touched while we are in lock screen.
Shell::Get()->session_controller()->LockScreenAndFlushForTest();
ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager();
shelf_layout_manager->UpdateVisibilityState();
- EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
// Coming out of the lock screen the window size should still remain.
GetSessionControllerClient()->UnlockScreen();
shelf_layout_manager->UpdateVisibilityState();
- EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
- window_bounds.ToString());
- EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(
+ ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
+ window_bounds.ToString());
+ EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
}
// Following tests are written to test the backdrop functionality.
namespace {
-WorkspaceLayoutManager* GetWorkspaceLayoutManager(WmWindow* container) {
- return static_cast<WorkspaceLayoutManager*>(container->GetLayoutManager());
+WorkspaceLayoutManager* GetWorkspaceLayoutManager(aura::Window* container) {
+ return static_cast<WorkspaceLayoutManager*>(
+ WmWindow::Get(container)->GetLayoutManager());
}
-class WorkspaceLayoutManagerBackdropTest : public AshTest {
+class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase {
public:
WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {}
~WorkspaceLayoutManagerBackdropTest() override {}
void SetUp() override {
- AshTest::SetUp();
+ AshTestBase::SetUp();
UpdateDisplay("800x600");
- default_container_ =
- ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer(
- kShellWindowId_DefaultContainer);
+ default_container_ = Shell::GetPrimaryRootWindowController()->GetContainer(
+ kShellWindowId_DefaultContainer);
}
// Turn the top window back drop on / off.
void ShowTopWindowBackdrop(bool show) {
std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop;
- if (show)
- backdrop.reset(new WorkspaceBackdropDelegate(default_container_));
+ if (show) {
+ backdrop.reset(
+ new WorkspaceBackdropDelegate(WmWindow::Get(default_container_)));
+ }
GetWorkspaceLayoutManager(default_container_)
->SetMaximizeBackdropDelegate(std::move(backdrop));
// Closing and / or opening can be a delayed operation.
@@ -965,18 +968,18 @@ class WorkspaceLayoutManagerBackdropTest : public AshTest {
}
// Return the default container.
- WmWindow* default_container() { return default_container_; }
+ aura::Window* default_container() { return default_container_; }
// Return the order of windows (top most first) as they are in the default
// container. If the window is visible it will be a big letter, otherwise a
// small one. The backdrop will be an X and unknown windows will be shown as
// '!'.
- std::string GetWindowOrderAsString(WmWindow* backdrop,
- WmWindow* wa,
- WmWindow* wb,
- WmWindow* wc) {
+ std::string GetWindowOrderAsString(aura::Window* backdrop,
+ aura::Window* wa,
+ aura::Window* wb,
+ aura::Window* wc) {
std::string result;
- WmWindow::Windows children = default_container()->GetChildren();
+ aura::Window::Windows children = default_container()->children();
for (int i = static_cast<int>(children.size()) - 1; i >= 0; --i) {
if (!result.empty())
result += ",";
@@ -996,7 +999,7 @@ class WorkspaceLayoutManagerBackdropTest : public AshTest {
private:
// The default container.
- WmWindow* default_container_;
+ aura::Window* default_container_;
DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerBackdropTest);
};
@@ -1015,83 +1018,82 @@ TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) {
// that the size is the same as the default container as well as that it is
// not visible.
ShowTopWindowBackdrop(true);
- ASSERT_EQ(1U, default_container()->GetChildren().size());
- EXPECT_FALSE(default_container()->GetChildren()[0]->IsVisible());
+ ASSERT_EQ(1U, default_container()->children().size());
+ EXPECT_FALSE(default_container()->children()[0]->IsVisible());
{
// Add a window and make sure that the backdrop is the second child.
- std::unique_ptr<WindowOwner> window_owner(
+ std::unique_ptr<aura::Window> window(
CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
- WmWindow* window = window_owner->window();
window->Show();
- ASSERT_EQ(2U, default_container()->GetChildren().size());
- EXPECT_TRUE(default_container()->GetChildren()[0]->IsVisible());
- EXPECT_TRUE(default_container()->GetChildren()[1]->IsVisible());
- EXPECT_EQ(window, default_container()->GetChildren()[1]);
- EXPECT_EQ(default_container()->GetBounds().ToString(),
- default_container()->GetChildren()[0]->GetBounds().ToString());
+ ASSERT_EQ(2U, default_container()->children().size());
+ EXPECT_TRUE(default_container()->children()[0]->IsVisible());
+ EXPECT_TRUE(default_container()->children()[1]->IsVisible());
+ EXPECT_EQ(window.get(), default_container()->children()[1]);
+ EXPECT_EQ(default_container()->bounds().ToString(),
+ default_container()->children()[0]->bounds().ToString());
}
// With the window gone the backdrop should be invisible again.
- ASSERT_EQ(1U, default_container()->GetChildren().size());
- EXPECT_FALSE(default_container()->GetChildren()[0]->IsVisible());
+ ASSERT_EQ(1U, default_container()->children().size());
+ EXPECT_FALSE(default_container()->children()[0]->IsVisible());
// Destroying the Backdrop should empty the container.
ShowTopWindowBackdrop(false);
- ASSERT_EQ(0U, default_container()->GetChildren().size());
+ ASSERT_EQ(0U, default_container()->children().size());
}
// Verify that the backdrop gets properly created and placed.
TEST_F(WorkspaceLayoutManagerBackdropTest, VerifyBackdropAndItsStacking) {
- std::unique_ptr<WindowOwner> window1_owner(
+ std::unique_ptr<aura::Window> window1(
CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
- WmWindow* window1 = window1_owner->window();
window1->Show();
// Get the default container and check that only a single window is in there.
- ASSERT_EQ(1U, default_container()->GetChildren().size());
- EXPECT_EQ(window1, default_container()->GetChildren()[0]);
- EXPECT_EQ("A", GetWindowOrderAsString(nullptr, window1, nullptr, nullptr));
+ ASSERT_EQ(1U, default_container()->children().size());
+ EXPECT_EQ(window1.get(), default_container()->children()[0]);
+ EXPECT_EQ("A",
+ GetWindowOrderAsString(nullptr, window1.get(), nullptr, nullptr));
// Create 2 more windows and check that they are also in the container.
- std::unique_ptr<WindowOwner> window2_owner(
+ std::unique_ptr<aura::Window> window2(
CreateTestWindow(gfx::Rect(10, 2, 3, 4)));
- WmWindow* window2 = window2_owner->window();
- std::unique_ptr<WindowOwner> window3_owner(
+ std::unique_ptr<aura::Window> window3(
CreateTestWindow(gfx::Rect(20, 2, 3, 4)));
- WmWindow* window3 = window3_owner->window();
window2->Show();
window3->Show();
- WmWindow* backdrop = nullptr;
- EXPECT_EQ("C,B,A",
- GetWindowOrderAsString(backdrop, window1, window2, window3));
+ aura::Window* backdrop = nullptr;
+ EXPECT_EQ("C,B,A", GetWindowOrderAsString(backdrop, window1.get(),
+ window2.get(), window3.get()));
// Turn on the backdrop mode and check that the window shows up where it
// should be (second highest number).
ShowTopWindowBackdrop(true);
- backdrop = default_container()->GetChildren()[2];
- EXPECT_EQ("C,X,B,A",
- GetWindowOrderAsString(backdrop, window1, window2, window3));
+ backdrop = default_container()->children()[2];
+ EXPECT_EQ("C,X,B,A", GetWindowOrderAsString(backdrop, window1.get(),
+ window2.get(), window3.get()));
// Switch the order of windows and check that it still remains in that
// location.
- default_container()->StackChildAtTop(window2);
- EXPECT_EQ("B,X,C,A",
- GetWindowOrderAsString(backdrop, window1, window2, window3));
+ default_container()->StackChildAtTop(window2.get());
+ EXPECT_EQ("B,X,C,A", GetWindowOrderAsString(backdrop, window1.get(),
+ window2.get(), window3.get()));
// Make the top window invisible and check.
window2->Hide();
- EXPECT_EQ("b,C,X,A",
- GetWindowOrderAsString(backdrop, window1, window2, window3));
+ EXPECT_EQ("b,C,X,A", GetWindowOrderAsString(backdrop, window1.get(),
+ window2.get(), window3.get()));
// Then delete window after window and see that everything is in order.
- window1_owner.reset();
- EXPECT_EQ("b,C,X",
- GetWindowOrderAsString(backdrop, window1, window2, window3));
- window3_owner.reset();
- EXPECT_EQ("b,x", GetWindowOrderAsString(backdrop, window1, window2, window3));
+ window1.reset();
+ EXPECT_EQ("b,C,X", GetWindowOrderAsString(backdrop, window1.get(),
+ window2.get(), window3.get()));
+ window3.reset();
+ EXPECT_EQ("b,x", GetWindowOrderAsString(backdrop, window1.get(),
+ window2.get(), window3.get()));
ShowTopWindowBackdrop(false);
- EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1, window2, window3));
+ EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(),
+ window3.get()));
}
// Tests that when hidding the shelf, that the backdrop stays fullscreen.
@@ -1106,7 +1108,7 @@ TEST_F(WorkspaceLayoutManagerBackdropTest,
ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state());
EXPECT_EQ(fullscreen_size,
- default_container()->GetChildren()[0]->GetBounds().size());
+ default_container()->children()[0]->bounds().size());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
shelf_layout_manager->UpdateVisibilityState();
@@ -1115,24 +1117,24 @@ TEST_F(WorkspaceLayoutManagerBackdropTest,
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
shelf_layout_manager->UpdateVisibilityState();
EXPECT_EQ(fullscreen_size,
- default_container()->GetChildren()[0]->GetBounds().size());
+ default_container()->children()[0]->bounds().size());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
shelf_layout_manager->UpdateVisibilityState();
EXPECT_EQ(fullscreen_size,
- default_container()->GetChildren()[0]->GetBounds().size());
+ default_container()->children()[0]->bounds().size());
}
-class WorkspaceLayoutManagerKeyboardTest : public AshTest {
+class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase {
public:
WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {}
~WorkspaceLayoutManagerKeyboardTest() override {}
void SetUp() override {
- AshTest::SetUp();
+ AshTestBase::SetUp();
UpdateDisplay("800x600");
- WmWindow* default_container =
- ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer(
+ aura::Window* default_container =
+ Shell::GetPrimaryRootWindowController()->GetContainer(
kShellWindowId_DefaultContainer);
layout_manager_ = GetWorkspaceLayoutManager(default_container);
}
@@ -1142,13 +1144,14 @@ class WorkspaceLayoutManagerKeyboardTest : public AshTest {
restore_work_area_insets_ =
display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets();
ShellPort::Get()->SetDisplayWorkAreaInsets(
- ShellPort::Get()->GetPrimaryRootWindow(),
+ WmWindow::Get(Shell::GetPrimaryRootWindow()),
gfx::Insets(0, 0, keyboard_bounds_.height(), 0));
}
void HideKeyboard() {
ShellPort::Get()->SetDisplayWorkAreaInsets(
- ShellPort::Get()->GetPrimaryRootWindow(), restore_work_area_insets_);
+ WmWindow::Get(Shell::GetPrimaryRootWindow()),
+ restore_work_area_insets_);
layout_manager_->OnKeyboardBoundsChanging(gfx::Rect());
}
@@ -1180,19 +1183,19 @@ class WorkspaceLayoutManagerKeyboardTest : public AshTest {
// Tests that when a child window gains focus the top level window containing it
// is resized to fit the remaining workspace area.
TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) {
+ WmWindowTestApi::GlobalMinimumSizeLock min_size_lock;
+
InitKeyboardBounds();
gfx::Rect work_area(
display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
- std::unique_ptr<WindowOwner> parent_window_owner(
+ std::unique_ptr<aura::Window> parent_window(
CreateToplevelTestWindow(work_area));
- WmWindow* parent_window = parent_window_owner->window();
- std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(work_area));
- WmWindow* window = window_owner->window();
- parent_window->AddChild(window);
+ std::unique_ptr<aura::Window> window(CreateTestWindow(work_area));
+ parent_window->AddChild(window.get());
- window->Activate();
+ wm::ActivateWindow(window.get());
int available_height =
display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() -
@@ -1201,23 +1204,22 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) {
gfx::Rect initial_window_bounds(50, 50, 100, 500);
parent_window->SetBounds(initial_window_bounds);
EXPECT_EQ(initial_window_bounds.ToString(),
- parent_window->GetBounds().ToString());
+ parent_window->bounds().ToString());
ShowKeyboard();
EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(),
- parent_window->GetBounds().ToString());
+ parent_window->bounds().ToString());
HideKeyboard();
EXPECT_EQ(initial_window_bounds.ToString(),
- parent_window->GetBounds().ToString());
+ parent_window->bounds().ToString());
}
TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
+ WmWindowTestApi::GlobalMinimumSizeLock min_size_lock;
InitKeyboardBounds();
gfx::Rect work_area(
display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
- std::unique_ptr<WindowOwner> window_owner(
- CreateToplevelTestWindow(work_area));
- WmWindow* window = window_owner->window();
+ std::unique_ptr<aura::Window> window(CreateToplevelTestWindow(work_area));
// The additional SetBounds() is needed as the aura-mus case uses Widget,
// which alters the supplied bounds.
window->SetBounds(work_area);
@@ -1226,25 +1228,25 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() -
keyboard_bounds().height();
- window->Activate();
+ wm::ActivateWindow(window.get());
- EXPECT_EQ(gfx::Rect(work_area).ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString());
ShowKeyboard();
EXPECT_EQ(gfx::Rect(work_area.origin(),
gfx::Size(work_area.width(), available_height))
.ToString(),
- window->GetBounds().ToString());
+ window->bounds().ToString());
HideKeyboard();
- EXPECT_EQ(gfx::Rect(work_area).ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString());
gfx::Rect small_window_bound(50, 50, 100, 500);
window->SetBounds(small_window_bound);
- EXPECT_EQ(small_window_bound.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString());
ShowKeyboard();
EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(),
- window->GetBounds().ToString());
+ window->bounds().ToString());
HideKeyboard();
- EXPECT_EQ(small_window_bound.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString());
gfx::Rect occluded_window_bounds(
50, keyboard_bounds().y() + keyboard_bounds().height() / 2, 50,
@@ -1257,26 +1259,24 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
gfx::Rect(50, keyboard_bounds().y() - keyboard_bounds().height() / 2,
occluded_window_bounds.width(), occluded_window_bounds.height())
.ToString(),
- window->GetBounds().ToString());
+ window->bounds().ToString());
HideKeyboard();
- EXPECT_EQ(occluded_window_bounds.ToString(), window->GetBounds().ToString());
+ EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString());
}
TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChange) {
InitKeyboardBounds();
- std::unique_ptr<WindowOwner> window_owner(
- CreateTestWindow(keyboard_bounds()));
- WmWindow* window = window_owner->window();
+ std::unique_ptr<aura::Window> window(CreateTestWindow(keyboard_bounds()));
// The additional SetBounds() is needed as the aura-mus case uses Widget,
// which alters the supplied bounds.
window->SetBounds(keyboard_bounds());
- window->GetWindowState()->set_ignore_keyboard_bounds_change(true);
- window->Activate();
+ wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true);
+ wm::ActivateWindow(window.get());
- EXPECT_EQ(keyboard_bounds(), window->GetBounds());
+ EXPECT_EQ(keyboard_bounds(), window->bounds());
ShowKeyboard();
- EXPECT_EQ(keyboard_bounds(), window->GetBounds());
+ EXPECT_EQ(keyboard_bounds(), window->bounds());
}
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698