Commit ef80e430 authored by oshima@chromium.org's avatar oshima@chromium.org

Cleanup enums for shelf

- move enums from ShelfLayoutManager to shelf_types.h
- remove redundant VisibilityState
- added SHELF_ prefix to these state.

BUG=151417
TEST=none

Review URL: https://chromiumcodereview.appspot.com/11316323

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171024 0039d316-1c4b-4281-b951-d872f2087c98
parent 5bb6f3c5
......@@ -151,6 +151,7 @@
'shell.h',
'shell_delegate.h',
'shell_factory.h',
'shelf_types.h',
'shell_window_ids.h',
'system/audio/audio_observer.h',
'system/audio/tray_volume.cc',
......@@ -353,7 +354,6 @@
'wm/session_state_observer.h',
'wm/shelf_layout_manager.cc',
'wm/shelf_layout_manager.h',
'wm/shelf_types.h',
'wm/stacking_controller.cc',
'wm/stacking_controller.h',
'wm/status_area_layout_manager.cc',
......
......@@ -8,7 +8,7 @@
#include "ash/ash_export.h"
#include "ash/launcher/background_animator.h"
#include "ash/launcher/launcher_types.h"
#include "ash/wm/shelf_types.h"
#include "ash/shelf_types.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/size.h"
......
......@@ -4,8 +4,8 @@
#include "ash/launcher/launcher_alignment_menu.h"
#include "ash/shelf_types.h"
#include "ash/shell.h"
#include "ash/wm/shelf_types.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
......
......@@ -6,7 +6,7 @@
#define ASH_LAUNCHER_LAUNCHER_BUTTON_HOST_H_
#include "ash/ash_export.h"
#include "ash/wm/shelf_types.h"
#include "ash/shelf_types.h"
#include "base/string16.h"
namespace ui {
......
......@@ -322,16 +322,16 @@ void LauncherTooltipManager::WillDeleteShelf() {
}
void LauncherTooltipManager::WillChangeVisibilityState(
ShelfLayoutManager::VisibilityState new_state) {
if (new_state == ShelfLayoutManager::HIDDEN) {
ShelfVisibilityState new_state) {
if (new_state == SHELF_HIDDEN) {
StopTimer();
Close();
}
}
void LauncherTooltipManager::OnAutoHideStateChanged(
ShelfLayoutManager::AutoHideState new_state) {
if (new_state == ShelfLayoutManager::AUTO_HIDE_HIDDEN) {
ShelfAutoHideState new_state) {
if (new_state == SHELF_AUTO_HIDE_HIDDEN) {
StopTimer();
// AutoHide state change happens during an event filter, so immediate close
// may cause a crash in the HandleMouseEvent() after the filter. So we just
......
......@@ -6,9 +6,9 @@
#define ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_
#include "ash/ash_export.h"
#include "ash/shelf_types.h"
#include "ash/wm/session_state_observer.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/shelf_types.h"
#include "base/basictypes.h"
#include "base/string16.h"
#include "ui/base/events/event_handler.h"
......@@ -84,9 +84,8 @@ protected:
// ShelfLayoutManager::Observer overrides:
virtual void WillDeleteShelf() OVERRIDE;
virtual void WillChangeVisibilityState(
ShelfLayoutManager::VisibilityState new_state) OVERRIDE;
virtual void OnAutoHideStateChanged(
ShelfLayoutManager::AutoHideState new_state) OVERRIDE;
ShelfVisibilityState new_state) OVERRIDE;
virtual void OnAutoHideStateChanged(ShelfAutoHideState new_state) OVERRIDE;
private:
class LauncherTooltipBubble;
......
......@@ -110,7 +110,7 @@ TEST_F(LauncherTooltipManagerTest, HideWhenShelfIsHidden) {
// Once the shelf is hidden, the tooltip should be invisible.
ASSERT_EQ(
internal::ShelfLayoutManager::HIDDEN,
SHELF_HIDDEN,
Shell::GetPrimaryRootWindowController()->shelf()->visibility_state());
EXPECT_FALSE(TooltipIsVisible());
......@@ -131,8 +131,7 @@ TEST_F(LauncherTooltipManagerTest, HideWhenShelfIsAutoHide) {
Shell::GetPrimaryRootWindowController()->shelf();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
shelf->UpdateAutoHideState();
ASSERT_EQ(internal::ShelfLayoutManager::AUTO_HIDE_HIDDEN,
shelf->auto_hide_state());
ASSERT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
// Tooltip visibility change for auto hide may take time.
EXPECT_TRUE(TooltipIsVisible());
......
......@@ -10,8 +10,8 @@
#include "ash/launcher/launcher_button_host.h"
#include "ash/launcher/launcher_model_observer.h"
#include "ash/shelf_types.h"
#include "ash/wm/gestures/shelf_gesture_handler.h"
#include "ash/wm/shelf_types.h"
#include "base/observer_list.h"
#include "ui/views/animation/bounds_animator_observer.h"
#include "ui/views/context_menu_controller.h"
......
......@@ -5,7 +5,7 @@
#ifndef ASH_LAUNCHER_OVERFLOW_BUBBLE_H_
#define ASH_LAUNCHER_OVERFLOW_BUBBLE_H_
#include "ash/wm/shelf_types.h"
#include "ash/shelf_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/views/widget/widget_observer.h"
......
......@@ -5,7 +5,7 @@
#ifndef ASH_LAUNCHER_OVERFLOW_BUTTON_H_
#define ASH_LAUNCHER_OVERFLOW_BUTTON_H_
#include "ash/wm/shelf_types.h"
#include "ash/shelf_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/views/controls/button/custom_button.h"
......
......@@ -11,6 +11,7 @@
#include "ash/display/display_controller.h"
#include "ash/display/display_manager.h"
#include "ash/focus_cycler.h"
#include "ash/shelf_types.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_factory.h"
......@@ -25,7 +26,6 @@
#include "ash/wm/root_window_layout_manager.h"
#include "ash/wm/screen_dimmer.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/shelf_types.h"
#include "ash/wm/status_area_layout_manager.h"
#include "ash/wm/system_background_controller.h"
#include "ash/wm/system_modal_container_layout_manager.h"
......
......@@ -6,8 +6,8 @@
#define ASH_ROOT_WINDOW_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/shelf_types.h"
#include "ash/system/user/login_status.h"
#include "ash/wm/shelf_types.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_SHELF_TYPES_H_
#define ASH_WM_SHELF_TYPES_H_
#ifndef ASH_SHELF_TYPES_H_
#define ASH_SHELF_TYPES_H_
namespace ash {
......@@ -21,6 +21,22 @@ enum ShelfAutoHideBehavior {
SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
};
enum ShelfVisibilityState {
// Always visible.
SHELF_VISIBLE,
// A couple of pixels are reserved at the bottom for the shelf.
SHELF_AUTO_HIDE,
// Nothing is shown. Used for fullscreen windows.
SHELF_HIDDEN,
};
enum ShelfAutoHideState {
SHELF_AUTO_HIDE_SHOWN,
SHELF_AUTO_HIDE_HIDDEN,
};
} // namespace ash
#endif // ASH_WM_SHELF_TYPES_H_
#endif // ASH_SHELF_TYPES_H_
......@@ -9,9 +9,9 @@
#include <vector>
#include "ash/ash_export.h"
#include "ash/shelf_types.h"
#include "ash/system/user/login_status.h"
#include "ash/wm/cursor_manager.h"
#include "ash/wm/shelf_types.h"
#include "ash/wm/system_modal_container_event_filter_delegate.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
......
......@@ -6,8 +6,8 @@
#include "ash/launcher/launcher.h"
#include "ash/root_window_controller.h"
#include "ash/shelf_types.h"
#include "ash/shell.h"
#include "ash/wm/shelf_types.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
......
......@@ -6,7 +6,7 @@
#define ASH_WM_SHELL_CONTEXT_MENU_H_
#include "ash/launcher/launcher_alignment_menu.h"
#include "ash/wm/shelf_types.h"
#include "ash/shelf_types.h"
#include "base/basictypes.h"
#include "ui/base/models/simple_menu_model.h"
......
......@@ -318,19 +318,19 @@ TEST_F(ShellTest, FullscreenWindowHidesShelf) {
// Shelf defaults to visible.
EXPECT_EQ(
internal::ShelfLayoutManager::VISIBLE,
SHELF_VISIBLE,
Shell::GetPrimaryRootWindowController()->shelf()->visibility_state());
// Fullscreen window hides it.
widget->SetFullscreen(true);
EXPECT_EQ(
internal::ShelfLayoutManager::HIDDEN,
SHELF_HIDDEN,
Shell::GetPrimaryRootWindowController()->shelf()->visibility_state());
// Restoring the window restores it.
widget->Restore();
EXPECT_EQ(
internal::ShelfLayoutManager::VISIBLE,
SHELF_VISIBLE,
Shell::GetPrimaryRootWindowController()->shelf()->visibility_state());
// Clean up.
......
......@@ -7,8 +7,8 @@
#include "ash/ash_export.h"
#include "ash/launcher/background_animator.h"
#include "ash/shelf_types.h"
#include "ash/system/user/login_status.h"
#include "ash/wm/shelf_types.h"
#include "ui/views/widget/widget.h"
namespace ash {
......
......@@ -6,8 +6,8 @@
#define ASH_SYSTEM_STATUS_AREA_WIDGET_DELEGATE_H_
#include "ash/ash_export.h"
#include "ash/shelf_types.h"
#include "ash/wm/gestures/shelf_gesture_handler.h"
#include "ash/wm/shelf_types.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/accessible_pane_view.h"
#include "ui/views/widget/widget_delegate.h"
......
......@@ -6,8 +6,8 @@
#define ASH_SYSTEM_TRAY_SYSTEM_TRAY_ITEM_H_
#include "ash/ash_export.h"
#include "ash/shelf_types.h"
#include "ash/system/user/login_status.h"
#include "ash/wm/shelf_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
......
......@@ -7,8 +7,8 @@
#include "ash/ash_export.h"
#include "ash/launcher/background_animator.h"
#include "ash/shelf_types.h"
#include "ash/system/tray/tray_views.h"
#include "ash/wm/shelf_types.h"
#include "ui/views/bubble/tray_bubble_view.h"
namespace ash {
......
......@@ -4,9 +4,9 @@
#include "ash/system/tray/tray_item_view.h"
#include "ash/shelf_types.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_item.h"
#include "ash/wm/shelf_types.h"
#include "ui/base/animation/slide_animation.h"
#include "ui/compositor/layer.h"
#include "ui/views/controls/image_view.h"
......
......@@ -6,7 +6,7 @@
#define ASH_SYSTEM_TRAY_TRAY_VIEWS_H_
#include "ash/ash_export.h"
#include "ash/wm/shelf_types.h"
#include "ash/shelf_types.h"
#include "ui/gfx/font.h"
#include "ui/gfx/size.h"
#include "ui/views/controls/button/custom_button.h"
......
......@@ -5,12 +5,12 @@
#include "ash/wm/gestures/shelf_gesture_handler.h"
#include "ash/root_window_controller.h"
#include "ash/shelf_types.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/system/status_area_widget.h"
#include "ash/wm/gestures/tray_gesture_handler.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/shelf_types.h"
#include "ash/wm/window_util.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
......
......@@ -157,7 +157,7 @@ ShelfLayoutManager::ShelfLayoutManager(StatusAreaWidget* status_area_widget)
window_overlaps_shelf_(false),
gesture_drag_status_(GESTURE_DRAG_NONE),
gesture_drag_amount_(0.f),
gesture_drag_auto_hide_state_(AUTO_HIDE_SHOWN),
gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN),
update_shelf_observer_(NULL) {
Shell::GetInstance()->AddShellObserver(this);
aura::client::GetActivationClient(root_window_)->AddObserver(this);
......@@ -183,9 +183,9 @@ void ShelfLayoutManager::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) {
bool ShelfLayoutManager::IsVisible() const {
return status_area_widget_->IsVisible() &&
(state_.visibility_state == VISIBLE ||
(state_.visibility_state == AUTO_HIDE &&
state_.auto_hide_state == AUTO_HIDE_SHOWN));
(state_.visibility_state == SHELF_VISIBLE ||
(state_.visibility_state == SHELF_AUTO_HIDE &&
state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN));
}
void ShelfLayoutManager::SetLauncher(Launcher* launcher) {
......@@ -258,25 +258,25 @@ void ShelfLayoutManager::LayoutShelf() {
void ShelfLayoutManager::UpdateVisibilityState() {
ShellDelegate* delegate = Shell::GetInstance()->delegate();
if (delegate && delegate->IsScreenLocked()) {
SetState(VISIBLE);
SetState(SHELF_VISIBLE);
} else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) {
SetState(AUTO_HIDE);
SetState(SHELF_AUTO_HIDE);
} else {
WorkspaceWindowState window_state(workspace_controller_->GetWindowState());
switch (window_state) {
case WORKSPACE_WINDOW_STATE_FULL_SCREEN:
SetState(HIDDEN);
SetState(SHELF_HIDDEN);
break;
case WORKSPACE_WINDOW_STATE_MAXIMIZED:
SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ?
AUTO_HIDE : VISIBLE);
SHELF_AUTO_HIDE : SHELF_VISIBLE);
break;
case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
case WORKSPACE_WINDOW_STATE_DEFAULT:
SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ?
AUTO_HIDE : VISIBLE);
SHELF_AUTO_HIDE : SHELF_VISIBLE);
SetWindowOverlapsShelf(window_state ==
WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF);
break;
......@@ -285,10 +285,10 @@ void ShelfLayoutManager::UpdateVisibilityState() {
}
void ShelfLayoutManager::UpdateAutoHideState() {
AutoHideState auto_hide_state =
ShelfAutoHideState auto_hide_state =
CalculateAutoHideState(state_.visibility_state);
if (auto_hide_state != state_.auto_hide_state) {
if (auto_hide_state == AUTO_HIDE_HIDDEN) {
if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) {
// Hides happen immediately.
SetState(state_.visibility_state);
FOR_EACH_OBSERVER(Observer, observers_,
......@@ -326,8 +326,8 @@ void ShelfLayoutManager::RemoveObserver(Observer* observer) {
void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS;
gesture_drag_amount_ = 0.f;
gesture_drag_auto_hide_state_ = visibility_state() == AUTO_HIDE ?
auto_hide_state() : AUTO_HIDE_SHOWN;
gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE ?
auto_hide_state() : SHELF_AUTO_HIDE_SHOWN;
UpdateShelfBackground(internal::BackgroundAnimator::CHANGE_ANIMATE);
}
......@@ -343,7 +343,8 @@ ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag(
// - dragging up on a hidden shelf, but it is currently completely visible.
if (horizontal && gesture.details().scroll_y() < 0) {
int min_height = 0;
if (gesture_drag_auto_hide_state_ == AUTO_HIDE_HIDDEN && launcher_widget())
if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN &&
launcher_widget())
min_height = launcher_widget()->GetContentsView()->
GetPreferredSize().height();
......@@ -368,7 +369,7 @@ void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
gfx::Rect bounds = GetIdealBounds();
float drag_ratio = fabs(gesture_drag_amount_) /
(horizontal ? bounds.height() : bounds.width());
if (gesture_drag_auto_hide_state_ == AUTO_HIDE_SHOWN) {
if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) {
should_change = drag_ratio > kDragHideThreshold;
} else {
bool correct_direction = false;
......@@ -384,7 +385,7 @@ void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
should_change = correct_direction && drag_ratio > kDragHideThreshold;
}
} else if (gesture.type() == ui::ET_SCROLL_FLING_START) {
if (gesture_drag_auto_hide_state_ == AUTO_HIDE_SHOWN) {
if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) {
should_change = horizontal ? fabs(gesture.details().velocity_y()) > 0 :
fabs(gesture.details().velocity_x()) > 0;
} else {
......@@ -405,16 +406,16 @@ void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
}
gesture_drag_auto_hide_state_ =
gesture_drag_auto_hide_state_ == AUTO_HIDE_SHOWN ? AUTO_HIDE_HIDDEN :
AUTO_HIDE_SHOWN;
gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ?
SHELF_AUTO_HIDE_HIDDEN : SHELF_AUTO_HIDE_SHOWN;
if (launcher_widget())
launcher_widget()->Deactivate();
status_area_widget_->Deactivate();
if (gesture_drag_auto_hide_state_ == AUTO_HIDE_HIDDEN &&
if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN &&
auto_hide_behavior_ != SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) {
gesture_drag_status_ = GESTURE_DRAG_NONE;
SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
} else if (gesture_drag_auto_hide_state_ == AUTO_HIDE_SHOWN &&
} else if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN &&
auto_hide_behavior_ != SHELF_AUTO_HIDE_BEHAVIOR_NEVER) {
gesture_drag_status_ = GESTURE_DRAG_NONE;
SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
......@@ -481,7 +482,7 @@ void ShelfLayoutManager::OnWindowActivated(aura::Window* active,
ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {}
void ShelfLayoutManager::SetState(VisibilityState visibility_state) {
void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
ShellDelegate* delegate = Shell::GetInstance()->delegate();
State state;
state.visibility_state = visibility_state;
......@@ -492,7 +493,7 @@ void ShelfLayoutManager::SetState(VisibilityState visibility_state) {
// won't have changed value. Do the dimming check before the early exit.
if (launcher_ && workspace_controller_) {
launcher_->SetDimsShelf(
(state.visibility_state == VISIBLE) &&
(state.visibility_state == SHELF_VISIBLE) &&
workspace_controller_->GetWindowState() ==
WORKSPACE_WINDOW_STATE_MAXIMIZED);
}
......@@ -503,8 +504,8 @@ void ShelfLayoutManager::SetState(VisibilityState visibility_state) {
FOR_EACH_OBSERVER(Observer, observers_,
WillChangeVisibilityState(visibility_state));
if (state.visibility_state == AUTO_HIDE) {
// When state is AUTO_HIDE we need to track when the mouse is over the
if (state.visibility_state == SHELF_AUTO_HIDE) {
// When state is SHELF_AUTO_HIDE we need to track when the mouse is over the
// launcher to unhide the shelf. AutoHideEventFilter does that for us.
if (!event_filter_.get())
event_filter_.reset(new AutoHideEventFilter(this));
......@@ -517,9 +518,9 @@ void ShelfLayoutManager::SetState(VisibilityState visibility_state) {
// Animating the background when transitioning from auto-hide & hidden to
// visible is janky. Update the background immediately in this case.
internal::BackgroundAnimator::ChangeType change_type =
(state_.visibility_state == AUTO_HIDE &&
state_.auto_hide_state == AUTO_HIDE_HIDDEN &&
state.visibility_state == VISIBLE) ?
(state_.visibility_state == SHELF_AUTO_HIDE &&
state_.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN &&
state.visibility_state == SHELF_VISIBLE) ?
internal::BackgroundAnimator::CHANGE_IMMEDIATE :
internal::BackgroundAnimator::CHANGE_ANIMATE;
StopAnimating();
......@@ -544,19 +545,19 @@ void ShelfLayoutManager::SetState(VisibilityState visibility_state) {
base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS));
status_animation_setter.SetTweenType(ui::Tween::EASE_OUT);
// Delay updating the background when going from AUTO_HIDE_SHOWN to
// AUTO_HIDE_HIDDEN until the shelf animates out. Otherwise during the
// Delay updating the background when going from SHELF_AUTO_HIDE_SHOWN to
// SHELF_AUTO_HIDE_HIDDEN until the shelf animates out. Otherwise during the
// animation you see the background change.
// Also delay the animation when the shelf was hidden, and has just been made
// visible (e.g. using a gesture-drag).
bool delay_shelf_update =
state.visibility_state == AUTO_HIDE &&
state.auto_hide_state == AUTO_HIDE_HIDDEN &&
old_state.visibility_state == AUTO_HIDE;
state.visibility_state == SHELF_AUTO_HIDE &&
state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN &&
old_state.visibility_state == SHELF_AUTO_HIDE;
if (state.visibility_state == VISIBLE &&
old_state.visibility_state == AUTO_HIDE &&
old_state.auto_hide_state == AUTO_HIDE_HIDDEN)
if (state.visibility_state == SHELF_VISIBLE &&
old_state.visibility_state == SHELF_AUTO_HIDE &&
old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN)
delay_shelf_update = true;
if (delay_shelf_update) {
......@@ -620,14 +621,14 @@ void ShelfLayoutManager::CalculateTargetBounds(
int shelf_size = 0;
int shelf_width = 0, shelf_height = 0;
GetShelfSize(&shelf_width, &shelf_height);
if (state.visibility_state == VISIBLE ||
(state.visibility_state == AUTO_HIDE &&
state.auto_hide_state == AUTO_HIDE_SHOWN)) {
if (state.visibility_state == SHELF_VISIBLE ||
(state.visibility_state == SHELF_AUTO_HIDE &&
state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)) {
shelf_size = std::max(shelf_width, shelf_height);
launcher_size.set_width(std::max(shelf_width,launcher_size.width()));
launcher_size.set_height(std::max(shelf_height,launcher_size.height()));
} else if (state.visibility_state == AUTO_HIDE &&
state.auto_hide_state == AUTO_HIDE_HIDDEN) {
} else if (state.visibility_state == SHELF_AUTO_HIDE &&
state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) {
shelf_size = kAutoHideSize;
// Keep the launcher to its full height when dragging is in progress.
if (gesture_drag_status_ == GESTURE_DRAG_NONE) {
......@@ -684,8 +685,8 @@ void ShelfLayoutManager::CalculateTargetBounds(
}
target_bounds->opacity =
(gesture_drag_status_ != GESTURE_DRAG_NONE ||
state.visibility_state == VISIBLE ||
state.visibility_state == AUTO_HIDE) ? 1.0f : 0.0f;
state.visibility_state == SHELF_VISIBLE ||
state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f;
if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS)
UpdateTargetBoundsForGesture(target_bounds);
}
......@@ -696,8 +697,9 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture(
bool horizontal = alignment() == SHELF_ALIGNMENT_BOTTOM;
int resistance_free_region = 0;
if (gesture_drag_auto_hide_state_ == AUTO_HIDE_HIDDEN &&
visibility_state() == AUTO_HIDE && auto_hide_state() != AUTO_HIDE_SHOWN) {
if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN &&
visibility_state() == SHELF_AUTO_HIDE &&
auto_hide_state() != SHELF_AUTO_HIDE_SHOWN) {
// If the shelf was hidden when the drag started (and the state hasn't
// changed since then, e.g. because the tray-menu was shown because of the
// drag), then allow the drag some resistance-free region at first to make
......@@ -797,40 +799,40 @@ void ShelfLayoutManager::UpdateShelfBackground(
bool ShelfLayoutManager::GetLauncherPaintsBackground() const {
return gesture_drag_status_ != GESTURE_DRAG_NONE ||
(!state_.is_screen_locked && window_overlaps_shelf_) ||
(state_.visibility_state == AUTO_HIDE) ;
(state_.visibility_state == SHELF_AUTO_HIDE) ;
}
void ShelfLayoutManager::UpdateAutoHideStateNow() {
SetState(state_.visibility_state);
}
ShelfLayoutManager::AutoHideState ShelfLayoutManager::CalculateAutoHideState(
VisibilityState visibility_state) const {
if (visibility_state != AUTO_HIDE || !launcher_widget())
return AUTO_HIDE_HIDDEN;
ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
ShelfVisibilityState visibility_state) const {
if (visibility_state != SHELF_AUTO_HIDE || !launcher_widget())
return SHELF_AUTO_HIDE_HIDDEN;
if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS)
return gesture_drag_auto_hide_state_;
Shell* shell = Shell::GetInstance();
if (shell->GetAppListTargetVisibility())
return AUTO_HIDE_SHOWN;
return SHELF_AUTO_HIDE_SHOWN;
if (status_area_widget_ && status_area_widget_->ShouldShowLauncher())
return AUTO_HIDE_SHOWN;
return SHELF_AUTO_HIDE_SHOWN;
if (launcher_ && launcher_->IsShowingMenu())
return AUTO_HIDE_SHOWN;
return SHELF_AUTO_HIDE_SHOWN;
if (launcher_ && launcher_->IsShowingOverflowBubble())
return AUTO_HIDE_SHOWN;
return SHELF_AUTO_HIDE_SHOWN;
if (launcher_widget()->IsActive() || status_area_widget_->IsActive())
return AUTO_HIDE_SHOWN;
return SHELF_AUTO_HIDE_SHOWN;
// Don't show if the user is dragging the mouse.
if (event_filter_.get() && event_filter_->in_mouse_drag())
return AUTO_HIDE_HIDDEN;
return SHELF_AUTO_HIDE_HIDDEN;
gfx::Rect shelf_region = launcher_widget()->GetWindowBoundsInScreen();
if (status_area_widget_ &&
......@@ -847,14 +849,14 @@ ShelfLayoutManager::AutoHideState ShelfLayoutManager::CalculateAutoHideState(
0);
}
return shelf_region.Contains(Shell::GetScreen()->GetCursorScreenPoint()) ?
AUTO_HIDE_SHOWN : AUTO_HIDE_HIDDEN;
SHELF_AUTO_HIDE_SHOWN : SHELF_AUTO_HIDE_HIDDEN;
}
void ShelfLayoutManager::UpdateHitTestBounds() {
gfx::Insets insets;
// Only modify the hit test when the shelf is visible, so we don't mess with
// hover hit testing in the auto-hide state.
if (state_.visibility_state == VISIBLE) {
if (state_.visibility_state == SHELF_VISIBLE) {
// Let clicks at the very top of the launcher through so windows can be
// resized with the bottom-right corner and bottom edge.
switch (alignment_) {
......@@ -886,9 +888,9 @@ bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) {
}
int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const {
if (state.visibility_state == VISIBLE)
if (state.visibility_state == SHELF_VISIBLE)
return size;
if (state.visibility_state == AUTO_HIDE)
if (state.visibility_state == SHELF_AUTO_HIDE)
return kAutoHideSize;
return 0;
}
......
......@@ -7,8 +7,8 @@
#include "ash/ash_export.h"
#include "ash/launcher/launcher.h"
#include "ash/shelf_types.h"
#include "ash/shell_observer.h"
#include "ash/wm/shelf_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/observer_list.h"
......@@ -45,32 +45,16 @@ class ASH_EXPORT ShelfLayoutManager :
public ash::ShellObserver,
public views::corewm::ActivationChangeShim {
public:
enum VisibilityState {
// Completely visible.
VISIBLE,
// A couple of pixels are reserved at the bottom for the shelf.
AUTO_HIDE,
// Nothing is shown. Used for fullscreen windows.
HIDDEN,
};
enum AutoHideState {
AUTO_HIDE_SHOWN,
AUTO_HIDE_HIDDEN,
};
class ASH_EXPORT Observer {
public:
// Called when the target ShelfLayoutManager will be deleted.
virtual void WillDeleteShelf() {}
// Called when the visibility change is scheduled.
virtual void WillChangeVisibilityState(VisibilityState new_state) {}
virtual void WillChangeVisibilityState(ShelfVisibilityState new_state) {}
// Called when the auto hide state is changed.
virtual void OnAutoHideStateChanged(AutoHideState new_state) {}
virtual void OnAutoHideStateChanged(ShelfAutoHideState new_state) {}
};
// We reserve a small area at the bottom of the workspace area to ensure that
......@@ -129,8 +113,10 @@ class ASH_EXPORT ShelfLayoutManager :
// Invoked by the shelf/launcher when the auto-hide state may have changed.
void UpdateAutoHideState();
VisibilityState visibility_state() const { return state_.visibility_state; }
AutoHideState auto_hide_state() const { return state_.auto_hide_state; }
ShelfVisibilityState visibility_state() const {
return state_.visibility_state;
}
ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; }
// Sets whether any windows overlap the shelf. If a window overlaps the shelf
// the shelf renders slightly differently.
......@@ -186,27 +172,28 @@ class ASH_EXPORT ShelfLayoutManager :
};
struct State {
State() : visibility_state(VISIBLE),
auto_hide_state(AUTO_HIDE_HIDDEN),
State() : visibility_state(SHELF_VISIBLE),
auto_hide_state(SHELF_AUTO_HIDE_HIDDEN),
is_screen_locked(false) {}
// Returns true if the two states are considered equal. As
// |auto_hide_state| only matters if |visibility_state| is |AUTO_HIDE|,
// Equals() ignores the |auto_hide_state| as appropriate.
// |auto_hide_state| only matters if |visibility_state| is
// |SHELF_AUTO_HIDE|, Equals() ignores the |auto_hide_state| as
// appropriate.
bool Equals(const State& other) const {
return other.visibility_state == visibility_state &&
(visibility_state != AUTO_HIDE ||
(visibility_state != SHELF_AUTO_HIDE ||
other.auto_hide_state == auto_hide_state) &&
other.is_screen_locked == is_screen_locked;
}
VisibilityState visibility_state;
AutoHideState auto_hide_state;
ShelfVisibilityState visibility_state;
ShelfAutoHideState auto_hide_state;
bool is_screen_locked;
};
// Sets the visibility of the shelf to |state|.
void SetState(VisibilityState visibility_state);
void SetState(ShelfVisibilityState visibility_state);
// Stops any animations.
void StopAnimating();
......@@ -236,7 +223,8 @@ class ASH_EXPORT ShelfLayoutManager :
// Returns the AutoHideState. This value is determined from the launcher and
// tray.
AutoHideState CalculateAutoHideState(VisibilityState visibility_state) const;
ShelfAutoHideState CalculateAutoHideState(
ShelfVisibilityState visibility_state) const;
// Updates the hit test bounds override for launcher and status area.
void UpdateHitTestBounds();
......@@ -299,7 +287,7 @@ class ASH_EXPORT ShelfLayoutManager :
float gesture_drag_amount_;
// Manage the auto-hide state during the gesture.
AutoHideState gesture_drag_auto_hide_state_;
ShelfAutoHideState gesture_drag_auto_hide_state_;
// Used to delay updating shelf background.
UpdateShelfObserver* update_shelf_observer_;
......
......@@ -67,7 +67,7 @@ class ShelfLayoutObserverTest : public ShelfLayoutManager::Observer {
private:
virtual void OnAutoHideStateChanged(
ShelfLayoutManager::AutoHideState new_state) OVERRIDE {
ShelfAutoHideState new_state) OVERRIDE {
changed_auto_hide_state_ = true;
}
......@@ -158,7 +158,7 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase {
}
void SetState(ShelfLayoutManager* shelf,
ShelfLayoutManager::VisibilityState state) {
ShelfVisibilityState state) {
shelf->SetState(state);
}
......@@ -196,7 +196,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
ShelfLayoutManager* shelf = GetShelfLayoutManager();
// Force an initial layout.
shelf->LayoutShelf();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
gfx::Rect status_bounds(
shelf->status_area_widget()->GetWindowBoundsInScreen());
......@@ -212,11 +212,11 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
display.bounds().bottom() - display.work_area().bottom());
// Hide the shelf.
SetState(shelf, ShelfLayoutManager::HIDDEN);
SetState(shelf, SHELF_HIDDEN);
// Run the animation to completion.
StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
StepWidgetLayerAnimatorToEnd(shelf->status_area_widget());
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
EXPECT_EQ(0,
display.bounds().bottom() - display.work_area().bottom());
......@@ -227,11 +227,11 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom());
// And show it again.
SetState(shelf, ShelfLayoutManager::VISIBLE);
SetState(shelf, SHELF_VISIBLE);
// Run the animation to completion.
StepWidgetLayerAnimatorToEnd(shelf->launcher_widget());
StepWidgetLayerAnimatorToEnd(shelf->status_area_widget());
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(shelf_height,
display.bounds().bottom() - display.work_area().bottom());
......@@ -252,15 +252,15 @@ TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
ShelfLayoutManager* shelf = GetShelfLayoutManager();
// Force an initial layout.
shelf->LayoutShelf();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
const gfx::Display& display = Shell::GetInstance()->display_manager()->
GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
// Hide the shelf.
SetState(shelf, ShelfLayoutManager::HIDDEN);
SetState(shelf, SHELF_HIDDEN);
shelf->LayoutShelf();
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
EXPECT_EQ(0, display.bounds().bottom() - display.work_area().bottom());
// Make sure the bounds of the two widgets changed.
......@@ -322,8 +322,8 @@ TEST_F(ShelfLayoutManagerTest, AutoHide) {
widget->Init(params);
widget->Maximize();
widget->Show();
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
// LayoutShelf() forces the animation to completion, at which point the
// launcher should go off the screen.
......@@ -338,8 +338,8 @@ TEST_F(ShelfLayoutManagerTest, AutoHide) {
generator.MoveMouseTo(0, root->bounds().bottom() - 1);
// Shelf should be shown again (but it shouldn't have changed the work area).
SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
SetState(shelf, SHELF_AUTO_HIDE);
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
shelf->LayoutShelf();
EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(),
shelf->launcher_widget()->GetWindowBoundsInScreen().y());
......@@ -349,8 +349,8 @@ TEST_F(ShelfLayoutManagerTest, AutoHide) {
// Move mouse back up.
generator.MoveMouseTo(0, 0);
SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
SetState(shelf, SHELF_AUTO_HIDE);
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
shelf->LayoutShelf();
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
shelf->launcher_widget()->GetWindowBoundsInScreen().y());
......@@ -359,16 +359,16 @@ TEST_F(ShelfLayoutManagerTest, AutoHide) {
generator.PressLeftButton();
generator.MoveMouseTo(0, root->bounds().bottom() - 1);
UpdateAutoHideStateNow();
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
generator.ReleaseLeftButton();
generator.MoveMouseTo(1, root->bounds().bottom() - 1);
UpdateAutoHideStateNow();
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
generator.PressLeftButton();
generator.MoveMouseTo(1, root->bounds().bottom() - 1);
UpdateAutoHideStateNow();
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
}
// Assertions around the lock screen showing.
......@@ -388,8 +388,8 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
widget->Init(params);
widget->Maximize();
widget->Show();
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
aura::RootWindow* root = Shell::GetPrimaryRootWindow();
// LayoutShelf() forces the animation to completion, at which point the
......@@ -416,11 +416,11 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
Shell::GetInstance()->delegate()->LockScreen();
shelf->UpdateVisibilityState();
// Showing a widget in the lock screen should force the shelf to be visibile.
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
Shell::GetInstance()->delegate()->UnlockScreen();
shelf->UpdateVisibilityState();
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
}
// Assertions around SetAutoHideBehavior.
......@@ -443,25 +443,25 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
Shell::GetScreen()->GetDisplayNearestWindow(window).bounds());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
widget->Maximize();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
window).work_area().bottom(),
widget->GetWorkAreaBoundsInScreen().bottom());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
window).work_area().bottom(),
widget->GetWorkAreaBoundsInScreen().bottom());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
window).work_area().bottom(),
widget->GetWorkAreaBoundsInScreen().bottom());
......@@ -483,28 +483,29 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) {
widget->Init(params);
widget->Show();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
// Focus the launcher. Have to go through the focus cycler as normal focus
// requests to it do nothing.
shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
widget->Activate();
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
// Trying to activate the status should fail, since we only allow activating
// it when the user is using the keyboard (i.e. through FocusCycler).
shelf->status_area_widget()->Activate();
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
}
// Makes sure shelf will be visible when app list opens as shelf is in VISIBLE
// state,and toggling app list won't change shelf visibility state.
// Makes sure shelf will be visible when app list opens as shelf is in
// SHELF_VISIBLE state,and toggling app list won't change shelf
// visibility state.
TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
Shell* shell = Shell::GetInstance();
internal::RootWindowController* controller =
......@@ -518,22 +519,22 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
window->SetBounds(gfx::Rect(0, 0, 100, 100));
window->Show();
EXPECT_FALSE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
// Toggle app list to show, and the shelf stays visible.
shell->ToggleAppList();
EXPECT_TRUE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
// Toggle app list to hide, and the shelf stays visible.
shell->ToggleAppList();
EXPECT_FALSE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
}
// Makes sure shelf will be shown with AUTO_HIDE_SHOWN state when app list opens
// as shelf is in AUTO_HIDE state, and toggling app list won't change shelf
// visibility state.
// Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state
// when app list opens as shelf is in SHELF_AUTO_HIDE state, and
// toggling app list won't change shelf visibility state.
TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
Shell* shell = Shell::GetInstance();
ShelfLayoutManager* shelf = shelf_layout_manager();
......@@ -550,7 +551,7 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
wm::ActivateWindow(window);
EXPECT_FALSE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
// Toggle app list to show.
shell->ToggleAppList();
......@@ -559,13 +560,13 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
// update the state.
shell->UpdateShelfVisibility();
EXPECT_TRUE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
// Toggle app list to hide.
shell->ToggleAppList();
EXPECT_FALSE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
}
// Makes sure shelf will be hidden when app list opens as shelf is in HIDDEN
......@@ -585,17 +586,17 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) {
// App list and shelf is not shown.
EXPECT_FALSE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
// Toggle app list to show.
shell->ToggleAppList();
EXPECT_TRUE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
// Toggle app list to hide.
shell->ToggleAppList();
EXPECT_FALSE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
}
// Tests SHELF_ALIGNMENT_LEFT and SHELF_ALIGNMENT_RIGHT.
......@@ -604,7 +605,7 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
// Force an initial layout.
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
shelf->LayoutShelf();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
gfx::Rect launcher_bounds(
......@@ -688,7 +689,7 @@ TEST_F(ShelfLayoutManagerTest, GestureDrag) {
gfx::Rect shelf_shown = shelf->launcher_widget()->GetWindowBoundsInScreen();
gfx::Rect bounds_shelf = window->bounds();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
......@@ -701,8 +702,8 @@ TEST_F(ShelfLayoutManagerTest, GestureDrag) {
end.set_y(start.y() + 100);
generator.GestureScrollSequence(start, end,
base::TimeDelta::FromMilliseconds(10), 1);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString());
EXPECT_NE(shelf_shown.ToString(),
......@@ -714,7 +715,7 @@ TEST_F(ShelfLayoutManagerTest, GestureDrag) {
// Swipe up to show the shelf.
generator.GestureScrollSequence(end, start,
base::TimeDelta::FromMilliseconds(10), 1);
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
EXPECT_EQ(shelf_shown.ToString(),
......@@ -724,8 +725,8 @@ TEST_F(ShelfLayoutManagerTest, GestureDrag) {
end.set_y(start.y() - 100);
generator.GestureScrollSequence(start, end,
base::TimeDelta::FromMilliseconds(10), 1);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(shelf_hidden.ToString(),
shelf->launcher_widget()->GetWindowBoundsInScreen().ToString());
......@@ -739,7 +740,7 @@ TEST_F(ShelfLayoutManagerTest, GestureDrag) {
end.set_y(start.y() + shelf_shown.height() * 3 / 10);
generator.GestureScrollSequence(start, end,
base::TimeDelta::FromMilliseconds(100), 1);
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
EXPECT_EQ(shelf_shown.ToString(),
......@@ -749,8 +750,8 @@ TEST_F(ShelfLayoutManagerTest, GestureDrag) {
end.set_y(start.y() + 100);
generator.GestureScrollSequence(start, end,
base::TimeDelta::FromMilliseconds(10), 1);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString());
EXPECT_EQ(shelf_hidden.ToString(),
......@@ -761,12 +762,12 @@ TEST_F(ShelfLayoutManagerTest, GestureDrag) {
gfx::Rect bounds_fullscreen = window->bounds();
EXPECT_TRUE(widget->IsFullscreen());
EXPECT_NE(bounds_noshelf.ToString(), bounds_fullscreen.ToString());
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
// Swipe-up. This should not change anything.
generator.GestureScrollSequence(end, start,
base::TimeDelta::FromMilliseconds(10), 1);
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString());
}
......@@ -809,7 +810,7 @@ TEST_F(ShelfLayoutManagerTest, GestureRevealsTrayBubble) {
end.set_y(start.y() - 400);
generator.GestureScrollSequence(start, end,
base::TimeDelta::FromMilliseconds(10), 1);
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_TRUE(tray->HasSystemBubble());
}
......@@ -818,14 +819,14 @@ TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) {
// Turn on auto-hide for the shelf.
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
// Focus the system tray. That should make the shelf visible again.
Shell::GetInstance()->accelerator_controller()->PerformAction(
FOCUS_SYSTEM_TRAY, ui::Accelerator());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_FALSE(Shell::GetInstance()->system_tray()->HasSystemBubble());
// Now activate the tray (using the keyboard, instead of using the mouse to
......@@ -838,8 +839,8 @@ TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) {
generator.PressKey(ui::VKEY_SPACE, 0);
generator.ReleaseKey(ui::VKEY_SPACE, 0);
EXPECT_TRUE(Shell::GetInstance()->system_tray()->HasSystemBubble());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_FALSE(observer.changed_auto_hide_state());
shelf->RemoveObserver(&observer);
......
......@@ -486,25 +486,25 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
w1->Show();
wm::ActivateWindow(w1.get());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
// Maximize the window.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
// Restore.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
// Fullscreen.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
// Normal.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
EXPECT_FALSE(GetWindowOverlapsShelf());
......@@ -518,12 +518,12 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
// Maximize again.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
// Minimize.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
// Since the restore from minimize will restore to the pre-minimize
// state (tested elsewhere), we abandon the current size and restore
......@@ -536,7 +536,7 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
// Restore.
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
// Create another window, maximized.
......@@ -546,14 +546,14 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
w2->Show();
wm::ActivateWindow(w2.get());
EXPECT_EQ(1, active_index());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
// Switch to w1.
wm::ActivateWindow(w1.get());
EXPECT_EQ(0, active_index());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(
w2->parent()).ToString(),
......@@ -562,8 +562,8 @@ TEST_F(WorkspaceManagerTest, ShelfStateUpdated) {
// Switch to w2.
wm::ActivateWindow(w2.get());
EXPECT_EQ(1, active_index());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(),
w2->bounds().ToString());
......@@ -721,26 +721,26 @@ TEST_F(WorkspaceManagerTest, GetWindowStateWithUnmanagedFullscreenWindow) {
ASSERT_EQ("1 M1 active=1", StateString());
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState());
w2->Hide();
ASSERT_EQ("1 P=M1 active=0", StateString());
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
w2->Show();
ASSERT_EQ("1 P=M1 active=0", StateString());
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState());
wm::ActivateWindow(w2.get());
ASSERT_EQ("1 M1 active=1", StateString());
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState());
w2.reset();
ASSERT_EQ("1 active=0", StateString());
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState());
}
......@@ -766,21 +766,21 @@ TEST_F(WorkspaceManagerTest,
// Even though auto-hide behavior is NEVER full-screen windows cause the shelf
// to hide.
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN,
manager_->GetWindowState());
w2->Hide();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
w2->Show();
wm::ActivateWindow(w2.get());
EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN,
manager_->GetWindowState());
w2.reset();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
}
// Verifies a window marked as persisting across all workspaces ends up in its
......@@ -812,7 +812,7 @@ TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) {
wm::ActivateWindow(w1.get());
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
EXPECT_EQ(ShelfLayoutManager::VISIBLE,
EXPECT_EQ(SHELF_VISIBLE,
shelf_layout_manager()->visibility_state());
EXPECT_FALSE(Launcher::ForPrimaryDisplay()->paints_background());
}
......
......@@ -9,7 +9,7 @@
#include "ash/launcher/launcher_delegate.h"
#include "ash/launcher/launcher_types.h"
#include "ash/wm/shelf_types.h"
#include "ash/shelf_types.h"
#include "chrome/browser/extensions/extension_prefs.h"
class BrowserLauncherItemControllerTest;
......
......@@ -11,8 +11,8 @@
#include "ash/launcher/launcher_model_observer.h"
#include "ash/launcher/launcher_types.h"
#include "ash/shelf_types.h"
#include "ash/shell_observer.h"
#include "ash/wm/shelf_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
......
......@@ -12,8 +12,8 @@
#include "ash/launcher/launcher_delegate.h"
#include "ash/launcher/launcher_model_observer.h"
#include "ash/launcher/launcher_types.h"
#include "ash/shelf_types.h"
#include "ash/shell_observer.h"
#include "ash/wm/shelf_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment