Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: ash/shelf/shelf_view_unittest.cc

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase at r285842 Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | ash/shell_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/shelf_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 19 matching lines...) Expand all
30 #include "ash/test/test_shelf_delegate.h" 30 #include "ash/test/test_shelf_delegate.h"
31 #include "ash/test/test_shelf_item_delegate.h" 31 #include "ash/test/test_shelf_item_delegate.h"
32 #include "ash/wm/coordinate_conversion.h" 32 #include "ash/wm/coordinate_conversion.h"
33 #include "base/basictypes.h" 33 #include "base/basictypes.h"
34 #include "base/command_line.h" 34 #include "base/command_line.h"
35 #include "base/compiler_specific.h" 35 #include "base/compiler_specific.h"
36 #include "base/memory/scoped_ptr.h" 36 #include "base/memory/scoped_ptr.h"
37 #include "base/strings/string_number_conversions.h" 37 #include "base/strings/string_number_conversions.h"
38 #include "grit/ash_resources.h" 38 #include "grit/ash_resources.h"
39 #include "ui/aura/test/aura_test_base.h" 39 #include "ui/aura/test/aura_test_base.h"
40 #include "ui/aura/test/event_generator.h"
41 #include "ui/aura/window.h" 40 #include "ui/aura/window.h"
42 #include "ui/aura/window_event_dispatcher.h" 41 #include "ui/aura/window_event_dispatcher.h"
43 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/compositor/layer.h" 43 #include "ui/compositor/layer.h"
45 #include "ui/events/event.h" 44 #include "ui/events/event.h"
46 #include "ui/events/event_constants.h" 45 #include "ui/events/event_constants.h"
46 #include "ui/events/test/event_generator.h"
47 #include "ui/views/view_model.h" 47 #include "ui/views/view_model.h"
48 #include "ui/views/widget/widget.h" 48 #include "ui/views/widget/widget.h"
49 #include "ui/views/widget/widget_delegate.h" 49 #include "ui/views/widget/widget_delegate.h"
50 50
51 namespace ash { 51 namespace ash {
52 namespace test { 52 namespace test {
53 53
54 //////////////////////////////////////////////////////////////////////////////// 54 ////////////////////////////////////////////////////////////////////////////////
55 // ShelfIconObserver tests. 55 // ShelfIconObserver tests.
56 56
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 int second_last_visible_item_id_in_overflow = 510 int second_last_visible_item_id_in_overflow =
511 GetItemId(test_api_for_overflow.GetLastVisibleIndex() - 1); 511 GetItemId(test_api_for_overflow.GetLastVisibleIndex() - 1);
512 512
513 int drag_item_index = 513 int drag_item_index =
514 test_api_for_overflow.GetLastVisibleIndex(); 514 test_api_for_overflow.GetLastVisibleIndex();
515 ShelfID drag_item_id = GetItemId(drag_item_index); 515 ShelfID drag_item_id = GetItemId(drag_item_index);
516 ShelfButton* drag_button = test_api_for_overflow.GetButton(drag_item_index); 516 ShelfButton* drag_button = test_api_for_overflow.GetButton(drag_item_index);
517 gfx::Point center_point_of_drag_item = 517 gfx::Point center_point_of_drag_item =
518 drag_button->GetBoundsInScreen().CenterPoint(); 518 drag_button->GetBoundsInScreen().CenterPoint();
519 519
520 aura::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(), 520 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(),
521 center_point_of_drag_item); 521 center_point_of_drag_item);
522 // Rip an item off to OverflowBubble. 522 // Rip an item off to OverflowBubble.
523 generator.PressLeftButton(); 523 generator.PressLeftButton();
524 gfx::Point rip_off_point(center_point_of_drag_item.x(), 0); 524 gfx::Point rip_off_point(center_point_of_drag_item.x(), 0);
525 generator.MoveMouseTo(rip_off_point); 525 generator.MoveMouseTo(rip_off_point);
526 test_api_for_overflow.RunMessageLoopUntilAnimationsDone(); 526 test_api_for_overflow.RunMessageLoopUntilAnimationsDone();
527 ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf()); 527 ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf());
528 ASSERT_FALSE(test_api_for_overflow.DraggedItemFromOverflowToShelf()); 528 ASSERT_FALSE(test_api_for_overflow.DraggedItemFromOverflowToShelf());
529 529
530 // Move a dragged item into Shelf at |drop_index|. 530 // Move a dragged item into Shelf at |drop_index|.
531 int drop_index = 1; 531 int drop_index = 1;
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 views::View* app_list_button = shelf_view_->GetAppListButtonView(); 1319 views::View* app_list_button = shelf_view_->GetAppListButtonView();
1320 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( 1320 EXPECT_TRUE(shelf_view_->ShouldHideTooltip(
1321 app_list_button->GetMirroredBounds().CenterPoint())); 1321 app_list_button->GetMirroredBounds().CenterPoint()));
1322 } 1322 }
1323 1323
1324 // Test that by moving the mouse cursor off the button onto the bubble it closes 1324 // Test that by moving the mouse cursor off the button onto the bubble it closes
1325 // the bubble. 1325 // the bubble.
1326 TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { 1326 TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) {
1327 ShelfTooltipManager* tooltip_manager = shelf_view_->tooltip_manager(); 1327 ShelfTooltipManager* tooltip_manager = shelf_view_->tooltip_manager();
1328 tooltip_manager->CreateZeroDelayTimerForTest(); 1328 tooltip_manager->CreateZeroDelayTimerForTest();
1329 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1329 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1330 1330
1331 // Move the mouse off any item and check that no tooltip is shown. 1331 // Move the mouse off any item and check that no tooltip is shown.
1332 generator.MoveMouseTo(gfx::Point(0, 0)); 1332 generator.MoveMouseTo(gfx::Point(0, 0));
1333 EXPECT_FALSE(tooltip_manager->IsVisible()); 1333 EXPECT_FALSE(tooltip_manager->IsVisible());
1334 1334
1335 // Move the mouse over the button and check that it is visible. 1335 // Move the mouse over the button and check that it is visible.
1336 views::View* app_list_button = shelf_view_->GetAppListButtonView(); 1336 views::View* app_list_button = shelf_view_->GetAppListButtonView();
1337 gfx::Rect bounds = app_list_button->GetBoundsInScreen(); 1337 gfx::Rect bounds = app_list_button->GetBoundsInScreen();
1338 generator.MoveMouseTo(bounds.CenterPoint()); 1338 generator.MoveMouseTo(bounds.CenterPoint());
1339 // Wait for the timer to go off. 1339 // Wait for the timer to go off.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 test_api_->overflow_bubble()->IsShowing()); 1411 test_api_->overflow_bubble()->IsShowing());
1412 1412
1413 ShelfViewTestAPI test_for_overflow_view( 1413 ShelfViewTestAPI test_for_overflow_view(
1414 test_api_->overflow_bubble()->shelf_view()); 1414 test_api_->overflow_bubble()->shelf_view());
1415 1415
1416 int ripped_index = test_for_overflow_view.GetLastVisibleIndex(); 1416 int ripped_index = test_for_overflow_view.GetLastVisibleIndex();
1417 gfx::Size bubble_size = test_for_overflow_view.GetPreferredSize(); 1417 gfx::Size bubble_size = test_for_overflow_view.GetPreferredSize();
1418 int item_width = test_for_overflow_view.GetButtonSize() + 1418 int item_width = test_for_overflow_view.GetButtonSize() +
1419 test_for_overflow_view.GetButtonSpacing(); 1419 test_for_overflow_view.GetButtonSpacing();
1420 1420
1421 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 1421 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
1422 gfx::Point()); 1422 gfx::Point());
1423 ShelfButton* button = test_for_overflow_view.GetButton(ripped_index); 1423 ShelfButton* button = test_for_overflow_view.GetButton(ripped_index);
1424 // Rip off the last visible item. 1424 // Rip off the last visible item.
1425 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); 1425 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint();
1426 gfx::Point rip_off_point(start_point.x(), 0); 1426 gfx::Point rip_off_point(start_point.x(), 0);
1427 generator.MoveMouseTo(start_point.x(), start_point.y()); 1427 generator.MoveMouseTo(start_point.x(), start_point.y());
1428 base::MessageLoop::current()->RunUntilIdle(); 1428 base::MessageLoop::current()->RunUntilIdle();
1429 generator.PressLeftButton(); 1429 generator.PressLeftButton();
1430 base::MessageLoop::current()->RunUntilIdle(); 1430 base::MessageLoop::current()->RunUntilIdle();
1431 generator.MoveMouseTo(rip_off_point.x(), rip_off_point.y()); 1431 generator.MoveMouseTo(rip_off_point.x(), rip_off_point.y());
1432 base::MessageLoop::current()->RunUntilIdle(); 1432 base::MessageLoop::current()->RunUntilIdle();
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 ShelfTestAPI(secondary_shelf).shelf_view(); 1599 ShelfTestAPI(secondary_shelf).shelf_view();
1600 1600
1601 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary); 1601 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary);
1602 ShelfButton* button = 1602 ShelfButton* button =
1603 test_api_for_secondary_shelf_view.GetButton(browser_index); 1603 test_api_for_secondary_shelf_view.GetButton(browser_index);
1604 1604
1605 // Fetch the start point of dragging. 1605 // Fetch the start point of dragging.
1606 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); 1606 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint();
1607 wm::ConvertPointFromScreen(second_root, &start_point); 1607 wm::ConvertPointFromScreen(second_root, &start_point);
1608 1608
1609 aura::test::EventGenerator generator(second_root, start_point); 1609 ui::test::EventGenerator generator(second_root, start_point);
1610 1610
1611 // Rip off the browser item. 1611 // Rip off the browser item.
1612 generator.PressLeftButton(); 1612 generator.PressLeftButton();
1613 generator.MoveMouseTo(start_point.x() + 400, start_point.y()); 1613 generator.MoveMouseTo(start_point.x() + 400, start_point.y());
1614 test_api_for_secondary_shelf_view.RunMessageLoopUntilAnimationsDone(); 1614 test_api_for_secondary_shelf_view.RunMessageLoopUntilAnimationsDone();
1615 EXPECT_TRUE(test_api_for_secondary_shelf_view.IsRippedOffFromShelf()); 1615 EXPECT_TRUE(test_api_for_secondary_shelf_view.IsRippedOffFromShelf());
1616 } 1616 }
1617 1617
1618 // Checks various drag and drop operations from OverflowBubble to Shelf. 1618 // Checks various drag and drop operations from OverflowBubble to Shelf.
1619 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) { 1619 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 test_api_->RunMessageLoopUntilAnimationsDone(); 1669 test_api_->RunMessageLoopUntilAnimationsDone();
1670 CheckAllItemsAreInBounds(); 1670 CheckAllItemsAreInBounds();
1671 } 1671 }
1672 1672
1673 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); 1673 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool());
1674 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, 1674 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest,
1675 testing::Bool()); 1675 testing::Bool());
1676 1676
1677 } // namespace test 1677 } // namespace test
1678 } // namespace ash 1678 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | ash/shell_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698