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

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

Issue 2807473003: Shelf: Hide overflow bubble when app launched from overflow. (Closed)
Patch Set: Fixed patch set 3 errors. Created 3 years, 8 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/common/shelf/shelf_view.cc ('k') | no next file » | 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>
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 682 }
683 683
684 void ReplaceShelfDelegate() { 684 void ReplaceShelfDelegate() {
685 // Clear the value first to avoid TestShelfDelegate's singleton check. 685 // Clear the value first to avoid TestShelfDelegate's singleton check.
686 test::ShellTestApi().SetShelfDelegate(nullptr); 686 test::ShellTestApi().SetShelfDelegate(nullptr);
687 shelf_delegate_ = new TestShelfDelegateForShelfView(); 687 shelf_delegate_ = new TestShelfDelegateForShelfView();
688 test_api_->SetShelfDelegate(shelf_delegate_); 688 test_api_->SetShelfDelegate(shelf_delegate_);
689 test::ShellTestApi().SetShelfDelegate(base::WrapUnique(shelf_delegate_)); 689 test::ShellTestApi().SetShelfDelegate(base::WrapUnique(shelf_delegate_));
690 } 690 }
691 691
692 // Returns the center coordinates for a button. Helper function for an event
693 // generator.
694 gfx::Point GetButtonCenter(ShelfID button_id) {
695 return GetButtonCenter(
696 test_api_->GetButton(model_->ItemIndexByID(button_id)));
697 }
698
699 gfx::Point GetButtonCenter(ShelfButton* button) {
700 return button->GetBoundsInScreen().CenterPoint();
701 }
702
692 ShelfModel* model_; 703 ShelfModel* model_;
693 ShelfView* shelf_view_; 704 ShelfView* shelf_view_;
694 int browser_index_; 705 int browser_index_;
695 706
696 // Owned by ash::WmShell. 707 // Owned by ash::WmShell.
697 TestShelfDelegateForShelfView* shelf_delegate_; 708 TestShelfDelegateForShelfView* shelf_delegate_;
698 709
699 std::unique_ptr<ShelfViewTestAPI> test_api_; 710 std::unique_ptr<ShelfViewTestAPI> test_api_;
700 711
701 private: 712 private:
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 selection_tracker->set_item_selected_action(SHELF_ACTION_WINDOW_MINIMIZED); 1836 selection_tracker->set_item_selected_action(SHELF_ACTION_WINDOW_MINIMIZED);
1826 SimulateClick(browser_index_); 1837 SimulateClick(browser_index_);
1827 1838
1828 selection_tracker->set_item_selected_action(SHELF_ACTION_WINDOW_ACTIVATED); 1839 selection_tracker->set_item_selected_action(SHELF_ACTION_WINDOW_ACTIVATED);
1829 SimulateClick(browser_index_); 1840 SimulateClick(browser_index_);
1830 1841
1831 histogram_tester.ExpectTotalCount( 1842 histogram_tester.ExpectTotalCount(
1832 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 1); 1843 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 1);
1833 } 1844 }
1834 1845
1846 TEST_F(ShelfViewTest, TestHideOverflow) {
1847 // Use an event generator instead of SimulateClick because the overflow bubble
1848 // is a PointerWatcher and gets the events directly.
1849 ui::test::EventGenerator& generator = GetEventGenerator();
1850
1851 // Add one app (which is on the main shelf) and then add buttons until
1852 // overflow. Add two more apps (which are on the overflow shelf).
1853 ShelfID first_app_id = AddAppShortcut();
1854 AddButtonsUntilOverflow();
1855 ShelfID overflow_app_id1 = AddAppShortcut();
1856 ShelfID overflow_app_id2 = AddAppShortcut();
1857
1858 // Verify that by clicking anywhere outside the shelf and overflow bubble, the
1859 // overflow bubble will close if it were open.
1860 EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
1861 test_api_->ShowOverflowBubble();
1862
1863 // Make sure the point we chose is not on the shelf or its overflow bubble.
1864 ASSERT_FALSE(test_api_->shelf_view()->GetBoundsInScreen().Contains(
1865 generator.current_location()));
1866 ASSERT_FALSE(
1867 test_api_->overflow_bubble()->shelf_view()->GetBoundsInScreen().Contains(
1868 generator.current_location()));
1869 generator.ClickLeftButton();
1870 EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
1871
1872 // Verify that by clicking a app which is on the main shelf while the overflow
1873 // bubble is opened, the overflow bubble will close.
1874 EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
1875 test_api_->ShowOverflowBubble();
1876 generator.set_current_location(GetButtonCenter(first_app_id));
1877 generator.ClickLeftButton();
1878 EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
1879
1880 // Verify that by clicking a app which is on the overflow shelf, the overflow
1881 // bubble will close.
1882 EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
1883 test_api_->ShowOverflowBubble();
1884 ShelfViewTestAPI test_api_for_overflow(
1885 test_api_->overflow_bubble()->shelf_view());
1886 ShelfButton* button_on_overflow_shelf =
1887 test_api_for_overflow.GetButton(model_->ItemIndexByID(overflow_app_id2));
1888 generator.set_current_location(GetButtonCenter(button_on_overflow_shelf));
1889 generator.ClickLeftButton();
1890 EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
1891
1892 // Verify dragging apps on the overflow shelf does not close the overflow
1893 // bubble.
1894 EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
1895 test_api_->ShowOverflowBubble();
1896 ShelfViewTestAPI test_api_for_overflow1(
1897 test_api_->overflow_bubble()->shelf_view());
1898 ShelfButton* button_on_overflow_shelf1 =
1899 test_api_for_overflow1.GetButton(model_->ItemIndexByID(overflow_app_id1));
1900 ShelfButton* button_on_overflow_shelf2 =
1901 test_api_for_overflow1.GetButton(model_->ItemIndexByID(overflow_app_id2));
1902 generator.set_current_location(GetButtonCenter(button_on_overflow_shelf1));
1903 generator.DragMouseTo(GetButtonCenter(button_on_overflow_shelf2));
1904 EXPECT_TRUE(test_api_->IsShowingOverflowBubble());
1905 }
1906
1835 class ShelfViewVisibleBoundsTest : public ShelfViewTest, 1907 class ShelfViewVisibleBoundsTest : public ShelfViewTest,
1836 public testing::WithParamInterface<bool> { 1908 public testing::WithParamInterface<bool> {
1837 public: 1909 public:
1838 ShelfViewVisibleBoundsTest() : text_direction_change_(GetParam()) {} 1910 ShelfViewVisibleBoundsTest() : text_direction_change_(GetParam()) {}
1839 1911
1840 void CheckAllItemsAreInBounds() { 1912 void CheckAllItemsAreInBounds() {
1841 gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen(); 1913 gfx::Rect visible_bounds = shelf_view_->GetVisibleItemsBoundsInScreen();
1842 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen(); 1914 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen();
1843 EXPECT_TRUE(shelf_bounds.Contains(visible_bounds)); 1915 EXPECT_TRUE(shelf_bounds.Contains(visible_bounds));
1844 for (int i = 0; i < test_api_->GetButtonCount(); ++i) 1916 for (int i = 0; i < test_api_->GetButtonCount(); ++i)
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 EXPECT_EQ(views::InkDropState::ACTIVATED, 3119 EXPECT_EQ(views::InkDropState::ACTIVATED,
3048 overflow_button_ink_drop_->GetTargetInkDropState()); 3120 overflow_button_ink_drop_->GetTargetInkDropState());
3049 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 3121 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
3050 IsEmpty()); 3122 IsEmpty());
3051 3123
3052 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 3124 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
3053 } 3125 }
3054 3126
3055 } // namespace test 3127 } // namespace test
3056 } // namespace ash 3128 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698