diff options
28 files changed, 551 insertions, 555 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index bbb8a8a..24a1a1b 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -164,8 +164,6 @@ 'launcher/launcher_model_observer.h', 'launcher/launcher_types.cc', 'launcher/launcher_types.h', - 'launcher/launcher_view.cc', - 'launcher/launcher_view.h', 'magnifier/magnification_controller.cc', 'magnifier/magnification_controller.h', 'magnifier/magnifier_constants.h', @@ -217,6 +215,8 @@ 'shelf/shelf_types.h', 'shelf/shelf_util.cc', 'shelf/shelf_util.h', + 'shelf/shelf_view.cc', + 'shelf/shelf_view.h', 'shelf/shelf_widget.cc', 'shelf/shelf_widget.h', 'shell.cc', @@ -622,8 +622,8 @@ 'test/cursor_manager_test_api.h', 'test/launcher_test_api.cc', 'test/launcher_test_api.h', - 'test/launcher_view_test_api.cc', - 'test/launcher_view_test_api.h', + 'test/shelf_view_test_api.cc', + 'test/shelf_view_test_api.h', 'test/display_manager_test_api.cc', 'test/display_manager_test_api.h', 'test/launcher_item_delegate_manager_test_api.cc', @@ -739,7 +739,6 @@ 'keyboard_overlay/keyboard_overlay_view_unittest.cc', 'launcher/launcher_model_unittest.cc', 'launcher/launcher_unittest.cc', - 'launcher/launcher_view_unittest.cc', 'magnifier/magnification_controller_unittest.cc', 'root_window_controller_unittest.cc', 'screen_ash_unittest.cc', @@ -750,6 +749,7 @@ 'shelf/shelf_layout_manager_unittest.cc', 'shelf/shelf_navigator_unittest.cc', 'shelf/shelf_tooltip_manager_unittest.cc', + 'shelf/shelf_view_unittest.cc', 'shelf/shelf_widget_unittest.cc', 'shell/app_list.cc', 'shell/bubble.cc', diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc index ae16485..9637acb 100644 --- a/ash/launcher/launcher.cc +++ b/ash/launcher/launcher.cc @@ -12,11 +12,11 @@ #include "ash/launcher/launcher_item_delegate.h" #include "ash/launcher/launcher_item_delegate_manager.h" #include "ash/launcher/launcher_model.h" -#include "ash/launcher/launcher_view.h" #include "ash/root_window_controller.h" #include "ash/screen_ash.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_navigator.h" +#include "ash/shelf/shelf_view.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "ash/shell_delegate.h" @@ -39,19 +39,19 @@ namespace ash { -const char Launcher::kNativeViewName[] = "LauncherView"; +const char Launcher::kNativeViewName[] = "ShelfView"; Launcher::Launcher(LauncherModel* launcher_model, LauncherDelegate* launcher_delegate, ShelfWidget* shelf_widget) - : launcher_view_(NULL), + : shelf_view_(NULL), alignment_(shelf_widget->GetAlignment()), delegate_(launcher_delegate), shelf_widget_(shelf_widget) { - launcher_view_ = new internal::LauncherView( + shelf_view_ = new internal::ShelfView( launcher_model, delegate_, shelf_widget_->shelf_layout_manager()); - launcher_view_->Init(); - shelf_widget_->GetContentsView()->AddChildView(launcher_view_); + shelf_view_->Init(); + shelf_widget_->GetContentsView()->AddChildView(shelf_view_); shelf_widget_->GetNativeView()->SetName(kNativeViewName); delegate_->OnLauncherCreated(this); } @@ -76,15 +76,15 @@ Launcher* Launcher::ForWindow(aura::Window* window) { void Launcher::SetAlignment(ShelfAlignment alignment) { alignment_ = alignment; - launcher_view_->OnShelfAlignmentChanged(); + shelf_view_->OnShelfAlignmentChanged(); // ShelfLayoutManager will resize the launcher. } gfx::Rect Launcher::GetScreenBoundsOfItemIconForWindow(aura::Window* window) { LauncherID id = delegate_->GetIDByWindow(window); - gfx::Rect bounds(launcher_view_->GetIdealBoundsOfItemIcon(id)); + gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); gfx::Point screen_origin; - views::View::ConvertPointToScreen(launcher_view_, &screen_origin); + views::View::ConvertPointToScreen(shelf_view_, &screen_origin); return gfx::Rect(screen_origin.x() + bounds.x(), screen_origin.y() + bounds.y(), bounds.width(), @@ -92,7 +92,7 @@ gfx::Rect Launcher::GetScreenBoundsOfItemIconForWindow(aura::Window* window) { } void Launcher::UpdateIconPositionForWindow(aura::Window* window) { - launcher_view_->UpdatePanelIconPosition( + shelf_view_->UpdatePanelIconPosition( delegate_->GetIDByWindow(window), ash::ScreenAsh::ConvertRectFromScreen( shelf_widget()->GetNativeView(), @@ -107,7 +107,7 @@ void Launcher::ActivateLauncherItem(int index) { ui::EF_NONE, false); - const ash::LauncherItem& item = launcher_view_->model()->items()[index]; + const ash::LauncherItem& item = shelf_view_->model()->items()[index]; ash::LauncherItemDelegate* item_delegate = Shell::GetInstance()->launcher_item_delegate_manager()-> GetLauncherItemDelegate(item.id); @@ -116,45 +116,45 @@ void Launcher::ActivateLauncherItem(int index) { void Launcher::CycleWindowLinear(CycleDirection direction) { int item_index = GetNextActivatedItemIndex( - *(launcher_view_->model()), direction); + *(shelf_view_->model()), direction); if (item_index >= 0) ActivateLauncherItem(item_index); } void Launcher::AddIconObserver(LauncherIconObserver* observer) { - launcher_view_->AddIconObserver(observer); + shelf_view_->AddIconObserver(observer); } void Launcher::RemoveIconObserver(LauncherIconObserver* observer) { - launcher_view_->RemoveIconObserver(observer); + shelf_view_->RemoveIconObserver(observer); } bool Launcher::IsShowingMenu() const { - return launcher_view_->IsShowingMenu(); + return shelf_view_->IsShowingMenu(); } bool Launcher::IsShowingOverflowBubble() const { - return launcher_view_->IsShowingOverflowBubble(); + return shelf_view_->IsShowingOverflowBubble(); } void Launcher::SetVisible(bool visible) const { - launcher_view_->SetVisible(visible); + shelf_view_->SetVisible(visible); } bool Launcher::IsVisible() const { - return launcher_view_->visible(); + return shelf_view_->visible(); } void Launcher::SchedulePaint() { - launcher_view_->SchedulePaintForAllButtons(); + shelf_view_->SchedulePaintForAllButtons(); } views::View* Launcher::GetAppListButtonView() const { - return launcher_view_->GetAppListButtonView(); + return shelf_view_->GetAppListButtonView(); } void Launcher::LaunchAppIndexAt(int item_index) { - LauncherModel* launcher_model = launcher_view_->model(); + LauncherModel* launcher_model = shelf_view_->model(); const LauncherItems& items = launcher_model->items(); int item_count = launcher_model->item_count(); int indexes_left = item_index >= 0 ? item_index : item_count; @@ -178,20 +178,20 @@ void Launcher::LaunchAppIndexAt(int item_index) { } } -void Launcher::SetLauncherViewBounds(gfx::Rect bounds) { - launcher_view_->SetBoundsRect(bounds); +void Launcher::SetShelfViewBounds(gfx::Rect bounds) { + shelf_view_->SetBoundsRect(bounds); } -gfx::Rect Launcher::GetLauncherViewBounds() const { - return launcher_view_->bounds(); +gfx::Rect Launcher::GetShelfViewBounds() const { + return shelf_view_->bounds(); } gfx::Rect Launcher::GetVisibleItemsBoundsInScreen() const { - return launcher_view_->GetVisibleItemsBoundsInScreen(); + return shelf_view_->GetVisibleItemsBoundsInScreen(); } app_list::ApplicationDragAndDropHost* Launcher::GetDragAndDropHostForAppList() { - return launcher_view_; + return shelf_view_; } } // namespace ash diff --git a/ash/launcher/launcher.h b/ash/launcher/launcher.h index 6173805..693f137 100644 --- a/ash/launcher/launcher.h +++ b/ash/launcher/launcher.h @@ -33,8 +33,8 @@ namespace ash { namespace internal { class FocusCycler; -class LauncherView; class ShelfLayoutManager; +class ShelfView; } namespace test { @@ -103,9 +103,9 @@ class ASH_EXPORT Launcher { ShelfWidget* shelf_widget() { return shelf_widget_; } - // Set the bounds of the launcher view. - void SetLauncherViewBounds(gfx::Rect bounds); - gfx::Rect GetLauncherViewBounds() const; + // Set the bounds of the shelf view. + void SetShelfViewBounds(gfx::Rect bounds); + gfx::Rect GetShelfViewBounds() const; // Returns rectangle bounding all visible launcher items. Used screen // coordinate system. @@ -117,8 +117,8 @@ class ASH_EXPORT Launcher { private: friend class ash::test::LauncherTestAPI; - // LauncherView used to display icons. - internal::LauncherView* launcher_view_; + // ShelfView used to display icons. + internal::ShelfView* shelf_view_; ShelfAlignment alignment_; diff --git a/ash/launcher/launcher_model.h b/ash/launcher/launcher_model.h index 0d54486..9d42844 100644 --- a/ash/launcher/launcher_model.h +++ b/ash/launcher/launcher_model.h @@ -14,7 +14,7 @@ namespace ash { class LauncherModelObserver; -// Model used by LauncherView. +// Model used by ShelfView. class ASH_EXPORT LauncherModel { public: enum Status { diff --git a/ash/launcher/launcher_unittest.cc b/ash/launcher/launcher_unittest.cc index 0778c33..3e72f6d 100644 --- a/ash/launcher/launcher_unittest.cc +++ b/ash/launcher/launcher_unittest.cc @@ -6,12 +6,12 @@ #include "ash/launcher/launcher_button.h" #include "ash/launcher/launcher_item_delegate_manager.h" #include "ash/launcher/launcher_model.h" -#include "ash/launcher/launcher_view.h" +#include "ash/shelf/shelf_view.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/launcher_test_api.h" -#include "ash/test/launcher_view_test_api.h" +#include "ash/test/shelf_view_test_api.h" #include "ash/test/test_launcher_item_delegate.h" #include "ash/wm/window_util.h" #include "ui/aura/root_window.h" @@ -26,7 +26,7 @@ #endif typedef ash::test::AshTestBase LauncherTest; -using ash::internal::LauncherView; +using ash::internal::ShelfView; using ash::internal::LauncherButton; namespace ash { @@ -34,7 +34,7 @@ namespace ash { class LauncherTest : public ash::test::AshTestBase { public: LauncherTest() : launcher_(NULL), - launcher_view_(NULL), + shelf_view_(NULL), launcher_model_(NULL), item_delegate_manager_(NULL) { } @@ -48,12 +48,12 @@ class LauncherTest : public ash::test::AshTestBase { ASSERT_TRUE(launcher_); ash::test::LauncherTestAPI test(launcher_); - launcher_view_ = test.launcher_view(); - launcher_model_ = launcher_view_->model(); + shelf_view_ = test.shelf_view(); + launcher_model_ = shelf_view_->model(); item_delegate_manager_ = Shell::GetInstance()->launcher_item_delegate_manager(); - test_.reset(new ash::test::LauncherViewTestAPI(launcher_view_)); + test_.reset(new ash::test::ShelfViewTestAPI(shelf_view_)); } virtual void TearDown() OVERRIDE { @@ -64,8 +64,8 @@ class LauncherTest : public ash::test::AshTestBase { return launcher_; } - LauncherView* launcher_view() { - return launcher_view_; + ShelfView* shelf_view() { + return shelf_view_; } LauncherModel* launcher_model() { @@ -76,16 +76,16 @@ class LauncherTest : public ash::test::AshTestBase { return item_delegate_manager_; } - ash::test::LauncherViewTestAPI* test_api() { + ash::test::ShelfViewTestAPI* test_api() { return test_.get(); } private: Launcher* launcher_; - LauncherView* launcher_view_; + ShelfView* shelf_view_; LauncherModel* launcher_model_; LauncherItemDelegateManager* item_delegate_manager_; - scoped_ptr<ash::test::LauncherViewTestAPI> test_; + scoped_ptr<ash::test::ShelfViewTestAPI> test_; DISALLOW_COPY_AND_ASSIGN(LauncherTest); }; @@ -155,7 +155,7 @@ TEST_F(LauncherTest, ShowOverflowBubble) { test_api()->ShowOverflowBubble(); EXPECT_TRUE(launcher()->IsShowingOverflowBubble()); - // Removes the first item in main launcher view. + // Removes the first item in main shelf view. launcher_model()->RemoveItemAt( launcher_model()->ItemIndexByID(first_item_id)); diff --git a/ash/shelf/overflow_bubble.cc b/ash/shelf/overflow_bubble.cc index d448f6f..554e89f5 100644 --- a/ash/shelf/overflow_bubble.cc +++ b/ash/shelf/overflow_bubble.cc @@ -7,9 +7,9 @@ #include <algorithm> #include "ash/launcher/launcher_types.h" -#include "ash/launcher/launcher_view.h" #include "ash/root_window_controller.h" #include "ash/shelf/shelf_layout_manager.h" +#include "ash/shelf/shelf_view.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "ash/system/tray/system_tray.h" @@ -30,22 +30,22 @@ namespace { // Max bubble size to screen size ratio. const float kMaxBubbleSizeToScreenRatio = 0.5f; -// Inner padding in pixels for launcher view inside bubble. +// Inner padding in pixels for shelf view inside bubble. const int kPadding = 2; -// Padding space in pixels between LauncherView's left/top edge to its contents. -const int kLauncherViewLeadingInset = 8; +// Padding space in pixels between ShelfView's left/top edge to its contents. +const int kShelfViewLeadingInset = 8; //////////////////////////////////////////////////////////////////////////////// // OverflowBubbleView -// OverflowBubbleView hosts a LauncherView to display overflown items. +// OverflowBubbleView hosts a ShelfView to display overflown items. class OverflowBubbleView : public views::BubbleDelegateView { public: OverflowBubbleView(); virtual ~OverflowBubbleView(); - void InitOverflowBubble(views::View* anchor, LauncherView* launcher_view); + void InitOverflowBubble(views::View* anchor, ShelfView* shelf_view); private: bool IsHorizontalAlignment() const { @@ -53,7 +53,7 @@ class OverflowBubbleView : public views::BubbleDelegateView { } const gfx::Size GetContentsSize() const { - return static_cast<views::View*>(launcher_view_)->GetPreferredSize(); + return static_cast<views::View*>(shelf_view_)->GetPreferredSize(); } // Gets arrow location based on shelf alignment. @@ -85,21 +85,21 @@ class OverflowBubbleView : public views::BubbleDelegateView { GetAnchorView()->GetWidget()->GetNativeView()); } - LauncherView* launcher_view_; // Owned by views hierarchy. + ShelfView* shelf_view_; // Owned by views hierarchy. gfx::Vector2d scroll_offset_; DISALLOW_COPY_AND_ASSIGN(OverflowBubbleView); }; OverflowBubbleView::OverflowBubbleView() - : launcher_view_(NULL) { + : shelf_view_(NULL) { } OverflowBubbleView::~OverflowBubbleView() { } void OverflowBubbleView::InitOverflowBubble(views::View* anchor, - LauncherView* launcher_view) { + ShelfView* shelf_view) { // set_anchor_view needs to be called before GetShelfLayoutManagerForLauncher // can be called. SetAnchorView(anchor); @@ -117,8 +117,8 @@ void OverflowBubbleView::InitOverflowBubble(views::View* anchor, SetFillsBoundsOpaquely(false); layer()->SetMasksToBounds(true); - launcher_view_ = launcher_view; - AddChildView(launcher_view_); + shelf_view_ = shelf_view; + AddChildView(shelf_view_); views::BubbleDelegateView::CreateBubble(this); } @@ -164,7 +164,7 @@ gfx::Size OverflowBubbleView::GetPreferredSize() { } void OverflowBubbleView::Layout() { - launcher_view_->SetBoundsRect(gfx::Rect( + shelf_view_->SetBoundsRect(gfx::Rect( gfx::PointAtOffsetFromOrigin(-scroll_offset_), GetContentsSize())); } @@ -205,7 +205,7 @@ gfx::Rect OverflowBubbleView::GetBubbleBounds() { const int border_size = views::BubbleBorder::is_arrow_on_horizontal(arrow()) ? bubble_insets.left() : bubble_insets.top(); - const int arrow_offset = border_size + kPadding + kLauncherViewLeadingInset + + const int arrow_offset = border_size + kPadding + kShelfViewLeadingInset + ShelfLayoutManager::GetPreferredShelfSize() / 2; const gfx::Size content_size = GetPreferredSize(); @@ -248,19 +248,19 @@ gfx::Rect OverflowBubbleView::GetBubbleBounds() { OverflowBubble::OverflowBubble() : bubble_(NULL), anchor_(NULL), - launcher_view_(NULL) { + shelf_view_(NULL) { } OverflowBubble::~OverflowBubble() { Hide(); } -void OverflowBubble::Show(views::View* anchor, LauncherView* launcher_view) { +void OverflowBubble::Show(views::View* anchor, ShelfView* shelf_view) { Hide(); OverflowBubbleView* bubble_view = new OverflowBubbleView(); - bubble_view->InitOverflowBubble(anchor, launcher_view); - launcher_view_ = launcher_view; + bubble_view->InitOverflowBubble(anchor, shelf_view); + shelf_view_ = shelf_view; anchor_ = anchor; Shell::GetInstance()->AddPreTargetHandler(this); @@ -281,7 +281,7 @@ void OverflowBubble::Hide() { bubble_->GetWidget()->Close(); bubble_ = NULL; anchor_ = NULL; - launcher_view_ = NULL; + shelf_view_ = NULL; } void OverflowBubble::HideBubbleAndRefreshButton() { @@ -300,7 +300,7 @@ void OverflowBubble::ProcessPressedEvent(ui::LocatedEvent* event) { gfx::Point event_location_in_screen = event->location(); aura::client::GetScreenPositionClient(target->GetRootWindow())-> ConvertPointToScreen(target, &event_location_in_screen); - if (!launcher_view_->IsShowingMenu() && + if (!shelf_view_->IsShowingMenu() && !bubble_->GetBoundsInScreen().Contains(event_location_in_screen) && !anchor_->GetBoundsInScreen().Contains(event_location_in_screen)) { HideBubbleAndRefreshButton(); @@ -321,7 +321,7 @@ void OverflowBubble::OnWidgetDestroying(views::Widget* widget) { DCHECK(widget == bubble_->GetWidget()); bubble_ = NULL; anchor_ = NULL; - launcher_view_ = NULL; + shelf_view_ = NULL; ShelfLayoutManager::ForLauncher( widget->GetNativeView())->shelf_widget()->launcher()->SchedulePaint(); } diff --git a/ash/shelf/overflow_bubble.h b/ash/shelf/overflow_bubble.h index aaf71aa..ad4d11f 100644 --- a/ash/shelf/overflow_bubble.h +++ b/ash/shelf/overflow_bubble.h @@ -25,7 +25,7 @@ class LauncherModel; namespace internal { -class LauncherView; +class ShelfView; // OverflowBubble displays the overflown launcher items in a bubble. class OverflowBubble : public ui::EventHandler, @@ -34,8 +34,8 @@ class OverflowBubble : public ui::EventHandler, OverflowBubble(); virtual ~OverflowBubble(); - // Shows an bubble pointing to |anchor| with |launcher_view| as its content. - void Show(views::View* anchor, LauncherView* launcher_view); + // Shows an bubble pointing to |anchor| with |shelf_view| as its content. + void Show(views::View* anchor, ShelfView* shelf_view); void Hide(); @@ -44,7 +44,7 @@ class OverflowBubble : public ui::EventHandler, void HideBubbleAndRefreshButton(); bool IsShowing() const { return !!bubble_; } - LauncherView* launcher_view() { return launcher_view_; } + ShelfView* shelf_view() { return shelf_view_; } private: void ProcessPressedEvent(ui::LocatedEvent* event); @@ -57,8 +57,8 @@ class OverflowBubble : public ui::EventHandler, virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; views::View* bubble_; // Owned by views hierarchy. - views::View* anchor_; // Owned by LauncherView. - LauncherView* launcher_view_; // Owned by |bubble_|. + views::View* anchor_; // Owned by ShelfView. + ShelfView* shelf_view_; // Owned by |bubble_|. DISALLOW_COPY_AND_ASSIGN(OverflowBubble); }; diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index d5441c4..25e5eff 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc @@ -290,12 +290,12 @@ void ShelfLayoutManager::LayoutShelf() { if (shelf_->launcher()) { // This is not part of UpdateBoundsAndOpacity() because - // SetLauncherViewBounds() sets the bounds immediately and does not animate. - // The height of the LauncherView for a horizontal shelf and the width of - // the LauncherView for a vertical shelf are set when |shelf_|'s bounds + // SetShelfViewBounds() sets the bounds immediately and does not animate. + // The height of the ShelfView for a horizontal shelf and the width of + // the ShelfView for a vertical shelf are set when |shelf_|'s bounds // are changed via UpdateBoundsAndOpacity(). This sets the origin and the // dimension in the other direction. - shelf_->launcher()->SetLauncherViewBounds( + shelf_->launcher()->SetShelfViewBounds( target_bounds.launcher_bounds_in_shelf); } } diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc index 805df20..93dfc57 100644 --- a/ash/shelf/shelf_layout_manager_unittest.cc +++ b/ash/shelf/shelf_layout_manager_unittest.cc @@ -10,11 +10,11 @@ #include "ash/display/display_manager.h" #include "ash/focus_cycler.h" #include "ash/launcher/launcher.h" -#include "ash/launcher/launcher_view.h" #include "ash/root_window_controller.h" #include "ash/screen_ash.h" #include "ash/session_state_delegate.h" #include "ash/shelf/shelf_layout_manager_observer.h" +#include "ash/shelf/shelf_view.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" @@ -784,7 +784,7 @@ TEST_F(ShelfLayoutManagerTest, LauncherUpdatedWhenStatusAreaChangesSize) { shelf_widget->status_area_widget()->SetBounds( gfx::Rect(0, 0, 200, 200)); EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - - test::LauncherTestAPI(launcher).launcher_view()->width()); + test::LauncherTestAPI(launcher).shelf_view()->width()); } diff --git a/ash/shelf/shelf_tooltip_manager.cc b/ash/shelf/shelf_tooltip_manager.cc index 8bfb53a..bdf3306 100644 --- a/ash/shelf/shelf_tooltip_manager.cc +++ b/ash/shelf/shelf_tooltip_manager.cc @@ -4,8 +4,8 @@ #include "ash/shelf/shelf_tooltip_manager.h" -#include "ash/launcher/launcher_view.h" #include "ash/shelf/shelf_layout_manager.h" +#include "ash/shelf/shelf_view.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/window_animations.h" @@ -138,12 +138,12 @@ gfx::Size ShelfTooltipManager::ShelfTooltipBubble::GetPreferredSize() { ShelfTooltipManager::ShelfTooltipManager( ShelfLayoutManager* shelf_layout_manager, - LauncherView* launcher_view) + ShelfView* shelf_view) : view_(NULL), widget_(NULL), anchor_(NULL), shelf_layout_manager_(shelf_layout_manager), - launcher_view_(launcher_view), + shelf_view_(shelf_view), weak_factory_(this) { if (shelf_layout_manager) shelf_layout_manager->AddObserver(this); @@ -253,7 +253,7 @@ void ShelfTooltipManager::OnMouseEvent(ui::MouseEvent* event) { return; DCHECK(view_); - DCHECK(launcher_view_); + DCHECK(shelf_view_); // Pressing the mouse button anywhere should close the tooltip. if (event->type() == ui::ET_MOUSE_PRESSED) { @@ -267,12 +267,12 @@ void ShelfTooltipManager::OnMouseEvent(ui::MouseEvent* event) { return; } - gfx::Point location_in_launcher_view = event->location(); + gfx::Point location_in_shelf_view = event->location(); aura::Window::ConvertPointToTarget( - target, launcher_view_->GetWidget()->GetNativeWindow(), - &location_in_launcher_view); + target, shelf_view_->GetWidget()->GetNativeWindow(), + &location_in_shelf_view); - if (launcher_view_->ShouldHideTooltip(location_in_launcher_view)) { + if (shelf_view_->ShouldHideTooltip(location_in_shelf_view)) { // Because this mouse event may arrive to |view_|, here we just schedule // the closing event rather than directly calling Close(). CloseSoon(); diff --git a/ash/shelf/shelf_tooltip_manager.h b/ash/shelf/shelf_tooltip_manager.h index 73f6e62..5bb5f09 100644 --- a/ash/shelf/shelf_tooltip_manager.h +++ b/ash/shelf/shelf_tooltip_manager.h @@ -28,11 +28,11 @@ class Label; namespace ash { namespace test { class ShelfTooltipManagerTest; -class LauncherViewTest; +class ShelfViewTest; } namespace internal { -class LauncherView; +class ShelfView; class ShelfLayoutManager; // ShelfTooltipManager manages the tooltip balloon poping up on shelf items. @@ -40,7 +40,7 @@ class ASH_EXPORT ShelfTooltipManager : public ui::EventHandler, public ShelfLayoutManagerObserver { public: ShelfTooltipManager(ShelfLayoutManager* shelf_layout_manager, - LauncherView* launcher_view); + ShelfView* shelf_view); virtual ~ShelfTooltipManager(); ShelfLayoutManager* shelf_layout_manager() { return shelf_layout_manager_; } @@ -92,7 +92,7 @@ protected: private: class ShelfTooltipBubble; - friend class test::LauncherViewTest; + friend class test::ShelfViewTest; friend class test::ShelfTooltipManagerTest; void CancelHidingAnimation(); @@ -108,7 +108,7 @@ protected: scoped_ptr<base::Timer> timer_; ShelfLayoutManager* shelf_layout_manager_; - LauncherView* launcher_view_; + ShelfView* shelf_view_; base::WeakPtrFactory<ShelfTooltipManager> weak_factory_; diff --git a/ash/shelf/shelf_tooltip_manager_unittest.cc b/ash/shelf/shelf_tooltip_manager_unittest.cc index 7d60b92..6f2f0fa 100644 --- a/ash/shelf/shelf_tooltip_manager_unittest.cc +++ b/ash/shelf/shelf_tooltip_manager_unittest.cc @@ -45,7 +45,7 @@ class ShelfTooltipManagerTest : public AshTestBase { Shell::GetPrimaryRootWindowController(); tooltip_manager_.reset(new internal::ShelfTooltipManager( controller->GetShelfLayoutManager(), - LauncherTestAPI(controller->shelf()->launcher()).launcher_view())); + LauncherTestAPI(controller->shelf()->launcher()).shelf_view())); } virtual void TearDown() OVERRIDE { diff --git a/ash/launcher/launcher_view.cc b/ash/shelf/shelf_view.cc index 4279c3c..25053e3 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/shelf/shelf_view.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/launcher/launcher_view.h" +#include "ash/shelf/shelf_view.h" #include <algorithm> @@ -338,11 +338,11 @@ gfx::Point GetPositionInScreen(const gfx::Point& root_location, // AnimationDelegate used when deleting an item. This steadily decreased the // opacity of the layer as the animation progress. -class LauncherView::FadeOutAnimationDelegate +class ShelfView::FadeOutAnimationDelegate : public views::BoundsAnimator::OwnedAnimationDelegate { public: - FadeOutAnimationDelegate(LauncherView* host, views::View* view) - : launcher_view_(host), + FadeOutAnimationDelegate(ShelfView* host, views::View* view) + : shelf_view_(host), view_(view) {} virtual ~FadeOutAnimationDelegate() {} @@ -352,13 +352,13 @@ class LauncherView::FadeOutAnimationDelegate view_->layer()->ScheduleDraw(); } virtual void AnimationEnded(const Animation* animation) OVERRIDE { - launcher_view_->OnFadeOutAnimationEnded(); + shelf_view_->OnFadeOutAnimationEnded(); } virtual void AnimationCanceled(const Animation* animation) OVERRIDE { } private: - LauncherView* launcher_view_; + ShelfView* shelf_view_; scoped_ptr<views::View> view_; DISALLOW_COPY_AND_ASSIGN(FadeOutAnimationDelegate); @@ -367,33 +367,33 @@ class LauncherView::FadeOutAnimationDelegate // AnimationDelegate used to trigger fading an element in. When an item is // inserted this delegate is attached to the animation that expands the size of // the item. When done it kicks off another animation to fade the item in. -class LauncherView::StartFadeAnimationDelegate +class ShelfView::StartFadeAnimationDelegate : public views::BoundsAnimator::OwnedAnimationDelegate { public: - StartFadeAnimationDelegate(LauncherView* host, + StartFadeAnimationDelegate(ShelfView* host, views::View* view) - : launcher_view_(host), + : shelf_view_(host), view_(view) {} virtual ~StartFadeAnimationDelegate() {} // AnimationDelegate overrides: virtual void AnimationEnded(const Animation* animation) OVERRIDE { - launcher_view_->FadeIn(view_); + shelf_view_->FadeIn(view_); } virtual void AnimationCanceled(const Animation* animation) OVERRIDE { view_->layer()->SetOpacity(1.0f); } private: - LauncherView* launcher_view_; + ShelfView* shelf_view_; views::View* view_; DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate); }; -LauncherView::LauncherView(LauncherModel* model, - LauncherDelegate* delegate, - ShelfLayoutManager* shelf_layout_manager) +ShelfView::ShelfView(LauncherModel* model, + LauncherDelegate* delegate, + ShelfLayoutManager* shelf_layout_manager) : model_(model), delegate_(delegate), view_model_(new views::ViewModel), @@ -424,7 +424,7 @@ LauncherView::LauncherView(LauncherModel* model, tooltip_.reset(new ShelfTooltipManager(shelf_layout_manager, this)); } -LauncherView::~LauncherView() { +ShelfView::~ShelfView() { bounds_animator_->RemoveObserver(this); model_->RemoveObserver(this); // If we are inside the MenuRunner, we need to know if we were getting @@ -433,7 +433,7 @@ LauncherView::~LauncherView() { *got_deleted_ = true; } -void LauncherView::Init() { +void ShelfView::Init() { model_->AddObserver(this); const LauncherItems& items(model_->items()); @@ -453,7 +453,7 @@ void LauncherView::Init() { // We'll layout when our bounds change. } -void LauncherView::OnShelfAlignmentChanged() { +void ShelfView::OnShelfAlignmentChanged() { UpdateFirstButtonPadding(); overflow_button_->OnShelfAlignmentChanged(); LayoutToIdealBounds(); @@ -482,7 +482,7 @@ void LauncherView::OnShelfAlignmentChanged() { overflow_bubble_->Hide(); } -void LauncherView::SchedulePaintForAllButtons() { +void ShelfView::SchedulePaintForAllButtons() { for (int i = 0; i < view_model_->view_size(); ++i) { if (i >= first_visible_index_ && i <= last_visible_index_) view_model_->view_at(i)->SchedulePaint(); @@ -491,7 +491,7 @@ void LauncherView::SchedulePaintForAllButtons() { overflow_button_->SchedulePaint(); } -gfx::Rect LauncherView::GetIdealBoundsOfItemIcon(LauncherID id) { +gfx::Rect ShelfView::GetIdealBoundsOfItemIcon(LauncherID id) { int index = model_->ItemIndexByID(id); if (index == -1 || (index > last_visible_index_ && index < model_->FirstPanelIndex())) @@ -508,8 +508,8 @@ gfx::Rect LauncherView::GetIdealBoundsOfItemIcon(LauncherID id) { icon_bounds.height()); } -void LauncherView::UpdatePanelIconPosition(LauncherID id, - const gfx::Point& midpoint) { +void ShelfView::UpdatePanelIconPosition(LauncherID id, + const gfx::Point& midpoint) { int current_index = model_->ItemIndexByID(id); int first_panel_index = model_->FirstPanelIndex(); if (current_index < first_panel_index) @@ -536,16 +536,16 @@ void LauncherView::UpdatePanelIconPosition(LauncherID id, model_->Move(current_index, target_index); } -bool LauncherView::IsShowingMenu() const { +bool ShelfView::IsShowingMenu() const { return (launcher_menu_runner_.get() && launcher_menu_runner_->IsRunning()); } -bool LauncherView::IsShowingOverflowBubble() const { +bool ShelfView::IsShowingOverflowBubble() const { return overflow_bubble_.get() && overflow_bubble_->IsShowing(); } -views::View* LauncherView::GetAppListButtonView() const { +views::View* ShelfView::GetAppListButtonView() const { for (int i = 0; i < model_->item_count(); ++i) { if (model_->items()[i].type == TYPE_APP_LIST) return view_model_->view_at(i); @@ -556,21 +556,21 @@ views::View* LauncherView::GetAppListButtonView() const { } //////////////////////////////////////////////////////////////////////////////// -// LauncherView, FocusTraversable implementation: +// ShelfView, FocusTraversable implementation: -views::FocusSearch* LauncherView::GetFocusSearch() { +views::FocusSearch* ShelfView::GetFocusSearch() { return focus_search_.get(); } -views::FocusTraversable* LauncherView::GetFocusTraversableParent() { +views::FocusTraversable* ShelfView::GetFocusTraversableParent() { return parent()->GetFocusTraversable(); } -View* LauncherView::GetFocusTraversableParentView() { +View* ShelfView::GetFocusTraversableParentView() { return this; } -void LauncherView::CreateDragIconProxy( +void ShelfView::CreateDragIconProxy( const gfx::Point& location_in_screen_coordinates, const gfx::ImageSkia& icon, views::View* replaced_view, @@ -593,20 +593,20 @@ void LauncherView::CreateDragIconProxy( drag_image_->SetWidgetVisible(true); } -void LauncherView::UpdateDragIconProxy( +void ShelfView::UpdateDragIconProxy( const gfx::Point& location_in_screen_coordinates) { drag_image_->SetScreenPosition( GetPositionInScreen(location_in_screen_coordinates, drag_replaced_view_) - drag_image_offset_); } -void LauncherView::DestroyDragIconProxy() { +void ShelfView::DestroyDragIconProxy() { drag_image_.reset(); drag_image_offset_ = gfx::Vector2d(0, 0); } -bool LauncherView::StartDrag(const std::string& app_id, - const gfx::Point& location_in_screen_coordinates) { +bool ShelfView::StartDrag(const std::string& app_id, + const gfx::Point& location_in_screen_coordinates) { // Bail if an operation is already going on - or the cursor is not inside. // This could happen if mouse / touch operations overlap. if (drag_and_drop_launcher_id_ || @@ -614,7 +614,7 @@ bool LauncherView::StartDrag(const std::string& app_id, return false; // If the AppsGridView (which was dispatching this event) was opened by our - // button, LauncherView dragging operations are locked and we have to unlock. + // button, ShelfView dragging operations are locked and we have to unlock. CancelDrag(-1); drag_and_drop_item_pinned_ = false; drag_and_drop_app_id_ = app_id; @@ -654,7 +654,7 @@ bool LauncherView::StartDrag(const std::string& app_id, return true; } -bool LauncherView::Drag(const gfx::Point& location_in_screen_coordinates) { +bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { if (!drag_and_drop_launcher_id_ || !GetBoundsInScreen().Contains(location_in_screen_coordinates)) return false; @@ -670,7 +670,7 @@ bool LauncherView::Drag(const gfx::Point& location_in_screen_coordinates) { return true; } -void LauncherView::EndDrag(bool cancel) { +void ShelfView::EndDrag(bool cancel) { if (!drag_and_drop_launcher_id_) return; @@ -696,7 +696,7 @@ void LauncherView::EndDrag(bool cancel) { drag_and_drop_launcher_id_ = 0; } -void LauncherView::LayoutToIdealBounds() { +void ShelfView::LayoutToIdealBounds() { IdealBounds ideal_bounds; CalculateIdealBounds(&ideal_bounds); @@ -708,7 +708,7 @@ void LauncherView::LayoutToIdealBounds() { overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); } -void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { +void ShelfView::CalculateIdealBounds(IdealBounds* bounds) { ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager(); int available_size = shelf->PrimaryAxisValue(width(), height()); @@ -864,14 +864,14 @@ void LauncherView::CalculateIdealBounds(IdealBounds* bounds) { view_model_->set_ideal_bounds(last_button_index, app_list_bounds); } if (overflow_bubble_.get() && overflow_bubble_->IsShowing()) - UpdateOverflowRange(overflow_bubble_->launcher_view()); + UpdateOverflowRange(overflow_bubble_->shelf_view()); } else { if (overflow_bubble_) overflow_bubble_->Hide(); } } -int LauncherView::DetermineLastVisibleIndex(int max_value) const { +int ShelfView::DetermineLastVisibleIndex(int max_value) const { ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager(); int index = model_->FirstPanelIndex() - 1; @@ -884,7 +884,7 @@ int LauncherView::DetermineLastVisibleIndex(int max_value) const { return index; } -int LauncherView::DetermineFirstVisiblePanelIndex(int min_value) const { +int ShelfView::DetermineFirstVisiblePanelIndex(int min_value) const { ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager(); int index = model_->FirstPanelIndex(); @@ -897,15 +897,15 @@ int LauncherView::DetermineFirstVisiblePanelIndex(int min_value) const { return index; } -void LauncherView::AddIconObserver(LauncherIconObserver* observer) { +void ShelfView::AddIconObserver(LauncherIconObserver* observer) { observers_.AddObserver(observer); } -void LauncherView::RemoveIconObserver(LauncherIconObserver* observer) { +void ShelfView::RemoveIconObserver(LauncherIconObserver* observer) { observers_.RemoveObserver(observer); } -void LauncherView::AnimateToIdealBounds() { +void ShelfView::AnimateToIdealBounds() { IdealBounds ideal_bounds; CalculateIdealBounds(&ideal_bounds); for (int i = 0; i < view_model_->view_size(); ++i) { @@ -921,7 +921,7 @@ void LauncherView::AnimateToIdealBounds() { overflow_button_->SetBoundsRect(ideal_bounds.overflow_bounds); } -views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { +views::View* ShelfView::CreateViewForItem(const LauncherItem& item) { views::View* view = NULL; switch (item.type) { case TYPE_BROWSER_SHORTCUT: @@ -972,7 +972,7 @@ views::View* LauncherView::CreateViewForItem(const LauncherItem& item) { return view; } -void LauncherView::FadeIn(views::View* view) { +void ShelfView::FadeIn(views::View* view) { view->SetVisible(true); view->layer()->SetOpacity(0); AnimateToIdealBounds(); @@ -980,8 +980,7 @@ void LauncherView::FadeIn(views::View* view) { view, new FadeInAnimationDelegate(view), true); } -void LauncherView::PrepareForDrag(Pointer pointer, - const ui::LocatedEvent& event) { +void ShelfView::PrepareForDrag(Pointer pointer, const ui::LocatedEvent& event) { DCHECK(!dragging()); DCHECK(drag_view_); drag_pointer_ = pointer; @@ -1005,7 +1004,7 @@ void LauncherView::PrepareForDrag(Pointer pointer, bounds_animator_->StopAnimatingView(drag_view_); } -void LauncherView::ContinueDrag(const ui::LocatedEvent& event) { +void ShelfView::ContinueDrag(const ui::LocatedEvent& event) { // Due to a syncing operation the application might have been removed. // Bail if it is gone. int current_index = view_model_->GetIndexOfView(drag_view_); @@ -1081,7 +1080,7 @@ void LauncherView::ContinueDrag(const ui::LocatedEvent& event) { bounds_animator_->StopAnimatingView(drag_view_); } -bool LauncherView::HandleRipOffDrag(const ui::LocatedEvent& event) { +bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) { // Determine the distance to the shelf. int delta = CalculateShelfDistance(event.root_location()); int current_index = view_model_->GetIndexOfView(drag_view_); @@ -1129,7 +1128,7 @@ bool LauncherView::HandleRipOffDrag(const ui::LocatedEvent& event) { return false; } -void LauncherView::FinalizeRipOffDrag(bool cancel) { +void ShelfView::FinalizeRipOffDrag(bool cancel) { if (!dragged_off_shelf_) return; // Make sure we do not come in here again. @@ -1188,7 +1187,7 @@ void LauncherView::FinalizeRipOffDrag(bool cancel) { DestroyDragIconProxy(); } -LauncherView::RemovableState LauncherView::RemovableByRipOff(int index) { +ShelfView::RemovableState ShelfView::RemovableByRipOff(int index) { LauncherItemType type = model_->items()[index].type; if (type == TYPE_APP_LIST || !delegate_->CanPin()) return NOT_REMOVABLE; @@ -1199,8 +1198,8 @@ LauncherView::RemovableState LauncherView::RemovableByRipOff(int index) { REMOVABLE : DRAGGABLE; } -bool LauncherView::SameDragType(LauncherItemType typea, - LauncherItemType typeb) const { +bool ShelfView::SameDragType(LauncherItemType typea, + LauncherItemType typeb) const { switch (typea) { case TYPE_APP_SHORTCUT: case TYPE_BROWSER_SHORTCUT: @@ -1218,7 +1217,7 @@ bool LauncherView::SameDragType(LauncherItemType typea, return false; } -std::pair<int, int> LauncherView::GetDragRange(int index) { +std::pair<int, int> ShelfView::GetDragRange(int index) { int min_index = -1; int max_index = -1; LauncherItemType type = model_->items()[index].type; @@ -1232,12 +1231,12 @@ std::pair<int, int> LauncherView::GetDragRange(int index) { return std::pair<int, int>(min_index, max_index); } -void LauncherView::ConfigureChildView(views::View* view) { +void ShelfView::ConfigureChildView(views::View* view) { view->SetPaintToLayer(true); view->layer()->SetFillsBoundsOpaquely(false); } -void LauncherView::ToggleOverflowBubble() { +void ShelfView::ToggleOverflowBubble() { if (IsShowingOverflowBubble()) { overflow_bubble_->Hide(); return; @@ -1246,8 +1245,8 @@ void LauncherView::ToggleOverflowBubble() { if (!overflow_bubble_) overflow_bubble_.reset(new OverflowBubble()); - LauncherView* overflow_view = new LauncherView( - model_, delegate_, tooltip_->shelf_layout_manager()); + ShelfView* overflow_view = + new ShelfView(model_, delegate_, tooltip_->shelf_layout_manager()); overflow_view->Init(); overflow_view->set_owner_overflow_bubble(overflow_bubble_.get()); overflow_view->OnShelfAlignmentChanged(); @@ -1258,7 +1257,7 @@ void LauncherView::ToggleOverflowBubble() { Shell::GetInstance()->UpdateShelfVisibility(); } -void LauncherView::UpdateFirstButtonPadding() { +void ShelfView::UpdateFirstButtonPadding() { if (ash::switches::UseAlternateShelfLayout()) return; @@ -1276,7 +1275,7 @@ void LauncherView::UpdateFirstButtonPadding() { } } -void LauncherView::OnFadeOutAnimationEnded() { +void ShelfView::OnFadeOutAnimationEnded() { AnimateToIdealBounds(); // If overflow button is visible and there is a valid new last item, fading @@ -1286,12 +1285,12 @@ void LauncherView::OnFadeOutAnimationEnded() { last_visible_view->layer()->SetOpacity(0); bounds_animator_->SetAnimationDelegate( last_visible_view, - new LauncherView::StartFadeAnimationDelegate(this, last_visible_view), + new ShelfView::StartFadeAnimationDelegate(this, last_visible_view), true); } } -void LauncherView::UpdateOverflowRange(LauncherView* overflow_view) { +void ShelfView::UpdateOverflowRange(ShelfView* overflow_view) { const int first_overflow_index = last_visible_index_ + 1; const int last_overflow_index = last_hidden_index_; DCHECK_LE(first_overflow_index, last_overflow_index); @@ -1301,7 +1300,7 @@ void LauncherView::UpdateOverflowRange(LauncherView* overflow_view) { overflow_view->last_visible_index_ = last_overflow_index; } -bool LauncherView::ShouldHideTooltip(const gfx::Point& cursor_location) { +bool ShelfView::ShouldHideTooltip(const gfx::Point& cursor_location) { gfx::Rect active_bounds; for (int i = 0; i < child_count(); ++i) { @@ -1318,14 +1317,14 @@ bool LauncherView::ShouldHideTooltip(const gfx::Point& cursor_location) { return !active_bounds.Contains(cursor_location); } -gfx::Rect LauncherView::GetVisibleItemsBoundsInScreen() { +gfx::Rect ShelfView::GetVisibleItemsBoundsInScreen() { gfx::Size preferred_size = GetPreferredSize(); gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); ConvertPointToScreen(this, &origin); return gfx::Rect(origin, preferred_size); } -int LauncherView::CancelDrag(int modified_index) { +int ShelfView::CancelDrag(int modified_index) { FinalizeRipOffDrag(true); if (!drag_view_) return modified_index; @@ -1354,7 +1353,7 @@ int LauncherView::CancelDrag(int modified_index) { return modified_view ? view_model_->GetIndexOfView(modified_view) : -1; } -gfx::Size LauncherView::GetPreferredSize() { +gfx::Size ShelfView::GetPreferredSize() { IdealBounds ideal_bounds; CalculateIdealBounds(&ideal_bounds); @@ -1378,7 +1377,7 @@ gfx::Size LauncherView::GetPreferredSize() { last_button_bounds.bottom() + leading_inset()); } -void LauncherView::OnBoundsChanged(const gfx::Rect& previous_bounds) { +void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { LayoutToIdealBounds(); FOR_EACH_OBSERVER(LauncherIconObserver, observers_, OnLauncherIconPositionsChanged()); @@ -1387,21 +1386,21 @@ void LauncherView::OnBoundsChanged(const gfx::Rect& previous_bounds) { overflow_bubble_->Hide(); } -views::FocusTraversable* LauncherView::GetPaneFocusTraversable() { +views::FocusTraversable* ShelfView::GetPaneFocusTraversable() { return this; } -void LauncherView::GetAccessibleState(ui::AccessibleViewState* state) { +void ShelfView::GetAccessibleState(ui::AccessibleViewState* state) { state->role = ui::AccessibilityTypes::ROLE_TOOLBAR; state->name = l10n_util::GetStringUTF16(IDS_ASH_SHELF_ACCESSIBLE_NAME); } -void LauncherView::OnGestureEvent(ui::GestureEvent* event) { +void ShelfView::OnGestureEvent(ui::GestureEvent* event) { if (gesture_handler_.ProcessGestureEvent(*event)) event->StopPropagation(); } -void LauncherView::LauncherItemAdded(int model_index) { +void ShelfView::LauncherItemAdded(int model_index) { { base::AutoReset<bool> cancelling_drag( &cancelling_drag_model_changed_, true); @@ -1437,7 +1436,7 @@ void LauncherView::LauncherItemAdded(int model_index) { } } -void LauncherView::LauncherItemRemoved(int model_index, LauncherID id) { +void ShelfView::LauncherItemRemoved(int model_index, LauncherID id) { if (id == context_menu_id_) launcher_menu_runner_.reset(); { @@ -1457,12 +1456,12 @@ void LauncherView::LauncherItemRemoved(int model_index, LauncherID id) { // above animation finishes, CalculateIdealBounds will be called to get // correct overflow range. CalculateIdealBounds could hide overflow bubble // and triggers LauncherItemChanged. And since we are still in the middle - // of LauncherItemRemoved, LauncherView in overflow bubble is not synced + // of LauncherItemRemoved, ShelfView in overflow bubble is not synced // with LauncherModel and will crash. if (overflow_bubble_ && overflow_bubble_->IsShowing()) { last_hidden_index_ = std::min(last_hidden_index_, view_model_->view_size() - 1); - UpdateOverflowRange(overflow_bubble_->launcher_view()); + UpdateOverflowRange(overflow_bubble_->shelf_view()); } // Close the tooltip because it isn't needed any longer and its anchor view @@ -1471,8 +1470,8 @@ void LauncherView::LauncherItemRemoved(int model_index, LauncherID id) { tooltip_->Close(); } -void LauncherView::LauncherItemChanged(int model_index, - const ash::LauncherItem& old_item) { +void ShelfView::LauncherItemChanged(int model_index, + const ash::LauncherItem& old_item) { const LauncherItem& item(model_->items()[model_index]); if (old_item.type != item.type) { // Type changed, swap the views. @@ -1516,7 +1515,7 @@ void LauncherView::LauncherItemChanged(int model_index, } } -void LauncherView::LauncherItemMoved(int start_index, int target_index) { +void ShelfView::LauncherItemMoved(int start_index, int target_index) { view_model_->Move(start_index, target_index); // When cancelling a drag due to a launcher item being added, the currently // dragged item is moved back to its initial position. AnimateToIdealBounds @@ -1526,7 +1525,7 @@ void LauncherView::LauncherItemMoved(int start_index, int target_index) { AnimateToIdealBounds(); } -void LauncherView::LauncherStatusChanged() { +void ShelfView::LauncherStatusChanged() { if (ash::switches::UseAlternateShelfLayout()) return; AppListButton* app_list_button = @@ -1537,9 +1536,9 @@ void LauncherView::LauncherStatusChanged() { app_list_button->StopLoadingAnimation(); } -void LauncherView::PointerPressedOnButton(views::View* view, - Pointer pointer, - const ui::LocatedEvent& event) { +void ShelfView::PointerPressedOnButton(views::View* view, + Pointer pointer, + const ui::LocatedEvent& event) { if (drag_view_) return; @@ -1558,9 +1557,9 @@ void LauncherView::PointerPressedOnButton(views::View* view, drag_offset_ = shelf->PrimaryAxisValue(event.x(), event.y()); } -void LauncherView::PointerDraggedOnButton(views::View* view, - Pointer pointer, - const ui::LocatedEvent& event) { +void ShelfView::PointerDraggedOnButton(views::View* view, + Pointer pointer, + const ui::LocatedEvent& event) { ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager(); if (!dragging() && drag_view_ && shelf->PrimaryAxisValue(abs(event.x() - drag_offset_), @@ -1572,9 +1571,9 @@ void LauncherView::PointerDraggedOnButton(views::View* view, ContinueDrag(event); } -void LauncherView::PointerReleasedOnButton(views::View* view, - Pointer pointer, - bool canceled) { +void ShelfView::PointerReleasedOnButton(views::View* view, + Pointer pointer, + bool canceled) { if (canceled) { CancelDrag(-1); } else if (drag_pointer_ == pointer) { @@ -1588,7 +1587,7 @@ void LauncherView::PointerReleasedOnButton(views::View* view, drag_view_ = NULL; } -void LauncherView::MouseMovedOverButton(views::View* view) { +void ShelfView::MouseMovedOverButton(views::View* view) { if (!ShouldShowTooltipForView(view)) return; @@ -1596,7 +1595,7 @@ void LauncherView::MouseMovedOverButton(views::View* view) { tooltip_->ResetTimer(); } -void LauncherView::MouseEnteredButton(views::View* view) { +void ShelfView::MouseEnteredButton(views::View* view) { if (!ShouldShowTooltipForView(view)) return; @@ -1607,12 +1606,12 @@ void LauncherView::MouseEnteredButton(views::View* view) { } } -void LauncherView::MouseExitedButton(views::View* view) { +void ShelfView::MouseExitedButton(views::View* view) { if (!tooltip_->IsVisible()) tooltip_->StopTimer(); } -base::string16 LauncherView::GetAccessibleName(const views::View* view) { +base::string16 ShelfView::GetAccessibleName(const views::View* view) { int view_index = view_model_->GetIndexOfView(view); // May be -1 while in the process of animating closed. if (view_index == -1) @@ -1623,8 +1622,7 @@ base::string16 LauncherView::GetAccessibleName(const views::View* view) { return item_delegate->GetTitle(); } -void LauncherView::ButtonPressed(views::Button* sender, - const ui::Event& event) { +void ShelfView::ButtonPressed(views::Button* sender, const ui::Event& event) { // Do not handle mouse release during drag. if (dragging()) return; @@ -1686,9 +1684,9 @@ void LauncherView::ButtonPressed(views::Button* sender, } } -bool LauncherView::ShowListMenuForView(const LauncherItem& item, - views::View* source, - const ui::Event& event) { +bool ShelfView::ShowListMenuForView(const LauncherItem& item, + views::View* source, + const ui::Event& event) { scoped_ptr<ash::LauncherMenuModel> menu_model; LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate(item.id); @@ -1708,9 +1706,9 @@ bool LauncherView::ShowListMenuForView(const LauncherItem& item, return true; } -void LauncherView::ShowContextMenuForView(views::View* source, - const gfx::Point& point, - ui:: MenuSourceType source_type) { +void ShelfView::ShowContextMenuForView(views::View* source, + const gfx::Point& point, + ui::MenuSourceType source_type) { int view_index = view_model_->GetIndexOfView(source); // TODO(simon.hong81): Create LauncherContextMenu for applist in its // LauncherItemDelegate. @@ -1743,12 +1741,11 @@ void LauncherView::ShowContextMenuForView(views::View* source, source_type); } -void LauncherView::ShowMenu( - scoped_ptr<views::MenuModelAdapter> menu_model_adapter, - views::View* source, - const gfx::Point& click_point, - bool context_menu, - ui::MenuSourceType source_type) { +void ShelfView::ShowMenu(scoped_ptr<views::MenuModelAdapter> menu_model_adapter, + views::View* source, + const gfx::Point& click_point, + bool context_menu, + ui::MenuSourceType source_type) { closing_event_time_ = base::TimeDelta(); launcher_menu_runner_.reset( new views::MenuRunner(menu_model_adapter->CreateMenu())); @@ -1833,13 +1830,13 @@ void LauncherView::ShowMenu( Shell::GetInstance()->UpdateShelfVisibility(); } -void LauncherView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) { +void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) { FOR_EACH_OBSERVER(LauncherIconObserver, observers_, OnLauncherIconPositionsChanged()); PreferredSizeChanged(); } -void LauncherView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { +void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { if (snap_back_from_rip_off_view_ && animator == bounds_animator_) { if (!animator->IsAnimating(snap_back_from_rip_off_view_)) { // Coming here the animation of the LauncherButton is finished and the @@ -1859,7 +1856,7 @@ void LauncherView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { } } -bool LauncherView::IsUsableEvent(const ui::Event& event) { +bool ShelfView::IsUsableEvent(const ui::Event& event) { if (closing_event_time_ == base::TimeDelta()) return true; @@ -1871,7 +1868,7 @@ bool LauncherView::IsUsableEvent(const ui::Event& event) { return (delta.InMilliseconds() < 0 || delta.InMilliseconds() > 130); } -const LauncherItem* LauncherView::LauncherItemForView( +const LauncherItem* ShelfView::LauncherItemForView( const views::View* view) const { int view_index = view_model_->GetIndexOfView(view); if (view_index == -1) @@ -1879,7 +1876,7 @@ const LauncherItem* LauncherView::LauncherItemForView( return &(model_->items()[view_index]); } -bool LauncherView::ShouldShowTooltipForView(const views::View* view) const { +bool ShelfView::ShouldShowTooltipForView(const views::View* view) const { if (view == GetAppListButtonView() && Shell::GetInstance()->GetAppListWindow()) return false; @@ -1891,7 +1888,7 @@ bool LauncherView::ShouldShowTooltipForView(const views::View* view) const { return item_delegate->ShouldShowTooltip(); } -int LauncherView::CalculateShelfDistance(const gfx::Point& coordinate) const { +int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { ShelfWidget* shelf = RootWindowController::ForLauncher( GetWidget()->GetNativeView())->shelf(); ash::ShelfAlignment align = shelf->GetAlignment(); diff --git a/ash/launcher/launcher_view.h b/ash/shelf/shelf_view.h index 4032884..0953dd34 100644 --- a/ash/launcher/launcher_view.h +++ b/ash/shelf/shelf_view.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_LAUNCHER_LAUNCHER_VIEW_H_ -#define ASH_LAUNCHER_LAUNCHER_VIEW_H_ +#ifndef ASH_SHELF_SHELF_VIEW_H_ +#define ASH_SHELF_SHELF_VIEW_H_ #include <utility> #include <vector> @@ -29,7 +29,7 @@ class ViewModel; namespace ash { namespace test { -class LauncherViewTestAPI; +class ShelfViewTestAPI; } class LauncherDelegate; @@ -47,19 +47,19 @@ class OverflowButton; class ShelfLayoutManager; class ShelfTooltipManager; -class ASH_EXPORT LauncherView : public views::View, - public LauncherModelObserver, - public views::ButtonListener, - public LauncherButtonHost, - public views::ContextMenuController, - public views::FocusTraversable, - public views::BoundsAnimatorObserver, - public app_list::ApplicationDragAndDropHost { +class ASH_EXPORT ShelfView : public views::View, + public LauncherModelObserver, + public views::ButtonListener, + public LauncherButtonHost, + public views::ContextMenuController, + public views::FocusTraversable, + public views::BoundsAnimatorObserver, + public app_list::ApplicationDragAndDropHost { public: - LauncherView(LauncherModel* model, - LauncherDelegate* delegate, - ShelfLayoutManager* shelf_layout_manager); - virtual ~LauncherView(); + ShelfView(LauncherModel* model, + LauncherDelegate* delegate, + ShelfLayoutManager* shelf_layout_manager); + virtual ~ShelfView(); ShelfTooltipManager* tooltip_manager() { return tooltip_.get(); } @@ -86,7 +86,7 @@ class ASH_EXPORT LauncherView : public views::View, // Returns true if overflow bubble is shown. bool IsShowingOverflowBubble() const; - // Sets owner overflow bubble instance from which this launcher view pops + // Sets owner overflow bubble instance from which this shelf view pops // out as overflow. void set_owner_overflow_bubble(OverflowBubble* owner) { owner_overflow_bubble_ = owner; @@ -134,7 +134,7 @@ class ASH_EXPORT LauncherView : public views::View, } private: - friend class ash::test::LauncherViewTestAPI; + friend class ash::test::ShelfViewTestAPI; class FadeOutAnimationDelegate; class StartFadeAnimationDelegate; @@ -224,7 +224,7 @@ class ASH_EXPORT LauncherView : public views::View, void OnFadeOutAnimationEnded(); // Updates the visible range of overflow items in |overflow_view|. - void UpdateOverflowRange(LauncherView* overflow_view); + void UpdateOverflowRange(ShelfView* overflow_view); // Overridden from views::View: virtual gfx::Size GetPreferredSize() OVERRIDE; @@ -318,7 +318,7 @@ class ASH_EXPORT LauncherView : public views::View, scoped_ptr<views::ViewModel> view_model_; // Index of first visible launcher item. When it it greater than 0, - // LauncherView is hosted in an overflow bubble. In this mode, it does not + // ShelfView is hosted in an overflow bubble. In this mode, it does not // show browser, app list and overflow button. int first_visible_index_; @@ -412,10 +412,10 @@ class ASH_EXPORT LauncherView : public views::View, // Holds LauncherItemDelegateManager. LauncherItemDelegateManager* item_manager_; - DISALLOW_COPY_AND_ASSIGN(LauncherView); + DISALLOW_COPY_AND_ASSIGN(ShelfView); }; } // namespace internal } // namespace ash -#endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ +#endif // ASH_SHELF_SHELF_VIEW_H_ diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc index 220fd64..1e1765b 100644 --- a/ash/launcher/launcher_view_unittest.cc +++ b/ash/shelf/shelf_view_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/launcher/launcher_view.h" +#include "ash/shelf/shelf_view.h" #include <algorithm> #include <vector> @@ -22,7 +22,7 @@ #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" #include "ash/test/launcher_test_api.h" -#include "ash/test/launcher_view_test_api.h" +#include "ash/test/shelf_view_test_api.h" #include "ash/test/shell_test_api.h" #include "ash/test/test_launcher_delegate.h" #include "ash/test/test_launcher_item_delegate.h" @@ -78,19 +78,19 @@ class TestLauncherIconObserver : public LauncherIconObserver { DISALLOW_COPY_AND_ASSIGN(TestLauncherIconObserver); }; -class LauncherViewIconObserverTest : public ash::test::AshTestBase { +class ShelfViewIconObserverTest : public ash::test::AshTestBase { public: - LauncherViewIconObserverTest() {} - virtual ~LauncherViewIconObserverTest() {} + ShelfViewIconObserverTest() {} + virtual ~ShelfViewIconObserverTest() {} virtual void SetUp() OVERRIDE { AshTestBase::SetUp(); Launcher* launcher = Launcher::ForPrimaryDisplay(); observer_.reset(new TestLauncherIconObserver(launcher)); - launcher_view_test_.reset(new LauncherViewTestAPI( - LauncherTestAPI(launcher).launcher_view())); - launcher_view_test_->SetAnimationDuration(1); + shelf_view_test_.reset(new ShelfViewTestAPI( + LauncherTestAPI(launcher).shelf_view())); + shelf_view_test_->SetAnimationDuration(1); } virtual void TearDown() OVERRIDE { @@ -100,8 +100,8 @@ class LauncherViewIconObserverTest : public ash::test::AshTestBase { TestLauncherIconObserver* observer() { return observer_.get(); } - LauncherViewTestAPI* launcher_view_test() { - return launcher_view_test_.get(); + ShelfViewTestAPI* shelf_view_test() { + return shelf_view_test_.get(); } Launcher* LauncherForSecondaryDisplay() { @@ -110,12 +110,12 @@ class LauncherViewIconObserverTest : public ash::test::AshTestBase { private: scoped_ptr<TestLauncherIconObserver> observer_; - scoped_ptr<LauncherViewTestAPI> launcher_view_test_; + scoped_ptr<ShelfViewTestAPI> shelf_view_test_; - DISALLOW_COPY_AND_ASSIGN(LauncherViewIconObserverTest); + DISALLOW_COPY_AND_ASSIGN(ShelfViewIconObserverTest); }; -TEST_F(LauncherViewIconObserverTest, AddRemove) { +TEST_F(ShelfViewIconObserverTest, AddRemove) { ash::test::TestLauncherDelegate* launcher_delegate = ash::test::TestLauncherDelegate::instance(); ASSERT_TRUE(launcher_delegate); @@ -128,13 +128,13 @@ TEST_F(LauncherViewIconObserverTest, AddRemove) { scoped_ptr<views::Widget> widget(new views::Widget()); widget->Init(params); launcher_delegate->AddLauncherItem(widget->GetNativeWindow()); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(observer()->change_notified()); observer()->Reset(); widget->Show(); widget->GetNativeWindow()->parent()->RemoveChild(widget->GetNativeWindow()); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(observer()->change_notified()); observer()->Reset(); } @@ -149,7 +149,7 @@ TEST_F(LauncherViewIconObserverTest, AddRemove) { #endif // Make sure creating/deleting an window on one displays notifies a // launcher on external display as well as one on primary. -TEST_F(LauncherViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { +TEST_F(ShelfViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { UpdateDisplay("400x400,400x400"); TestLauncherIconObserver second_observer(LauncherForSecondaryDisplay()); @@ -165,14 +165,14 @@ TEST_F(LauncherViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { scoped_ptr<views::Widget> widget(new views::Widget()); widget->Init(params); launcher_delegate->AddLauncherItem(widget->GetNativeWindow()); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(observer()->change_notified()); EXPECT_TRUE(second_observer.change_notified()); observer()->Reset(); second_observer.Reset(); widget->GetNativeWindow()->parent()->RemoveChild(widget->GetNativeWindow()); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(observer()->change_notified()); EXPECT_TRUE(second_observer.change_notified()); @@ -180,39 +180,39 @@ TEST_F(LauncherViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { second_observer.Reset(); } -TEST_F(LauncherViewIconObserverTest, BoundsChanged) { +TEST_F(ShelfViewIconObserverTest, BoundsChanged) { ash::ShelfWidget* shelf = Shell::GetPrimaryRootWindowController()->shelf(); Launcher* launcher = Launcher::ForPrimaryDisplay(); gfx::Size shelf_size = shelf->GetWindowBoundsInScreen().size(); shelf_size.set_width(shelf_size.width() / 2); ASSERT_GT(shelf_size.width(), 0); - launcher->SetLauncherViewBounds(gfx::Rect(shelf_size)); - // No animation happens for LauncherView bounds change. + launcher->SetShelfViewBounds(gfx::Rect(shelf_size)); + // No animation happens for ShelfView bounds change. EXPECT_TRUE(observer()->change_notified()); observer()->Reset(); } //////////////////////////////////////////////////////////////////////////////// -// LauncherView tests. +// ShelfView tests. -class LauncherViewTest : public AshTestBase { +class ShelfViewTest : public AshTestBase { public: - LauncherViewTest() : model_(NULL), launcher_view_(NULL), browser_index_(1) {} - virtual ~LauncherViewTest() {} + ShelfViewTest() : model_(NULL), shelf_view_(NULL), browser_index_(1) {} + virtual ~ShelfViewTest() {} virtual void SetUp() OVERRIDE { AshTestBase::SetUp(); test::ShellTestApi test_api(Shell::GetInstance()); model_ = test_api.launcher_model(); Launcher* launcher = Launcher::ForPrimaryDisplay(); - launcher_view_ = test::LauncherTestAPI(launcher).launcher_view(); + shelf_view_ = test::LauncherTestAPI(launcher).shelf_view(); // The bounds should be big enough for 4 buttons + overflow chevron. - launcher_view_->SetBounds(0, 0, 500, + shelf_view_->SetBounds(0, 0, 500, internal::ShelfLayoutManager::GetPreferredShelfSize()); - test_api_.reset(new LauncherViewTestAPI(launcher_view_)); + test_api_.reset(new ShelfViewTestAPI(shelf_view_)); test_api_->SetAnimationDuration(1); // Speeds up animation for test. item_manager_ = @@ -325,12 +325,12 @@ class LauncherViewTest : public AshTestBase { void VerifyLauncherItemBoundsAreValid() { for (int i=0;i <= test_api_->GetLastVisibleIndex(); ++i) { if (test_api_->GetButton(i)) { - gfx::Rect launcher_view_bounds = launcher_view_->GetLocalBounds(); + gfx::Rect shelf_view_bounds = shelf_view_->GetLocalBounds(); gfx::Rect item_bounds = test_api_->GetBoundsByIndex(i); EXPECT_TRUE(item_bounds.x() >= 0); EXPECT_TRUE(item_bounds.y() >= 0); - EXPECT_TRUE(item_bounds.right() <= launcher_view_bounds.width()); - EXPECT_TRUE(item_bounds.bottom() <= launcher_view_bounds.height()); + EXPECT_TRUE(item_bounds.right() <= shelf_view_bounds.width()); + EXPECT_TRUE(item_bounds.bottom() <= shelf_view_bounds.height()); } } } @@ -338,7 +338,7 @@ class LauncherViewTest : public AshTestBase { views::View* SimulateButtonPressed( internal::LauncherButtonHost::Pointer pointer, int button_index) { - internal::LauncherButtonHost* button_host = launcher_view_; + internal::LauncherButtonHost* button_host = shelf_view_; views::View* button = test_api_->GetButton(button_index); ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, button->bounds().origin(), @@ -349,7 +349,7 @@ class LauncherViewTest : public AshTestBase { views::View* SimulateClick(internal::LauncherButtonHost::Pointer pointer, int button_index) { - internal::LauncherButtonHost* button_host = launcher_view_; + internal::LauncherButtonHost* button_host = shelf_view_; views::View* button = SimulateButtonPressed(pointer, button_index); button_host->PointerReleasedOnButton(button, internal::LauncherButtonHost::MOUSE, @@ -360,7 +360,7 @@ class LauncherViewTest : public AshTestBase { views::View* SimulateDrag(internal::LauncherButtonHost::Pointer pointer, int button_index, int destination_index) { - internal::LauncherButtonHost* button_host = launcher_view_; + internal::LauncherButtonHost* button_host = shelf_view_; views::View* button = SimulateButtonPressed(pointer, button_index); // Drag. @@ -393,40 +393,40 @@ class LauncherViewTest : public AshTestBase { } views::View* GetTooltipAnchorView() { - return launcher_view_->tooltip_manager()->anchor_; + return shelf_view_->tooltip_manager()->anchor_; } void ShowTooltip() { - launcher_view_->tooltip_manager()->ShowInternal(); + shelf_view_->tooltip_manager()->ShowInternal(); } LauncherModel* model_; - internal::LauncherView* launcher_view_; + internal::ShelfView* shelf_view_; int browser_index_; LauncherItemDelegateManager* item_manager_; - scoped_ptr<LauncherViewTestAPI> test_api_; + scoped_ptr<ShelfViewTestAPI> test_api_; private: - DISALLOW_COPY_AND_ASSIGN(LauncherViewTest); + DISALLOW_COPY_AND_ASSIGN(ShelfViewTest); }; -class LauncherViewLegacyShelfLayoutTest : public LauncherViewTest { +class ShelfViewLegacyShelfLayoutTest : public ShelfViewTest { public: - LauncherViewLegacyShelfLayoutTest() : LauncherViewTest() { + ShelfViewLegacyShelfLayoutTest() : ShelfViewTest() { browser_index_ = 0; } - virtual ~LauncherViewLegacyShelfLayoutTest() {} + virtual ~ShelfViewLegacyShelfLayoutTest() {} virtual void SetUp() OVERRIDE { CommandLine::ForCurrentProcess()->AppendSwitch( ash::switches::kAshDisableAlternateShelfLayout); - LauncherViewTest::SetUp(); + ShelfViewTest::SetUp(); } private: - DISALLOW_COPY_AND_ASSIGN(LauncherViewLegacyShelfLayoutTest); + DISALLOW_COPY_AND_ASSIGN(ShelfViewLegacyShelfLayoutTest); }; class ScopedTextDirectionChange { @@ -453,45 +453,45 @@ class ScopedTextDirectionChange { std::string original_locale_; }; -class LauncherViewTextDirectionTest - : public LauncherViewTest, +class ShelfViewTextDirectionTest + : public ShelfViewTest, public testing::WithParamInterface<bool> { public: - LauncherViewTextDirectionTest() : text_direction_change_(GetParam()) {} - virtual ~LauncherViewTextDirectionTest() {} + ShelfViewTextDirectionTest() : text_direction_change_(GetParam()) {} + virtual ~ShelfViewTextDirectionTest() {} virtual void SetUp() OVERRIDE { - LauncherViewTest::SetUp(); + ShelfViewTest::SetUp(); } virtual void TearDown() OVERRIDE { - LauncherViewTest::TearDown(); + ShelfViewTest::TearDown(); } private: ScopedTextDirectionChange text_direction_change_; - DISALLOW_COPY_AND_ASSIGN(LauncherViewTextDirectionTest); + DISALLOW_COPY_AND_ASSIGN(ShelfViewTextDirectionTest); }; // Checks that the ideal item icon bounds match the view's bounds in the screen // in both LTR and RTL. -TEST_P(LauncherViewTextDirectionTest, IdealBoundsOfItemIcon) { +TEST_P(ShelfViewTextDirectionTest, IdealBoundsOfItemIcon) { LauncherID id = AddPlatformApp(); internal::LauncherButton* button = GetButtonByID(id); gfx::Rect item_bounds = button->GetBoundsInScreen(); gfx::Point icon_offset = button->GetIconBounds().origin(); item_bounds.Offset(icon_offset.OffsetFromOrigin()); - gfx::Rect ideal_bounds = launcher_view_->GetIdealBoundsOfItemIcon(id); + gfx::Rect ideal_bounds = shelf_view_->GetIdealBoundsOfItemIcon(id); gfx::Point screen_origin; - views::View::ConvertPointToScreen(launcher_view_, &screen_origin); + views::View::ConvertPointToScreen(shelf_view_, &screen_origin); ideal_bounds.Offset(screen_origin.x(), screen_origin.y()); EXPECT_EQ(item_bounds.x(), ideal_bounds.x()); EXPECT_EQ(item_bounds.y(), ideal_bounds.y()); } -// Checks that launcher view contents are considered in the correct drag group. -TEST_F(LauncherViewTest, EnforceDragType) { +// Checks that shelf view contents are considered in the correct drag group. +TEST_F(ShelfViewTest, EnforceDragType) { EXPECT_TRUE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_PLATFORM_APP)); EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, TYPE_APP_SHORTCUT)); EXPECT_FALSE(test_api_->SameDragType(TYPE_PLATFORM_APP, @@ -527,7 +527,7 @@ TEST_F(LauncherViewTest, EnforceDragType) { // Adds platform app button until overflow and verifies that the last added // platform app button is hidden. -TEST_F(LauncherViewTest, AddBrowserUntilOverflow) { +TEST_F(ShelfViewTest, AddBrowserUntilOverflow) { // All buttons should be visible. ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -551,7 +551,7 @@ TEST_F(LauncherViewTest, AddBrowserUntilOverflow) { // Adds one platform app button then adds app shortcut until overflow. Verifies // that the browser button gets hidden on overflow and last added app shortcut // is still visible. -TEST_F(LauncherViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) { +TEST_F(ShelfViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) { // All buttons should be visible. ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -574,7 +574,7 @@ TEST_F(LauncherViewTest, AddAppShortcutWithBrowserButtonUntilOverflow) { EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); } -TEST_F(LauncherViewLegacyShelfLayoutTest, +TEST_F(ShelfViewLegacyShelfLayoutTest, AddAppShortcutWithBrowserButtonUntilOverflow) { // All buttons should be visible. ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, @@ -600,7 +600,7 @@ TEST_F(LauncherViewLegacyShelfLayoutTest, EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); } -TEST_F(LauncherViewTest, AddPanelHidesPlatformAppButton) { +TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -627,7 +627,7 @@ TEST_F(LauncherViewTest, AddPanelHidesPlatformAppButton) { EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); } -TEST_F(LauncherViewLegacyShelfLayoutTest, AddPanelHidesPlatformAppButton) { +TEST_F(ShelfViewLegacyShelfLayoutTest, AddPanelHidesPlatformAppButton) { ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -658,7 +658,7 @@ TEST_F(LauncherViewLegacyShelfLayoutTest, AddPanelHidesPlatformAppButton) { // When there are more panels then platform app buttons we should hide panels // rather than platform apps. -TEST_F(LauncherViewTest, PlatformAppHidesExcessPanels) { +TEST_F(ShelfViewTest, PlatformAppHidesExcessPanels) { ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -700,7 +700,7 @@ TEST_F(LauncherViewTest, PlatformAppHidesExcessPanels) { // Adds button until overflow then removes first added one. Verifies that // the last added one changes from invisible to visible and overflow // chevron is gone. -TEST_F(LauncherViewTest, RemoveButtonRevealsOverflowed) { +TEST_F(ShelfViewTest, RemoveButtonRevealsOverflowed) { // All buttons should be visible. ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -730,7 +730,7 @@ TEST_F(LauncherViewTest, RemoveButtonRevealsOverflowed) { } // Verifies that remove last overflowed button should hide overflow chevron. -TEST_F(LauncherViewTest, RemoveLastOverflowed) { +TEST_F(ShelfViewTest, RemoveLastOverflowed) { // All buttons should be visible. ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -750,7 +750,7 @@ TEST_F(LauncherViewTest, RemoveLastOverflowed) { // Adds platform app button without waiting for animation to finish and verifies // that all added buttons are visible. -TEST_F(LauncherViewTest, AddButtonQuickly) { +TEST_F(ShelfViewTest, AddButtonQuickly) { // All buttons should be visible. ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -763,7 +763,7 @@ TEST_F(LauncherViewTest, AddButtonQuickly) { ASSERT_LT(added_count, 10000); } - // LauncherView should be big enough to hold at least 3 new buttons. + // ShelfView should be big enough to hold at least 3 new buttons. ASSERT_GE(added_count, 3); // Wait for the last animation to finish. @@ -781,8 +781,8 @@ TEST_F(LauncherViewTest, AddButtonQuickly) { // Check that model changes are handled correctly while a launcher icon is being // dragged. -TEST_F(LauncherViewTest, ModelChangesWhileDragging) { - internal::LauncherButtonHost* button_host = launcher_view_; +TEST_F(ShelfViewTest, ModelChangesWhileDragging) { + internal::LauncherButtonHost* button_host = shelf_view_; std::vector<std::pair<LauncherID, views::View*> > id_map; SetupForDragTest(&id_map); @@ -848,8 +848,8 @@ TEST_F(LauncherViewTest, ModelChangesWhileDragging) { false); } -TEST_F(LauncherViewLegacyShelfLayoutTest, ModelChangesWhileDragging) { - internal::LauncherButtonHost* button_host = launcher_view_; +TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) { + internal::LauncherButtonHost* button_host = shelf_view_; std::vector<std::pair<LauncherID, views::View*> > id_map; SetupForDragTest(&id_map); @@ -916,8 +916,8 @@ TEST_F(LauncherViewLegacyShelfLayoutTest, ModelChangesWhileDragging) { } // Check that 2nd drag from the other pointer would be ignored. -TEST_F(LauncherViewTest, SimultaneousDrag) { - internal::LauncherButtonHost* button_host = launcher_view_; +TEST_F(ShelfViewTest, SimultaneousDrag) { + internal::LauncherButtonHost* button_host = shelf_view_; std::vector<std::pair<LauncherID, views::View*> > id_map; SetupForDragTest(&id_map); @@ -965,8 +965,8 @@ TEST_F(LauncherViewTest, SimultaneousDrag) { // Check that clicking first on one item and then dragging another works as // expected. -TEST_F(LauncherViewTest, ClickOneDragAnother) { - internal::LauncherButtonHost* button_host = launcher_view_; +TEST_F(ShelfViewTest, ClickOneDragAnother) { + internal::LauncherButtonHost* button_host = shelf_view_; std::vector<std::pair<LauncherID, views::View*> > id_map; SetupForDragTest(&id_map); @@ -989,7 +989,7 @@ TEST_F(LauncherViewTest, ClickOneDragAnother) { } // Confirm that item status changes are reflected in the buttons. -TEST_F(LauncherViewTest, LauncherItemStatus) { +TEST_F(ShelfViewTest, LauncherItemStatus) { ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -1007,7 +1007,7 @@ TEST_F(LauncherViewTest, LauncherItemStatus) { ASSERT_EQ(internal::LauncherButton::STATE_ATTENTION, button->state()); } -TEST_F(LauncherViewLegacyShelfLayoutTest, +TEST_F(ShelfViewLegacyShelfLayoutTest, LauncherItemPositionReflectedOnStateChanged) { ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -1042,7 +1042,7 @@ TEST_F(LauncherViewLegacyShelfLayoutTest, // Confirm that item status changes are reflected in the buttons // for platform apps. -TEST_F(LauncherViewTest, LauncherItemStatusPlatformApp) { +TEST_F(ShelfViewTest, LauncherItemStatusPlatformApp) { ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -1061,7 +1061,7 @@ TEST_F(LauncherViewTest, LauncherItemStatusPlatformApp) { } // Confirm that launcher item bounds are correctly updated on shelf changes. -TEST_F(LauncherViewTest, LauncherItemBoundsCheck) { +TEST_F(ShelfViewTest, LauncherItemBoundsCheck) { internal::ShelfLayoutManager* shelf_layout_manager = Shell::GetPrimaryRootWindowController()->shelf()->shelf_layout_manager(); VerifyLauncherItemBoundsAreValid(); @@ -1073,7 +1073,7 @@ TEST_F(LauncherViewTest, LauncherItemBoundsCheck) { VerifyLauncherItemBoundsAreValid(); } -TEST_F(LauncherViewTest, ShelfTooltipTest) { +TEST_F(ShelfViewTest, ShelfTooltipTest) { ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -1084,9 +1084,9 @@ TEST_F(LauncherViewTest, ShelfTooltipTest) { internal::LauncherButton* app_button = GetButtonByID(app_button_id); internal::LauncherButton* platform_button = GetButtonByID(platform_button_id); - internal::LauncherButtonHost* button_host = launcher_view_; + internal::LauncherButtonHost* button_host = shelf_view_; internal::ShelfTooltipManager* tooltip_manager = - launcher_view_->tooltip_manager(); + shelf_view_->tooltip_manager(); button_host->MouseEnteredButton(app_button); // There's a delay to show the tooltip, so it's not visible yet. @@ -1121,10 +1121,10 @@ TEST_F(LauncherViewTest, ShelfTooltipTest) { // Verify a fix for crash caused by a tooltip update for a deleted launcher // button, see crbug.com/288838. -TEST_F(LauncherViewTest, RemovingItemClosesTooltip) { - internal::LauncherButtonHost* button_host = launcher_view_; +TEST_F(ShelfViewTest, RemovingItemClosesTooltip) { + internal::LauncherButtonHost* button_host = shelf_view_; internal::ShelfTooltipManager* tooltip_manager = - launcher_view_->tooltip_manager(); + shelf_view_->tooltip_manager(); // Add an item to the launcher. LauncherID app_button_id = AddAppShortcut(); @@ -1147,10 +1147,10 @@ TEST_F(LauncherViewTest, RemovingItemClosesTooltip) { } // Changing the shelf alignment closes any open tooltip. -TEST_F(LauncherViewTest, ShelfAlignmentClosesTooltip) { - internal::LauncherButtonHost* button_host = launcher_view_; +TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { + internal::LauncherButtonHost* button_host = shelf_view_; internal::ShelfTooltipManager* tooltip_manager = - launcher_view_->tooltip_manager(); + shelf_view_->tooltip_manager(); // Add an item to the launcher. LauncherID app_button_id = AddAppShortcut(); @@ -1168,7 +1168,7 @@ TEST_F(LauncherViewTest, ShelfAlignmentClosesTooltip) { EXPECT_FALSE(tooltip_manager->IsVisible()); } -TEST_F(LauncherViewTest, ShouldHideTooltipTest) { +TEST_F(ShelfViewTest, ShouldHideTooltipTest) { LauncherID app_button_id = AddAppShortcut(); LauncherID platform_button_id = AddPlatformApp(); @@ -1178,14 +1178,14 @@ TEST_F(LauncherViewTest, ShouldHideTooltipTest) { if (!button) continue; - EXPECT_FALSE(launcher_view_->ShouldHideTooltip( + EXPECT_FALSE(shelf_view_->ShouldHideTooltip( button->GetMirroredBounds().CenterPoint())) - << "LauncherView tries to hide on button " << i; + << "ShelfView tries to hide on button " << i; } // The tooltip should not hide on the app-list button. - views::View* app_list_button = launcher_view_->GetAppListButtonView(); - EXPECT_FALSE(launcher_view_->ShouldHideTooltip( + views::View* app_list_button = shelf_view_->GetAppListButtonView(); + EXPECT_FALSE(shelf_view_->ShouldHideTooltip( app_list_button->GetMirroredBounds().CenterPoint())); // The tooltip shouldn't hide if the mouse is in the gap between two buttons. @@ -1193,7 +1193,7 @@ TEST_F(LauncherViewTest, ShouldHideTooltipTest) { gfx::Rect platform_button_rect = GetButtonByID(platform_button_id)->GetMirroredBounds(); ASSERT_FALSE(app_button_rect.Intersects(platform_button_rect)); - EXPECT_FALSE(launcher_view_->ShouldHideTooltip( + EXPECT_FALSE(shelf_view_->ShouldHideTooltip( gfx::UnionRects(app_button_rect, platform_button_rect).CenterPoint())); // The tooltip should hide if it's outside of all buttons. @@ -1205,21 +1205,21 @@ TEST_F(LauncherViewTest, ShouldHideTooltipTest) { all_area.Union(button->GetMirroredBounds()); } - all_area.Union(launcher_view_->GetAppListButtonView()->GetMirroredBounds()); - EXPECT_FALSE(launcher_view_->ShouldHideTooltip(all_area.origin())); - EXPECT_FALSE(launcher_view_->ShouldHideTooltip( + all_area.Union(shelf_view_->GetAppListButtonView()->GetMirroredBounds()); + EXPECT_FALSE(shelf_view_->ShouldHideTooltip(all_area.origin())); + EXPECT_FALSE(shelf_view_->ShouldHideTooltip( gfx::Point(all_area.right() - 1, all_area.bottom() - 1))); - EXPECT_TRUE(launcher_view_->ShouldHideTooltip( + EXPECT_TRUE(shelf_view_->ShouldHideTooltip( gfx::Point(all_area.right(), all_area.y()))); - EXPECT_TRUE(launcher_view_->ShouldHideTooltip( + EXPECT_TRUE(shelf_view_->ShouldHideTooltip( gfx::Point(all_area.x() - 1, all_area.y()))); - EXPECT_TRUE(launcher_view_->ShouldHideTooltip( + EXPECT_TRUE(shelf_view_->ShouldHideTooltip( gfx::Point(all_area.x(), all_area.y() - 1))); - EXPECT_TRUE(launcher_view_->ShouldHideTooltip( + EXPECT_TRUE(shelf_view_->ShouldHideTooltip( gfx::Point(all_area.x(), all_area.bottom()))); } -TEST_F(LauncherViewTest, ShouldHideTooltipWithAppListWindowTest) { +TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) { Shell::GetInstance()->ToggleAppList(NULL); ASSERT_TRUE(Shell::GetInstance()->GetAppListWindow()); @@ -1229,22 +1229,22 @@ TEST_F(LauncherViewTest, ShouldHideTooltipWithAppListWindowTest) { if (!button) continue; - EXPECT_FALSE(launcher_view_->ShouldHideTooltip( + EXPECT_FALSE(shelf_view_->ShouldHideTooltip( button->GetMirroredBounds().CenterPoint())) - << "LauncherView tries to hide on button " << i; + << "ShelfView tries to hide on button " << i; } // The tooltip should hide on the app-list button. - views::View* app_list_button = launcher_view_->GetAppListButtonView(); - EXPECT_TRUE(launcher_view_->ShouldHideTooltip( + views::View* app_list_button = shelf_view_->GetAppListButtonView(); + EXPECT_TRUE(shelf_view_->ShouldHideTooltip( app_list_button->GetMirroredBounds().CenterPoint())); } // Test that by moving the mouse cursor off the button onto the bubble it closes // the bubble. -TEST_F(LauncherViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { +TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { internal::ShelfTooltipManager* tooltip_manager = - launcher_view_->tooltip_manager(); + shelf_view_->tooltip_manager(); tooltip_manager->CreateZeroDelayTimerForTest(); aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); @@ -1253,7 +1253,7 @@ TEST_F(LauncherViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { EXPECT_FALSE(tooltip_manager->IsVisible()); // Move the mouse over the button and check that it is visible. - views::View* app_list_button = launcher_view_->GetAppListButtonView(); + views::View* app_list_button = shelf_view_->GetAppListButtonView(); gfx::Rect bounds = app_list_button->GetBoundsInScreen(); generator.MoveMouseTo(bounds.CenterPoint()); // Wait for the timer to go off. @@ -1281,10 +1281,10 @@ TEST_F(LauncherViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { EXPECT_FALSE(tooltip_manager->IsVisible()); } -// Resizing launcher view while an add animation without fade-in is running, +// Resizing shelf view while an add animation without fade-in is running, // which happens when overflow happens. App list button should end up in its // new ideal bounds. -TEST_F(LauncherViewTest, ResizeDuringOverflowAddAnimation) { +TEST_F(ShelfViewTest, ResizeDuringOverflowAddAnimation) { // All buttons should be visible. ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -1300,10 +1300,10 @@ TEST_F(LauncherViewTest, ResizeDuringOverflowAddAnimation) { ASSERT_LT(items_added, 10000); } - // Resize launcher view with that animation running and stay overflown. - gfx::Rect bounds = launcher_view_->bounds(); + // Resize shelf view with that animation running and stay overflown. + gfx::Rect bounds = shelf_view_->bounds(); bounds.set_width(bounds.width() - kLauncherPreferredSize); - launcher_view_->SetBoundsRect(bounds); + shelf_view_->SetBoundsRect(bounds); ASSERT_TRUE(test_api_->IsOverflowButtonVisible()); // Finish the animation. @@ -1320,7 +1320,7 @@ TEST_F(LauncherViewTest, ResizeDuringOverflowAddAnimation) { // Check that the first item in the list follows Fitt's law by including the // first pixel and being therefore bigger then the others. -TEST_F(LauncherViewLegacyShelfLayoutTest, CheckFittsLaw) { +TEST_F(ShelfViewLegacyShelfLayoutTest, CheckFittsLaw) { // All buttons should be visible. ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); @@ -1329,14 +1329,14 @@ TEST_F(LauncherViewLegacyShelfLayoutTest, CheckFittsLaw) { EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); } -class LauncherViewVisibleBoundsTest : public LauncherViewTest, +class ShelfViewVisibleBoundsTest : public ShelfViewTest, public testing::WithParamInterface<bool> { public: - LauncherViewVisibleBoundsTest() : text_direction_change_(GetParam()) {} + ShelfViewVisibleBoundsTest() : text_direction_change_(GetParam()) {} void CheckAllItemsAreInBounds() { - gfx::Rect visible_bounds = launcher_view_->GetVisibleItemsBoundsInScreen(); - gfx::Rect launcher_bounds = launcher_view_->GetBoundsInScreen(); + gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); + gfx::Rect launcher_bounds = shelf_view_->GetBoundsInScreen(); EXPECT_TRUE(launcher_bounds.Contains(visible_bounds)); for (int i = 0; i < test_api_->GetButtonCount(); ++i) if (internal::LauncherButton* button = test_api_->GetButton(i)) @@ -1345,8 +1345,8 @@ class LauncherViewVisibleBoundsTest : public LauncherViewTest, } void CheckAppListButtonIsInBounds() { - gfx::Rect visible_bounds = launcher_view_->GetVisibleItemsBoundsInScreen(); - gfx::Rect app_list_button_bounds = launcher_view_->GetAppListButtonView()-> + gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); + gfx::Rect app_list_button_bounds = shelf_view_->GetAppListButtonView()-> GetBoundsInScreen(); EXPECT_TRUE(visible_bounds.Contains(app_list_button_bounds)); } @@ -1354,10 +1354,10 @@ class LauncherViewVisibleBoundsTest : public LauncherViewTest, private: ScopedTextDirectionChange text_direction_change_; - DISALLOW_COPY_AND_ASSIGN(LauncherViewVisibleBoundsTest); + DISALLOW_COPY_AND_ASSIGN(ShelfViewVisibleBoundsTest); }; -TEST_P(LauncherViewVisibleBoundsTest, ItemsAreInBounds) { +TEST_P(ShelfViewVisibleBoundsTest, ItemsAreInBounds) { // Adding elements leaving some empty space. for (int i = 0; i < 3; i++) { AddAppShortcut(); @@ -1373,8 +1373,8 @@ TEST_P(LauncherViewVisibleBoundsTest, ItemsAreInBounds) { CheckAllItemsAreInBounds(); } -INSTANTIATE_TEST_CASE_P(LtrRtl, LauncherViewTextDirectionTest, testing::Bool()); -INSTANTIATE_TEST_CASE_P(VisibleBounds, LauncherViewVisibleBoundsTest, +INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); +INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, testing::Bool()); } // namespace test diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc index 70d6604..42204a7 100644 --- a/ash/shelf/shelf_widget.cc +++ b/ash/shelf/shelf_widget.cc @@ -8,11 +8,11 @@ #include "ash/focus_cycler.h" #include "ash/launcher/launcher_delegate.h" #include "ash/launcher/launcher_model.h" -#include "ash/launcher/launcher_view.h" #include "ash/root_window_controller.h" #include "ash/session_state_delegate.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_navigator.h" +#include "ash/shelf/shelf_view.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" @@ -233,7 +233,7 @@ void DimmerView::DimmerEventFilter::OnTouchEvent(ui::TouchEvent* event) { namespace ash { -// The contents view of the Shelf. This view contains LauncherView and +// The contents view of the Shelf. This view contains ShelfView and // sizes it to the width of the shelf minus the size of the status area. class ShelfWidget::DelegateView : public views::WidgetDelegate, public views::AccessiblePaneView, diff --git a/ash/shelf/shelf_widget_unittest.cc b/ash/shelf/shelf_widget_unittest.cc index b12549f..6004a6c 100644 --- a/ash/shelf/shelf_widget_unittest.cc +++ b/ash/shelf/shelf_widget_unittest.cc @@ -7,13 +7,13 @@ #include "ash/launcher/launcher.h" #include "ash/launcher/launcher_button.h" #include "ash/launcher/launcher_model.h" -#include "ash/launcher/launcher_view.h" #include "ash/root_window_controller.h" #include "ash/shelf/shelf_layout_manager.h" +#include "ash/shelf/shelf_view.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/launcher_test_api.h" -#include "ash/test/launcher_view_test_api.h" +#include "ash/test/shelf_view_test_api.h" #include "ash/wm/window_util.h" #include "ui/aura/root_window.h" #include "ui/gfx/display.h" @@ -141,7 +141,7 @@ TEST_F(ShelfWidgetTest, LauncherInitiallySized) { // Test only makes sense if the status is > 0, which it better be. EXPECT_GT(status_width, 0); EXPECT_EQ(status_width, shelf_widget->GetContentsView()->width() - - test::LauncherTestAPI(launcher).launcher_view()->width()); + test::LauncherTestAPI(launcher).shelf_view()->width()); } // Verifies when the shell is deleted with a full screen window we don't crash. @@ -187,7 +187,7 @@ TEST_F(ShelfWidgetTest, LauncherInitiallySizedAfterLogin) { EXPECT_GT(status_width, 0); EXPECT_EQ(status_width, shelf->GetContentsView()->width() - - test::LauncherTestAPI(launcher).launcher_view()->width()); + test::LauncherTestAPI(launcher).shelf_view()->width()); } #endif diff --git a/ash/shell.h b/ash/shell.h index 4e8658c..af884f4 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -281,7 +281,7 @@ class ASH_EXPORT Shell // Initializes |launcher_|. Does nothing if it's already initialized. void CreateLauncher(); - // Show launcher view if it was created hidden (before session has started). + // Show shelf view if it was created hidden (before session has started). void ShowLauncher(); // Adds/removes observer. diff --git a/ash/test/launcher_test_api.cc b/ash/test/launcher_test_api.cc index e92625f..77724c7 100644 --- a/ash/test/launcher_test_api.cc +++ b/ash/test/launcher_test_api.cc @@ -16,8 +16,8 @@ LauncherTestAPI::LauncherTestAPI(Launcher* launcher) LauncherTestAPI::~LauncherTestAPI() { } -internal::LauncherView* LauncherTestAPI::launcher_view() { - return launcher_->launcher_view_; +internal::ShelfView* LauncherTestAPI::shelf_view() { + return launcher_->shelf_view_; } } // namespace test diff --git a/ash/test/launcher_test_api.h b/ash/test/launcher_test_api.h index 57424af..ea6b613 100644 --- a/ash/test/launcher_test_api.h +++ b/ash/test/launcher_test_api.h @@ -12,7 +12,7 @@ namespace ash { class Launcher; namespace internal { -class LauncherView; +class ShelfView; } namespace test { @@ -24,8 +24,8 @@ class LauncherTestAPI { ~LauncherTestAPI(); - // An accessor for |launcher_view|. - internal::LauncherView* launcher_view(); + // An accessor for |shelf_view|. + internal::ShelfView* shelf_view(); private: Launcher* launcher_; @@ -36,4 +36,4 @@ class LauncherTestAPI { } // namespace test } // namespace ash -#endif // ASH_TEST_LAUNCHER_VIEW_TEST_API_H_ +#endif // ASH_TEST_LAUNCHER_TEST_API_H_ diff --git a/ash/test/launcher_view_test_api.cc b/ash/test/launcher_view_test_api.cc deleted file mode 100644 index fa1be56..0000000 --- a/ash/test/launcher_view_test_api.cc +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/test/launcher_view_test_api.h" - -#include "ash/launcher/launcher_button.h" -#include "ash/launcher/launcher_model.h" -#include "ash/launcher/launcher_view.h" -#include "ash/shelf/overflow_button.h" -#include "base/message_loop/message_loop.h" -#include "ui/views/animation/bounds_animator.h" -#include "ui/views/view_model.h" - -namespace { - -// A class used to wait for animations. -class TestAPIAnimationObserver : public views::BoundsAnimatorObserver { - public: - TestAPIAnimationObserver() {} - virtual ~TestAPIAnimationObserver() {} - - // views::BoundsAnimatorObserver overrides: - virtual void OnBoundsAnimatorProgressed( - views::BoundsAnimator* animator) OVERRIDE {} - virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator) OVERRIDE { - base::MessageLoop::current()->Quit(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(TestAPIAnimationObserver); -}; - -} // namespace - -namespace ash { -namespace test { - -LauncherViewTestAPI::LauncherViewTestAPI(internal::LauncherView* launcher_view) - : launcher_view_(launcher_view) { -} - -LauncherViewTestAPI::~LauncherViewTestAPI() { -} - -int LauncherViewTestAPI::GetButtonCount() { - return launcher_view_->view_model_->view_size(); -} - -internal::LauncherButton* LauncherViewTestAPI::GetButton(int index) { - // App list button is not a LauncherButton. - if (launcher_view_->model_->items()[index].type == ash::TYPE_APP_LIST) - return NULL; - - return static_cast<internal::LauncherButton*>( - launcher_view_->view_model_->view_at(index)); -} - -int LauncherViewTestAPI::GetLastVisibleIndex() { - return launcher_view_->last_visible_index_; -} - -bool LauncherViewTestAPI::IsOverflowButtonVisible() { - return launcher_view_->overflow_button_->visible(); -} - -void LauncherViewTestAPI::ShowOverflowBubble() { - if (!launcher_view_->IsShowingOverflowBubble()) - launcher_view_->ToggleOverflowBubble(); -} - -const gfx::Rect& LauncherViewTestAPI::GetBoundsByIndex(int index) { - return launcher_view_->view_model_->view_at(index)->bounds(); -} - -const gfx::Rect& LauncherViewTestAPI::GetIdealBoundsByIndex(int index) { - return launcher_view_->view_model_->ideal_bounds(index); -} - -void LauncherViewTestAPI::SetAnimationDuration(int duration_ms) { - launcher_view_->bounds_animator_->SetAnimationDuration(duration_ms); -} - -void LauncherViewTestAPI::RunMessageLoopUntilAnimationsDone() { - if (!launcher_view_->bounds_animator_->IsAnimating()) - return; - - scoped_ptr<TestAPIAnimationObserver> observer(new TestAPIAnimationObserver()); - launcher_view_->bounds_animator_->AddObserver(observer.get()); - - // This nested loop will quit when TestAPIAnimationObserver's - // OnBoundsAnimatorDone is called. - base::MessageLoop::current()->Run(); - - launcher_view_->bounds_animator_->RemoveObserver(observer.get()); -} - -bool LauncherViewTestAPI::SameDragType(LauncherItemType typea, - LauncherItemType typeb) const { - return launcher_view_->SameDragType(typea, typeb); -} - -} // namespace test -} // namespace ash diff --git a/ash/test/shelf_view_test_api.cc b/ash/test/shelf_view_test_api.cc new file mode 100644 index 0000000..a234e37 --- /dev/null +++ b/ash/test/shelf_view_test_api.cc @@ -0,0 +1,104 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/test/shelf_view_test_api.h" + +#include "ash/launcher/launcher_button.h" +#include "ash/launcher/launcher_model.h" +#include "ash/shelf/overflow_button.h" +#include "ash/shelf/shelf_view.h" +#include "base/message_loop/message_loop.h" +#include "ui/views/animation/bounds_animator.h" +#include "ui/views/view_model.h" + +namespace { + +// A class used to wait for animations. +class TestAPIAnimationObserver : public views::BoundsAnimatorObserver { + public: + TestAPIAnimationObserver() {} + virtual ~TestAPIAnimationObserver() {} + + // views::BoundsAnimatorObserver overrides: + virtual void OnBoundsAnimatorProgressed( + views::BoundsAnimator* animator) OVERRIDE {} + virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator) OVERRIDE { + base::MessageLoop::current()->Quit(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(TestAPIAnimationObserver); +}; + +} // namespace + +namespace ash { +namespace test { + +ShelfViewTestAPI::ShelfViewTestAPI(internal::ShelfView* shelf_view) + : shelf_view_(shelf_view) { +} + +ShelfViewTestAPI::~ShelfViewTestAPI() { +} + +int ShelfViewTestAPI::GetButtonCount() { + return shelf_view_->view_model_->view_size(); +} + +internal::LauncherButton* ShelfViewTestAPI::GetButton(int index) { + // App list button is not a LauncherButton. + if (shelf_view_->model_->items()[index].type == ash::TYPE_APP_LIST) + return NULL; + + return static_cast<internal::LauncherButton*>( + shelf_view_->view_model_->view_at(index)); +} + +int ShelfViewTestAPI::GetLastVisibleIndex() { + return shelf_view_->last_visible_index_; +} + +bool ShelfViewTestAPI::IsOverflowButtonVisible() { + return shelf_view_->overflow_button_->visible(); +} + +void ShelfViewTestAPI::ShowOverflowBubble() { + if (!shelf_view_->IsShowingOverflowBubble()) + shelf_view_->ToggleOverflowBubble(); +} + +const gfx::Rect& ShelfViewTestAPI::GetBoundsByIndex(int index) { + return shelf_view_->view_model_->view_at(index)->bounds(); +} + +const gfx::Rect& ShelfViewTestAPI::GetIdealBoundsByIndex(int index) { + return shelf_view_->view_model_->ideal_bounds(index); +} + +void ShelfViewTestAPI::SetAnimationDuration(int duration_ms) { + shelf_view_->bounds_animator_->SetAnimationDuration(duration_ms); +} + +void ShelfViewTestAPI::RunMessageLoopUntilAnimationsDone() { + if (!shelf_view_->bounds_animator_->IsAnimating()) + return; + + scoped_ptr<TestAPIAnimationObserver> observer(new TestAPIAnimationObserver()); + shelf_view_->bounds_animator_->AddObserver(observer.get()); + + // This nested loop will quit when TestAPIAnimationObserver's + // OnBoundsAnimatorDone is called. + base::MessageLoop::current()->Run(); + + shelf_view_->bounds_animator_->RemoveObserver(observer.get()); +} + +bool ShelfViewTestAPI::SameDragType(LauncherItemType typea, + LauncherItemType typeb) const { + return shelf_view_->SameDragType(typea, typeb); +} + +} // namespace test +} // namespace ash diff --git a/ash/test/launcher_view_test_api.h b/ash/test/shelf_view_test_api.h index 0162f7f..d8920ac 100644 --- a/ash/test/launcher_view_test_api.h +++ b/ash/test/shelf_view_test_api.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_TEST_LAUNCHER_VIEW_TEST_API_H_ -#define ASH_TEST_LAUNCHER_VIEW_TEST_API_H_ +#ifndef ASH_TEST_SHELF_VIEW_TEST_API_H_ +#define ASH_TEST_SHELF_VIEW_TEST_API_H_ #include "ash/launcher/launcher_types.h" #include "base/basictypes.h" @@ -16,16 +16,16 @@ namespace ash { namespace internal { class LauncherButton; -class LauncherView; +class ShelfView; } namespace test { -// Use the api in this class to test LauncherView. -class LauncherViewTestAPI { +// Use the api in this class to test ShelfView. +class ShelfViewTestAPI { public: - explicit LauncherViewTestAPI(internal::LauncherView* launcher_view); - ~LauncherViewTestAPI(); + explicit ShelfViewTestAPI(internal::ShelfView* shelf_view); + ~ShelfViewTestAPI(); // Number of icons displayed. int GetButtonCount(); @@ -43,7 +43,7 @@ class LauncherViewTestAPI { // Returns true if overflow button is visible. bool IsOverflowButtonVisible(); - // Makes launcher view show its overflow bubble. + // Makes shelf view show its overflow bubble. void ShowOverflowBubble(); // Sets animation duration in milliseconds for test. @@ -52,19 +52,19 @@ class LauncherViewTestAPI { // Runs message loop and waits until all add/remove animations are done. void RunMessageLoopUntilAnimationsDone(); - // An accessor for |launcher_view|. - internal::LauncherView* launcher_view() { return launcher_view_; } + // An accessor for |shelf_view|. + internal::ShelfView* shelf_view() { return shelf_view_; } - // Wrapper for LauncherView::SameDragType. + // Wrapper for ShelfView::SameDragType. bool SameDragType(LauncherItemType typea, LauncherItemType typeb) const; private: - internal::LauncherView* launcher_view_; + internal::ShelfView* shelf_view_; - DISALLOW_COPY_AND_ASSIGN(LauncherViewTestAPI); + DISALLOW_COPY_AND_ASSIGN(ShelfViewTestAPI); }; } // namespace test } // namespace ash -#endif // ASH_TEST_LAUNCHER_VIEW_TEST_API_H_ +#endif // ASH_TEST_SHELF_VIEW_TEST_API_H_ diff --git a/ash/wm/dock/docked_window_layout_manager_unittest.cc b/ash/wm/dock/docked_window_layout_manager_unittest.cc index 5be28e8..6ec585f 100644 --- a/ash/wm/dock/docked_window_layout_manager_unittest.cc +++ b/ash/wm/dock/docked_window_layout_manager_unittest.cc @@ -16,7 +16,7 @@ #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" #include "ash/test/launcher_test_api.h" -#include "ash/test/launcher_view_test_api.h" +#include "ash/test/shelf_view_test_api.h" #include "ash/test/shell_test_api.h" #include "ash/test/test_launcher_delegate.h" #include "ash/wm/coordinate_conversion.h" @@ -54,9 +54,9 @@ class DockedWindowLayoutManagerTest UpdateDisplay("600x600"); ASSERT_TRUE(test::TestLauncherDelegate::instance()); - launcher_view_test_.reset(new test::LauncherViewTestAPI( - test::LauncherTestAPI(Launcher::ForPrimaryDisplay()).launcher_view())); - launcher_view_test_->SetAnimationDuration(1); + shelf_view_test_.reset(new test::ShelfViewTestAPI( + test::LauncherTestAPI(Launcher::ForPrimaryDisplay()).shelf_view())); + shelf_view_test_->SetAnimationDuration(1); } protected: @@ -217,7 +217,7 @@ class DockedWindowLayoutManagerTest private: scoped_ptr<WindowResizer> resizer_; - scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; + scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; aura::client::WindowType window_type_; // Location at start of the drag in |window->parent()|'s coordinates. diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc index eda6a8a..1eb5a17 100644 --- a/ash/wm/overview/window_selector_unittest.cc +++ b/ash/wm/overview/window_selector_unittest.cc @@ -9,7 +9,7 @@ #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/launcher_test_api.h" -#include "ash/test/launcher_view_test_api.h" +#include "ash/test/shelf_view_test_api.h" #include "ash/test/shell_test_api.h" #include "ash/test/test_launcher_delegate.h" #include "ash/wm/mru_window_tracker.h" @@ -58,9 +58,9 @@ class WindowSelectorTest : public test::AshTestBase { test::AshTestBase::SetUp(); ASSERT_TRUE(test::TestLauncherDelegate::instance()); - launcher_view_test_.reset(new test::LauncherViewTestAPI( - test::LauncherTestAPI(Launcher::ForPrimaryDisplay()).launcher_view())); - launcher_view_test_->SetAnimationDuration(1); + shelf_view_test_.reset(new test::ShelfViewTestAPI( + test::LauncherTestAPI(Launcher::ForPrimaryDisplay()).shelf_view())); + shelf_view_test_->SetAnimationDuration(1); } aura::Window* CreateWindow(const gfx::Rect& bounds) { @@ -79,7 +79,7 @@ class WindowSelectorTest : public test::AshTestBase { aura::Window* window = CreateTestWindowInShellWithDelegateAndType( NULL, aura::client::WINDOW_TYPE_PANEL, 0, bounds); test::TestLauncherDelegate::instance()->AddLauncherItem(window); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); return window; } @@ -155,14 +155,14 @@ class WindowSelectorTest : public test::AshTestBase { Shell::GetPrimaryRootWindow())->GetFocusedWindow(); } - test::LauncherViewTestAPI* launcher_view_test() { - return launcher_view_test_.get(); + test::ShelfViewTestAPI* shelf_view_test() { + return shelf_view_test_.get(); } private: aura::test::TestWindowDelegate delegate_; NonActivatableActivationDelegate non_activatable_activation_delegate_; - scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; + scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); }; diff --git a/ash/wm/panels/panel_layout_manager_unittest.cc b/ash/wm/panels/panel_layout_manager_unittest.cc index ae305e9..7c61f73 100644 --- a/ash/wm/panels/panel_layout_manager_unittest.cc +++ b/ash/wm/panels/panel_layout_manager_unittest.cc @@ -8,17 +8,17 @@ #include "ash/launcher/launcher.h" #include "ash/launcher/launcher_button.h" #include "ash/launcher/launcher_model.h" -#include "ash/launcher/launcher_view.h" #include "ash/root_window_controller.h" #include "ash/screen_ash.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_types.h" +#include "ash/shelf/shelf_view.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" #include "ash/test/launcher_test_api.h" -#include "ash/test/launcher_view_test_api.h" +#include "ash/test/shelf_view_test_api.h" #include "ash/test/shell_test_api.h" #include "ash/test/test_launcher_delegate.h" #include "ash/wm/window_util.h" @@ -50,9 +50,9 @@ class PanelLayoutManagerTest : public test::AshTestBase { test::AshTestBase::SetUp(); ASSERT_TRUE(test::TestLauncherDelegate::instance()); - launcher_view_test_.reset(new test::LauncherViewTestAPI( - GetLauncherView(Launcher::ForPrimaryDisplay()))); - launcher_view_test_->SetAnimationDuration(1); + shelf_view_test_.reset(new test::ShelfViewTestAPI( + GetShelfView(Launcher::ForPrimaryDisplay()))); + shelf_view_test_->SetAnimationDuration(1); } aura::Window* CreateNormalWindow(const gfx::Rect& bounds) { @@ -72,7 +72,7 @@ class PanelLayoutManagerTest : public test::AshTestBase { static_cast<PanelLayoutManager*>(GetPanelContainer(window)-> layout_manager()); manager->Relayout(); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); return window; } @@ -109,8 +109,8 @@ class PanelLayoutManagerTest : public test::AshTestBase { } void PanelsNotOverlapping(aura::Window* panel1, aura::Window* panel2) { - // Waits until all launcher view animations are done. - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + // Waits until all shelf view animations are done. + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow(); gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow(); @@ -120,8 +120,8 @@ class PanelLayoutManagerTest : public test::AshTestBase { // TODO(dcheng): This should be const, but GetScreenBoundsOfItemIconForWindow // takes a non-const Window. We can probably fix that. void IsPanelAboveLauncherIcon(aura::Window* panel) { - // Waits until all launcher view animations are done. - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + // Waits until all shelf view animations are done. + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); Launcher* launcher = RootWindowController::ForLauncher(panel)->shelf()->launcher(); @@ -211,15 +211,15 @@ class PanelLayoutManagerTest : public test::AshTestBase { return widget->IsVisible(); } - test::LauncherViewTestAPI* launcher_view_test() { - return launcher_view_test_.get(); + test::ShelfViewTestAPI* shelf_view_test() { + return shelf_view_test_.get(); } - // Clicks the launcher items on |launcher_view| that is + // Clicks the launcher items on |shelf_view| that is /// associated with given |window|. - void ClickLauncherItemForWindow(LauncherView* launcher_view, + void ClickLauncherItemForWindow(ShelfView* shelf_view, aura::Window* window) { - test::LauncherViewTestAPI test_api(launcher_view); + test::ShelfViewTestAPI test_api(shelf_view); test_api.SetAnimationDuration(1); test_api.RunMessageLoopUntilAnimationsDone(); LauncherModel* model = @@ -252,8 +252,8 @@ class PanelLayoutManagerTest : public test::AshTestBase { RootWindowController::ForWindow(window)->shelf()-> shelf_layout_manager(); shelf->SetAutoHideBehavior(behavior); - LauncherView* launcher_view = GetLauncherView(Launcher::ForWindow(window)); - test::LauncherViewTestAPI test_api(launcher_view); + ShelfView* shelf_view = GetShelfView(Launcher::ForWindow(window)); + test::ShelfViewTestAPI test_api(shelf_view); test_api.RunMessageLoopUntilAnimationsDone(); } @@ -265,12 +265,12 @@ class PanelLayoutManagerTest : public test::AshTestBase { shelf->SetState(visibility_state); } - internal::LauncherView* GetLauncherView(Launcher* launcher) { - return test::LauncherTestAPI(launcher).launcher_view(); + internal::ShelfView* GetShelfView(Launcher* launcher) { + return test::LauncherTestAPI(launcher).shelf_view(); } private: - scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; + scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; bool IsHorizontal(ShelfAlignment alignment) { return alignment == SHELF_ALIGNMENT_BOTTOM || @@ -384,12 +384,12 @@ TEST_F(PanelLayoutManagerTest, MultiplePanelStacking) { // Changing the active window should update the stacking order. wm::ActivateWindow(w1.get()); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get())); EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); wm::ActivateWindow(w2.get()); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); @@ -415,12 +415,12 @@ TEST_F(PanelLayoutManagerTest, MultiplePanelStackingVertical) { // Changing the active window should update the stacking order. wm::ActivateWindow(w1.get()); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get())); EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); wm::ActivateWindow(w2.get()); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); @@ -436,7 +436,7 @@ TEST_F(PanelLayoutManagerTest, MultiplePanelCallout) { scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); scoped_ptr<aura::Window> w4(CreateNormalWindow(gfx::Rect())); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); EXPECT_TRUE(IsPanelCalloutVisible(w1.get())); EXPECT_TRUE(IsPanelCalloutVisible(w2.get())); EXPECT_TRUE(IsPanelCalloutVisible(w3.get())); @@ -462,7 +462,7 @@ TEST_F(PanelLayoutManagerTest, RemoveLeftPanel) { // At this point, windows should be stacked with 1 < 2 < 3 wm::ActivateWindow(w1.get()); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); // Now, windows should be stacked 1 > 2 > 3 w1.reset(); EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); @@ -545,7 +545,7 @@ TEST_F(PanelLayoutManagerTest, FanWindows) { scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); @@ -564,7 +564,7 @@ TEST_F(PanelLayoutManagerTest, FanLargeWindow) { scoped_ptr<aura::Window> w2(CreatePanelWindow(large_bounds)); scoped_ptr<aura::Window> w3(CreatePanelWindow(small_bounds)); - launcher_view_test()->RunMessageLoopUntilAnimationsDone(); + shelf_view_test()->RunMessageLoopUntilAnimationsDone(); int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); @@ -610,10 +610,9 @@ TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); scoped_ptr<aura::Window> p2_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); - LauncherView* launcher_view_1st = - GetLauncherView(Launcher::ForPrimaryDisplay()); - LauncherView* launcher_view_2nd = - GetLauncherView(Launcher::ForWindow(root_windows[1])); + ShelfView* shelf_view_1st = GetShelfView(Launcher::ForPrimaryDisplay()); + ShelfView* shelf_view_2nd = + GetShelfView(Launcher::ForWindow(root_windows[1])); EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); @@ -627,7 +626,7 @@ TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { // Test a panel on 1st display. // Clicking on the same display has no effect. - ClickLauncherItemForWindow(launcher_view_1st, p1_d1.get()); + ClickLauncherItemForWindow(shelf_view_1st, p1_d1.get()); EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); @@ -637,7 +636,7 @@ TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { // Test if clicking on another display moves the panel to // that display. - ClickLauncherItemForWindow(launcher_view_2nd, p1_d1.get()); + ClickLauncherItemForWindow(shelf_view_2nd, p1_d1.get()); EXPECT_EQ(root_windows[1], p1_d1->GetRootWindow()); EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); @@ -647,7 +646,7 @@ TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { // Test a panel on 2nd display. // Clicking on the same display has no effect. - ClickLauncherItemForWindow(launcher_view_2nd, p1_d2.get()); + ClickLauncherItemForWindow(shelf_view_2nd, p1_d2.get()); EXPECT_EQ(root_windows[1], p1_d1->GetRootWindow()); EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); @@ -657,7 +656,7 @@ TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { // Test if clicking on another display moves the panel to // that display. - ClickLauncherItemForWindow(launcher_view_1st, p1_d2.get()); + ClickLauncherItemForWindow(shelf_view_1st, p1_d2.get()); EXPECT_EQ(root_windows[1], p1_d1->GetRootWindow()); EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); EXPECT_EQ(root_windows[0], p1_d2->GetRootWindow()); @@ -667,7 +666,7 @@ TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { // Test if clicking on a previously moved window moves the // panel back to the original display. - ClickLauncherItemForWindow(launcher_view_1st, p1_d1.get()); + ClickLauncherItemForWindow(shelf_view_1st, p1_d1.get()); EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); EXPECT_EQ(root_windows[0], p1_d2->GetRootWindow()); diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc index 31c4f11..2006aa1 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc @@ -12,11 +12,11 @@ #include "ash/launcher/launcher.h" #include "ash/launcher/launcher_button.h" #include "ash/launcher/launcher_model.h" -#include "ash/launcher/launcher_view.h" #include "ash/shelf/shelf_util.h" +#include "ash/shelf/shelf_view.h" #include "ash/shell.h" #include "ash/test/launcher_test_api.h" -#include "ash/test/launcher_view_test_api.h" +#include "ash/test/shelf_view_test_api.h" #include "ash/test/shell_test_api.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" @@ -278,7 +278,7 @@ class LauncherAppBrowserTest : public ExtensionBrowserTest { // Try to rip off |item_index|. void RipOffItemIndex(int index, aura::test::EventGenerator* generator, - ash::test::LauncherViewTestAPI* test, + ash::test::ShelfViewTestAPI* test, RipOffCommand command) { ash::internal::LauncherButton* button = test->GetButton(index); gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); @@ -1545,8 +1545,8 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) { // Get a number of interfaces we need. aura::test::EventGenerator generator( ash::Shell::GetPrimaryRootWindow(), gfx::Point()); - ash::test::LauncherViewTestAPI test( - ash::test::LauncherTestAPI(launcher_).launcher_view()); + ash::test::ShelfViewTestAPI test( + ash::test::LauncherTestAPI(launcher_).shelf_view()); AppListService* service = AppListService::Get(); // There should be two items in our launcher by this time. @@ -1555,7 +1555,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) { // Open the app list menu and check that the drag and drop host was set. gfx::Rect app_list_bounds = - test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen(); + test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), app_list_bounds.CenterPoint().y()); base::MessageLoop::current()->RunUntilIdle(); @@ -1587,7 +1587,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) { // Drag the item into the launcher and check that a new item gets created. const views::ViewModel* vm_launcher = - test.launcher_view()->view_model_for_test(); + test.shelf_view()->view_model_for_test(); views::View* launcher1 = vm_launcher->view_at(1); gfx::Rect bounds_launcher_1 = launcher1->GetBoundsInScreen(); generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(), @@ -1664,8 +1664,8 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) { IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragOffShelf) { aura::test::EventGenerator generator( ash::Shell::GetPrimaryRootWindow(), gfx::Point()); - ash::test::LauncherViewTestAPI test( - ash::test::LauncherTestAPI(launcher_).launcher_view()); + ash::test::ShelfViewTestAPI test( + ash::test::LauncherTestAPI(launcher_).shelf_view()); // Create a known application and check that we have 3 items in the launcher. CreateShortcut("app1"); @@ -1762,8 +1762,8 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ClickItem) { // Get a number of interfaces we need. aura::test::EventGenerator generator( ash::Shell::GetPrimaryRootWindow(), gfx::Point()); - ash::test::LauncherViewTestAPI test( - ash::test::LauncherTestAPI(launcher_).launcher_view()); + ash::test::ShelfViewTestAPI test( + ash::test::LauncherTestAPI(launcher_).shelf_view()); AppListService* service = AppListService::Get(); // There should be two items in our launcher by this time. EXPECT_EQ(2, model_->item_count()); @@ -1771,7 +1771,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ClickItem) { // Open the app list menu and check that the drag and drop host was set. gfx::Rect app_list_bounds = - test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen(); + test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), app_list_bounds.CenterPoint().y()); generator.ClickLeftButton(); @@ -1863,8 +1863,8 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, OverflowBubble) { // No overflow yet. EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); - ash::test::LauncherViewTestAPI test( - ash::test::LauncherTestAPI(launcher_).launcher_view()); + ash::test::ShelfViewTestAPI test( + ash::test::LauncherTestAPI(launcher_).shelf_view()); int items_added = 0; while (!test.IsOverflowButtonVisible()) { diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc b/chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc index 65b40962..cd38b3a 100644 --- a/chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc +++ b/chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "ash/launcher/launcher.h" -#include "ash/launcher/launcher_view.h" +#include "ash/shelf/shelf_view.h" #include "ash/shell.h" #include "ash/test/launcher_test_api.h" #include "base/command_line.h" @@ -45,9 +45,9 @@ void CloseBrowser(Browser* browser) { gfx::Rect GetChromeIconBoundsForRootWindow(aura::RootWindow* root_window) { ash::Launcher* launcher = ash::Launcher::ForWindow(root_window); - const ash::internal::LauncherView* launcher_view = - ash::test::LauncherTestAPI(launcher).launcher_view(); - const views::ViewModel* view_model = launcher_view->view_model_for_test(); + const ash::internal::ShelfView* shelf_view = + ash::test::LauncherTestAPI(launcher).shelf_view(); + const views::ViewModel* view_model = shelf_view->view_model_for_test(); EXPECT_EQ(2, view_model->view_size()); return view_model->view_at(1)->GetBoundsInScreen(); |