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

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

Issue 2228713003: mash: Convert ShelfView to wm common types, clean up Shelf access (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix control reaches end of non-void function warnings Created 4 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
« no previous file with comments | « ash/shelf/shelf_view.cc ('k') | ash/shelf/shelf_widget_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/common/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/common/shelf/app_list_button.h" 12 #include "ash/common/shelf/app_list_button.h"
13 #include "ash/common/shelf/overflow_bubble.h" 13 #include "ash/common/shelf/overflow_bubble.h"
14 #include "ash/common/shelf/overflow_bubble_view.h" 14 #include "ash/common/shelf/overflow_bubble_view.h"
15 #include "ash/common/shelf/shelf_button.h" 15 #include "ash/common/shelf/shelf_button.h"
16 #include "ash/common/shelf/shelf_constants.h" 16 #include "ash/common/shelf/shelf_constants.h"
17 #include "ash/common/shelf/shelf_icon_observer.h"
17 #include "ash/common/shelf/shelf_menu_model.h" 18 #include "ash/common/shelf/shelf_menu_model.h"
18 #include "ash/common/shelf/shelf_model.h" 19 #include "ash/common/shelf/shelf_model.h"
19 #include "ash/common/shelf/shelf_tooltip_manager.h" 20 #include "ash/common/shelf/shelf_tooltip_manager.h"
21 #include "ash/common/shelf/wm_shelf.h"
20 #include "ash/common/shell_window_ids.h" 22 #include "ash/common/shell_window_ids.h"
21 #include "ash/common/test/material_design_controller_test_api.h" 23 #include "ash/common/test/material_design_controller_test_api.h"
22 #include "ash/common/wm_shell.h" 24 #include "ash/common/wm_shell.h"
23 #include "ash/root_window_controller.h"
24 #include "ash/shelf/shelf.h"
25 #include "ash/shelf/shelf_icon_observer.h"
26 #include "ash/shelf/shelf_widget.h" 25 #include "ash/shelf/shelf_widget.h"
27 #include "ash/shell.h" 26 #include "ash/shell.h"
28 #include "ash/test/ash_test_base.h" 27 #include "ash/test/ash_test_base.h"
29 #include "ash/test/ash_test_helper.h" 28 #include "ash/test/ash_test_helper.h"
30 #include "ash/test/overflow_bubble_view_test_api.h" 29 #include "ash/test/overflow_bubble_view_test_api.h"
31 #include "ash/test/shelf_test_api.h" 30 #include "ash/test/shelf_test_api.h"
32 #include "ash/test/shelf_view_test_api.h" 31 #include "ash/test/shelf_view_test_api.h"
33 #include "ash/test/test_shelf_delegate.h" 32 #include "ash/test/test_shelf_delegate.h"
34 #include "ash/test/test_shelf_item_delegate.h" 33 #include "ash/test/test_shelf_item_delegate.h"
35 #include "ash/test/test_shell_delegate.h" 34 #include "ash/test/test_shell_delegate.h"
36 #include "ash/test/test_system_tray_delegate.h" 35 #include "ash/test/test_system_tray_delegate.h"
37 #include "base/compiler_specific.h"
38 #include "base/i18n/rtl.h" 36 #include "base/i18n/rtl.h"
37 #include "base/macros.h"
39 #include "base/memory/ptr_util.h" 38 #include "base/memory/ptr_util.h"
40 #include "base/run_loop.h" 39 #include "base/run_loop.h"
41 #include "base/strings/string_number_conversions.h" 40 #include "base/strings/string_number_conversions.h"
42 #include "base/strings/utf_string_conversions.h" 41 #include "base/strings/utf_string_conversions.h"
43 #include "base/test/histogram_tester.h" 42 #include "base/test/histogram_tester.h"
44 #include "base/test/user_action_tester.h" 43 #include "base/test/user_action_tester.h"
45 #include "base/threading/thread_task_runner_handle.h" 44 #include "base/threading/thread_task_runner_handle.h"
46 #include "base/time/time.h" 45 #include "base/time/time.h"
47 #include "testing/gmock/include/gmock/gmock.h" 46 #include "testing/gmock/include/gmock/gmock.h"
48 #include "ui/app_list/presenter/app_list_presenter.h" 47 #include "ui/app_list/presenter/app_list_presenter.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 EXPECT_TRUE(observer()->change_notified()); 185 EXPECT_TRUE(observer()->change_notified());
187 observer()->Reset(); 186 observer()->Reset();
188 187
189 widget->Show(); 188 widget->Show();
190 widget->GetNativeWindow()->parent()->RemoveChild(widget->GetNativeWindow()); 189 widget->GetNativeWindow()->parent()->RemoveChild(widget->GetNativeWindow());
191 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 190 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
192 EXPECT_TRUE(observer()->change_notified()); 191 EXPECT_TRUE(observer()->change_notified());
193 observer()->Reset(); 192 observer()->Reset();
194 } 193 }
195 194
196 // Sometimes fails on trybots on win7_aura. http://crbug.com/177135
197 #if defined(OS_WIN)
198 #define MAYBE_AddRemoveWithMultipleDisplays \
199 DISABLED_AddRemoveWithMultipleDisplays
200 #else
201 #define MAYBE_AddRemoveWithMultipleDisplays AddRemoveWithMultipleDisplays
202 #endif
203 // Make sure creating/deleting an window on one displays notifies a 195 // Make sure creating/deleting an window on one displays notifies a
204 // shelf on external display as well as one on primary. 196 // shelf on external display as well as one on primary.
205 TEST_F(ShelfViewIconObserverTest, MAYBE_AddRemoveWithMultipleDisplays) { 197 TEST_F(ShelfViewIconObserverTest, AddRemoveWithMultipleDisplays) {
198 if (!SupportsMultipleDisplays())
199 return;
200
206 UpdateDisplay("400x400,400x400"); 201 UpdateDisplay("400x400,400x400");
207 TestShelfIconObserver second_observer(ShelfForSecondaryDisplay()); 202 TestShelfIconObserver second_observer(ShelfForSecondaryDisplay());
208 203
209 TestShelfDelegate* shelf_delegate = TestShelfDelegate::instance(); 204 TestShelfDelegate* shelf_delegate = TestShelfDelegate::instance();
210 ASSERT_TRUE(shelf_delegate); 205 ASSERT_TRUE(shelf_delegate);
211 206
212 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 207 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
213 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 208 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
214 params.bounds = gfx::Rect(0, 0, 200, 200); 209 params.bounds = gfx::Rect(0, 0, 200, 200);
215 params.context = CurrentContext(); 210 params.context = CurrentContext();
(...skipping 10 matching lines...) Expand all
226 widget->GetNativeWindow()->parent()->RemoveChild(widget->GetNativeWindow()); 221 widget->GetNativeWindow()->parent()->RemoveChild(widget->GetNativeWindow());
227 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 222 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
228 EXPECT_TRUE(observer()->change_notified()); 223 EXPECT_TRUE(observer()->change_notified());
229 EXPECT_TRUE(second_observer.change_notified()); 224 EXPECT_TRUE(second_observer.change_notified());
230 225
231 observer()->Reset(); 226 observer()->Reset();
232 second_observer.Reset(); 227 second_observer.Reset();
233 } 228 }
234 229
235 TEST_F(ShelfViewIconObserverTest, BoundsChanged) { 230 TEST_F(ShelfViewIconObserverTest, BoundsChanged) {
236 ShelfWidget* widget = Shell::GetPrimaryRootWindowController()->shelf_widget(); 231 views::Widget* widget =
232 GetPrimaryShelf()->GetShelfViewForTesting()->GetWidget();
237 gfx::Rect shelf_bounds = widget->GetWindowBoundsInScreen(); 233 gfx::Rect shelf_bounds = widget->GetWindowBoundsInScreen();
238 shelf_bounds.set_width(shelf_bounds.width() / 2); 234 shelf_bounds.set_width(shelf_bounds.width() / 2);
239 ASSERT_GT(shelf_bounds.width(), 0); 235 ASSERT_GT(shelf_bounds.width(), 0);
240 widget->SetBounds(shelf_bounds); 236 widget->SetBounds(shelf_bounds);
241 // No animation happens for ShelfView bounds change. 237 // No animation happens for ShelfView bounds change.
242 EXPECT_TRUE(observer()->change_notified()); 238 EXPECT_TRUE(observer()->change_notified());
243 observer()->Reset(); 239 observer()->Reset();
244 } 240 }
245 241
246 //////////////////////////////////////////////////////////////////////////////// 242 ////////////////////////////////////////////////////////////////////////////////
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 GetItemId(test_api_for_overflow.GetFirstVisibleIndex()); 606 GetItemId(test_api_for_overflow.GetFirstVisibleIndex());
611 int second_last_visible_item_id_in_overflow = 607 int second_last_visible_item_id_in_overflow =
612 GetItemId(test_api_for_overflow.GetLastVisibleIndex() - 1); 608 GetItemId(test_api_for_overflow.GetLastVisibleIndex() - 1);
613 609
614 int drag_item_index = test_api_for_overflow.GetLastVisibleIndex(); 610 int drag_item_index = test_api_for_overflow.GetLastVisibleIndex();
615 ShelfID drag_item_id = GetItemId(drag_item_index); 611 ShelfID drag_item_id = GetItemId(drag_item_index);
616 ShelfButton* drag_button = test_api_for_overflow.GetButton(drag_item_index); 612 ShelfButton* drag_button = test_api_for_overflow.GetButton(drag_item_index);
617 gfx::Point center_point_of_drag_item = 613 gfx::Point center_point_of_drag_item =
618 drag_button->GetBoundsInScreen().CenterPoint(); 614 drag_button->GetBoundsInScreen().CenterPoint();
619 615
620 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(), 616 ui::test::EventGenerator& generator = GetEventGenerator();
621 center_point_of_drag_item); 617 generator.set_current_location(center_point_of_drag_item);
622 // Rip an item off to OverflowBubble. 618 // Rip an item off to OverflowBubble.
623 generator.PressLeftButton(); 619 generator.PressLeftButton();
624 gfx::Point rip_off_point(center_point_of_drag_item.x(), 0); 620 gfx::Point rip_off_point(center_point_of_drag_item.x(), 0);
625 generator.MoveMouseTo(rip_off_point); 621 generator.MoveMouseTo(rip_off_point);
626 test_api_for_overflow.RunMessageLoopUntilAnimationsDone(); 622 test_api_for_overflow.RunMessageLoopUntilAnimationsDone();
627 ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf()); 623 ASSERT_TRUE(test_api_for_overflow.IsRippedOffFromShelf());
628 ASSERT_FALSE(test_api_for_overflow.DraggedItemFromOverflowToShelf()); 624 ASSERT_FALSE(test_api_for_overflow.DraggedItemFromOverflowToShelf());
629 625
630 // Move a dragged item into Shelf at |drop_index|. 626 // Move a dragged item into Shelf at |drop_index|.
631 int drop_index = 1; 627 int drop_index = 1;
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); 966 EXPECT_TRUE(test_api_->IsOverflowButtonVisible());
971 967
972 // Test that any two successive visible icons never overlap in all shelf 968 // Test that any two successive visible icons never overlap in all shelf
973 // alignment types. 969 // alignment types.
974 const ShelfAlignment kAlignments[] = { 970 const ShelfAlignment kAlignments[] = {
975 SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, SHELF_ALIGNMENT_BOTTOM, 971 SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, SHELF_ALIGNMENT_BOTTOM,
976 SHELF_ALIGNMENT_BOTTOM_LOCKED, 972 SHELF_ALIGNMENT_BOTTOM_LOCKED,
977 }; 973 };
978 974
979 for (ShelfAlignment alignment : kAlignments) { 975 for (ShelfAlignment alignment : kAlignments) {
980 shelf_view_->shelf()->SetAlignment(alignment); 976 shelf_view_->wm_shelf()->SetAlignment(alignment);
981 // For every 2 successive visible icons, expect that their bounds don't 977 // For every 2 successive visible icons, expect that their bounds don't
982 // intersect. 978 // intersect.
983 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) { 979 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) {
984 if (!(test_api_->GetButton(i)->visible() && 980 if (!(test_api_->GetButton(i)->visible() &&
985 test_api_->GetButton(i + 1)->visible())) { 981 test_api_->GetButton(i + 1)->visible())) {
986 continue; 982 continue;
987 } 983 }
988 984
989 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); 985 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i);
990 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); 986 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1);
991 EXPECT_FALSE(bounds1.Intersects(bounds2)); 987 EXPECT_FALSE(bounds1.Intersects(bounds2));
992 } 988 }
993 } 989 }
994 } 990 }
995 991
996 // Making sure the overflow bubble arrow correctly tracks with shelf position. 992 // Making sure the overflow bubble arrow correctly tracks with shelf position.
997 TEST_P(ShelfViewTextDirectionTest, OverflowArrowForShelfPosition) { 993 TEST_P(ShelfViewTextDirectionTest, OverflowArrowForShelfPosition) {
998 const ShelfAlignment kAlignments[] = { 994 const ShelfAlignment kAlignments[] = {
999 SHELF_ALIGNMENT_BOTTOM, SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, 995 SHELF_ALIGNMENT_BOTTOM, SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT,
1000 SHELF_ALIGNMENT_BOTTOM_LOCKED, 996 SHELF_ALIGNMENT_BOTTOM_LOCKED,
1001 }; 997 };
1002 998
1003 // These must match what is expected for each alignment above. 999 // These must match what is expected for each alignment above.
1004 const views::BubbleBorder::Arrow kArrows[] = { 1000 const views::BubbleBorder::Arrow kArrows[] = {
1005 views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP, 1001 views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP,
1006 views::BubbleBorder::RIGHT_TOP, views::BubbleBorder::BOTTOM_LEFT, 1002 views::BubbleBorder::RIGHT_TOP, views::BubbleBorder::BOTTOM_LEFT,
1007 }; 1003 };
1008 1004
1009 for (size_t i = 0; i < arraysize(kAlignments); i++) { 1005 for (size_t i = 0; i < arraysize(kAlignments); i++) {
1010 shelf_view_->shelf()->SetAlignment(kAlignments[i]); 1006 shelf_view_->wm_shelf()->SetAlignment(kAlignments[i]);
1011 1007
1012 // Make sure there are enough icons to trigger the overflow in new 1008 // Make sure there are enough icons to trigger the overflow in new
1013 // orientation. 1009 // orientation.
1014 AddButtonsUntilOverflow(); 1010 AddButtonsUntilOverflow();
1015 test_api_->ShowOverflowBubble(); 1011 test_api_->ShowOverflowBubble();
1016 ASSERT_TRUE(test_api_->overflow_bubble() && 1012 ASSERT_TRUE(test_api_->overflow_bubble() &&
1017 test_api_->overflow_bubble()->IsShowing()); 1013 test_api_->overflow_bubble()->IsShowing());
1018 1014
1019 EXPECT_EQ(kArrows[i], test_api_->overflow_bubble()->bubble_view()->arrow()); 1015 EXPECT_EQ(kArrows[i], test_api_->overflow_bubble()->bubble_view()->arrow());
1020 OverflowBubbleViewTestAPI bubble_view_api( 1016 OverflowBubbleViewTestAPI bubble_view_api(
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 model_->Set(index, item); 1325 model_->Set(index, item);
1330 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); 1326 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state());
1331 item.status = STATUS_ATTENTION; 1327 item.status = STATUS_ATTENTION;
1332 model_->Set(index, item); 1328 model_->Set(index, item);
1333 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); 1329 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state());
1334 } 1330 }
1335 1331
1336 // Confirm that shelf item bounds are correctly updated on shelf changes. 1332 // Confirm that shelf item bounds are correctly updated on shelf changes.
1337 TEST_F(ShelfViewTest, ShelfItemBoundsCheck) { 1333 TEST_F(ShelfViewTest, ShelfItemBoundsCheck) {
1338 VerifyShelfItemBoundsAreValid(); 1334 VerifyShelfItemBoundsAreValid();
1339 shelf_view_->shelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1335 shelf_view_->wm_shelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1340 test_api_->RunMessageLoopUntilAnimationsDone(); 1336 test_api_->RunMessageLoopUntilAnimationsDone();
1341 VerifyShelfItemBoundsAreValid(); 1337 VerifyShelfItemBoundsAreValid();
1342 shelf_view_->shelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1338 shelf_view_->wm_shelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1343 test_api_->RunMessageLoopUntilAnimationsDone(); 1339 test_api_->RunMessageLoopUntilAnimationsDone();
1344 VerifyShelfItemBoundsAreValid(); 1340 VerifyShelfItemBoundsAreValid();
1345 } 1341 }
1346 1342
1347 TEST_F(ShelfViewTest, ShelfTooltipTest) { 1343 TEST_F(ShelfViewTest, ShelfTooltipTest) {
1348 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); 1344 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount());
1349 1345
1350 // Prepare some items to the shelf. 1346 // Prepare some items to the shelf.
1351 ShelfID app_button_id = AddAppShortcut(); 1347 ShelfID app_button_id = AddAppShortcut();
1352 ShelfID platform_button_id = AddPlatformApp(); 1348 ShelfID platform_button_id = AddPlatformApp();
1353 1349
1354 ShelfButton* app_button = GetButtonByID(app_button_id); 1350 ShelfButton* app_button = GetButtonByID(app_button_id);
1355 ShelfButton* platform_button = GetButtonByID(platform_button_id); 1351 ShelfButton* platform_button = GetButtonByID(platform_button_id);
1356 1352
1357 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); 1353 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager();
1358 EXPECT_TRUE(test_api_->shelf_view()->GetWidget()->GetNativeWindow()); 1354 EXPECT_TRUE(test_api_->shelf_view()->GetWidget()->GetNativeWindow());
1359 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 1355 ui::test::EventGenerator& generator = GetEventGenerator();
1360 1356
1361 generator.MoveMouseTo(app_button->GetBoundsInScreen().CenterPoint()); 1357 generator.MoveMouseTo(app_button->GetBoundsInScreen().CenterPoint());
1362 // There's a delay to show the tooltip, so it's not visible yet. 1358 // There's a delay to show the tooltip, so it's not visible yet.
1363 EXPECT_FALSE(tooltip_manager->IsVisible()); 1359 EXPECT_FALSE(tooltip_manager->IsVisible());
1364 EXPECT_EQ(nullptr, tooltip_manager->GetCurrentAnchorView()); 1360 EXPECT_EQ(nullptr, tooltip_manager->GetCurrentAnchorView());
1365 1361
1366 tooltip_manager->ShowTooltip(app_button); 1362 tooltip_manager->ShowTooltip(app_button);
1367 EXPECT_TRUE(tooltip_manager->IsVisible()); 1363 EXPECT_TRUE(tooltip_manager->IsVisible());
1368 EXPECT_EQ(app_button, tooltip_manager->GetCurrentAnchorView()); 1364 EXPECT_EQ(app_button, tooltip_manager->GetCurrentAnchorView());
1369 1365
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 AppListButton* app_list_button = shelf_view_->GetAppListButton(); 1495 AppListButton* app_list_button = shelf_view_->GetAppListButton();
1500 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( 1496 EXPECT_TRUE(shelf_view_->ShouldHideTooltip(
1501 app_list_button->GetMirroredBounds().CenterPoint())); 1497 app_list_button->GetMirroredBounds().CenterPoint()));
1502 } 1498 }
1503 1499
1504 // Test that by moving the mouse cursor off the button onto the bubble it closes 1500 // Test that by moving the mouse cursor off the button onto the bubble it closes
1505 // the bubble. 1501 // the bubble.
1506 TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { 1502 TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) {
1507 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); 1503 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager();
1508 tooltip_manager->set_timer_delay_for_test(0); 1504 tooltip_manager->set_timer_delay_for_test(0);
1509 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1505 ui::test::EventGenerator& generator = GetEventGenerator();
1510 1506
1511 // Move the mouse off any item and check that no tooltip is shown. 1507 // Move the mouse off any item and check that no tooltip is shown.
1512 generator.MoveMouseTo(gfx::Point(0, 0)); 1508 generator.MoveMouseTo(gfx::Point(0, 0));
1513 EXPECT_FALSE(tooltip_manager->IsVisible()); 1509 EXPECT_FALSE(tooltip_manager->IsVisible());
1514 1510
1515 // Move the mouse over the button and check that it is visible. 1511 // Move the mouse over the button and check that it is visible.
1516 AppListButton* app_list_button = shelf_view_->GetAppListButton(); 1512 AppListButton* app_list_button = shelf_view_->GetAppListButton();
1517 gfx::Rect bounds = app_list_button->GetBoundsInScreen(); 1513 gfx::Rect bounds = app_list_button->GetBoundsInScreen();
1518 generator.MoveMouseTo(bounds.CenterPoint()); 1514 generator.MoveMouseTo(bounds.CenterPoint());
1519 // Wait for the timer to go off. 1515 // Wait for the timer to go off.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 test_api_->overflow_bubble()->IsShowing()); 1587 test_api_->overflow_bubble()->IsShowing());
1592 1588
1593 ShelfViewTestAPI test_for_overflow_view( 1589 ShelfViewTestAPI test_for_overflow_view(
1594 test_api_->overflow_bubble()->shelf_view()); 1590 test_api_->overflow_bubble()->shelf_view());
1595 1591
1596 int ripped_index = test_for_overflow_view.GetLastVisibleIndex(); 1592 int ripped_index = test_for_overflow_view.GetLastVisibleIndex();
1597 gfx::Size bubble_size = test_for_overflow_view.GetPreferredSize(); 1593 gfx::Size bubble_size = test_for_overflow_view.GetPreferredSize();
1598 int item_width = test_for_overflow_view.GetButtonSize() + 1594 int item_width = test_for_overflow_view.GetButtonSize() +
1599 test_for_overflow_view.GetButtonSpacing(); 1595 test_for_overflow_view.GetButtonSpacing();
1600 1596
1601 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 1597 ui::test::EventGenerator& generator = GetEventGenerator();
1602 gfx::Point());
1603 ShelfButton* button = test_for_overflow_view.GetButton(ripped_index); 1598 ShelfButton* button = test_for_overflow_view.GetButton(ripped_index);
1604 // Rip off the last visible item. 1599 // Rip off the last visible item.
1605 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); 1600 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint();
1606 gfx::Point rip_off_point(start_point.x(), 0); 1601 gfx::Point rip_off_point(start_point.x(), 0);
1607 generator.MoveMouseTo(start_point.x(), start_point.y()); 1602 generator.MoveMouseTo(start_point.x(), start_point.y());
1608 base::RunLoop().RunUntilIdle(); 1603 base::RunLoop().RunUntilIdle();
1609 generator.PressLeftButton(); 1604 generator.PressLeftButton();
1610 base::RunLoop().RunUntilIdle(); 1605 base::RunLoop().RunUntilIdle();
1611 generator.MoveMouseTo(rip_off_point.x(), rip_off_point.y()); 1606 generator.MoveMouseTo(rip_off_point.x(), rip_off_point.y());
1612 base::RunLoop().RunUntilIdle(); 1607 base::RunLoop().RunUntilIdle();
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 // invisible. 1813 // invisible.
1819 SetShelfItemTypeToAppShortcut(platform_app_id); 1814 SetShelfItemTypeToAppShortcut(platform_app_id);
1820 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible()); 1815 EXPECT_FALSE(GetButtonByID(platform_app_id)->visible());
1821 } 1816 }
1822 1817
1823 // Tests that the AppListButton renders as active in response to touches. 1818 // Tests that the AppListButton renders as active in response to touches.
1824 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) { 1819 TEST_F(ShelfViewTest, AppListButtonTouchFeedback) {
1825 AppListButton* app_list_button = shelf_view_->GetAppListButton(); 1820 AppListButton* app_list_button = shelf_view_->GetAppListButton();
1826 EXPECT_FALSE(app_list_button->draw_background_as_active()); 1821 EXPECT_FALSE(app_list_button->draw_background_as_active());
1827 1822
1828 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1823 ui::test::EventGenerator& generator = GetEventGenerator();
1829 generator.set_current_location( 1824 generator.set_current_location(
1830 app_list_button->GetBoundsInScreen().CenterPoint()); 1825 app_list_button->GetBoundsInScreen().CenterPoint());
1831 generator.PressTouch(); 1826 generator.PressTouch();
1832 EXPECT_TRUE(app_list_button->draw_background_as_active()); 1827 EXPECT_TRUE(app_list_button->draw_background_as_active());
1833 1828
1834 generator.ReleaseTouch(); 1829 generator.ReleaseTouch();
1835 EXPECT_FALSE(app_list_button->draw_background_as_active()); 1830 EXPECT_FALSE(app_list_button->draw_background_as_active());
1836 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); 1831 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility());
1837 } 1832 }
1838 1833
1839 // Tests that a touch that slides out of the bounds of the AppListButton leads 1834 // Tests that a touch that slides out of the bounds of the AppListButton leads
1840 // to the end of rendering an active state. 1835 // to the end of rendering an active state.
1841 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) { 1836 TEST_F(ShelfViewTest, AppListButtonTouchFeedbackCancellation) {
1842 AppListButton* app_list_button = shelf_view_->GetAppListButton(); 1837 AppListButton* app_list_button = shelf_view_->GetAppListButton();
1843 EXPECT_FALSE(app_list_button->draw_background_as_active()); 1838 EXPECT_FALSE(app_list_button->draw_background_as_active());
1844 1839
1845 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1840 ui::test::EventGenerator& generator = GetEventGenerator();
1846 generator.set_current_location( 1841 generator.set_current_location(
1847 app_list_button->GetBoundsInScreen().CenterPoint()); 1842 app_list_button->GetBoundsInScreen().CenterPoint());
1848 generator.PressTouch(); 1843 generator.PressTouch();
1849 EXPECT_TRUE(app_list_button->draw_background_as_active()); 1844 EXPECT_TRUE(app_list_button->draw_background_as_active());
1850 1845
1851 gfx::Point moved_point( 1846 gfx::Point moved_point(
1852 app_list_button->GetBoundsInScreen().right() + 1, 1847 app_list_button->GetBoundsInScreen().right() + 1,
1853 app_list_button->GetBoundsInScreen().CenterPoint().y()); 1848 app_list_button->GetBoundsInScreen().CenterPoint().y());
1854 generator.MoveTouch(moved_point); 1849 generator.MoveTouch(moved_point);
1855 EXPECT_FALSE(app_list_button->draw_background_as_active()); 1850 EXPECT_FALSE(app_list_button->draw_background_as_active());
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 test_api_->CloseMenu(); 2558 test_api_->CloseMenu();
2564 EXPECT_EQ(views::InkDropState::HIDDEN, 2559 EXPECT_EQ(views::InkDropState::HIDDEN,
2565 browser_button_ink_drop_->GetTargetInkDropState()); 2560 browser_button_ink_drop_->GetTargetInkDropState());
2566 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), 2561 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(),
2567 ElementsAre(views::InkDropState::ACTIVATED, 2562 ElementsAre(views::InkDropState::ACTIVATED,
2568 views::InkDropState::DEACTIVATED)); 2563 views::InkDropState::DEACTIVATED));
2569 } 2564 }
2570 2565
2571 } // namespace test 2566 } // namespace test
2572 } // namespace ash 2567 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view.cc ('k') | ash/shelf/shelf_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698