Chromium Code Reviews| 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/common/shelf/shelf_constants.h" | 12 #include "ash/common/shelf/shelf_constants.h" |
| 13 #include "ash/common/shelf/shelf_item_delegate_manager.h" | 13 #include "ash/common/shelf/shelf_item_delegate_manager.h" |
| 14 #include "ash/common/shelf/shelf_menu_model.h" | |
| 14 #include "ash/common/shelf/shelf_model.h" | 15 #include "ash/common/shelf/shelf_model.h" |
| 15 #include "ash/common/shell_window_ids.h" | 16 #include "ash/common/shell_window_ids.h" |
| 16 #include "ash/root_window_controller.h" | 17 #include "ash/root_window_controller.h" |
| 17 #include "ash/shelf/app_list_button.h" | 18 #include "ash/shelf/app_list_button.h" |
| 18 #include "ash/shelf/overflow_bubble.h" | 19 #include "ash/shelf/overflow_bubble.h" |
| 19 #include "ash/shelf/overflow_bubble_view.h" | 20 #include "ash/shelf/overflow_bubble_view.h" |
| 20 #include "ash/shelf/shelf.h" | 21 #include "ash/shelf/shelf.h" |
| 21 #include "ash/shelf/shelf_button.h" | 22 #include "ash/shelf/shelf_button.h" |
| 22 #include "ash/shelf/shelf_icon_observer.h" | 23 #include "ash/shelf/shelf_icon_observer.h" |
| 23 #include "ash/shelf/shelf_tooltip_manager.h" | 24 #include "ash/shelf/shelf_tooltip_manager.h" |
| 24 #include "ash/shelf/shelf_widget.h" | 25 #include "ash/shelf/shelf_widget.h" |
| 25 #include "ash/shell.h" | 26 #include "ash/shell.h" |
| 26 #include "ash/test/ash_test_base.h" | 27 #include "ash/test/ash_test_base.h" |
| 27 #include "ash/test/overflow_bubble_view_test_api.h" | 28 #include "ash/test/overflow_bubble_view_test_api.h" |
| 28 #include "ash/test/shelf_test_api.h" | 29 #include "ash/test/shelf_test_api.h" |
| 29 #include "ash/test/shelf_view_test_api.h" | 30 #include "ash/test/shelf_view_test_api.h" |
| 30 #include "ash/test/shell_test_api.h" | 31 #include "ash/test/shell_test_api.h" |
| 31 #include "ash/test/test_shelf_delegate.h" | 32 #include "ash/test/test_shelf_delegate.h" |
| 32 #include "ash/test/test_shelf_item_delegate.h" | 33 #include "ash/test/test_shelf_item_delegate.h" |
| 33 #include "base/compiler_specific.h" | 34 #include "base/compiler_specific.h" |
| 34 #include "base/i18n/rtl.h" | 35 #include "base/i18n/rtl.h" |
| 35 #include "base/strings/string_number_conversions.h" | 36 #include "base/strings/string_number_conversions.h" |
| 37 #include "base/strings/utf_string_conversions.h" | |
| 36 #include "base/test/histogram_tester.h" | 38 #include "base/test/histogram_tester.h" |
| 37 #include "base/test/user_action_tester.h" | 39 #include "base/test/user_action_tester.h" |
| 40 #include "base/threading/thread_task_runner_handle.h" | |
| 38 #include "base/time/time.h" | 41 #include "base/time/time.h" |
| 42 #include "testing/gmock/include/gmock/gmock.h" | |
| 39 #include "ui/aura/test/aura_test_base.h" | 43 #include "ui/aura/test/aura_test_base.h" |
| 40 #include "ui/aura/window.h" | 44 #include "ui/aura/window.h" |
| 41 #include "ui/aura/window_event_dispatcher.h" | 45 #include "ui/aura/window_event_dispatcher.h" |
| 42 #include "ui/compositor/layer.h" | 46 #include "ui/compositor/layer.h" |
| 43 #include "ui/events/event.h" | 47 #include "ui/events/event.h" |
| 44 #include "ui/events/event_constants.h" | 48 #include "ui/events/event_constants.h" |
| 45 #include "ui/events/event_utils.h" | 49 #include "ui/events/event_utils.h" |
| 46 #include "ui/events/test/event_generator.h" | 50 #include "ui/events/test/event_generator.h" |
| 47 #include "ui/gfx/geometry/point.h" | 51 #include "ui/gfx/geometry/point.h" |
| 52 #include "ui/views/animation/ink_drop_impl.h" | |
| 53 #include "ui/views/animation/test/ink_drop_host_view_test_api.h" | |
| 48 #include "ui/views/bubble/bubble_frame_view.h" | 54 #include "ui/views/bubble/bubble_frame_view.h" |
| 49 #include "ui/views/view_model.h" | 55 #include "ui/views/view_model.h" |
| 50 #include "ui/views/widget/widget.h" | 56 #include "ui/views/widget/widget.h" |
| 51 #include "ui/views/widget/widget_delegate.h" | 57 #include "ui/views/widget/widget_delegate.h" |
| 52 #include "ui/wm/core/coordinate_conversion.h" | 58 #include "ui/wm/core/coordinate_conversion.h" |
| 53 | 59 |
| 60 using testing::ElementsAre; | |
| 61 using testing::IsEmpty; | |
| 62 | |
| 54 namespace ash { | 63 namespace ash { |
| 55 namespace test { | 64 namespace test { |
| 56 | 65 |
| 57 //////////////////////////////////////////////////////////////////////////////// | 66 //////////////////////////////////////////////////////////////////////////////// |
| 58 // ShelfIconObserver tests. | 67 // ShelfIconObserver tests. |
| 59 | 68 |
| 60 class TestShelfIconObserver : public ShelfIconObserver { | 69 class TestShelfIconObserver : public ShelfIconObserver { |
| 61 public: | 70 public: |
| 62 explicit TestShelfIconObserver(Shelf* shelf) | 71 explicit TestShelfIconObserver(Shelf* shelf) |
| 63 : shelf_(shelf), | 72 : shelf_(shelf), |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 shelf_view_->PointerPressedOnButton(button, pointer, click_event); | 470 shelf_view_->PointerPressedOnButton(button, pointer, click_event); |
| 462 return button; | 471 return button; |
| 463 } | 472 } |
| 464 | 473 |
| 465 // Simulates a single mouse click. | 474 // Simulates a single mouse click. |
| 466 void SimulateClick(int button_index) { | 475 void SimulateClick(int button_index) { |
| 467 ShelfButton* button = SimulateButtonPressed(ShelfView::MOUSE, button_index); | 476 ShelfButton* button = SimulateButtonPressed(ShelfView::MOUSE, button_index); |
| 468 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, gfx::Point(), | 477 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, gfx::Point(), |
| 469 button->GetBoundsInScreen().origin(), | 478 button->GetBoundsInScreen().origin(), |
| 470 ui::EventTimeForNow(), 0, 0); | 479 ui::EventTimeForNow(), 0, 0); |
| 471 test_api_->ButtonPressed(button, release_event); | 480 test_api_->ButtonPressed( |
| 481 button, release_event, | |
| 482 views::test::InkDropHostViewTestApi(button).ink_drop()); | |
| 472 shelf_view_->PointerReleasedOnButton(button, ShelfView::MOUSE, false); | 483 shelf_view_->PointerReleasedOnButton(button, ShelfView::MOUSE, false); |
| 473 } | 484 } |
| 474 | 485 |
| 475 // Simulates the second click of a double click. | 486 // Simulates the second click of a double click. |
| 476 void SimulateDoubleClick(int button_index) { | 487 void SimulateDoubleClick(int button_index) { |
| 477 ShelfButton* button = SimulateButtonPressed(ShelfView::MOUSE, button_index); | 488 ShelfButton* button = SimulateButtonPressed(ShelfView::MOUSE, button_index); |
| 478 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, gfx::Point(), | 489 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, gfx::Point(), |
| 479 button->GetBoundsInScreen().origin(), | 490 button->GetBoundsInScreen().origin(), |
| 480 ui::EventTimeForNow(), ui::EF_IS_DOUBLE_CLICK, | 491 ui::EventTimeForNow(), ui::EF_IS_DOUBLE_CLICK, |
| 481 0); | 492 0); |
| 482 test_api_->ButtonPressed(button, release_event); | 493 test_api_->ButtonPressed( |
| 494 button, release_event, | |
| 495 views::test::InkDropHostViewTestApi(button).ink_drop()); | |
| 483 shelf_view_->PointerReleasedOnButton(button, ShelfView::MOUSE, false); | 496 shelf_view_->PointerReleasedOnButton(button, ShelfView::MOUSE, false); |
| 484 } | 497 } |
| 485 | 498 |
| 486 void DoDrag(int dist_x, | 499 void DoDrag(int dist_x, |
| 487 int dist_y, | 500 int dist_y, |
| 488 views::View* button, | 501 views::View* button, |
| 489 ShelfView::Pointer pointer, | 502 ShelfView::Pointer pointer, |
| 490 views::View* to) { | 503 views::View* to) { |
| 491 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, gfx::Point(dist_x, dist_y), | 504 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, gfx::Point(dist_x, dist_y), |
| 492 to->GetBoundsInScreen().origin(), | 505 to->GetBoundsInScreen().origin(), |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1980 AddAppShortcut(); | 1993 AddAppShortcut(); |
| 1981 } | 1994 } |
| 1982 test_api_->RunMessageLoopUntilAnimationsDone(); | 1995 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1983 CheckAllItemsAreInBounds(); | 1996 CheckAllItemsAreInBounds(); |
| 1984 } | 1997 } |
| 1985 | 1998 |
| 1986 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1999 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
| 1987 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 2000 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, |
| 1988 testing::Bool()); | 2001 testing::Bool()); |
| 1989 | 2002 |
| 2003 namespace { | |
| 2004 // Should match the smae constant in shelf_view.cc. | |
|
James Cook
2016/06/13 19:55:35
I would expose the constant, either in shelf_view.
mohsen
2016/06/14 06:24:38
How about making it a private constant member of S
| |
| 2005 const int kMinimumDragDistance = 8; | |
| 2006 | |
| 2007 // An InkDrop implementation that wraps another InkDrop instance to keep track | |
| 2008 // of state changes requested on it. | |
| 2009 class InkDropSpy : public views::InkDrop { | |
| 2010 public: | |
| 2011 explicit InkDropSpy(std::unique_ptr<views::InkDrop> ink_drop) | |
| 2012 : ink_drop_(std::move(ink_drop)) {} | |
| 2013 ~InkDropSpy() override {} | |
| 2014 | |
| 2015 std::vector<views::InkDropState> GetAndResetRequestedStates() { | |
| 2016 std::vector<views::InkDropState> requested_states; | |
| 2017 requested_states.swap(requested_states_); | |
| 2018 return requested_states; | |
| 2019 } | |
| 2020 | |
| 2021 // views::InkDrop: | |
| 2022 views::InkDropState GetTargetInkDropState() const override { | |
| 2023 return ink_drop_->GetTargetInkDropState(); | |
| 2024 } | |
| 2025 void AnimateToState(views::InkDropState ink_drop_state) override { | |
| 2026 requested_states_.push_back(ink_drop_state); | |
| 2027 ink_drop_->AnimateToState(ink_drop_state); | |
| 2028 } | |
| 2029 void SnapToActivated() override { ink_drop_->SnapToActivated(); } | |
| 2030 void SetHovered(bool is_hovered) override { | |
| 2031 ink_drop_->SetHovered(is_hovered); | |
| 2032 } | |
| 2033 void SetFocused(bool is_focused) override { | |
| 2034 ink_drop_->SetFocused(is_focused); | |
| 2035 } | |
| 2036 | |
| 2037 std::unique_ptr<views::InkDrop> ink_drop_; | |
| 2038 std::vector<views::InkDropState> requested_states_; | |
| 2039 | |
| 2040 private: | |
| 2041 DISALLOW_COPY_AND_ASSIGN(InkDropSpy); | |
| 2042 }; | |
| 2043 | |
| 2044 // A menu model that contains minimum number of items needed for a menu to be | |
| 2045 // shown on a shelf item. | |
| 2046 class TestShelfMenuModel : public ShelfMenuModel, | |
| 2047 public ui::SimpleMenuModel::Delegate { | |
| 2048 public: | |
| 2049 TestShelfMenuModel() : ShelfMenuModel(this) { Build(); } | |
| 2050 ~TestShelfMenuModel() override {} | |
| 2051 | |
| 2052 private: | |
| 2053 void Build() { | |
| 2054 // A menu is expected to have at least 6 items. Three spacing separators, | |
| 2055 // one title, and at least two more items. | |
| 2056 AddSeparator(ui::SPACING_SEPARATOR); | |
| 2057 AddItem(0, base::ASCIIToUTF16("Title")); | |
| 2058 AddSeparator(ui::SPACING_SEPARATOR); | |
| 2059 AddItem(1, base::ASCIIToUTF16("Item 1")); | |
| 2060 AddItem(2, base::ASCIIToUTF16("Item 2")); | |
| 2061 AddSeparator(ui::SPACING_SEPARATOR); | |
| 2062 } | |
| 2063 | |
| 2064 // ShelfMenuModel: | |
| 2065 bool IsCommandActive(int command_id) const override { return false; } | |
| 2066 | |
| 2067 // ui::SimpleMenuModel::Delegate: | |
| 2068 bool IsCommandIdChecked(int command_id) const override { return false; } | |
| 2069 bool IsCommandIdEnabled(int command_id) const override { | |
| 2070 return command_id != 0; | |
| 2071 } | |
| 2072 bool GetAcceleratorForCommandId(int command_id, | |
| 2073 ui::Accelerator* accelerator) override { | |
| 2074 return false; | |
| 2075 } | |
| 2076 void ExecuteCommand(int command_id, int event_flags) override {} | |
| 2077 | |
| 2078 DISALLOW_COPY_AND_ASSIGN(TestShelfMenuModel); | |
| 2079 }; | |
| 2080 | |
| 2081 // A ShelfItemDelegate that returns a menu for the shelf item. | |
| 2082 class ListMenuShelfItemDelegate : public TestShelfItemDelegate { | |
| 2083 public: | |
| 2084 ListMenuShelfItemDelegate() : TestShelfItemDelegate(nullptr) {} | |
| 2085 ~ListMenuShelfItemDelegate() override {} | |
| 2086 | |
| 2087 private: | |
| 2088 // TestShelfItemDelegate: | |
| 2089 ShelfMenuModel* CreateApplicationMenu(int event_flags) override { | |
| 2090 return new TestShelfMenuModel; | |
| 2091 } | |
| 2092 | |
| 2093 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate); | |
| 2094 }; | |
| 2095 } // namespace | |
|
James Cook
2016/06/13 19:55:35
nit: blank line above
mohsen
2016/06/14 06:24:39
Done.
| |
| 2096 | |
| 2097 class ShelfViewInkDropTest : public ShelfViewTest { | |
| 2098 public: | |
| 2099 ShelfViewInkDropTest() : ink_drop_(nullptr) {} | |
|
James Cook
2016/06/13 19:55:35
initialize browser_button_ to nullptr?
mohsen
2016/06/14 06:24:39
Oops. Done.
| |
| 2100 ~ShelfViewInkDropTest() override {} | |
| 2101 | |
| 2102 void SetUp() override { | |
| 2103 ShelfViewTest::SetUp(); | |
| 2104 | |
| 2105 browser_button_ = test_api_->GetButton(browser_index_); | |
| 2106 | |
| 2107 views::InkDropImpl* ink_drop_impl = new views::InkDropImpl(browser_button_); | |
| 2108 ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | |
| 2109 views::test::InkDropHostViewTestApi(browser_button_) | |
| 2110 .SetInkDrop(base::WrapUnique(ink_drop_)); | |
| 2111 } | |
| 2112 | |
| 2113 void TearDown() override { | |
| 2114 ink_drop_ = nullptr; | |
|
James Cook
2016/06/13 19:55:35
optional: You could skip nulling these out.
mohsen
2016/06/14 06:24:39
Done.
| |
| 2115 browser_button_ = nullptr; | |
| 2116 ShelfViewTest::TearDown(); | |
| 2117 } | |
| 2118 | |
| 2119 void CloseMenu() { | |
| 2120 Shelf* shelf = Shelf::ForPrimaryDisplay(); | |
| 2121 ShelfViewTestAPI(ShelfTestAPI(shelf).shelf_view()).CloseMenu(); | |
| 2122 } | |
| 2123 | |
| 2124 protected: | |
| 2125 InkDropSpy* ink_drop_; | |
| 2126 ShelfButton* browser_button_; | |
| 2127 | |
| 2128 private: | |
| 2129 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); | |
| 2130 }; | |
| 2131 | |
| 2132 // Tests that clicking on a shelf item that does not show a menu transitions ink | |
|
James Cook
2016/06/13 19:55:35
Thanks for documenting the purpose of each test. I
| |
| 2133 // drop states correctly. | |
| 2134 TEST_F(ShelfViewInkDropTest, WithoutMenuPressRelease) { | |
| 2135 views::CustomButton* button = browser_button_; | |
| 2136 gfx::Point press_location = button->GetLocalBounds().CenterPoint(); | |
| 2137 | |
| 2138 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, | |
| 2139 press_location, ui::EventTimeForNow(), | |
| 2140 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2141 button->OnMousePressed(press_event); | |
| 2142 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2143 ink_drop_->GetTargetInkDropState()); | |
| 2144 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | |
| 2145 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2146 | |
| 2147 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, | |
| 2148 press_location, ui::EventTimeForNow(), | |
| 2149 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2150 button->OnMouseReleased(release_event); | |
| 2151 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | |
| 2152 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | |
| 2153 ElementsAre(views::InkDropState::ACTION_TRIGGERED)); | |
| 2154 } | |
| 2155 | |
| 2156 // Tests that dragging outside of a shelf item transitions ink drop states | |
| 2157 // correctly. | |
| 2158 TEST_F(ShelfViewInkDropTest, WithoutMenuPressDragReleaseOutside) { | |
| 2159 views::CustomButton* button = browser_button_; | |
| 2160 gfx::Point press_location = button->GetLocalBounds().CenterPoint(); | |
| 2161 | |
| 2162 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, | |
| 2163 press_location, ui::EventTimeForNow(), | |
| 2164 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2165 button->OnMousePressed(press_event); | |
| 2166 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2167 ink_drop_->GetTargetInkDropState()); | |
| 2168 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | |
| 2169 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2170 | |
| 2171 press_location.Offset(kMinimumDragDistance / 2, 0); | |
| 2172 ui::MouseEvent drag_event_small(ui::ET_MOUSE_DRAGGED, press_location, | |
| 2173 press_location, ui::EventTimeForNow(), | |
| 2174 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2175 button->OnMouseDragged(drag_event_small); | |
| 2176 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2177 ink_drop_->GetTargetInkDropState()); | |
| 2178 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); | |
| 2179 | |
| 2180 press_location.Offset(kMinimumDragDistance, 0); | |
| 2181 ui::MouseEvent drag_event_large(ui::ET_MOUSE_DRAGGED, press_location, | |
| 2182 press_location, ui::EventTimeForNow(), | |
| 2183 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2184 button->OnMouseDragged(drag_event_large); | |
| 2185 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | |
| 2186 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | |
| 2187 ElementsAre(views::InkDropState::HIDDEN)); | |
| 2188 | |
| 2189 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, | |
| 2190 press_location, ui::EventTimeForNow(), | |
| 2191 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2192 button->OnMouseReleased(release_event); | |
| 2193 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | |
| 2194 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); | |
| 2195 } | |
| 2196 | |
| 2197 // Tests that dragging outside of a shelf item and back transitions ink drop | |
| 2198 // states correctly. | |
| 2199 TEST_F(ShelfViewInkDropTest, WithoutMenuPressDragReleaseInside) { | |
| 2200 views::CustomButton* button = browser_button_; | |
| 2201 gfx::Point press_location = button->GetLocalBounds().CenterPoint(); | |
| 2202 | |
| 2203 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, | |
| 2204 press_location, ui::EventTimeForNow(), | |
| 2205 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2206 button->OnMousePressed(press_event); | |
| 2207 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2208 ink_drop_->GetTargetInkDropState()); | |
| 2209 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | |
| 2210 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2211 | |
| 2212 press_location.Offset(kMinimumDragDistance * 2, 0); | |
| 2213 ui::MouseEvent drag_event_outside(ui::ET_MOUSE_DRAGGED, press_location, | |
| 2214 press_location, ui::EventTimeForNow(), | |
| 2215 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2216 button->OnMouseDragged(drag_event_outside); | |
| 2217 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | |
| 2218 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | |
| 2219 ElementsAre(views::InkDropState::HIDDEN)); | |
| 2220 | |
| 2221 press_location.Offset(-kMinimumDragDistance * 2, 0); | |
| 2222 ui::MouseEvent drag_event_indise(ui::ET_MOUSE_DRAGGED, press_location, | |
|
James Cook
2016/06/13 19:55:35
nit: indise -> inside
mohsen
2016/06/14 06:24:38
Done.
| |
| 2223 press_location, ui::EventTimeForNow(), | |
| 2224 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2225 button->OnMouseDragged(drag_event_indise); | |
| 2226 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | |
| 2227 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); | |
| 2228 | |
| 2229 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, | |
| 2230 press_location, ui::EventTimeForNow(), | |
| 2231 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2232 button->OnMouseReleased(release_event); | |
| 2233 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | |
| 2234 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), IsEmpty()); | |
| 2235 } | |
| 2236 | |
| 2237 // Tests that clicking on a shelf item that shows an app list menu transitions | |
| 2238 // ink drop state correctly. | |
| 2239 TEST_F(ShelfViewInkDropTest, WithMenuPressRelease) { | |
| 2240 // Set a delegate for the shelf item that returns an app list menu. | |
| 2241 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | |
| 2242 ListMenuShelfItemDelegate* list_menu_delegate = new ListMenuShelfItemDelegate; | |
| 2243 item_manager_->SetShelfItemDelegate(browser_shelf_id, | |
| 2244 base::WrapUnique(list_menu_delegate)); | |
| 2245 | |
| 2246 views::CustomButton* button = browser_button_; | |
| 2247 gfx::Point press_location = button->GetLocalBounds().CenterPoint(); | |
| 2248 | |
| 2249 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, press_location, | |
| 2250 press_location, ui::EventTimeForNow(), | |
| 2251 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2252 button->OnMousePressed(press_event); | |
| 2253 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2254 ink_drop_->GetTargetInkDropState()); | |
| 2255 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | |
| 2256 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2257 | |
| 2258 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 2259 FROM_HERE, | |
| 2260 base::Bind(&ShelfViewInkDropTest::CloseMenu, base::Unretained(this))); | |
|
James Cook
2016/06/13 19:55:35
You might add a comment below that a menu will be
mohsen
2016/06/14 06:24:39
Sure. Done.
| |
| 2261 | |
| 2262 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, press_location, | |
| 2263 press_location, ui::EventTimeForNow(), | |
| 2264 ui::EF_LEFT_MOUSE_BUTTON, 0); | |
| 2265 button->OnMouseReleased(release_event); | |
| 2266 EXPECT_EQ(views::InkDropState::HIDDEN, ink_drop_->GetTargetInkDropState()); | |
| 2267 EXPECT_THAT(ink_drop_->GetAndResetRequestedStates(), | |
| 2268 ElementsAre(views::InkDropState::ACTIVATED, | |
| 2269 views::InkDropState::DEACTIVATED)); | |
| 2270 } | |
| 2271 | |
| 1990 } // namespace test | 2272 } // namespace test |
| 1991 } // namespace ash | 2273 } // namespace ash |
| OLD | NEW |