| 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 <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/public/cpp/config.h" | 12 #include "ash/public/cpp/config.h" |
| 13 #include "ash/public/cpp/shelf_item_delegate.h" | 13 #include "ash/public/cpp/shelf_item_delegate.h" |
| 14 #include "ash/public/cpp/shell_window_ids.h" | 14 #include "ash/public/cpp/shell_window_ids.h" |
| 15 #include "ash/root_window_controller.h" | 15 #include "ash/root_window_controller.h" |
| 16 #include "ash/shelf/app_list_button.h" | 16 #include "ash/shelf/app_list_button.h" |
| 17 #include "ash/shelf/overflow_bubble.h" | 17 #include "ash/shelf/overflow_bubble.h" |
| 18 #include "ash/shelf/overflow_bubble_view.h" | 18 #include "ash/shelf/overflow_bubble_view.h" |
| 19 #include "ash/shelf/overflow_button.h" | 19 #include "ash/shelf/overflow_button.h" |
| 20 #include "ash/shelf/shelf.h" |
| 20 #include "ash/shelf/shelf_button.h" | 21 #include "ash/shelf/shelf_button.h" |
| 21 #include "ash/shelf/shelf_constants.h" | 22 #include "ash/shelf/shelf_constants.h" |
| 22 #include "ash/shelf/shelf_model.h" | 23 #include "ash/shelf/shelf_model.h" |
| 24 #include "ash/shelf/shelf_observer.h" |
| 23 #include "ash/shelf/shelf_tooltip_manager.h" | 25 #include "ash/shelf/shelf_tooltip_manager.h" |
| 24 #include "ash/shelf/shelf_widget.h" | 26 #include "ash/shelf/shelf_widget.h" |
| 25 #include "ash/shelf/wm_shelf.h" | |
| 26 #include "ash/shelf/wm_shelf_observer.h" | |
| 27 #include "ash/shell.h" | 27 #include "ash/shell.h" |
| 28 #include "ash/shell_port.h" | 28 #include "ash/shell_port.h" |
| 29 #include "ash/system/web_notification/web_notification_tray.h" | 29 #include "ash/system/web_notification/web_notification_tray.h" |
| 30 #include "ash/test/ash_test_base.h" | 30 #include "ash/test/ash_test_base.h" |
| 31 #include "ash/test/ash_test_helper.h" | 31 #include "ash/test/ash_test_helper.h" |
| 32 #include "ash/test/overflow_bubble_view_test_api.h" | 32 #include "ash/test/overflow_bubble_view_test_api.h" |
| 33 #include "ash/test/overflow_button_test_api.h" | 33 #include "ash/test/overflow_button_test_api.h" |
| 34 #include "ash/test/shelf_view_test_api.h" | 34 #include "ash/test/shelf_view_test_api.h" |
| 35 #include "ash/test/shell_test_api.h" | 35 #include "ash/test/shell_test_api.h" |
| 36 #include "ash/test/test_shell_delegate.h" | 36 #include "ash/test/test_shell_delegate.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 namespace test { | 78 namespace test { |
| 79 namespace { | 79 namespace { |
| 80 | 80 |
| 81 int64_t GetPrimaryDisplayId() { | 81 int64_t GetPrimaryDisplayId() { |
| 82 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 82 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 //////////////////////////////////////////////////////////////////////////////// | 87 //////////////////////////////////////////////////////////////////////////////// |
| 88 // WmShelfObserver::OnShelfIconPositionsChanged tests. | 88 // ShelfObserver::OnShelfIconPositionsChanged tests. |
| 89 | 89 |
| 90 class TestWmShelfObserver : public WmShelfObserver { | 90 class TestShelfObserver : public ShelfObserver { |
| 91 public: | 91 public: |
| 92 explicit TestWmShelfObserver(WmShelf* shelf) : shelf_(shelf) { | 92 explicit TestShelfObserver(Shelf* shelf) : shelf_(shelf) { |
| 93 shelf_->AddObserver(this); | 93 shelf_->AddObserver(this); |
| 94 } | 94 } |
| 95 | 95 |
| 96 ~TestWmShelfObserver() override { shelf_->RemoveObserver(this); } | 96 ~TestShelfObserver() override { shelf_->RemoveObserver(this); } |
| 97 | 97 |
| 98 // WmShelfObserver implementation. | 98 // ShelfObserver implementation. |
| 99 void OnShelfIconPositionsChanged() override { | 99 void OnShelfIconPositionsChanged() override { |
| 100 icon_positions_changed_ = true; | 100 icon_positions_changed_ = true; |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool icon_positions_changed() const { return icon_positions_changed_; } | 103 bool icon_positions_changed() const { return icon_positions_changed_; } |
| 104 void Reset() { icon_positions_changed_ = false; } | 104 void Reset() { icon_positions_changed_ = false; } |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 WmShelf* shelf_; | 107 Shelf* shelf_; |
| 108 bool icon_positions_changed_ = false; | 108 bool icon_positions_changed_ = false; |
| 109 | 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(TestWmShelfObserver); | 110 DISALLOW_COPY_AND_ASSIGN(TestShelfObserver); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 class WmShelfObserverIconTest : public AshTestBase { | 113 class ShelfObserverIconTest : public AshTestBase { |
| 114 public: | 114 public: |
| 115 WmShelfObserverIconTest() {} | 115 ShelfObserverIconTest() {} |
| 116 ~WmShelfObserverIconTest() override {} | 116 ~ShelfObserverIconTest() override {} |
| 117 | 117 |
| 118 void SetUp() override { | 118 void SetUp() override { |
| 119 AshTestBase::SetUp(); | 119 AshTestBase::SetUp(); |
| 120 observer_.reset(new TestWmShelfObserver(GetPrimaryShelf())); | 120 observer_.reset(new TestShelfObserver(GetPrimaryShelf())); |
| 121 shelf_view_test_.reset( | 121 shelf_view_test_.reset( |
| 122 new ShelfViewTestAPI(GetPrimaryShelf()->GetShelfViewForTesting())); | 122 new ShelfViewTestAPI(GetPrimaryShelf()->GetShelfViewForTesting())); |
| 123 shelf_view_test_->SetAnimationDuration(1); | 123 shelf_view_test_->SetAnimationDuration(1); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void TearDown() override { | 126 void TearDown() override { |
| 127 observer_.reset(); | 127 observer_.reset(); |
| 128 AshTestBase::TearDown(); | 128 AshTestBase::TearDown(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 TestWmShelfObserver* observer() { return observer_.get(); } | 131 TestShelfObserver* observer() { return observer_.get(); } |
| 132 | 132 |
| 133 ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); } | 133 ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); } |
| 134 | 134 |
| 135 private: | 135 private: |
| 136 std::unique_ptr<TestWmShelfObserver> observer_; | 136 std::unique_ptr<TestShelfObserver> observer_; |
| 137 std::unique_ptr<ShelfViewTestAPI> shelf_view_test_; | 137 std::unique_ptr<ShelfViewTestAPI> shelf_view_test_; |
| 138 | 138 |
| 139 DISALLOW_COPY_AND_ASSIGN(WmShelfObserverIconTest); | 139 DISALLOW_COPY_AND_ASSIGN(ShelfObserverIconTest); |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 // A ShelfItemDelegate that tracks selections and reports a custom action. | 142 // A ShelfItemDelegate that tracks selections and reports a custom action. |
| 143 class ShelfItemSelectionTracker : public ShelfItemDelegate { | 143 class ShelfItemSelectionTracker : public ShelfItemDelegate { |
| 144 public: | 144 public: |
| 145 ShelfItemSelectionTracker() : ShelfItemDelegate(ShelfID()) {} | 145 ShelfItemSelectionTracker() : ShelfItemDelegate(ShelfID()) {} |
| 146 ~ShelfItemSelectionTracker() override {} | 146 ~ShelfItemSelectionTracker() override {} |
| 147 | 147 |
| 148 size_t item_selected_count() const { return item_selected_count_; } | 148 size_t item_selected_count() const { return item_selected_count_; } |
| 149 void set_item_selected_action(ShelfAction item_selected_action) { | 149 void set_item_selected_action(ShelfAction item_selected_action) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 161 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override {} | 161 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override {} |
| 162 void Close() override {} | 162 void Close() override {} |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 size_t item_selected_count_ = 0; | 165 size_t item_selected_count_ = 0; |
| 166 ShelfAction item_selected_action_ = SHELF_ACTION_NONE; | 166 ShelfAction item_selected_action_ = SHELF_ACTION_NONE; |
| 167 | 167 |
| 168 DISALLOW_COPY_AND_ASSIGN(ShelfItemSelectionTracker); | 168 DISALLOW_COPY_AND_ASSIGN(ShelfItemSelectionTracker); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 TEST_F(WmShelfObserverIconTest, AddRemove) { | 171 TEST_F(ShelfObserverIconTest, AddRemove) { |
| 172 ShelfItem item; | 172 ShelfItem item; |
| 173 item.id = ShelfID("foo"); | 173 item.id = ShelfID("foo"); |
| 174 item.type = TYPE_APP; | 174 item.type = TYPE_APP; |
| 175 EXPECT_FALSE(observer()->icon_positions_changed()); | 175 EXPECT_FALSE(observer()->icon_positions_changed()); |
| 176 const int shelf_item_index = Shell::Get()->shelf_model()->Add(item); | 176 const int shelf_item_index = Shell::Get()->shelf_model()->Add(item); |
| 177 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 177 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 178 EXPECT_TRUE(observer()->icon_positions_changed()); | 178 EXPECT_TRUE(observer()->icon_positions_changed()); |
| 179 observer()->Reset(); | 179 observer()->Reset(); |
| 180 | 180 |
| 181 EXPECT_FALSE(observer()->icon_positions_changed()); | 181 EXPECT_FALSE(observer()->icon_positions_changed()); |
| 182 Shell::Get()->shelf_model()->RemoveItemAt(shelf_item_index); | 182 Shell::Get()->shelf_model()->RemoveItemAt(shelf_item_index); |
| 183 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 183 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 184 EXPECT_TRUE(observer()->icon_positions_changed()); | 184 EXPECT_TRUE(observer()->icon_positions_changed()); |
| 185 observer()->Reset(); | 185 observer()->Reset(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Make sure creating/deleting an window on one displays notifies a | 188 // Make sure creating/deleting an window on one displays notifies a |
| 189 // shelf on external display as well as one on primary. | 189 // shelf on external display as well as one on primary. |
| 190 TEST_F(WmShelfObserverIconTest, AddRemoveWithMultipleDisplays) { | 190 TEST_F(ShelfObserverIconTest, AddRemoveWithMultipleDisplays) { |
| 191 // TODO: investigate failure in mash, http://crbug.com/695751. | 191 // TODO: investigate failure in mash, http://crbug.com/695751. |
| 192 if (Shell::GetAshConfig() == Config::MASH) | 192 if (Shell::GetAshConfig() == Config::MASH) |
| 193 return; | 193 return; |
| 194 | 194 |
| 195 UpdateDisplay("400x400,400x400"); | 195 UpdateDisplay("400x400,400x400"); |
| 196 observer()->Reset(); | 196 observer()->Reset(); |
| 197 | 197 |
| 198 WmShelf* second_shelf = WmShelf::ForWindow(Shell::GetAllRootWindows()[1]); | 198 Shelf* second_shelf = Shelf::ForWindow(Shell::GetAllRootWindows()[1]); |
| 199 TestWmShelfObserver second_observer(second_shelf); | 199 TestShelfObserver second_observer(second_shelf); |
| 200 | 200 |
| 201 ShelfItem item; | 201 ShelfItem item; |
| 202 item.id = ShelfID("foo"); | 202 item.id = ShelfID("foo"); |
| 203 item.type = TYPE_APP; | 203 item.type = TYPE_APP; |
| 204 EXPECT_FALSE(observer()->icon_positions_changed()); | 204 EXPECT_FALSE(observer()->icon_positions_changed()); |
| 205 EXPECT_FALSE(second_observer.icon_positions_changed()); | 205 EXPECT_FALSE(second_observer.icon_positions_changed()); |
| 206 const int shelf_item_index = Shell::Get()->shelf_model()->Add(item); | 206 const int shelf_item_index = Shell::Get()->shelf_model()->Add(item); |
| 207 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 207 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 208 EXPECT_TRUE(observer()->icon_positions_changed()); | 208 EXPECT_TRUE(observer()->icon_positions_changed()); |
| 209 EXPECT_TRUE(second_observer.icon_positions_changed()); | 209 EXPECT_TRUE(second_observer.icon_positions_changed()); |
| 210 observer()->Reset(); | 210 observer()->Reset(); |
| 211 second_observer.Reset(); | 211 second_observer.Reset(); |
| 212 | 212 |
| 213 EXPECT_FALSE(observer()->icon_positions_changed()); | 213 EXPECT_FALSE(observer()->icon_positions_changed()); |
| 214 EXPECT_FALSE(second_observer.icon_positions_changed()); | 214 EXPECT_FALSE(second_observer.icon_positions_changed()); |
| 215 Shell::Get()->shelf_model()->RemoveItemAt(shelf_item_index); | 215 Shell::Get()->shelf_model()->RemoveItemAt(shelf_item_index); |
| 216 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 216 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 217 EXPECT_TRUE(observer()->icon_positions_changed()); | 217 EXPECT_TRUE(observer()->icon_positions_changed()); |
| 218 EXPECT_TRUE(second_observer.icon_positions_changed()); | 218 EXPECT_TRUE(second_observer.icon_positions_changed()); |
| 219 | 219 |
| 220 observer()->Reset(); | 220 observer()->Reset(); |
| 221 second_observer.Reset(); | 221 second_observer.Reset(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 TEST_F(WmShelfObserverIconTest, BoundsChanged) { | 224 TEST_F(ShelfObserverIconTest, BoundsChanged) { |
| 225 views::Widget* widget = | 225 views::Widget* widget = |
| 226 GetPrimaryShelf()->GetShelfViewForTesting()->GetWidget(); | 226 GetPrimaryShelf()->GetShelfViewForTesting()->GetWidget(); |
| 227 gfx::Rect shelf_bounds = widget->GetWindowBoundsInScreen(); | 227 gfx::Rect shelf_bounds = widget->GetWindowBoundsInScreen(); |
| 228 shelf_bounds.set_width(shelf_bounds.width() / 2); | 228 shelf_bounds.set_width(shelf_bounds.width() / 2); |
| 229 ASSERT_GT(shelf_bounds.width(), 0); | 229 ASSERT_GT(shelf_bounds.width(), 0); |
| 230 widget->SetBounds(shelf_bounds); | 230 widget->SetBounds(shelf_bounds); |
| 231 // No animation happens for ShelfView bounds change. | 231 // No animation happens for ShelfView bounds change. |
| 232 EXPECT_TRUE(observer()->icon_positions_changed()); | 232 EXPECT_TRUE(observer()->icon_positions_changed()); |
| 233 observer()->Reset(); | 233 observer()->Reset(); |
| 234 } | 234 } |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | 904 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); |
| 905 | 905 |
| 906 // Test that any two successive visible icons never overlap in all shelf | 906 // Test that any two successive visible icons never overlap in all shelf |
| 907 // alignment types. | 907 // alignment types. |
| 908 const ShelfAlignment kAlignments[] = { | 908 const ShelfAlignment kAlignments[] = { |
| 909 SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, SHELF_ALIGNMENT_BOTTOM, | 909 SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, SHELF_ALIGNMENT_BOTTOM, |
| 910 SHELF_ALIGNMENT_BOTTOM_LOCKED, | 910 SHELF_ALIGNMENT_BOTTOM_LOCKED, |
| 911 }; | 911 }; |
| 912 | 912 |
| 913 for (ShelfAlignment alignment : kAlignments) { | 913 for (ShelfAlignment alignment : kAlignments) { |
| 914 shelf_view_->wm_shelf()->SetAlignment(alignment); | 914 shelf_view_->shelf()->SetAlignment(alignment); |
| 915 // For every 2 successive visible icons, expect that their bounds don't | 915 // For every 2 successive visible icons, expect that their bounds don't |
| 916 // intersect. | 916 // intersect. |
| 917 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) { | 917 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) { |
| 918 if (!(test_api_->GetButton(i)->visible() && | 918 if (!(test_api_->GetButton(i)->visible() && |
| 919 test_api_->GetButton(i + 1)->visible())) { | 919 test_api_->GetButton(i + 1)->visible())) { |
| 920 continue; | 920 continue; |
| 921 } | 921 } |
| 922 | 922 |
| 923 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); | 923 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); |
| 924 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); | 924 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 model_->Set(index, item); | 1273 model_->Set(index, item); |
| 1274 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); | 1274 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); |
| 1275 item.status = STATUS_ATTENTION; | 1275 item.status = STATUS_ATTENTION; |
| 1276 model_->Set(index, item); | 1276 model_->Set(index, item); |
| 1277 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); | 1277 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 // Confirm that shelf item bounds are correctly updated on shelf changes. | 1280 // Confirm that shelf item bounds are correctly updated on shelf changes. |
| 1281 TEST_F(ShelfViewTest, ShelfItemBoundsCheck) { | 1281 TEST_F(ShelfViewTest, ShelfItemBoundsCheck) { |
| 1282 VerifyShelfItemBoundsAreValid(); | 1282 VerifyShelfItemBoundsAreValid(); |
| 1283 shelf_view_->wm_shelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1283 shelf_view_->shelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1284 test_api_->RunMessageLoopUntilAnimationsDone(); | 1284 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1285 VerifyShelfItemBoundsAreValid(); | 1285 VerifyShelfItemBoundsAreValid(); |
| 1286 shelf_view_->wm_shelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1286 shelf_view_->shelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1287 test_api_->RunMessageLoopUntilAnimationsDone(); | 1287 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1288 VerifyShelfItemBoundsAreValid(); | 1288 VerifyShelfItemBoundsAreValid(); |
| 1289 } | 1289 } |
| 1290 | 1290 |
| 1291 TEST_F(ShelfViewTest, ShelfTooltipTest) { | 1291 TEST_F(ShelfViewTest, ShelfTooltipTest) { |
| 1292 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); | 1292 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, test_api_->GetButtonCount()); |
| 1293 | 1293 |
| 1294 // Prepare some items to the shelf. | 1294 // Prepare some items to the shelf. |
| 1295 ShelfID app_button_id = AddAppShortcut(); | 1295 ShelfID app_button_id = AddAppShortcut(); |
| 1296 ShelfID platform_button_id = AddApp(); | 1296 ShelfID platform_button_id = AddApp(); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 test_for_overflow_view.GetBoundsForDragInsertInScreen(); | 1634 test_for_overflow_view.GetBoundsForDragInsertInScreen(); |
| 1635 first_point = first_button->GetBoundsInScreen().CenterPoint(); | 1635 first_point = first_button->GetBoundsInScreen().CenterPoint(); |
| 1636 last_point = last_button->GetBoundsInScreen().CenterPoint(); | 1636 last_point = last_button->GetBoundsInScreen().CenterPoint(); |
| 1637 EXPECT_FALSE(drag_reinsert_bounds.Contains(first_point)); | 1637 EXPECT_FALSE(drag_reinsert_bounds.Contains(first_point)); |
| 1638 EXPECT_TRUE(drag_reinsert_bounds.Contains(last_point)); | 1638 EXPECT_TRUE(drag_reinsert_bounds.Contains(last_point)); |
| 1639 } | 1639 } |
| 1640 | 1640 |
| 1641 // Check the drag insertion bounds of shelf view in multi monitor environment. | 1641 // Check the drag insertion bounds of shelf view in multi monitor environment. |
| 1642 TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) { | 1642 TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) { |
| 1643 UpdateDisplay("800x600,800x600"); | 1643 UpdateDisplay("800x600,800x600"); |
| 1644 WmShelf* secondary_shelf = WmShelf::ForWindow(Shell::GetAllRootWindows()[1]); | 1644 Shelf* secondary_shelf = Shelf::ForWindow(Shell::GetAllRootWindows()[1]); |
| 1645 ShelfView* shelf_view_for_secondary = | 1645 ShelfView* shelf_view_for_secondary = |
| 1646 secondary_shelf->GetShelfViewForTesting(); | 1646 secondary_shelf->GetShelfViewForTesting(); |
| 1647 | 1647 |
| 1648 // The bounds should be big enough for 4 buttons + overflow chevron. | 1648 // The bounds should be big enough for 4 buttons + overflow chevron. |
| 1649 shelf_view_for_secondary->SetBounds(0, 0, 500, kShelfSize); | 1649 shelf_view_for_secondary->SetBounds(0, 0, 500, kShelfSize); |
| 1650 | 1650 |
| 1651 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); | 1651 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); |
| 1652 // Speeds up animation for test. | 1652 // Speeds up animation for test. |
| 1653 test_api_for_secondary.SetAnimationDuration(1); | 1653 test_api_for_secondary.SetAnimationDuration(1); |
| 1654 | 1654 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 // Checks that a point of overflow bubble in primary shelf should not be | 1699 // Checks that a point of overflow bubble in primary shelf should not be |
| 1700 // contained by insert bounds of secondary shelf. | 1700 // contained by insert bounds of secondary shelf. |
| 1701 EXPECT_FALSE(drag_reinsert_bounds_in_secondary.Contains(point_in_shelf_view)); | 1701 EXPECT_FALSE(drag_reinsert_bounds_in_secondary.Contains(point_in_shelf_view)); |
| 1702 } | 1702 } |
| 1703 | 1703 |
| 1704 // Checks the rip an item off from left aligned shelf in secondary monitor. | 1704 // Checks the rip an item off from left aligned shelf in secondary monitor. |
| 1705 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { | 1705 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { |
| 1706 UpdateDisplay("800x600,800x600"); | 1706 UpdateDisplay("800x600,800x600"); |
| 1707 ASSERT_EQ(2U, ShellPort::Get()->GetAllRootWindows().size()); | 1707 ASSERT_EQ(2U, ShellPort::Get()->GetAllRootWindows().size()); |
| 1708 | 1708 |
| 1709 WmShelf* secondary_shelf = WmShelf::ForWindow(Shell::GetAllRootWindows()[1]); | 1709 Shelf* secondary_shelf = Shelf::ForWindow(Shell::GetAllRootWindows()[1]); |
| 1710 | 1710 |
| 1711 secondary_shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1711 secondary_shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 1712 ASSERT_EQ(SHELF_ALIGNMENT_LEFT, secondary_shelf->alignment()); | 1712 ASSERT_EQ(SHELF_ALIGNMENT_LEFT, secondary_shelf->alignment()); |
| 1713 | 1713 |
| 1714 // Initially, app list and browser shortcut are added. | 1714 // Initially, app list and browser shortcut are added. |
| 1715 EXPECT_EQ(2, model_->item_count()); | 1715 EXPECT_EQ(2, model_->item_count()); |
| 1716 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); | 1716 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); |
| 1717 EXPECT_GT(browser_index, 0); | 1717 EXPECT_GT(browser_index, 0); |
| 1718 | 1718 |
| 1719 ShelfView* shelf_view_for_secondary = | 1719 ShelfView* shelf_view_for_secondary = |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2522 }; | 2522 }; |
| 2523 | 2523 |
| 2524 // A test ShellDelegate implementation for overflow button tests that returns a | 2524 // A test ShellDelegate implementation for overflow button tests that returns a |
| 2525 // TestShelfMenuModel for the shell context menu. | 2525 // TestShelfMenuModel for the shell context menu. |
| 2526 class TestOverflowButtonShellDelegate : public TestShellDelegate { | 2526 class TestOverflowButtonShellDelegate : public TestShellDelegate { |
| 2527 public: | 2527 public: |
| 2528 TestOverflowButtonShellDelegate() {} | 2528 TestOverflowButtonShellDelegate() {} |
| 2529 ~TestOverflowButtonShellDelegate() override {} | 2529 ~TestOverflowButtonShellDelegate() override {} |
| 2530 | 2530 |
| 2531 // TestShellDelegate: | 2531 // TestShellDelegate: |
| 2532 ui::MenuModel* CreateContextMenu(WmShelf* wm_shelf, | 2532 ui::MenuModel* CreateContextMenu(Shelf* shelf, |
| 2533 const ShelfItem* item) override { | 2533 const ShelfItem* item) override { |
| 2534 // Caller takes ownership of the returned object. | 2534 // Caller takes ownership of the returned object. |
| 2535 return new TestShellMenuModel; | 2535 return new TestShellMenuModel; |
| 2536 } | 2536 } |
| 2537 | 2537 |
| 2538 private: | 2538 private: |
| 2539 DISALLOW_COPY_AND_ASSIGN(TestOverflowButtonShellDelegate); | 2539 DISALLOW_COPY_AND_ASSIGN(TestOverflowButtonShellDelegate); |
| 2540 }; | 2540 }; |
| 2541 | 2541 |
| 2542 std::string ToString(ShelfAlignment shelf_alignment) { | 2542 std::string ToString(ShelfAlignment shelf_alignment) { |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3136 EXPECT_EQ(views::InkDropState::ACTIVATED, | 3136 EXPECT_EQ(views::InkDropState::ACTIVATED, |
| 3137 overflow_button_ink_drop_->GetTargetInkDropState()); | 3137 overflow_button_ink_drop_->GetTargetInkDropState()); |
| 3138 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | 3138 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), |
| 3139 IsEmpty()); | 3139 IsEmpty()); |
| 3140 | 3140 |
| 3141 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 3141 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
| 3142 } | 3142 } |
| 3143 | 3143 |
| 3144 } // namespace test | 3144 } // namespace test |
| 3145 } // namespace ash | 3145 } // namespace ash |
| OLD | NEW |