Autohide behavior simplified to always/never
BUG=146773 Review URL: https://chromiumcodereview.appspot.com/10987005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158639 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@@ -25,38 +25,19 @@ LauncherContextMenu::~LauncherContextMenu() {
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
bool LauncherContextMenu::IsAutoHideMenuHideChecked() {
|
bool LauncherContextMenu::IsAutoHideMenuHideChecked() {
|
||||||
internal::RootWindowController* controller =
|
return ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ==
|
||||||
Shell::GetPrimaryRootWindowController();
|
|
||||||
ash::ShelfAutoHideBehavior auto_hide_behavior =
|
|
||||||
Shell::GetInstance()->GetShelfAutoHideBehavior();
|
Shell::GetInstance()->GetShelfAutoHideBehavior();
|
||||||
return (controller->IsInMaximizedMode() &&
|
|
||||||
(auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT ||
|
|
||||||
auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS)) ||
|
|
||||||
(!controller->IsInMaximizedMode() &&
|
|
||||||
auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() {
|
ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() {
|
||||||
ash::ShelfAutoHideBehavior auto_hide_behavior;
|
return IsAutoHideMenuHideChecked() ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER :
|
||||||
if (Shell::GetPrimaryRootWindowController()->IsInMaximizedMode()) {
|
ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
|
||||||
if (IsAutoHideMenuHideChecked())
|
|
||||||
auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
|
|
||||||
else
|
|
||||||
auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT;
|
|
||||||
} else if (IsAutoHideMenuHideChecked()) {
|
|
||||||
auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT;
|
|
||||||
} else {
|
|
||||||
auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
|
|
||||||
}
|
|
||||||
return auto_hide_behavior;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
int LauncherContextMenu::GetAutoHideResourceStringId() {
|
int LauncherContextMenu::GetAutoHideResourceStringId() {
|
||||||
return Shell::GetPrimaryRootWindowController()->IsInMaximizedMode() ?
|
return IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_NOT_MAXIMIZED;
|
||||||
IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_MAXIMIZED :
|
|
||||||
IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_NOT_MAXIMIZED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LauncherContextMenu::IsCommandIdChecked(int command_id) const {
|
bool LauncherContextMenu::IsCommandIdChecked(int command_id) const {
|
||||||
|
@@ -29,29 +29,25 @@ TEST_F(LauncherContextMenuTest, ToggleAutoHide) {
|
|||||||
wm::ActivateWindow(window.get());
|
wm::ActivateWindow(window.get());
|
||||||
|
|
||||||
Shell* shell = Shell::GetInstance();
|
Shell* shell = Shell::GetInstance();
|
||||||
// If the auto-hide behavior isn't DEFAULT, the rest of the tests don't make
|
shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
||||||
// sense.
|
|
||||||
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT,
|
|
||||||
shell->GetShelfAutoHideBehavior());
|
|
||||||
EXPECT_FALSE(LauncherContextMenu::IsAutoHideMenuHideChecked());
|
|
||||||
shell->SetShelfAutoHideBehavior(
|
|
||||||
LauncherContextMenu::GetToggledAutoHideBehavior());
|
|
||||||
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
|
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
|
||||||
shell->GetShelfAutoHideBehavior());
|
shell->GetShelfAutoHideBehavior());
|
||||||
shell->SetShelfAutoHideBehavior(
|
|
||||||
LauncherContextMenu::GetToggledAutoHideBehavior());
|
|
||||||
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT,
|
|
||||||
shell->GetShelfAutoHideBehavior());
|
|
||||||
|
|
||||||
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
|
||||||
EXPECT_TRUE(LauncherContextMenu::IsAutoHideMenuHideChecked());
|
EXPECT_TRUE(LauncherContextMenu::IsAutoHideMenuHideChecked());
|
||||||
shell->SetShelfAutoHideBehavior(
|
shell->SetShelfAutoHideBehavior(
|
||||||
LauncherContextMenu::GetToggledAutoHideBehavior());
|
LauncherContextMenu::GetToggledAutoHideBehavior());
|
||||||
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
|
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
|
||||||
shell->GetShelfAutoHideBehavior());
|
shell->GetShelfAutoHideBehavior());
|
||||||
|
|
||||||
|
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
||||||
|
EXPECT_FALSE(LauncherContextMenu::IsAutoHideMenuHideChecked());
|
||||||
shell->SetShelfAutoHideBehavior(
|
shell->SetShelfAutoHideBehavior(
|
||||||
LauncherContextMenu::GetToggledAutoHideBehavior());
|
LauncherContextMenu::GetToggledAutoHideBehavior());
|
||||||
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT,
|
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
|
||||||
|
shell->GetShelfAutoHideBehavior());
|
||||||
|
EXPECT_TRUE(LauncherContextMenu::IsAutoHideMenuHideChecked());
|
||||||
|
shell->SetShelfAutoHideBehavior(
|
||||||
|
LauncherContextMenu::GetToggledAutoHideBehavior());
|
||||||
|
EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
|
||||||
shell->GetShelfAutoHideBehavior());
|
shell->GetShelfAutoHideBehavior());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -92,6 +92,8 @@ typedef test::AshTestBase RootWindowControllerTest;
|
|||||||
TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
|
TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
|
||||||
UpdateDisplay("600x600,500x500");
|
UpdateDisplay("600x600,500x500");
|
||||||
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
|
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
|
||||||
|
ash::Shell::GetInstance()->SetShelfAutoHideBehavior(
|
||||||
|
ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
||||||
|
|
||||||
views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100));
|
views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100));
|
||||||
EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow());
|
EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow());
|
||||||
@@ -147,7 +149,7 @@ TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
|
|||||||
EXPECT_EQ("50,10 100x100",
|
EXPECT_EQ("50,10 100x100",
|
||||||
normal->GetNativeView()->GetBoundsInRootWindow().ToString());
|
normal->GetNativeView()->GetBoundsInRootWindow().ToString());
|
||||||
|
|
||||||
// Maximized area on primary display has 2px (given as
|
// Maximized area on primary display has 3px (given as
|
||||||
// kAutoHideSize in shelf_layout_manager.cc) inset at the bottom.
|
// kAutoHideSize in shelf_layout_manager.cc) inset at the bottom.
|
||||||
EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow());
|
EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow());
|
||||||
EXPECT_EQ("0,0 600x597",
|
EXPECT_EQ("0,0 600x597",
|
||||||
|
@@ -22,6 +22,8 @@ typedef test::AshTestBase ScreenAshTest;
|
|||||||
#if !defined(OS_WIN)
|
#if !defined(OS_WIN)
|
||||||
TEST_F(ScreenAshTest, Bounds) {
|
TEST_F(ScreenAshTest, Bounds) {
|
||||||
UpdateDisplay("600x600,500x500");
|
UpdateDisplay("600x600,500x500");
|
||||||
|
Shell::GetInstance()->SetShelfAutoHideBehavior(
|
||||||
|
ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
||||||
|
|
||||||
views::Widget* primary =
|
views::Widget* primary =
|
||||||
views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100));
|
views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100));
|
||||||
@@ -39,7 +41,7 @@ TEST_F(ScreenAshTest, Bounds) {
|
|||||||
secondary->GetNativeView()).ToString());
|
secondary->GetNativeView()).ToString());
|
||||||
|
|
||||||
// Unmaximized work area bounds
|
// Unmaximized work area bounds
|
||||||
EXPECT_EQ("0,0 600x552",
|
EXPECT_EQ("0,0 600x597",
|
||||||
ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent(
|
ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent(
|
||||||
primary->GetNativeView()).ToString());
|
primary->GetNativeView()).ToString());
|
||||||
EXPECT_EQ("0,0 500x500",
|
EXPECT_EQ("0,0 500x500",
|
||||||
@@ -55,7 +57,7 @@ TEST_F(ScreenAshTest, Bounds) {
|
|||||||
secondary->GetNativeView()).ToString());
|
secondary->GetNativeView()).ToString());
|
||||||
|
|
||||||
// Work area bounds
|
// Work area bounds
|
||||||
EXPECT_EQ("0,0 600x552",
|
EXPECT_EQ("0,0 600x597",
|
||||||
ScreenAsh::GetDisplayWorkAreaBoundsInParent(
|
ScreenAsh::GetDisplayWorkAreaBoundsInParent(
|
||||||
primary->GetNativeView()).ToString());
|
primary->GetNativeView()).ToString());
|
||||||
EXPECT_EQ("0,0 500x500",
|
EXPECT_EQ("0,0 500x500",
|
||||||
|
@@ -175,7 +175,7 @@ class ShelfLayoutManager::UpdateShelfObserver
|
|||||||
ShelfLayoutManager::ShelfLayoutManager(views::Widget* status)
|
ShelfLayoutManager::ShelfLayoutManager(views::Widget* status)
|
||||||
: root_window_(Shell::GetPrimaryRootWindow()),
|
: root_window_(Shell::GetPrimaryRootWindow()),
|
||||||
in_layout_(false),
|
in_layout_(false),
|
||||||
auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT),
|
auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER),
|
||||||
alignment_(SHELF_ALIGNMENT_BOTTOM),
|
alignment_(SHELF_ALIGNMENT_BOTTOM),
|
||||||
launcher_(NULL),
|
launcher_(NULL),
|
||||||
status_(status),
|
status_(status),
|
||||||
@@ -297,8 +297,8 @@ void ShelfLayoutManager::UpdateVisibilityState() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WORKSPACE_WINDOW_STATE_MAXIMIZED:
|
case WORKSPACE_WINDOW_STATE_MAXIMIZED:
|
||||||
SetState(auto_hide_behavior_ != SHELF_AUTO_HIDE_BEHAVIOR_NEVER ?
|
SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ?
|
||||||
AUTO_HIDE : VISIBLE);
|
AUTO_HIDE : VISIBLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
|
case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
|
||||||
@@ -498,8 +498,7 @@ ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {}
|
|||||||
gfx::Rect ShelfLayoutManager::GetMaximizedWindowBounds(
|
gfx::Rect ShelfLayoutManager::GetMaximizedWindowBounds(
|
||||||
aura::Window* window) {
|
aura::Window* window) {
|
||||||
gfx::Rect bounds(ScreenAsh::GetDisplayBoundsInParent(window));
|
gfx::Rect bounds(ScreenAsh::GetDisplayBoundsInParent(window));
|
||||||
if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT ||
|
if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) {
|
||||||
auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) {
|
|
||||||
AdjustBoundsBasedOnAlignment(kAutoHideSize, &bounds);
|
AdjustBoundsBasedOnAlignment(kAutoHideSize, &bounds);
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
@@ -311,6 +311,7 @@ TEST_F(ShelfLayoutManagerTest, AutoHide) {
|
|||||||
generator.MoveMouseTo(0, 0);
|
generator.MoveMouseTo(0, 0);
|
||||||
|
|
||||||
ShelfLayoutManager* shelf = GetShelfLayoutManager();
|
ShelfLayoutManager* shelf = GetShelfLayoutManager();
|
||||||
|
shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
||||||
views::Widget* widget = new views::Widget;
|
views::Widget* widget = new views::Widget;
|
||||||
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
|
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
|
||||||
params.bounds = gfx::Rect(0, 0, 200, 200);
|
params.bounds = gfx::Rect(0, 0, 200, 200);
|
||||||
@@ -374,6 +375,7 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
|
|||||||
generator.MoveMouseTo(0, 0);
|
generator.MoveMouseTo(0, 0);
|
||||||
|
|
||||||
ShelfLayoutManager* shelf = GetShelfLayoutManager();
|
ShelfLayoutManager* shelf = GetShelfLayoutManager();
|
||||||
|
shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
||||||
views::Widget* widget = new views::Widget;
|
views::Widget* widget = new views::Widget;
|
||||||
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
|
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
|
||||||
params.bounds = gfx::Rect(0, 0, 200, 200);
|
params.bounds = gfx::Rect(0, 0, 200, 200);
|
||||||
@@ -434,20 +436,12 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
|
|||||||
aura::Window* window = widget->GetNativeWindow();
|
aura::Window* window = widget->GetNativeWindow();
|
||||||
gfx::Rect display_bounds(
|
gfx::Rect display_bounds(
|
||||||
gfx::Screen::GetDisplayNearestWindow(window).bounds());
|
gfx::Screen::GetDisplayNearestWindow(window).bounds());
|
||||||
EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
|
|
||||||
shelf->GetMaximizedWindowBounds(window).bottom());
|
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
|
||||||
|
|
||||||
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
||||||
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
|
EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
|
||||||
shelf->GetMaximizedWindowBounds(window).bottom());
|
shelf->GetMaximizedWindowBounds(window).bottom());
|
||||||
|
|
||||||
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
|
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
|
||||||
EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
|
|
||||||
shelf->GetMaximizedWindowBounds(window).bottom());
|
|
||||||
|
|
||||||
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
|
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
||||||
EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
|
EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize,
|
||||||
@@ -511,7 +505,7 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
|
|||||||
Shell* shell = Shell::GetInstance();
|
Shell* shell = Shell::GetInstance();
|
||||||
ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
|
ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
|
||||||
shelf->LayoutShelf();
|
shelf->LayoutShelf();
|
||||||
shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
|
shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
|
||||||
|
|
||||||
// Create a normal unmaximized windowm shelf should be visible.
|
// Create a normal unmaximized windowm shelf should be visible.
|
||||||
aura::Window* window = CreateTestWindow();
|
aura::Window* window = CreateTestWindow();
|
||||||
@@ -538,7 +532,7 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
|
|||||||
Shell* shell = Shell::GetInstance();
|
Shell* shell = Shell::GetInstance();
|
||||||
ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
|
ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
|
||||||
shelf->LayoutShelf();
|
shelf->LayoutShelf();
|
||||||
shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
|
shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
||||||
|
|
||||||
// Create a window and show it in maximized state.
|
// Create a window and show it in maximized state.
|
||||||
aura::Window* window = CreateTestWindow();
|
aura::Window* window = CreateTestWindow();
|
||||||
|
@@ -14,9 +14,6 @@ enum ShelfAlignment {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum ShelfAutoHideBehavior {
|
enum ShelfAutoHideBehavior {
|
||||||
// The default; maximized windows trigger an auto-hide.
|
|
||||||
SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT,
|
|
||||||
|
|
||||||
// Always auto-hide.
|
// Always auto-hide.
|
||||||
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
|
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
|
||||||
|
|
||||||
|
@@ -461,6 +461,7 @@ TEST_F(WorkspaceManager2Test, ShelfStateUpdated) {
|
|||||||
scoped_ptr<Window> w1(CreateTestWindow());
|
scoped_ptr<Window> w1(CreateTestWindow());
|
||||||
const gfx::Rect w1_bounds(0, 1, 101, 102);
|
const gfx::Rect w1_bounds(0, 1, 101, 102);
|
||||||
ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
|
ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
|
||||||
|
shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
||||||
const gfx::Rect touches_shelf_bounds(
|
const gfx::Rect touches_shelf_bounds(
|
||||||
0, shelf->GetIdealBounds().y() - 10, 101, 102);
|
0, shelf->GetIdealBounds().y() - 10, 101, 102);
|
||||||
// Move |w1| to overlap the shelf.
|
// Move |w1| to overlap the shelf.
|
||||||
@@ -483,7 +484,7 @@ TEST_F(WorkspaceManager2Test, ShelfStateUpdated) {
|
|||||||
w1->Show();
|
w1->Show();
|
||||||
wm::ActivateWindow(w1.get());
|
wm::ActivateWindow(w1.get());
|
||||||
|
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
|
|
||||||
// Maximize the window.
|
// Maximize the window.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
||||||
@@ -492,7 +493,7 @@ TEST_F(WorkspaceManager2Test, ShelfStateUpdated) {
|
|||||||
|
|
||||||
// Restore.
|
// Restore.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
||||||
|
|
||||||
// Fullscreen.
|
// Fullscreen.
|
||||||
@@ -501,7 +502,7 @@ TEST_F(WorkspaceManager2Test, ShelfStateUpdated) {
|
|||||||
|
|
||||||
// Normal.
|
// Normal.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
||||||
EXPECT_FALSE(GetWindowOverlapsShelf());
|
EXPECT_FALSE(GetWindowOverlapsShelf());
|
||||||
|
|
||||||
@@ -520,7 +521,7 @@ TEST_F(WorkspaceManager2Test, ShelfStateUpdated) {
|
|||||||
|
|
||||||
// Minimize.
|
// Minimize.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
|
|
||||||
// Since the restore from minimize will restore to the pre-minimize
|
// Since the restore from minimize will restore to the pre-minimize
|
||||||
// state (tested elsewhere), we abandon the current size and restore
|
// state (tested elsewhere), we abandon the current size and restore
|
||||||
@@ -533,7 +534,7 @@ TEST_F(WorkspaceManager2Test, ShelfStateUpdated) {
|
|||||||
|
|
||||||
// Restore.
|
// Restore.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
||||||
|
|
||||||
// Create another window, maximized.
|
// Create another window, maximized.
|
||||||
@@ -550,7 +551,7 @@ TEST_F(WorkspaceManager2Test, ShelfStateUpdated) {
|
|||||||
// Switch to w1.
|
// Switch to w1.
|
||||||
wm::ActivateWindow(w1.get());
|
wm::ActivateWindow(w1.get());
|
||||||
EXPECT_EQ(0, active_index());
|
EXPECT_EQ(0, active_index());
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
||||||
EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(
|
EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(
|
||||||
w2->parent()).ToString(),
|
w2->parent()).ToString(),
|
||||||
|
@@ -471,6 +471,7 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
|
|||||||
scoped_ptr<Window> w1(CreateTestWindow());
|
scoped_ptr<Window> w1(CreateTestWindow());
|
||||||
const gfx::Rect w1_bounds(0, 1, 101, 102);
|
const gfx::Rect w1_bounds(0, 1, 101, 102);
|
||||||
ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
|
ShelfLayoutManager* shelf = Shell::GetInstance()->shelf();
|
||||||
|
shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
||||||
const gfx::Rect touches_shelf_bounds(
|
const gfx::Rect touches_shelf_bounds(
|
||||||
0, shelf->GetIdealBounds().y() - 10, 101, 102);
|
0, shelf->GetIdealBounds().y() - 10, 101, 102);
|
||||||
// Move |w1| to overlap the shelf.
|
// Move |w1| to overlap the shelf.
|
||||||
@@ -493,7 +494,7 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
|
|||||||
w1->Show();
|
w1->Show();
|
||||||
wm::ActivateWindow(w1.get());
|
wm::ActivateWindow(w1.get());
|
||||||
|
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
|
|
||||||
// Maximize the window.
|
// Maximize the window.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
||||||
@@ -502,7 +503,7 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
|
|||||||
|
|
||||||
// Restore.
|
// Restore.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
||||||
|
|
||||||
// Fullscreen.
|
// Fullscreen.
|
||||||
@@ -511,7 +512,7 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
|
|||||||
|
|
||||||
// Normal.
|
// Normal.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
||||||
|
|
||||||
// Maximize again.
|
// Maximize again.
|
||||||
@@ -521,11 +522,11 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
|
|||||||
|
|
||||||
// Minimize.
|
// Minimize.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
|
|
||||||
// Restore.
|
// Restore.
|
||||||
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
||||||
|
|
||||||
// Create another window, maximized.
|
// Create another window, maximized.
|
||||||
@@ -539,7 +540,7 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
|
|||||||
|
|
||||||
// Switch to w1.
|
// Switch to w1.
|
||||||
w1->Show();
|
w1->Show();
|
||||||
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
|
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
||||||
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
|
||||||
EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(),
|
EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(),
|
||||||
w2->bounds().ToString());
|
w2->bounds().ToString());
|
||||||
|
@@ -35,7 +35,6 @@ namespace ash {
|
|||||||
const char kPinnedAppsPrefAppIDPath[] = "id";
|
const char kPinnedAppsPrefAppIDPath[] = "id";
|
||||||
|
|
||||||
const char kShelfAutoHideBehaviorAlways[] = "Always";
|
const char kShelfAutoHideBehaviorAlways[] = "Always";
|
||||||
const char kShelfAutoHideBehaviorDefault[] = "Default";
|
|
||||||
const char kShelfAutoHideBehaviorNever[] = "Never";
|
const char kShelfAutoHideBehaviorNever[] = "Never";
|
||||||
|
|
||||||
extern const char kShelfAlignmentBottom[] = "Bottom";
|
extern const char kShelfAlignmentBottom[] = "Bottom";
|
||||||
@@ -52,7 +51,7 @@ void RegisterChromeLauncherUserPrefs(PrefService* user_prefs) {
|
|||||||
CreateDefaultPinnedAppsList(),
|
CreateDefaultPinnedAppsList(),
|
||||||
PrefService::SYNCABLE_PREF);
|
PrefService::SYNCABLE_PREF);
|
||||||
user_prefs->RegisterStringPref(prefs::kShelfAutoHideBehavior,
|
user_prefs->RegisterStringPref(prefs::kShelfAutoHideBehavior,
|
||||||
kShelfAutoHideBehaviorDefault,
|
kShelfAutoHideBehaviorNever,
|
||||||
PrefService::SYNCABLE_PREF);
|
PrefService::SYNCABLE_PREF);
|
||||||
user_prefs->RegisterStringPref(prefs::kShelfAlignment,
|
user_prefs->RegisterStringPref(prefs::kShelfAlignment,
|
||||||
kShelfAlignmentBottom,
|
kShelfAlignmentBottom,
|
||||||
|
@@ -21,7 +21,6 @@ extern const char kPinnedAppsPrefAppIDPath[];
|
|||||||
|
|
||||||
// Values used for prefs::kShelfAutoHideBehavior.
|
// Values used for prefs::kShelfAutoHideBehavior.
|
||||||
extern const char kShelfAutoHideBehaviorAlways[];
|
extern const char kShelfAutoHideBehaviorAlways[];
|
||||||
extern const char kShelfAutoHideBehaviorDefault[];
|
|
||||||
extern const char kShelfAutoHideBehaviorNever[];
|
extern const char kShelfAutoHideBehaviorNever[];
|
||||||
|
|
||||||
// Values used for prefs::kShelfAlignment.
|
// Values used for prefs::kShelfAlignment.
|
||||||
|
@@ -482,9 +482,6 @@ void ChromeLauncherController::SetAutoHideBehavior(
|
|||||||
ash::Shell::GetInstance()->SetShelfAutoHideBehavior(behavior);
|
ash::Shell::GetInstance()->SetShelfAutoHideBehavior(behavior);
|
||||||
const char* value = NULL;
|
const char* value = NULL;
|
||||||
switch (behavior) {
|
switch (behavior) {
|
||||||
case ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT:
|
|
||||||
value = ash::kShelfAutoHideBehaviorDefault;
|
|
||||||
break;
|
|
||||||
case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
|
case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
|
||||||
value = ash::kShelfAutoHideBehaviorAlways;
|
value = ash::kShelfAutoHideBehaviorAlways;
|
||||||
break;
|
break;
|
||||||
@@ -852,13 +849,16 @@ void ChromeLauncherController::UpdateAppLaunchersFromPref() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() {
|
void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() {
|
||||||
|
// Note: To maintain sync compatibility with old images of chrome/chromeos
|
||||||
|
// the set of values that may be encountered includes the now-extinct
|
||||||
|
// "Default" as well as "Never" and "Always", "Default" should now
|
||||||
|
// be treated as "Never".
|
||||||
|
// (http://code.google.com/p/chromium/issues/detail?id=146773)
|
||||||
const std::string behavior_value(
|
const std::string behavior_value(
|
||||||
profile_->GetPrefs()->GetString(prefs::kShelfAutoHideBehavior));
|
profile_->GetPrefs()->GetString(prefs::kShelfAutoHideBehavior));
|
||||||
ash::ShelfAutoHideBehavior behavior =
|
ash::ShelfAutoHideBehavior behavior =
|
||||||
ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT;
|
ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
|
||||||
if (behavior_value == ash::kShelfAutoHideBehaviorNever)
|
if (behavior_value == ash::kShelfAutoHideBehaviorAlways)
|
||||||
behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
|
|
||||||
else if (behavior_value == ash::kShelfAutoHideBehaviorAlways)
|
|
||||||
behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
|
behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
|
||||||
ash::Shell::GetInstance()->SetShelfAutoHideBehavior(behavior);
|
ash::Shell::GetInstance()->SetShelfAutoHideBehavior(behavior);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user