| 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, | 273 shelf_view_->SetBounds(0, 0, 500, kShelfSize); |
| 274 internal::ShelfLayoutManager::GetPreferredShelfSize()); | |
| 275 | 274 |
| 276 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); | 275 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); |
| 277 test_api_->SetAnimationDuration(1); // Speeds up animation for test. | 276 test_api_->SetAnimationDuration(1); // Speeds up animation for test. |
| 278 | 277 |
| 279 item_manager_ = Shell::GetInstance()->shelf_item_delegate_manager(); | 278 item_manager_ = Shell::GetInstance()->shelf_item_delegate_manager(); |
| 280 DCHECK(item_manager_); | 279 DCHECK(item_manager_); |
| 281 | 280 |
| 282 // Add browser shortcut shelf item at index 0 for test. | 281 // Add browser shortcut shelf item at index 0 for test. |
| 283 AddBrowserShortcut(); | 282 AddBrowserShortcut(); |
| 284 } | 283 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 internal::ShelfView* shelf_view_; | 574 internal::ShelfView* shelf_view_; |
| 576 int browser_index_; | 575 int browser_index_; |
| 577 ShelfItemDelegateManager* item_manager_; | 576 ShelfItemDelegateManager* item_manager_; |
| 578 | 577 |
| 579 scoped_ptr<ShelfViewTestAPI> test_api_; | 578 scoped_ptr<ShelfViewTestAPI> test_api_; |
| 580 | 579 |
| 581 private: | 580 private: |
| 582 DISALLOW_COPY_AND_ASSIGN(ShelfViewTest); | 581 DISALLOW_COPY_AND_ASSIGN(ShelfViewTest); |
| 583 }; | 582 }; |
| 584 | 583 |
| 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 | |
| 603 class ScopedTextDirectionChange { | 584 class ScopedTextDirectionChange { |
| 604 public: | 585 public: |
| 605 ScopedTextDirectionChange(bool is_rtl) | 586 ScopedTextDirectionChange(bool is_rtl) |
| 606 : is_rtl_(is_rtl) { | 587 : is_rtl_(is_rtl) { |
| 607 original_locale_ = l10n_util::GetApplicationLocale(std::string()); | 588 original_locale_ = l10n_util::GetApplicationLocale(std::string()); |
| 608 if (is_rtl_) | 589 if (is_rtl_) |
| 609 base::i18n::SetICUDefaultLocale("he"); | 590 base::i18n::SetICUDefaultLocale("he"); |
| 610 CheckTextDirectionIsCorrect(); | 591 CheckTextDirectionIsCorrect(); |
| 611 } | 592 } |
| 612 | 593 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 | 719 |
| 739 last_added = AddAppShortcut(); | 720 last_added = AddAppShortcut(); |
| 740 ++items_added; | 721 ++items_added; |
| 741 ASSERT_LT(items_added, 10000); | 722 ASSERT_LT(items_added, 10000); |
| 742 } | 723 } |
| 743 | 724 |
| 744 // And the platform app button is invisible. | 725 // And the platform app button is invisible. |
| 745 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); | 726 EXPECT_FALSE(GetButtonByID(browser_button_id)->visible()); |
| 746 } | 727 } |
| 747 | 728 |
| 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 | |
| 775 TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { | 729 TEST_F(ShelfViewTest, AddPanelHidesPlatformAppButton) { |
| 776 // All buttons should be visible. | 730 // All buttons should be visible. |
| 777 ASSERT_EQ(test_api_->GetButtonCount(), | 731 ASSERT_EQ(test_api_->GetButtonCount(), |
| 778 test_api_->GetLastVisibleIndex() + 1); | 732 test_api_->GetLastVisibleIndex() + 1); |
| 779 | 733 |
| 780 // Add platform app button until overflow, remember last visible platform app | 734 // Add platform app button until overflow, remember last visible platform app |
| 781 // button. | 735 // button. |
| 782 int items_added = 0; | 736 int items_added = 0; |
| 783 ShelfID first_added = AddPlatformApp(); | 737 ShelfID first_added = AddPlatformApp(); |
| 784 EXPECT_TRUE(GetButtonByID(first_added)->visible()); | 738 EXPECT_TRUE(GetButtonByID(first_added)->visible()); |
| 785 while (true) { | 739 while (true) { |
| 786 ShelfID added = AddPlatformApp(); | 740 ShelfID added = AddPlatformApp(); |
| 787 if (test_api_->IsOverflowButtonVisible()) { | 741 if (test_api_->IsOverflowButtonVisible()) { |
| 788 EXPECT_FALSE(GetButtonByID(added)->visible()); | 742 EXPECT_FALSE(GetButtonByID(added)->visible()); |
| 789 RemoveByID(added); | 743 RemoveByID(added); |
| 790 break; | 744 break; |
| 791 } | 745 } |
| 792 ++items_added; | 746 ++items_added; |
| 793 ASSERT_LT(items_added, 10000); | 747 ASSERT_LT(items_added, 10000); |
| 794 } | 748 } |
| 795 | 749 |
| 796 ShelfID panel = AddPanel(); | 750 ShelfID panel = AddPanel(); |
| 797 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | 751 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); |
| 798 | 752 |
| 799 RemoveByID(panel); | 753 RemoveByID(panel); |
| 800 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); | 754 EXPECT_FALSE(test_api_->IsOverflowButtonVisible()); |
| 801 } | 755 } |
| 802 | 756 |
| 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 | |
| 833 // When there are more panels then platform app buttons we should hide panels | 757 // When there are more panels then platform app buttons we should hide panels |
| 834 // rather than platform apps. | 758 // rather than platform apps. |
| 835 TEST_F(ShelfViewTest, PlatformAppHidesExcessPanels) { | 759 TEST_F(ShelfViewTest, PlatformAppHidesExcessPanels) { |
| 836 // All buttons should be visible. | 760 // All buttons should be visible. |
| 837 ASSERT_EQ(test_api_->GetButtonCount(), | 761 ASSERT_EQ(test_api_->GetButtonCount(), |
| 838 test_api_->GetLastVisibleIndex() + 1); | 762 test_api_->GetLastVisibleIndex() + 1); |
| 839 | 763 |
| 840 // Add platform app button. | 764 // Add platform app button. |
| 841 ShelfID platform_app = AddPlatformApp(); | 765 ShelfID platform_app = AddPlatformApp(); |
| 842 ShelfID first_panel = AddPanel(); | 766 ShelfID first_panel = AddPanel(); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 3); | 939 dragged_button = SimulateDrag(internal::ShelfButtonHost::MOUSE, 1, 3); |
| 1016 new_id = AddPanel(); | 940 new_id = AddPanel(); |
| 1017 id_map.insert(id_map.begin() + 7, | 941 id_map.insert(id_map.begin() + 7, |
| 1018 std::make_pair(new_id, GetButtonByID(new_id))); | 942 std::make_pair(new_id, GetButtonByID(new_id))); |
| 1019 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 943 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
| 1020 button_host->PointerReleasedOnButton(dragged_button, | 944 button_host->PointerReleasedOnButton(dragged_button, |
| 1021 internal::ShelfButtonHost::MOUSE, | 945 internal::ShelfButtonHost::MOUSE, |
| 1022 false); | 946 false); |
| 1023 } | 947 } |
| 1024 | 948 |
| 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))); | |
| 1085 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | |
| 1086 button_host->PointerReleasedOnButton(dragged_button, | |
| 1087 internal::ShelfButtonHost::MOUSE, | |
| 1088 false); | |
| 1089 } | |
| 1090 | |
| 1091 // Check that 2nd drag from the other pointer would be ignored. | 949 // Check that 2nd drag from the other pointer would be ignored. |
| 1092 TEST_F(ShelfViewTest, SimultaneousDrag) { | 950 TEST_F(ShelfViewTest, SimultaneousDrag) { |
| 1093 internal::ShelfButtonHost* button_host = shelf_view_; | 951 internal::ShelfButtonHost* button_host = shelf_view_; |
| 1094 | 952 |
| 1095 std::vector<std::pair<ShelfID, views::View*> > id_map; | 953 std::vector<std::pair<ShelfID, views::View*> > id_map; |
| 1096 SetupForDragTest(&id_map); | 954 SetupForDragTest(&id_map); |
| 1097 | 955 |
| 1098 // Start a mouse drag. | 956 // Start a mouse drag. |
| 1099 views::View* dragged_button_mouse = SimulateDrag( | 957 views::View* dragged_button_mouse = SimulateDrag( |
| 1100 internal::ShelfButtonHost::MOUSE, 1, 3); | 958 internal::ShelfButtonHost::MOUSE, 1, 3); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 internal::ShelfButton* button = GetButtonByID(last_added); | 1030 internal::ShelfButton* button = GetButtonByID(last_added); |
| 1173 ASSERT_EQ(internal::ShelfButton::STATE_RUNNING, button->state()); | 1031 ASSERT_EQ(internal::ShelfButton::STATE_RUNNING, button->state()); |
| 1174 item.status = STATUS_ACTIVE; | 1032 item.status = STATUS_ACTIVE; |
| 1175 model_->Set(index, item); | 1033 model_->Set(index, item); |
| 1176 ASSERT_EQ(internal::ShelfButton::STATE_ACTIVE, button->state()); | 1034 ASSERT_EQ(internal::ShelfButton::STATE_ACTIVE, button->state()); |
| 1177 item.status = STATUS_ATTENTION; | 1035 item.status = STATUS_ATTENTION; |
| 1178 model_->Set(index, item); | 1036 model_->Set(index, item); |
| 1179 ASSERT_EQ(internal::ShelfButton::STATE_ATTENTION, button->state()); | 1037 ASSERT_EQ(internal::ShelfButton::STATE_ATTENTION, button->state()); |
| 1180 } | 1038 } |
| 1181 | 1039 |
| 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 | |
| 1216 // Confirm that item status changes are reflected in the buttons | 1040 // Confirm that item status changes are reflected in the buttons |
| 1217 // for platform apps. | 1041 // for platform apps. |
| 1218 TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { | 1042 TEST_F(ShelfViewTest, ShelfItemStatusPlatformApp) { |
| 1219 // All buttons should be visible. | 1043 // All buttons should be visible. |
| 1220 ASSERT_EQ(test_api_->GetButtonCount(), | 1044 ASSERT_EQ(test_api_->GetButtonCount(), |
| 1221 test_api_->GetLastVisibleIndex() + 1); | 1045 test_api_->GetLastVisibleIndex() + 1); |
| 1222 | 1046 |
| 1223 // Add platform app button. | 1047 // Add platform app button. |
| 1224 ShelfID last_added = AddPlatformApp(); | 1048 ShelfID last_added = AddPlatformApp(); |
| 1225 ShelfItem item = GetItemByID(last_added); | 1049 ShelfItem item = GetItemByID(last_added); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 AddPlatformAppNoWait(); | 1291 AddPlatformAppNoWait(); |
| 1468 while (!test_api_->IsOverflowButtonVisible()) { | 1292 while (!test_api_->IsOverflowButtonVisible()) { |
| 1469 test_api_->RunMessageLoopUntilAnimationsDone(); | 1293 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1470 AddPlatformAppNoWait(); | 1294 AddPlatformAppNoWait(); |
| 1471 ++items_added; | 1295 ++items_added; |
| 1472 ASSERT_LT(items_added, 10000); | 1296 ASSERT_LT(items_added, 10000); |
| 1473 } | 1297 } |
| 1474 | 1298 |
| 1475 // Resize shelf view with that animation running and stay overflown. | 1299 // Resize shelf view with that animation running and stay overflown. |
| 1476 gfx::Rect bounds = shelf_view_->bounds(); | 1300 gfx::Rect bounds = shelf_view_->bounds(); |
| 1477 bounds.set_width(bounds.width() - kShelfPreferredSize); | 1301 bounds.set_width(bounds.width() - kShelfSize); |
| 1478 shelf_view_->SetBoundsRect(bounds); | 1302 shelf_view_->SetBoundsRect(bounds); |
| 1479 ASSERT_TRUE(test_api_->IsOverflowButtonVisible()); | 1303 ASSERT_TRUE(test_api_->IsOverflowButtonVisible()); |
| 1480 | 1304 |
| 1481 // Finish the animation. | 1305 // Finish the animation. |
| 1482 test_api_->RunMessageLoopUntilAnimationsDone(); | 1306 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1483 | 1307 |
| 1484 // App list button should ends up in its new ideal bounds. | 1308 // App list button should ends up in its new ideal bounds. |
| 1485 const int app_list_button_index = test_api_->GetButtonCount() - 1; | 1309 const int app_list_button_index = test_api_->GetButtonCount() - 1; |
| 1486 const gfx::Rect& app_list_ideal_bounds = | 1310 const gfx::Rect& app_list_ideal_bounds = |
| 1487 test_api_->GetIdealBoundsByIndex(app_list_button_index); | 1311 test_api_->GetIdealBoundsByIndex(app_list_button_index); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); | 1364 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); |
| 1541 EXPECT_EQ(bubble_size.width(), | 1365 EXPECT_EQ(bubble_size.width(), |
| 1542 test_for_overflow_view.GetPreferredSize().width()); | 1366 test_for_overflow_view.GetPreferredSize().width()); |
| 1543 | 1367 |
| 1544 generator.ReleaseLeftButton(); | 1368 generator.ReleaseLeftButton(); |
| 1545 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); | 1369 test_for_overflow_view.RunMessageLoopUntilAnimationsDone(); |
| 1546 EXPECT_EQ(bubble_size.width(), | 1370 EXPECT_EQ(bubble_size.width(), |
| 1547 test_for_overflow_view.GetPreferredSize().width()); | 1371 test_for_overflow_view.GetPreferredSize().width()); |
| 1548 } | 1372 } |
| 1549 | 1373 |
| 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 | |
| 1561 // Check the drag insertion bounds of scrolled overflow bubble. | 1374 // Check the drag insertion bounds of scrolled overflow bubble. |
| 1562 TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) { | 1375 TEST_F(ShelfViewTest, CheckDragInsertBoundsOfScrolledOverflowBubble) { |
| 1563 UpdateDisplay("400x300"); | 1376 UpdateDisplay("400x300"); |
| 1564 | 1377 |
| 1565 EXPECT_EQ(2, model_->item_count()); | 1378 EXPECT_EQ(2, model_->item_count()); |
| 1566 | 1379 |
| 1567 AddButtonsUntilOverflow(); | 1380 AddButtonsUntilOverflow(); |
| 1568 | 1381 |
| 1569 // Show overflow bubble. | 1382 // Show overflow bubble. |
| 1570 test_api_->ShowOverflowBubble(); | 1383 test_api_->ShowOverflowBubble(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 // win8-aura doesn't support multiple display. | 1430 // win8-aura doesn't support multiple display. |
| 1618 if (!SupportsMultipleDisplays()) | 1431 if (!SupportsMultipleDisplays()) |
| 1619 return; | 1432 return; |
| 1620 | 1433 |
| 1621 UpdateDisplay("800x600,800x600"); | 1434 UpdateDisplay("800x600,800x600"); |
| 1622 Shelf* secondary_shelf = Shelf::ForWindow(Shell::GetAllRootWindows()[1]); | 1435 Shelf* secondary_shelf = Shelf::ForWindow(Shell::GetAllRootWindows()[1]); |
| 1623 internal::ShelfView* shelf_view_for_secondary = | 1436 internal::ShelfView* shelf_view_for_secondary = |
| 1624 ShelfTestAPI(secondary_shelf).shelf_view(); | 1437 ShelfTestAPI(secondary_shelf).shelf_view(); |
| 1625 | 1438 |
| 1626 // The bounds should be big enough for 4 buttons + overflow chevron. | 1439 // The bounds should be big enough for 4 buttons + overflow chevron. |
| 1627 shelf_view_for_secondary->SetBounds(0, 0, 500, | 1440 shelf_view_for_secondary->SetBounds(0, 0, 500, kShelfSize); |
| 1628 internal::ShelfLayoutManager::GetPreferredShelfSize()); | |
| 1629 | 1441 |
| 1630 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); | 1442 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); |
| 1631 // Speeds up animation for test. | 1443 // Speeds up animation for test. |
| 1632 test_api_for_secondary.SetAnimationDuration(1); | 1444 test_api_for_secondary.SetAnimationDuration(1); |
| 1633 | 1445 |
| 1634 AddButtonsUntilOverflow(); | 1446 AddButtonsUntilOverflow(); |
| 1635 | 1447 |
| 1636 // Test #1: Test drag insertion bounds of primary shelf. | 1448 // Test #1: Test drag insertion bounds of primary shelf. |
| 1637 // Show overflow bubble. | 1449 // Show overflow bubble. |
| 1638 test_api_->ShowOverflowBubble(); | 1450 test_api_->ShowOverflowBubble(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 test_api_->RunMessageLoopUntilAnimationsDone(); | 1589 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1778 CheckAllItemsAreInBounds(); | 1590 CheckAllItemsAreInBounds(); |
| 1779 } | 1591 } |
| 1780 | 1592 |
| 1781 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1593 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
| 1782 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 1594 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, |
| 1783 testing::Bool()); | 1595 testing::Bool()); |
| 1784 | 1596 |
| 1785 } // namespace test | 1597 } // namespace test |
| 1786 } // namespace ash | 1598 } // namespace ash |
| OLD | NEW |