diff options
Diffstat (limited to 'ash')
-rw-r--r-- | ash/shelf/shelf_view.cc | 2 | ||||
-rw-r--r-- | ash/shelf/shelf_view_unittest.cc | 48 | ||||
-rw-r--r-- | ash/test/shelf_view_test_api.cc | 4 | ||||
-rw-r--r-- | ash/test/shelf_view_test_api.h | 2 |
4 files changed, 49 insertions, 7 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. diff --git a/ash/test/shelf_view_test_api.cc b/ash/test/shelf_view_test_api.cc index b0e0dff..d40f900 100644 --- a/ash/test/shelf_view_test_api.cc +++ b/ash/test/shelf_view_test_api.cc @@ -128,8 +128,8 @@ gfx::Rect ShelfViewTestAPI::GetBoundsForDragInsertInScreen() { return shelf_view_->GetBoundsForDragInsertInScreen(); } -bool ShelfViewTestAPI::IsDraggingShelfItem() { - return shelf_view_->dragging(); +bool ShelfViewTestAPI::IsRippedOffFromShelf() { + return shelf_view_->dragged_off_shelf_; } bool ShelfViewTestAPI::DraggedItemFromOverflowToShelf() { diff --git a/ash/test/shelf_view_test_api.h b/ash/test/shelf_view_test_api.h index 56ca723..71d8f74 100644 --- a/ash/test/shelf_view_test_api.h +++ b/ash/test/shelf_view_test_api.h @@ -84,7 +84,7 @@ class ShelfViewTestAPI { gfx::Rect GetBoundsForDragInsertInScreen(); // Returns true if item is ripped off. - bool IsDraggingShelfItem(); + bool IsRippedOffFromShelf(); // Returns true if an item is ripped off and entered into shelf. bool DraggedItemFromOverflowToShelf(); |