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

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

Issue 2237903003: mash: Migrate Shelf aura::Window uses to WmWindow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move shelf notify functions to WmShell. 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.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/common/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_icon_observer.h"
18 #include "ash/common/shelf/shelf_menu_model.h" 18 #include "ash/common/shelf/shelf_menu_model.h"
19 #include "ash/common/shelf/shelf_model.h" 19 #include "ash/common/shelf/shelf_model.h"
20 #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" 21 #include "ash/common/shelf/wm_shelf.h"
22 #include "ash/common/shell_window_ids.h" 22 #include "ash/common/shell_window_ids.h"
23 #include "ash/common/system/web_notification/web_notification_tray.h" 23 #include "ash/common/system/web_notification/web_notification_tray.h"
24 #include "ash/common/test/material_design_controller_test_api.h" 24 #include "ash/common/test/material_design_controller_test_api.h"
25 #include "ash/common/wm_shell.h" 25 #include "ash/common/wm_shell.h"
26 #include "ash/common/wm_window.h"
26 #include "ash/shelf/shelf_widget.h" 27 #include "ash/shelf/shelf_widget.h"
27 #include "ash/shell.h" 28 #include "ash/shell.h"
28 #include "ash/test/ash_test_base.h" 29 #include "ash/test/ash_test_base.h"
29 #include "ash/test/ash_test_helper.h" 30 #include "ash/test/ash_test_helper.h"
30 #include "ash/test/overflow_bubble_view_test_api.h" 31 #include "ash/test/overflow_bubble_view_test_api.h"
31 #include "ash/test/shelf_test_api.h" 32 #include "ash/test/shelf_test_api.h"
32 #include "ash/test/shelf_view_test_api.h" 33 #include "ash/test/shelf_view_test_api.h"
33 #include "ash/test/test_shelf_delegate.h" 34 #include "ash/test/test_shelf_delegate.h"
34 #include "ash/test/test_shelf_item_delegate.h" 35 #include "ash/test/test_shelf_item_delegate.h"
35 #include "ash/test/test_shell_delegate.h" 36 #include "ash/test/test_shell_delegate.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 void TearDown() override { 117 void TearDown() override {
117 observer_.reset(); 118 observer_.reset();
118 AshTestBase::TearDown(); 119 AshTestBase::TearDown();
119 } 120 }
120 121
121 TestShelfIconObserver* observer() { return observer_.get(); } 122 TestShelfIconObserver* observer() { return observer_.get(); }
122 123
123 ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); } 124 ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); }
124 125
125 Shelf* ShelfForSecondaryDisplay() { 126 Shelf* ShelfForSecondaryDisplay() {
126 return Shelf::ForWindow(Shell::GetAllRootWindows()[1]); 127 return Shelf::ForWindow(WmShell::Get()->GetAllRootWindows()[1]);
127 } 128 }
128 129
129 private: 130 private:
130 std::unique_ptr<TestShelfIconObserver> observer_; 131 std::unique_ptr<TestShelfIconObserver> observer_;
131 std::unique_ptr<ShelfViewTestAPI> shelf_view_test_; 132 std::unique_ptr<ShelfViewTestAPI> shelf_view_test_;
132 133
133 DISALLOW_COPY_AND_ASSIGN(ShelfViewIconObserverTest); 134 DISALLOW_COPY_AND_ASSIGN(ShelfViewIconObserverTest);
134 }; 135 };
135 136
136 // TestShelfItemDelegate which tracks whether it gets selected. 137 // TestShelfItemDelegate which tracks whether it gets selected.
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 EXPECT_TRUE(drag_reinsert_bounds.Contains(last_point)); 1685 EXPECT_TRUE(drag_reinsert_bounds.Contains(last_point));
1685 } 1686 }
1686 1687
1687 // Check the drag insertion bounds of shelf view in multi monitor environment. 1688 // Check the drag insertion bounds of shelf view in multi monitor environment.
1688 TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) { 1689 TEST_F(ShelfViewTest, CheckDragInsertBoundsWithMultiMonitor) {
1689 // win8-aura doesn't support multiple display. 1690 // win8-aura doesn't support multiple display.
1690 if (!SupportsMultipleDisplays()) 1691 if (!SupportsMultipleDisplays())
1691 return; 1692 return;
1692 1693
1693 UpdateDisplay("800x600,800x600"); 1694 UpdateDisplay("800x600,800x600");
1694 Shelf* secondary_shelf = Shelf::ForWindow(Shell::GetAllRootWindows()[1]); 1695 Shelf* secondary_shelf =
1696 Shelf::ForWindow(WmShell::Get()->GetAllRootWindows()[1]);
1695 ShelfView* shelf_view_for_secondary = 1697 ShelfView* shelf_view_for_secondary =
1696 ShelfTestAPI(secondary_shelf).shelf_view(); 1698 ShelfTestAPI(secondary_shelf).shelf_view();
1697 1699
1698 // The bounds should be big enough for 4 buttons + overflow chevron. 1700 // The bounds should be big enough for 4 buttons + overflow chevron.
1699 shelf_view_for_secondary->SetBounds(0, 0, 500, GetShelfConstant(SHELF_SIZE)); 1701 shelf_view_for_secondary->SetBounds(0, 0, 500, GetShelfConstant(SHELF_SIZE));
1700 1702
1701 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary); 1703 ShelfViewTestAPI test_api_for_secondary(shelf_view_for_secondary);
1702 // Speeds up animation for test. 1704 // Speeds up animation for test.
1703 test_api_for_secondary.SetAnimationDuration(1); 1705 test_api_for_secondary.SetAnimationDuration(1);
1704 1706
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 EXPECT_FALSE(drag_reinsert_bounds_in_secondary.Contains(point_in_shelf_view)); 1755 EXPECT_FALSE(drag_reinsert_bounds_in_secondary.Contains(point_in_shelf_view));
1754 } 1756 }
1755 1757
1756 // Checks the rip an item off from left aligned shelf in secondary monitor. 1758 // Checks the rip an item off from left aligned shelf in secondary monitor.
1757 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { 1759 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) {
1758 // win8-aura doesn't support multiple display. 1760 // win8-aura doesn't support multiple display.
1759 if (!SupportsMultipleDisplays()) 1761 if (!SupportsMultipleDisplays())
1760 return; 1762 return;
1761 1763
1762 UpdateDisplay("800x600,800x600"); 1764 UpdateDisplay("800x600,800x600");
1763 ASSERT_EQ(2U, Shell::GetAllRootWindows().size()); 1765 ASSERT_EQ(2U, WmShell::Get()->GetAllRootWindows().size());
1764 1766
1765 aura::Window* second_root = Shell::GetAllRootWindows()[1]; 1767 WmWindow* second_root = WmShell::Get()->GetAllRootWindows()[1];
1766 Shelf* secondary_shelf = Shelf::ForWindow(second_root); 1768 Shelf* secondary_shelf = Shelf::ForWindow(second_root);
1767 1769
1768 secondary_shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 1770 secondary_shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
1769 ASSERT_EQ(SHELF_ALIGNMENT_LEFT, secondary_shelf->alignment()); 1771 ASSERT_EQ(SHELF_ALIGNMENT_LEFT, secondary_shelf->alignment());
1770 1772
1771 // Initially, app list and browser shortcut are added. 1773 // Initially, app list and browser shortcut are added.
1772 EXPECT_EQ(2, model_->item_count()); 1774 EXPECT_EQ(2, model_->item_count());
1773 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); 1775 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT);
1774 EXPECT_GT(browser_index, 0); 1776 EXPECT_GT(browser_index, 0);
1775 1777
1776 ShelfView* shelf_view_for_secondary = 1778 ShelfView* shelf_view_for_secondary =
1777 ShelfTestAPI(secondary_shelf).shelf_view(); 1779 ShelfTestAPI(secondary_shelf).shelf_view();
1778 1780
1779 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary); 1781 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary);
1780 ShelfButton* button = 1782 ShelfButton* button =
1781 test_api_for_secondary_shelf_view.GetButton(browser_index); 1783 test_api_for_secondary_shelf_view.GetButton(browser_index);
1782 1784
1783 // Fetch the start point of dragging. 1785 // Fetch the start point of dragging.
1784 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); 1786 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint();
1785 ::wm::ConvertPointFromScreen(second_root, &start_point); 1787 start_point = second_root->ConvertPointFromScreen(start_point);
1786 1788
1787 ui::test::EventGenerator generator(second_root, start_point); 1789 ui::test::EventGenerator generator(Shell::GetAllRootWindows()[1],
1790 start_point);
1788 1791
1789 // Rip off the browser item. 1792 // Rip off the browser item.
1790 generator.PressLeftButton(); 1793 generator.PressLeftButton();
1791 generator.MoveMouseTo(start_point.x() + 400, start_point.y()); 1794 generator.MoveMouseTo(start_point.x() + 400, start_point.y());
1792 test_api_for_secondary_shelf_view.RunMessageLoopUntilAnimationsDone(); 1795 test_api_for_secondary_shelf_view.RunMessageLoopUntilAnimationsDone();
1793 EXPECT_TRUE(test_api_for_secondary_shelf_view.IsRippedOffFromShelf()); 1796 EXPECT_TRUE(test_api_for_secondary_shelf_view.IsRippedOffFromShelf());
1794 } 1797 }
1795 1798
1796 // Checks various drag and drop operations from OverflowBubble to Shelf. 1799 // Checks various drag and drop operations from OverflowBubble to Shelf.
1797 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) { 1800 TEST_F(ShelfViewTest, CheckDragAndDropFromOverflowBubbleToShelf) {
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
2571 test_api_->CloseMenu(); 2574 test_api_->CloseMenu();
2572 EXPECT_EQ(views::InkDropState::HIDDEN, 2575 EXPECT_EQ(views::InkDropState::HIDDEN,
2573 browser_button_ink_drop_->GetTargetInkDropState()); 2576 browser_button_ink_drop_->GetTargetInkDropState());
2574 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), 2577 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(),
2575 ElementsAre(views::InkDropState::ACTIVATED, 2578 ElementsAre(views::InkDropState::ACTIVATED,
2576 views::InkDropState::DEACTIVATED)); 2579 views::InkDropState::DEACTIVATED));
2577 } 2580 }
2578 2581
2579 } // namespace test 2582 } // namespace test
2580 } // namespace ash 2583 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf.cc ('k') | ash/shelf/shelf_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698