Commit 6da4ffab authored by tfarina@chromium.org's avatar tfarina@chromium.org

ash: Rename LauncherButtonHost to ShelfButtonHost.

- move launcher_button_host.h from launcher/ to shelf/
- rename to shelf_button_host.h

BUG=248353
TEST=None, no functional changes
R=harrym@chromium.org,jamescook@chromium.org

Review URL: https://codereview.chromium.org/57453002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233337 0039d316-1c4b-4281-b951-d872f2087c98
parent 006f475c
......@@ -210,6 +210,7 @@
'shelf/shelf_alignment_menu.h',
'shelf/shelf_bezel_event_filter.cc',
'shelf/shelf_bezel_event_filter.h',
'shelf/shelf_button_host.h',
'shelf/shelf_icon_observer.h',
'shelf/shelf_layout_manager.cc',
'shelf/shelf_layout_manager.h',
......
......@@ -7,7 +7,7 @@
#include <algorithm>
#include "ash/ash_switches.h"
#include "ash/launcher/launcher_button_host.h"
#include "ash/shelf/shelf_button_host.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "grit/ash_resources.h"
#include "skia/ext/image_operations.h"
......@@ -221,7 +221,7 @@ bool LauncherButton::IconView::HitTestRect(const gfx::Rect& rect) const {
LauncherButton* LauncherButton::Create(
views::ButtonListener* listener,
LauncherButtonHost* host,
ShelfButtonHost* host,
ShelfLayoutManager* shelf_layout_manager) {
LauncherButton* button =
new LauncherButton(listener, host, shelf_layout_manager);
......@@ -230,7 +230,7 @@ LauncherButton* LauncherButton::Create(
}
LauncherButton::LauncherButton(views::ButtonListener* listener,
LauncherButtonHost* host,
ShelfButtonHost* host,
ShelfLayoutManager* shelf_layout_manager)
: CustomButton(listener),
host_(host),
......@@ -355,24 +355,24 @@ void LauncherButton::ShowContextMenu(const gfx::Point& p,
bool LauncherButton::OnMousePressed(const ui::MouseEvent& event) {
CustomButton::OnMousePressed(event);
host_->PointerPressedOnButton(this, LauncherButtonHost::MOUSE, event);
host_->PointerPressedOnButton(this, ShelfButtonHost::MOUSE, event);
return true;
}
void LauncherButton::OnMouseReleased(const ui::MouseEvent& event) {
CustomButton::OnMouseReleased(event);
host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, false);
host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, false);
}
void LauncherButton::OnMouseCaptureLost() {
ClearState(STATE_HOVERED);
host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, true);
host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, true);
CustomButton::OnMouseCaptureLost();
}
bool LauncherButton::OnMouseDragged(const ui::MouseEvent& event) {
CustomButton::OnMouseDragged(event);
host_->PointerDraggedOnButton(this, LauncherButtonHost::MOUSE, event);
host_->PointerDraggedOnButton(this, ShelfButtonHost::MOUSE, event);
return true;
}
......@@ -481,16 +481,16 @@ void LauncherButton::OnGestureEvent(ui::GestureEvent* event) {
ClearState(STATE_HOVERED);
return CustomButton::OnGestureEvent(event);
case ui::ET_GESTURE_SCROLL_BEGIN:
host_->PointerPressedOnButton(this, LauncherButtonHost::TOUCH, *event);
host_->PointerPressedOnButton(this, ShelfButtonHost::TOUCH, *event);
event->SetHandled();
return;
case ui::ET_GESTURE_SCROLL_UPDATE:
host_->PointerDraggedOnButton(this, LauncherButtonHost::TOUCH, *event);
host_->PointerDraggedOnButton(this, ShelfButtonHost::TOUCH, *event);
event->SetHandled();
return;
case ui::ET_GESTURE_SCROLL_END:
case ui::ET_SCROLL_FLING_START:
host_->PointerReleasedOnButton(this, LauncherButtonHost::TOUCH, false);
host_->PointerReleasedOnButton(this, ShelfButtonHost::TOUCH, false);
event->SetHandled();
return;
default:
......
......@@ -13,7 +13,7 @@
namespace ash {
namespace internal {
class LauncherButtonHost;
class ShelfButtonHost;
class ShelfLayoutManager;
// Button used for items on the launcher, except for the AppList.
......@@ -41,7 +41,7 @@ class ASH_EXPORT LauncherButton : public views::CustomButton {
// Called to create an instance of a LauncherButton.
static LauncherButton* Create(views::ButtonListener* listener,
LauncherButtonHost* host,
ShelfButtonHost* host,
ShelfLayoutManager* shelf_layout_manager);
// Sets the image to display for this entry.
......@@ -70,7 +70,7 @@ class ASH_EXPORT LauncherButton : public views::CustomButton {
protected:
LauncherButton(views::ButtonListener* listener,
LauncherButtonHost* host,
ShelfButtonHost* host,
ShelfLayoutManager* shelf_layout_manager);
// Class that draws the icon part of a button, so it can be animated
......@@ -118,7 +118,7 @@ class ASH_EXPORT LauncherButton : public views::CustomButton {
// Override to subclass IconView.
virtual IconView* CreateIconView();
IconView* icon_view() const { return icon_view_; }
LauncherButtonHost* host() const { return host_; }
ShelfButtonHost* host() const { return host_; }
private:
class BarView;
......@@ -134,7 +134,7 @@ class ASH_EXPORT LauncherButton : public views::CustomButton {
// Updates the status bar (bitmap, orientation, visibility).
void UpdateBar();
LauncherButtonHost* host_;
ShelfButtonHost* host_;
IconView* icon_view_;
// Draws a bar underneath the image to represent the state of the application.
BarView* bar_;
......
......@@ -5,8 +5,8 @@
#include "ash/shelf/alternate_app_list_button.h"
#include "ash/ash_switches.h"
#include "ash/launcher/launcher_button_host.h"
#include "ash/launcher/launcher_types.h"
#include "ash/shelf/shelf_button_host.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
......@@ -31,7 +31,7 @@ const int AlternateAppListButton::kImageBoundsSize = 7;
AlternateAppListButton::AlternateAppListButton(views::ButtonListener* listener,
LauncherButtonHost* host,
ShelfButtonHost* host,
ShelfWidget* shelf_widget)
: views::ImageButton(listener),
host_(host),
......@@ -46,23 +46,23 @@ AlternateAppListButton::~AlternateAppListButton() {
bool AlternateAppListButton::OnMousePressed(const ui::MouseEvent& event) {
ImageButton::OnMousePressed(event);
host_->PointerPressedOnButton(this, LauncherButtonHost::MOUSE, event);
host_->PointerPressedOnButton(this, ShelfButtonHost::MOUSE, event);
return true;
}
void AlternateAppListButton::OnMouseReleased(const ui::MouseEvent& event) {
ImageButton::OnMouseReleased(event);
host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, false);
host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, false);
}
void AlternateAppListButton::OnMouseCaptureLost() {
host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, true);
host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, true);
ImageButton::OnMouseCaptureLost();
}
bool AlternateAppListButton::OnMouseDragged(const ui::MouseEvent& event) {
ImageButton::OnMouseDragged(event);
host_->PointerDraggedOnButton(this, LauncherButtonHost::MOUSE, event);
host_->PointerDraggedOnButton(this, ShelfButtonHost::MOUSE, event);
return true;
}
......@@ -84,16 +84,16 @@ void AlternateAppListButton::OnMouseExited(const ui::MouseEvent& event) {
void AlternateAppListButton::OnGestureEvent(ui::GestureEvent* event) {
switch (event->type()) {
case ui::ET_GESTURE_SCROLL_BEGIN:
host_->PointerPressedOnButton(this, LauncherButtonHost::TOUCH, *event);
host_->PointerPressedOnButton(this, ShelfButtonHost::TOUCH, *event);
event->SetHandled();
return;
case ui::ET_GESTURE_SCROLL_UPDATE:
host_->PointerDraggedOnButton(this, LauncherButtonHost::TOUCH, *event);
host_->PointerDraggedOnButton(this, ShelfButtonHost::TOUCH, *event);
event->SetHandled();
return;
case ui::ET_GESTURE_SCROLL_END:
case ui::ET_SCROLL_FLING_START:
host_->PointerReleasedOnButton(this, LauncherButtonHost::TOUCH, false);
host_->PointerReleasedOnButton(this, ShelfButtonHost::TOUCH, false);
event->SetHandled();
return;
default:
......
......@@ -13,19 +13,19 @@ class ShelfWidget;
namespace internal {
class LauncherButtonHost;
class ShelfButtonHost;
// Button used for the AppList icon on the launcher.
// This class is an alternate implementation to
// ash::internal::AppListButton for the purposes of testing an
// alternate shelf layout (see ash_switches: UseAlternateShelfLayout).
// Button used for the AppList icon on the shelf.
// This class is an alternate implementation to ash::internal::AppListButton
// for the purposes of testing an alternate shelf layout
// (see ash_switches: UseAlternateShelfLayout).
class AlternateAppListButton : public views::ImageButton {
public:
// Bounds size (inset) required for the app icon image (in pixels).
static const int kImageBoundsSize;
AlternateAppListButton(views::ButtonListener* listener,
LauncherButtonHost* host,
ShelfButtonHost* host,
ShelfWidget* shelf_widget);
virtual ~AlternateAppListButton();
......@@ -45,7 +45,7 @@ class AlternateAppListButton : public views::ImageButton {
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
private:
LauncherButtonHost* host_;
ShelfButtonHost* host_;
// Reference to the shelf widget containing this button, owned by the
// root window controller.
ShelfWidget* shelf_widget_;
......
......@@ -6,8 +6,8 @@
#include <vector>
#include "ash/launcher/launcher_button_host.h"
#include "ash/launcher/launcher_types.h"
#include "ash/shelf/shelf_button_host.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/base/accessibility/accessible_view_state.h"
......@@ -25,7 +25,7 @@ const int kAnimationDurationInMs = 600;
const float kAnimationOpacity[] = { 1.0f, 0.4f, 1.0f };
AppListButton::AppListButton(views::ButtonListener* listener,
LauncherButtonHost* host)
ShelfButtonHost* host)
: views::ImageButton(listener),
host_(host) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
......@@ -86,23 +86,23 @@ void AppListButton::StopLoadingAnimation() {
bool AppListButton::OnMousePressed(const ui::MouseEvent& event) {
ImageButton::OnMousePressed(event);
host_->PointerPressedOnButton(this, LauncherButtonHost::MOUSE, event);
host_->PointerPressedOnButton(this, ShelfButtonHost::MOUSE, event);
return true;
}
void AppListButton::OnMouseReleased(const ui::MouseEvent& event) {
ImageButton::OnMouseReleased(event);
host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, false);
host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, false);
}
void AppListButton::OnMouseCaptureLost() {
host_->PointerReleasedOnButton(this, LauncherButtonHost::MOUSE, true);
host_->PointerReleasedOnButton(this, ShelfButtonHost::MOUSE, true);
ImageButton::OnMouseCaptureLost();
}
bool AppListButton::OnMouseDragged(const ui::MouseEvent& event) {
ImageButton::OnMouseDragged(event);
host_->PointerDraggedOnButton(this, LauncherButtonHost::MOUSE, event);
host_->PointerDraggedOnButton(this, ShelfButtonHost::MOUSE, event);
return true;
}
......
......@@ -10,13 +10,12 @@
namespace ash {
namespace internal {
class LauncherButtonHost;
class ShelfButtonHost;
// Button used for the AppList icon on the launcher.
// Button used for the AppList icon on the shelf.
class AppListButton : public views::ImageButton {
public:
AppListButton(views::ButtonListener* listener,
LauncherButtonHost* host);
AppListButton(views::ButtonListener* listener, ShelfButtonHost* host);
virtual ~AppListButton();
void StartLoadingAnimation();
......@@ -34,7 +33,7 @@ class AppListButton : public views::ImageButton {
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
private:
LauncherButtonHost* host_;
ShelfButtonHost* host_;
DISALLOW_COPY_AND_ASSIGN(AppListButton);
};
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2013 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.
#ifndef ASH_LAUNCHER_LAUNCHER_BUTTON_HOST_H_
#define ASH_LAUNCHER_LAUNCHER_BUTTON_HOST_H_
#ifndef ASH_SHELF_SHELF_BUTTON_HOST_H_
#define ASH_SHELF_SHELF_BUTTON_HOST_H_
#include "ash/ash_export.h"
#include "base/strings/string16.h"
......@@ -19,9 +19,9 @@ class View;
namespace ash {
namespace internal {
// The launcher buttons communicate back to the host by way of this interface.
// This interface is used to enable reordering the items on the launcher.
class ASH_EXPORT LauncherButtonHost {
// The shelf buttons communicate back to the host by way of this interface.
// This interface is used to enable reordering the items on the shelf.
class ASH_EXPORT ShelfButtonHost {
public:
enum Pointer {
NONE,
......@@ -58,10 +58,10 @@ class ASH_EXPORT LauncherButtonHost {
virtual base::string16 GetAccessibleName(const views::View* view) = 0;
protected:
virtual ~LauncherButtonHost() {}
virtual ~ShelfButtonHost() {}
};
} // namespace internal
} // namespace ash
#endif // ASH_LAUNCHER_LAUNCHER_BUTTON_HOST_H_
#endif // ASH_SHELF_SHELF_BUTTON_HOST_H_
......@@ -633,7 +633,7 @@ bool ShelfView::StartDrag(const std::string& app_id,
ui::MouseEvent event(ui::ET_MOUSE_PRESSED,
pt, location_in_screen_coordinates, 0);
PointerPressedOnButton(
drag_and_drop_view, LauncherButtonHost::DRAG_AND_DROP, event);
drag_and_drop_view, ShelfButtonHost::DRAG_AND_DROP, event);
// Drag the item where it really belongs.
Drag(location_in_screen_coordinates);
......@@ -652,7 +652,7 @@ bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) {
ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, gfx::Point(), 0);
PointerDraggedOnButton(
drag_and_drop_view, LauncherButtonHost::DRAG_AND_DROP, event);
drag_and_drop_view, ShelfButtonHost::DRAG_AND_DROP, event);
return true;
}
......@@ -663,7 +663,7 @@ void ShelfView::EndDrag(bool cancel) {
views::View* drag_and_drop_view = view_model_->view_at(
model_->ItemIndexByID(drag_and_drop_launcher_id_));
PointerReleasedOnButton(
drag_and_drop_view, LauncherButtonHost::DRAG_AND_DROP, cancel);
drag_and_drop_view, ShelfButtonHost::DRAG_AND_DROP, cancel);
// Either destroy the temporarily created item - or - make the item visible.
if (drag_and_drop_item_pinned_ && cancel)
......
......@@ -8,8 +8,8 @@
#include <utility>
#include <vector>
#include "ash/launcher/launcher_button_host.h"
#include "ash/launcher/launcher_model_observer.h"
#include "ash/shelf/shelf_button_host.h"
#include "ash/wm/gestures/shelf_gesture_handler.h"
#include "base/observer_list.h"
#include "ui/app_list/views/app_list_drag_and_drop_host.h"
......@@ -50,7 +50,7 @@ class ShelfTooltipManager;
class ASH_EXPORT ShelfView : public views::View,
public LauncherModelObserver,
public views::ButtonListener,
public LauncherButtonHost,
public ShelfButtonHost,
public views::ContextMenuController,
public views::FocusTraversable,
public views::BoundsAnimatorObserver,
......@@ -245,13 +245,11 @@ class ASH_EXPORT ShelfView : public views::View,
virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE;
virtual void LauncherStatusChanged() OVERRIDE;
// Overridden from LauncherButtonHost:
virtual void PointerPressedOnButton(
views::View* view,
// Overridden from ShelfButtonHost:
virtual void PointerPressedOnButton(views::View* view,
Pointer pointer,
const ui::LocatedEvent& event) OVERRIDE;
virtual void PointerDraggedOnButton(
views::View* view,
virtual void PointerDraggedOnButton(views::View* view,
Pointer pointer,
const ui::LocatedEvent& event) OVERRIDE;
virtual void PointerReleasedOnButton(views::View* view,
......
......@@ -336,9 +336,9 @@ class ShelfViewTest : public AshTestBase {
}
views::View* SimulateButtonPressed(
internal::LauncherButtonHost::Pointer pointer,
internal::ShelfButtonHost::Pointer pointer,
int button_index) {
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
views::View* button = test_api_->GetButton(button_index);
ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED,
button->bounds().origin(),
......@@ -347,20 +347,20 @@ class ShelfViewTest : public AshTestBase {
return button;
}
views::View* SimulateClick(internal::LauncherButtonHost::Pointer pointer,
views::View* SimulateClick(internal::ShelfButtonHost::Pointer pointer,
int button_index) {
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
views::View* button = SimulateButtonPressed(pointer, button_index);
button_host->PointerReleasedOnButton(button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
return button;
}
views::View* SimulateDrag(internal::LauncherButtonHost::Pointer pointer,
views::View* SimulateDrag(internal::ShelfButtonHost::Pointer pointer,
int button_index,
int destination_index) {
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
views::View* button = SimulateButtonPressed(pointer, button_index);
// Drag.
......@@ -782,7 +782,7 @@ TEST_F(ShelfViewTest, AddButtonQuickly) {
// Check that model changes are handled correctly while a launcher icon is being
// dragged.
TEST_F(ShelfViewTest, ModelChangesWhileDragging) {
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
std::vector<std::pair<LauncherID, views::View*> > id_map;
SetupForDragTest(&id_map);
......@@ -790,19 +790,18 @@ TEST_F(ShelfViewTest, ModelChangesWhileDragging) {
// Dragging browser shortcut at index 1.
EXPECT_TRUE(model_->items()[1].type == TYPE_BROWSER_SHORTCUT);
views::View* dragged_button = SimulateDrag(
internal::LauncherButtonHost::MOUSE, 1, 3);
internal::ShelfButtonHost::MOUSE, 1, 3);
std::rotate(id_map.begin() + 1,
id_map.begin() + 2,
id_map.begin() + 4);
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
EXPECT_TRUE(model_->items()[3].type == TYPE_BROWSER_SHORTCUT);
// Dragging changes model order.
dragged_button = SimulateDrag(
internal::LauncherButtonHost::MOUSE, 1, 3);
dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 3);
std::rotate(id_map.begin() + 1,
id_map.begin() + 2,
id_map.begin() + 4);
......@@ -810,7 +809,7 @@ TEST_F(ShelfViewTest, ModelChangesWhileDragging) {
// Cancelling the drag operation restores previous order.
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
true);
std::rotate(id_map.begin() + 1,
id_map.begin() + 3,
......@@ -818,38 +817,38 @@ TEST_F(ShelfViewTest, ModelChangesWhileDragging) {
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
// Deleting an item keeps the remaining intact.
dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 1, 3);
dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 3);
model_->RemoveItemAt(1);
id_map.erase(id_map.begin() + 1);
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
// Adding a launcher item cancels the drag and respects the order.
dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 1, 3);
dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 3);
LauncherID new_id = AddAppShortcut();
id_map.insert(id_map.begin() + 6,
std::make_pair(new_id, GetButtonByID(new_id)));
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
// Adding a launcher item at the end (i.e. a panel) canels drag and respects
// the order.
dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 1, 3);
dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 3);
new_id = AddPanel();
id_map.insert(id_map.begin() + 7,
std::make_pair(new_id, GetButtonByID(new_id)));
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
}
TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) {
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
std::vector<std::pair<LauncherID, views::View*> > id_map;
SetupForDragTest(&id_map);
......@@ -857,19 +856,18 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) {
// Dragging browser shortcut at index 0.
EXPECT_TRUE(model_->items()[0].type == TYPE_BROWSER_SHORTCUT);
views::View* dragged_button = SimulateDrag(
internal::LauncherButtonHost::MOUSE, 0, 2);
internal::ShelfButtonHost::MOUSE, 0, 2);
std::rotate(id_map.begin(),
id_map.begin() + 1,
id_map.begin() + 3);
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
EXPECT_TRUE(model_->items()[2].type == TYPE_BROWSER_SHORTCUT);
// Dragging changes model order.
dragged_button = SimulateDrag(
internal::LauncherButtonHost::MOUSE, 0, 2);
dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 0, 2);
std::rotate(id_map.begin(),
id_map.begin() + 1,
id_map.begin() + 3);
......@@ -877,7 +875,7 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) {
// Cancelling the drag operation restores previous order.
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
true);
std::rotate(id_map.begin(),
id_map.begin() + 2,
......@@ -885,80 +883,78 @@ TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) {
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
// Deleting an item keeps the remaining intact.
dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 0, 2);
dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 0, 2);
model_->RemoveItemAt(1);
id_map.erase(id_map.begin() + 1);
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
// Adding a launcher item cancels the drag and respects the order.
dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 0, 2);
dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 0, 2);
LauncherID new_id = AddAppShortcut();
id_map.insert(id_map.begin() + 5,
std::make_pair(new_id, GetButtonByID(new_id)));
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
// Adding a launcher item at the end (i.e. a panel) canels drag and respects
// the order.
dragged_button = SimulateDrag(internal::LauncherButtonHost::MOUSE, 0, 2);
dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 0, 2);
new_id = AddPanel();
id_map.insert(id_map.begin() + 7,
std::make_pair(new_id, GetButtonByID(new_id)));
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
}
// Check that 2nd drag from the other pointer would be ignored.
TEST_F(ShelfViewTest, SimultaneousDrag) {
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
std::vector<std::pair<LauncherID, views::View*> > id_map;
SetupForDragTest(&id_map);
// Start a mouse drag.
views::View* dragged_button_mouse = SimulateDrag(
internal::LauncherButtonHost::MOUSE, 1, 3);
internal::ShelfButtonHost::MOUSE, 1, 3);
std::rotate(id_map.begin() + 1,
id_map.begin() + 2,
id_map.begin() + 4);
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
// Attempt a touch drag before the mouse drag finishes.
views::View* dragged_button_touch = SimulateDrag(
internal::LauncherButtonHost::TOUCH, 4, 2);
internal::ShelfButtonHost::TOUCH, 4, 2);
// Nothing changes since 2nd drag is ignored.
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
// Finish the mouse drag.
button_host->PointerReleasedOnButton(dragged_button_mouse,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
// Now start a touch drag.
dragged_button_touch = SimulateDrag(
internal::LauncherButtonHost::TOUCH, 4, 2);
dragged_button_touch = SimulateDrag(internal::ShelfButtonHost::TOUCH, 4, 2);
std::rotate(id_map.begin() + 3,
id_map.begin() + 4,
id_map.begin() + 5);
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
// And attempt a mouse drag before the touch drag finishes.
dragged_button_mouse = SimulateDrag(
internal::LauncherButtonHost::MOUSE, 1, 2);
dragged_button_mouse = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 2);
// Nothing changes since 2nd drag is ignored.
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button_touch,
internal::LauncherButtonHost::TOUCH,
internal::ShelfButtonHost::TOUCH,
false);
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
}
......@@ -966,24 +962,24 @@ TEST_F(ShelfViewTest, SimultaneousDrag) {
// Check that clicking first on one item and then dragging another works as
// expected.
TEST_F(ShelfViewTest, ClickOneDragAnother) {
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
std::vector<std::pair<LauncherID, views::View*> > id_map;
SetupForDragTest(&id_map);
// A click on item 1 is simulated.
SimulateClick(internal::LauncherButtonHost::MOUSE, 1);
SimulateClick(internal::ShelfButtonHost::MOUSE, 1);
// Dragging browser index at 0 should change the model order correctly.
EXPECT_TRUE(model_->items()[1].type == TYPE_BROWSER_SHORTCUT);
views::View* dragged_button = SimulateDrag(
internal::LauncherButtonHost::MOUSE, 1, 3);
internal::ShelfButtonHost::MOUSE, 1, 3);
std::rotate(id_map.begin() + 1,
id_map.begin() + 2,
id_map.begin() + 4);
ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map));
button_host->PointerReleasedOnButton(dragged_button,
internal::LauncherButtonHost::MOUSE,
internal::ShelfButtonHost::MOUSE,
false);
EXPECT_TRUE(model_->items()[3].type == TYPE_BROWSER_SHORTCUT);
}
......@@ -1084,7 +1080,7 @@ TEST_F(ShelfViewTest, ShelfTooltipTest) {
internal::LauncherButton* app_button = GetButtonByID(app_button_id);
internal::LauncherButton* platform_button = GetButtonByID(platform_button_id);
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
internal::ShelfTooltipManager* tooltip_manager =
shelf_view_->tooltip_manager();
......@@ -1122,7 +1118,7 @@ TEST_F(ShelfViewTest, ShelfTooltipTest) {
// Verify a fix for crash caused by a tooltip update for a deleted launcher
// button, see crbug.com/288838.
TEST_F(ShelfViewTest, RemovingItemClosesTooltip) {
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
internal::ShelfTooltipManager* tooltip_manager =
shelf_view_->tooltip_manager();
......@@ -1148,7 +1144,7 @@ TEST_F(ShelfViewTest, RemovingItemClosesTooltip) {
// Changing the shelf alignment closes any open tooltip.
TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) {
internal::LauncherButtonHost* button_host = shelf_view_;
internal::ShelfButtonHost* button_host = shelf_view_;
internal::ShelfTooltipManager* tooltip_manager =
shelf_view_->tooltip_manager();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment