OLD | NEW |
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 virtual ~ShelfViewTest() {} | 263 virtual ~ShelfViewTest() {} |
264 | 264 |
265 virtual void SetUp() OVERRIDE { | 265 virtual void SetUp() OVERRIDE { |
266 AshTestBase::SetUp(); | 266 AshTestBase::SetUp(); |
267 test::ShellTestApi test_api(Shell::GetInstance()); | 267 test::ShellTestApi test_api(Shell::GetInstance()); |
268 model_ = test_api.shelf_model(); | 268 model_ = test_api.shelf_model(); |
269 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 269 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
270 shelf_view_ = ShelfTestAPI(shelf).shelf_view(); | 270 shelf_view_ = ShelfTestAPI(shelf).shelf_view(); |
271 | 271 |
272 // The bounds should be big enough for 4 buttons + overflow chevron. | 272 // The bounds should be big enough for 4 buttons + overflow chevron. |
273 shelf_view_->SetBounds(0, 0, 500, kShelfSize); | 273 shelf_view_->SetBounds(0, 0, 500, |
| 274 internal::ShelfLayoutManager::GetPreferredShelfSize()); |
274 | 275 |
275 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); | 276 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); |
276 test_api_->SetAnimationDuration(1); // Speeds up animation for test. | 277 test_api_->SetAnimationDuration(1); // Speeds up animation for test. |
277 | 278 |
278 item_manager_ = Shell::GetInstance()->shelf_item_delegate_manager(); | 279 item_manager_ = Shell::GetInstance()->shelf_item_delegate_manager(); |
279 DCHECK(item_manager_); | 280 DCHECK(item_manager_); |
280 | 281 |
281 // Add browser shortcut shelf item at index 0 for test. | 282 // Add browser shortcut shelf item at index 0 for test. |
282 AddBrowserShortcut(); | 283 AddBrowserShortcut(); |
283 } | 284 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 internal::ShelfView* shelf_view_; | 575 internal::ShelfView* shelf_view_; |
575 int browser_index_; | 576 int browser_index_; |
576 ShelfItemDelegateManager* item_manager_; | 577 ShelfItemDelegateManager* item_manager_; |
577 | 578 |
578 scoped_ptr<ShelfViewTestAPI> test_api_; | 579 scoped_ptr<ShelfViewTestAPI> test_api_; |
579 | 580 |
580 private: | 581 private: |
581 DISALLOW_COPY_AND_ASSIGN(ShelfViewTest); | 582 DISALLOW_COPY_AND_ASSIGN(ShelfViewTest); |
582 }; | 583 }; |
583 | 584 |
| 585 class ShelfViewLegacyShelfLayoutTest : public ShelfViewTest { |
| 586 public: |
| 587 ShelfViewLegacyShelfLayoutTest() : ShelfViewTest() { |
| 588 browser_index_ = 0; |
| 589 } |
| 590 |
| 591 virtual ~ShelfViewLegacyShelfLayoutTest() {} |
| 592 |
| 593 virtual void SetUp() OVERRIDE { |
| 594 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 595 ash::switches::kAshDisableAlternateShelfLayout); |
| 596 ShelfViewTest::SetUp(); |
| 597 } |
| 598 |
| 599 private: |
| 600 DISALLOW_COPY_AND_ASSIGN(ShelfViewLegacyShelfLayoutTest); |
| 601 }; |
| 602 |
584 class ScopedTextDirectionChange { | 603 class ScopedTextDirectionChange { |
585 public: | 604 public: |
586 ScopedTextDirectionChange(bool is_rtl) | 605 ScopedTextDirectionChange(bool is_rtl) |
587 : is_rtl_(is_rtl) { | 606 : is_rtl_(is_rtl) { |
588 original_locale_ = l10n_util::GetApplicationLocale(std::string()); | 607 original_locale_ = l10n_util::GetApplicationLocale(std::string()); |
589 if (is_rtl_) | 608 if (is_rtl_) |
590 base::i18n::SetICUDefaultLocale("he"); | 609 base::i18n::SetICUDefaultLocale("he"); |
591 CheckTextDirectionIsCorrect(); | 610 CheckTextDirectionIsCorrect(); |
592 } | 611 } |
593 | 612 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 738 |
720 last_added = AddAppShortcut(); | 739 last_added = AddAppShortcut(); |
721 ++items_added; | 740 ++items_added; |
722 ASSERT_LT(items_added, 10000); | 741 ASSERT_LT(items_added, 10000); |
723 } | 742 } |
724 | 743 |
725 // And the platform app button is invisible. | 744 // And the platform app button is invisible. |
726 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); | 745 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); |
727 } | 746 } |
728 | 747 |
| 748 TEST_F(ShelfViewLegacyShelfLayoutTest, |
| 749 AddAppShortcutWithBrowserButtonUntilOverflow) { |
| 750 // All buttons should be visible. |
| 751 ASSERT_EQ(test_api_->GetButtonCount(), |
| 752 test_api_->GetLastVisibleIndex() + 1); |
| 753 |
| 754 |
| 755 ShelfID browser_button_id = AddPlatformApp(); |
| 756 |
| 757 // Add app shortcut until overflow. |
| 758 int items_added = 0; |
| 759 ShelfID last_added = AddAppShortcut(); |
| 760 while (!test_api_->IsOverflowButtonVisible()) { |
| 761 // Added button is visible after animation while in this loop. |
| 762 EXPECT_TRUE(GetButtonByID(last_added)->visible()); |
| 763 |
| 764 last_added = AddAppShortcut(); |
| 765 ++items_added; |
| 766 ASSERT_LT(items_added, 10000); |
| 767 } |
| 768 |
| 769 // The last added app short button should be visible. |
| 770 EXPECT_TRUE(GetButtonByID(last_added)->visible()); |
| 771 // And the platform app button is invisible. |
| 772 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); |
| 773 } |
| 774 |
729 TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { | 775 TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { |
730 // All buttons should be visible. | 776 // All buttons should be visible. |
731 ASSERT_EQ(test_api_->GetButtonCount(), | 777 ASSERT_EQ(test_api_->GetButtonCount(), |
732 test_api_->GetLastVisibleIndex() + 1); | 778 test_api_->GetLastVisibleIndex() + 1); |
733 | 779 |
734 // Add platform app button until overflow, remember last visible platform app | 780 // Add platform app button until overflow, remember last visible platform app |
735 // button. | 781 // button. |
736 int items_added = 0; | 782 int items_added = 0; |
737 ShelfID first_added = AddPlatformApp(); | 783 ShelfID first_added = AddPlatformApp(); |
738 EXPECT_TRUE(GetButtonByID(first_added)->visible()); | 784 EXPECT_TRUE(GetButtonByID(first_added)->visible()); |
739 while (true) { | 785 while (true) { |
740 ShelfID added = AddPlatformApp(); | 786 ShelfID added = AddPlatformApp(); |
741 if (test_api_->IsOverflowButtonVisible()) { | 787 if (test_api_->IsOverflowButtonVisible()) { |
742 EXPECT_FALSE(GetButtonByID(added)->visible()); | 788 EXPECT_FALSE(GetButtonByID(added)->visible()); |
743 RemoveByID(added); | 789 RemoveByID(added); |
744 break; | 790 break; |
745 } | 791 } |
746 ++items_added; | 792 ++items_added; |
747 ASSERT_LT(items_added, 10000); | 793 ASSERT_LT(items_added, 10000); |
748 } | 794 } |
749 | 795 |
750 ShelfID panel = AddPanel(); | 796 ShelfID panel = AddPanel(); |
751 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | 797 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); |
752 | 798 |
753 RemoveByID(panel); | 799 RemoveByID(panel); |
754 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); | 800 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); |
755 } | 801 } |
756 | 802 |
| 803 TEST_F(ShelfViewLegacyShelfLayoutTest, AddPanelHidesPlatformAppButton) { |
| 804 // All buttons should be visible. |
| 805 ASSERT_EQ(test_api_->GetButtonCount(), |
| 806 test_api_->GetLastVisibleIndex() + 1); |
| 807 |
| 808 // Add platform app button until overflow, remember last visible platform app |
| 809 // button. |
| 810 int items_added = 0; |
| 811 ShelfID first_added = AddPlatformApp(); |
| 812 EXPECT_TRUE(GetButtonByID(first_added)->visible()); |
| 813 ShelfID last_visible = first_added; |
| 814 while (true) { |
| 815 ShelfID added = AddPlatformApp(); |
| 816 if (test_api_->IsOverflowButtonVisible()) { |
| 817 EXPECT_FALSE(GetButtonByID(added)->visible()); |
| 818 break; |
| 819 } |
| 820 last_visible = added; |
| 821 ++items_added; |
| 822 ASSERT_LT(items_added, 10000); |
| 823 } |
| 824 |
| 825 ShelfID panel = AddPanel(); |
| 826 EXPECT_TRUE(GetButtonByID(panel)->visible()); |
| 827 EXPECT_FALSE(GetButtonByID(last_visible)->visible()); |
| 828 |
| 829 RemoveByID(panel); |
| 830 EXPECT_TRUE(GetButtonByID(last_visible)->visible()); |
| 831 } |
| 832 |
757 // When there are more panels then platform app buttons we should hide panels | 833 // When there are more panels then platform app buttons we should hide panels |
758 // rather than platform apps. | 834 // rather than platform apps. |
759 TEST_F(ShelfViewTest, PlatformAppHidesExcessPanels) { | 835 TEST_F(ShelfViewTest, PlatformAppHidesExcessPanels) { |
760 // All buttons should be visible. | 836 // All buttons should be visible. |
761 ASSERT_EQ(test_api_->GetButtonCount(), | 837 ASSERT_EQ(test_api_->GetButtonCount(), |
762 test_api_->GetLastVisibleIndex() + 1); | 838 test_api_->GetLastVisibleIndex() + 1); |
763 | 839 |
764 // Add platform app button. | 840 // Add platform app button. |
765 ShelfID platform_app = AddPlatformApp(); | 841 ShelfID platform_app = AddPlatformApp(); |
766 ShelfID first_panel = AddPanel(); | 842 ShelfID first_panel = AddPanel(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 button_host->PointerReleasedOnButton(dragged_button, | 1009 button_host->PointerReleasedOnButton(dragged_button, |
934 internal::ShelfButtonHost::MOUSE, | 1010 internal::ShelfButtonHost::MOUSE, |
935 false); | 1011 false); |
936 | 1012 |
937 // Adding a shelf item at the end (i.e. a panel) canels drag and respects | 1013 // Adding a shelf item at the end (i.e. a panel) canels drag and respects |
938 // the order. | 1014 // the order. |
939 dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 3); | 1015 dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 3); |
940 new_id = AddPanel(); | 1016 new_id = AddPanel(); |
941 id_map.insert(id_map.begin() + 7, | 1017 id_map.insert(id_map.begin() + 7, |
942 std::make_pair(new_id, GetButtonByID(new_id))); | 1018 std::make_pair(new_id, GetButtonByID(new_id))); |
| 1019 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
| 1020 button_host->PointerReleasedOnButton(dragged_button, |
| 1021 internal::ShelfButtonHost::MOUSE, |
| 1022 false); |
| 1023 } |
| 1024 |
| 1025 TEST_F(ShelfViewLegacyShelfLayoutTest, ModelChangesWhileDragging) { |
| 1026 internal::ShelfButtonHost* button_host = shelf_view_; |
| 1027 |
| 1028 std::vector<std::pair<ShelfID, views::View*> > id_map; |
| 1029 SetupForDragTest(&id_map); |
| 1030 |
| 1031 // Dragging browser shortcut at index 0. |
| 1032 EXPECT_TRUE(model_->items()[0].type == TYPE_BROWSER_SHORTCUT); |
| 1033 views::View* dragged_button = SimulateDrag( |
| 1034 internal::ShelfButtonHost::MOUSE, 0, 2); |
| 1035 std::rotate(id_map.begin(), |
| 1036 id_map.begin() + 1, |
| 1037 id_map.begin() + 3); |
| 1038 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
| 1039 button_host->PointerReleasedOnButton(dragged_button, |
| 1040 internal::ShelfButtonHost::MOUSE, |
| 1041 false); |
| 1042 EXPECT_TRUE(model_->items()[2].type == TYPE_BROWSER_SHORTCUT); |
| 1043 |
| 1044 // Dragging changes model order. |
| 1045 dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 0, 2); |
| 1046 std::rotate(id_map.begin(), |
| 1047 id_map.begin() + 1, |
| 1048 id_map.begin() + 3); |
| 1049 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
| 1050 |
| 1051 // Cancelling the drag operation restores previous order. |
| 1052 button_host->PointerReleasedOnButton(dragged_button, |
| 1053 internal::ShelfButtonHost::MOUSE, |
| 1054 true); |
| 1055 std::rotate(id_map.begin(), |
| 1056 id_map.begin() + 2, |
| 1057 id_map.begin() + 3); |
| 1058 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
| 1059 |
| 1060 // Deleting an item keeps the remaining intact. |
| 1061 dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 0, 2); |
| 1062 model_->RemoveItemAt(1); |
| 1063 id_map.erase(id_map.begin() + 1); |
| 1064 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
| 1065 button_host->PointerReleasedOnButton(dragged_button, |
| 1066 internal::ShelfButtonHost::MOUSE, |
| 1067 false); |
| 1068 |
| 1069 // Adding a shelf item cancels the drag and respects the order. |
| 1070 dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 0, 2); |
| 1071 ShelfID new_id = AddAppShortcut(); |
| 1072 id_map.insert(id_map.begin() + 5, |
| 1073 std::make_pair(new_id, GetButtonByID(new_id))); |
| 1074 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
| 1075 button_host->PointerReleasedOnButton(dragged_button, |
| 1076 internal::ShelfButtonHost::MOUSE, |
| 1077 false); |
| 1078 |
| 1079 // Adding a shelf item at the end (i.e. a panel) canels drag and respects |
| 1080 // the order. |
| 1081 dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 0, 2); |
| 1082 new_id = AddPanel(); |
| 1083 id_map.insert(id_map.begin() + 7, |
| 1084 std::make_pair(new_id, GetButtonByID(new_id))); |
943 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1085 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
944 button_host->PointerReleasedOnButton(dragged_button, | 1086 button_host->PointerReleasedOnButton(dragged_button, |
945 internal::ShelfButtonHost::MOUSE, | 1087 internal::ShelfButtonHost::MOUSE, |
946 false); | 1088 false); |
947 } | 1089 } |
948 | 1090 |
949 // Check that 2nd drag from the other pointer would be ignored. | 1091 // Check that 2nd drag from the other pointer would be ignored. |
950 TEST_F(ShelfViewTest, SimultaneousDrag) { | 1092 TEST_F(ShelfViewTest, SimultaneousDrag) { |
951 internal::ShelfButtonHost* button_host = shelf_view_; | 1093 internal::ShelfButtonHost* button_host = shelf_view_; |
952 | 1094 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 internal::ShelfButton* button = GetButtonByID(last_added); | 1172 internal::ShelfButton* button = GetButtonByID(last_added); |
1031 ASSERT_EQ(internal::ShelfButton::STATE_RUNNING, button->state()); | 1173 ASSERT_EQ(internal::ShelfButton::STATE_RUNNING, button->state()); |
1032 item.status = STATUS_ACTIVE; | 1174 item.status = STATUS_ACTIVE; |
1033 model_->Set(index, item); | 1175 model_->Set(index, item); |
1034 ASSERT_EQ(internal::ShelfButton::STATE_ACTIVE, button->state()); | 1176 ASSERT_EQ(internal::ShelfButton::STATE_ACTIVE, button->state()); |
1035 item.status = STATUS_ATTENTION; | 1177 item.status = STATUS_ATTENTION; |
1036 model_->Set(index, item); | 1178 model_->Set(index, item); |
1037 ASSERT_EQ(internal::ShelfButton::STATE_ATTENTION, button->state()); | 1179 ASSERT_EQ(internal::ShelfButton::STATE_ATTENTION, button->state()); |
1038 } | 1180 } |
1039 | 1181 |
| 1182 TEST_F(ShelfViewLegacyShelfLayoutTest, |
| 1183 ShelfItemPositionReflectedOnStateChanged) { |
| 1184 // All buttons should be visible. |
| 1185 ASSERT_EQ(test_api_->GetButtonCount(), |
| 1186 test_api_->GetLastVisibleIndex() + 1); |
| 1187 |
| 1188 // Add 2 items to the shelf. |
| 1189 ShelfID item1_id = AddPlatformApp(); |
| 1190 ShelfID item2_id = AddPlatformAppNoWait(); |
| 1191 internal::ShelfButton* item1_button = GetButtonByID(item1_id); |
| 1192 internal::ShelfButton* item2_button = GetButtonByID(item2_id); |
| 1193 |
| 1194 internal::ShelfButton::State state_mask = |
| 1195 static_cast<internal::ShelfButton::State>( |
| 1196 internal::ShelfButton::STATE_NORMAL | |
| 1197 internal::ShelfButton::STATE_HOVERED | |
| 1198 internal::ShelfButton::STATE_RUNNING | |
| 1199 internal::ShelfButton::STATE_ACTIVE | |
| 1200 internal::ShelfButton::STATE_ATTENTION | |
| 1201 internal::ShelfButton::STATE_FOCUSED); |
| 1202 |
| 1203 // Clear the button states. |
| 1204 item1_button->ClearState(state_mask); |
| 1205 item2_button->ClearState(state_mask); |
| 1206 |
| 1207 // Since default alignment in tests is bottom, state is reflected in y-axis. |
| 1208 ASSERT_EQ(item1_button->GetIconBounds().y(), |
| 1209 item2_button->GetIconBounds().y()); |
| 1210 item1_button->AddState(internal::ShelfButton::STATE_HOVERED); |
| 1211 ASSERT_NE(item1_button->GetIconBounds().y(), |
| 1212 item2_button->GetIconBounds().y()); |
| 1213 item1_button->ClearState(internal::ShelfButton::STATE_HOVERED); |
| 1214 } |
| 1215 |
1040 // Confirm that item status changes are reflected in the buttons | 1216 // Confirm that item status changes are reflected in the buttons |
1041 // for platform apps. | 1217 // for platform apps. |
1042 TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { | 1218 TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { |
1043 // All buttons should be visible. | 1219 // All buttons should be visible. |
1044 ASSERT_EQ(test_api_->GetButtonCount(), | 1220 ASSERT_EQ(test_api_->GetButtonCount(), |
1045 test_api_->GetLastVisibleIndex() + 1); | 1221 test_api_->GetLastVisibleIndex() + 1); |
1046 | 1222 |
1047 // Add platform app button. | 1223 // Add platform app button. |
1048 ShelfID last_added = AddPlatformApp(); | 1224 ShelfID last_added = AddPlatformApp(); |
1049 ShelfItem item = GetItemByID(last_added); | 1225 ShelfItem item = GetItemByID(last_added); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 AddPlatformAppNoWait(); | 1467 AddPlatformAppNoWait(); |
1292 while (!test_api_->IsOverflowButtonVisible()) { | 1468 while (!test_api_->IsOverflowButtonVisible()) { |
1293 test_api_->RunMessageLoopUntilAnimationsDone(); | 1469 test_api_->RunMessageLoopUntilAnimationsDone(); |
1294 AddPlatformAppNoWait(); | 1470 AddPlatformAppNoWait(); |
1295 ++items_added; | 1471 ++items_added; |
1296 ASSERT_LT(items_added, 10000); | 1472 ASSERT_LT(items_added, 10000); |
1297 } | 1473 } |
1298 | 1474 |
1299 // Resize shelf view with that animation running and stay overflown. | 1475 // Resize shelf view with that animation running and stay overflown. |
1300 gfx::Rect bounds = shelf_view_->bounds(); | 1476 gfx::Rect bounds = shelf_view_->bounds(); |
1301 bounds.set_width(bounds.width() - kShelfSize); | 1477 bounds.set_width(bounds.width() - kShelfPreferredSize); |
1302 shelf_view_->SetBoundsRect(bounds); | 1478 shelf_view_->SetBoundsRect(bounds); |
1303 ASSERT_TRUE(test_api_->IsOverflowButtonVisible()); | 1479 ASSERT_TRUE(test_api_->IsOverflowButtonVisible()); |
1304 | 1480 |
1305 // Finish the animation. | 1481 // Finish the animation. |
1306 test_api_->RunMessageLoopUntilAnimationsDone(); | 1482 test_api_->RunMessageLoopUntilAnimationsDone(); |
1307 | 1483 |
1308 // App list button should ends up in its new ideal bounds. | 1484 // App list button should ends up in its new ideal bounds. |
1309 const int app_list_button_index = test_api_->GetButtonCount() - 1; | 1485 const int app_list_button_index = test_api_->GetButtonCount() - 1; |
1310 const gfx::Rect& app_list_ideal_bounds = | 1486 const gfx::Rect& app_list_ideal_bounds = |
1311 test_api_->GetIdealBoundsByIndex(app_list_button_index); | 1487 test_api_->GetIdealBoundsByIndex(app_list_button_index); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); | 1540 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); |
1365 EXPECT_EQ(bubble_size.width(), | 1541 EXPECT_EQ(bubble_size.width(), |
1366 test_for_overflow_view.GetPreferredSize().width()); | 1542 test_for_overflow_view.GetPreferredSize().width()); |
1367 | 1543 |
1368 generator.ReleaseLeftButton(); | 1544 generator.ReleaseLeftButton(); |
1369 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); | 1545 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); |
1370 EXPECT_EQ(bubble_size.width(), | 1546 EXPECT_EQ(bubble_size.width(), |
1371 test_for_overflow_view.GetPreferredSize().width()); | 1547 test_for_overflow_view.GetPreferredSize().width()); |
1372 } | 1548 } |
1373 | 1549 |
| 1550 // Check that the first item in the list follows Fitt's law by including the |
| 1551 // first pixel and being therefore bigger then the others. |
| 1552 TEST_F(ShelfViewLegacyShelfLayoutTest, CheckFittsLaw) { |
| 1553 // All buttons should be visible. |
| 1554 ASSERT_EQ(test_api_->GetButtonCount(), |
| 1555 test_api_->GetLastVisibleIndex() + 1); |
| 1556 gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); |
| 1557 gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); |
| 1558 EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); |
| 1559 } |
| 1560 |
1374 // Check the drag insertion bounds of scrolled overflow bubble. | 1561 // Check the drag insertion bounds of scrolled overflow bubble. |
1375 TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) { | 1562 TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) { |
1376 UpdateDisplay("400x300"); | 1563 UpdateDisplay("400x300"); |
1377 | 1564 |
1378 EXPECT_EQ(2, model_->item_count()); | 1565 EXPECT_EQ(2, model_->item_count()); |
1379 | 1566 |
1380 AddButtonsUntilOverflow(); | 1567 AddButtonsUntilOverflow(); |
1381 | 1568 |
1382 // Show overflow bubble. | 1569 // Show overflow bubble. |
1383 test_api_->ShowOverflowBubble(); | 1570 test_api_->ShowOverflowBubble(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 // win8-aura doesn't support multiple display. | 1617 // win8-aura doesn't support multiple display. |
1431 if (!SupportsMultipleDisplays()) | 1618 if (!SupportsMultipleDisplays()) |
1432 return; | 1619 return; |
1433 | 1620 |
1434 UpdateDisplay("800x600,800x600"); | 1621 UpdateDisplay("800x600,800x600"); |
1435 Shelf* secondary_shelf = Shelf::ForWindow(Shell::GetAllRootWindows()[1]); | 1622 Shelf* secondary_shelf = Shelf::ForWindow(Shell::GetAllRootWindows()[1]); |
1436 internal::ShelfView* shelf_view_for_secondary = | 1623 internal::ShelfView* shelf_view_for_secondary = |
1437 ShelfTestAPI(secondary_shelf).shelf_view(); | 1624 ShelfTestAPI(secondary_shelf).shelf_view(); |
1438 | 1625 |
1439 // The bounds should be big enough for 4 buttons + overflow chevron. | 1626 // The bounds should be big enough for 4 buttons + overflow chevron. |
1440 shelf_view_for_secondary->SetBounds(0, 0, 500, kShelfSize); | 1627 shelf_view_for_secondary->SetBounds(0, 0, 500, |
| 1628 internal::ShelfLayoutManager::GetPreferredShelfSize()); |
1441 | 1629 |
1442 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); | 1630 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); |
1443 // Speeds up animation for test. | 1631 // Speeds up animation for test. |
1444 test_api_for_secondary.SetAnimationDuration(1); | 1632 test_api_for_secondary.SetAnimationDuration(1); |
1445 | 1633 |
1446 AddButtonsUntilOverflow(); | 1634 AddButtonsUntilOverflow(); |
1447 | 1635 |
1448 // Test #1: Test drag insertion bounds of primary shelf. | 1636 // Test #1: Test drag insertion bounds of primary shelf. |
1449 // Show overflow bubble. | 1637 // Show overflow bubble. |
1450 test_api_->ShowOverflowBubble(); | 1638 test_api_->ShowOverflowBubble(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 test_api_->RunMessageLoopUntilAnimationsDone(); | 1777 test_api_->RunMessageLoopUntilAnimationsDone(); |
1590 CheckAllItemsAreInBounds(); | 1778 CheckAllItemsAreInBounds(); |
1591 } | 1779 } |
1592 | 1780 |
1593 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1781 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
1594 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 1782 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, |
1595 testing::Bool()); | 1783 testing::Bool()); |
1596 | 1784 |
1597 } // namespace test | 1785 } // namespace test |
1598 } // namespace ash | 1786 } // namespace ash |
OLD | NEW |