summaryrefslogtreecommitdiffstats
path: root/ash/shelf
diff options
context:
space:
mode:
authorsimonhong@chromium.org <simonhong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-13 14:42:50 +0000
committersimonhong@chromium.org <simonhong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-13 14:42:50 +0000
commit74095f04124d43e21f65692249afea5c30cc25ea (patch)
tree33ec5f233843f2ed1feede0e0e7d7bd7a3c9da63 /ash/shelf
parent210451cc8198a0d3eedfba3b5f0b60dc52e47e2d (diff)
downloadchromium_src-74095f04124d43e21f65692249afea5c30cc25ea.zip
chromium_src-74095f04124d43e21f65692249afea5c30cc25ea.tar.gz
chromium_src-74095f04124d43e21f65692249afea5c30cc25ea.tar.bz2
[ash] Can't rip off an item from left positioned shelf in secondary monitor
Root window coordinated point is passed to CalculateShelfDistance(). R=skuhne@chromium.org, jamescook@chromium.org BUG=328226 TEST=ash_unittests --gtest_filter=ShelfViewTest.CheckRipOffFromLeftShelfAlignmentWithMultiMonitor Review URL: https://codereview.chromium.org/113743002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shelf')
-rw-r--r--ash/shelf/shelf_view.cc2
-rw-r--r--ash/shelf/shelf_view_unittest.cc48
2 files changed, 46 insertions, 4 deletions
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index 38550e0..3b7e204 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -1130,7 +1130,7 @@ bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) {
}
// Check if we are too far away from the shelf to enter the ripped off state.
// Determine the distance to the shelf.
- int delta = CalculateShelfDistance(event.root_location());
+ int delta = CalculateShelfDistance(screen_location);
if (delta > kRipOffDistance) {
// Create a proxy view item which can be moved anywhere.
ShelfButton* button = static_cast<ShelfButton*>(drag_view_);
diff --git a/ash/shelf/shelf_view_unittest.cc b/ash/shelf/shelf_view_unittest.cc
index d3e2b1d..ec1468a 100644
--- a/ash/shelf/shelf_view_unittest.cc
+++ b/ash/shelf/shelf_view_unittest.cc
@@ -29,6 +29,7 @@
#include "ash/test/shell_test_api.h"
#include "ash/test/test_shelf_delegate.h"
#include "ash/test/test_shelf_item_delegate.h"
+#include "ash/wm/coordinate_conversion.h"
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
@@ -502,7 +503,7 @@ class ShelfViewTest : public AshTestBase {
gfx::Point rip_off_point(center_point_of_drag_item.x(), 0);
generator.MoveMouseTo(rip_off_point);
test_api_for_overflow.RunMessageLoopUntilAnimationsDone();
- ASSERT_TRUE(test_api_for_overflow.IsDraggingShelfItem());
+ ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf());
ASSERT_FALSE(test_api_for_overflow.DraggedItemFromOverflowToShelf());
// Move a dragged item into Shelf at |drop_index|.
@@ -517,7 +518,7 @@ class ShelfViewTest : public AshTestBase {
generator.MoveMouseTo(modified_drop_point);
test_api_for_overflow.RunMessageLoopUntilAnimationsDone();
test_api_->RunMessageLoopUntilAnimationsDone();
- ASSERT_TRUE(test_api_for_overflow.IsDraggingShelfItem());
+ ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf());
ASSERT_TRUE(test_api_for_overflow.DraggedItemFromOverflowToShelf());
if (cancel)
@@ -527,7 +528,7 @@ class ShelfViewTest : public AshTestBase {
test_api_for_overflow.RunMessageLoopUntilAnimationsDone();
test_api_->RunMessageLoopUntilAnimationsDone();
- ASSERT_FALSE(test_api_for_overflow.IsDraggingShelfItem());
+ ASSERT_FALSE(test_api_for_overflow.IsRippedOffFromShelf());
ASSERT_FALSE(test_api_for_overflow.DraggedItemFromOverflowToShelf());
// Compare pre-stored items' id with newly positioned items' after dragging
@@ -1671,6 +1672,47 @@ TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) {
EXPECT_FALSE(drag_reinsert_bounds_in_secondary.Contains(point_in_shelf_view));
}
+// Checks the rip an item off from left aligned shelf in secondary monitor.
+TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) {
+ // win8-aura doesn't support multiple display.
+ if (!SupportsMultipleDisplays())
+ return;
+
+ UpdateDisplay("800x600,800x600");
+ ASSERT_EQ(2U, Shell::GetAllRootWindows().size());
+
+ aura::Window* second_root = Shell::GetAllRootWindows()[1];
+
+ Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, second_root);
+ ASSERT_EQ(SHELF_ALIGNMENT_LEFT,
+ Shell::GetInstance()->GetShelfAlignment(second_root));
+
+ // Initially, app list and browser shortcut are added.
+ EXPECT_EQ(2, model_->item_count());
+ int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT);
+ EXPECT_GT(browser_index, 0);
+
+ Launcher* secondary_launcher = Launcher::ForWindow(second_root);
+ internal::ShelfView* shelf_view_for_secondary =
+ test::LauncherTestAPI(secondary_launcher).shelf_view();
+
+ ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary);
+ internal::ShelfButton* button =
+ test_api_for_secondary_shelf_view.GetButton(browser_index);
+
+ // Fetch the start point of dragging.
+ gfx::Point start_point = button->GetBoundsInScreen().CenterPoint();
+ wm::ConvertPointFromScreen(second_root, &start_point);
+
+ aura::test::EventGenerator generator(second_root, start_point);
+
+ // Rip off the browser item.
+ generator.PressLeftButton();
+ generator.MoveMouseTo(start_point.x() + 400, start_point.y());
+ test_api_for_secondary_shelf_view.RunMessageLoopUntilAnimationsDone();
+ EXPECT_TRUE(test_api_for_secondary_shelf_view.IsRippedOffFromShelf());
+}
+
// Checks various drag and drop operations from OverflowBubble to Shelf.
TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) {
// Replace LauncherDelegate.