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/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/overflow_button.h" | |
| 15 #include "ash/common/shelf/shelf_button.h" | 16 #include "ash/common/shelf/shelf_button.h" |
| 16 #include "ash/common/shelf/shelf_constants.h" | 17 #include "ash/common/shelf/shelf_constants.h" |
| 17 #include "ash/common/shelf/shelf_icon_observer.h" | 18 #include "ash/common/shelf/shelf_icon_observer.h" |
| 18 #include "ash/common/shelf/shelf_menu_model.h" | 19 #include "ash/common/shelf/shelf_menu_model.h" |
| 19 #include "ash/common/shelf/shelf_model.h" | 20 #include "ash/common/shelf/shelf_model.h" |
| 20 #include "ash/common/shelf/shelf_tooltip_manager.h" | 21 #include "ash/common/shelf/shelf_tooltip_manager.h" |
| 21 #include "ash/common/shelf/wm_shelf.h" | 22 #include "ash/common/shelf/wm_shelf.h" |
| 22 #include "ash/common/shell_window_ids.h" | 23 #include "ash/common/shell_window_ids.h" |
| 23 #include "ash/common/system/web_notification/web_notification_tray.h" | 24 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 24 #include "ash/common/test/material_design_controller_test_api.h" | 25 #include "ash/common/test/material_design_controller_test_api.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 35 #include "ash/test/test_shelf_item_delegate.h" | 36 #include "ash/test/test_shelf_item_delegate.h" |
| 36 #include "ash/test/test_shell_delegate.h" | 37 #include "ash/test/test_shell_delegate.h" |
| 37 #include "ash/test/test_system_tray_delegate.h" | 38 #include "ash/test/test_system_tray_delegate.h" |
| 38 #include "base/i18n/rtl.h" | 39 #include "base/i18n/rtl.h" |
| 39 #include "base/macros.h" | 40 #include "base/macros.h" |
| 40 #include "base/memory/ptr_util.h" | 41 #include "base/memory/ptr_util.h" |
| 41 #include "base/run_loop.h" | 42 #include "base/run_loop.h" |
| 42 #include "base/strings/string_number_conversions.h" | 43 #include "base/strings/string_number_conversions.h" |
| 43 #include "base/strings/utf_string_conversions.h" | 44 #include "base/strings/utf_string_conversions.h" |
| 44 #include "base/test/histogram_tester.h" | 45 #include "base/test/histogram_tester.h" |
| 46 #include "base/test/test_mock_time_task_runner.h" | |
| 45 #include "base/test/user_action_tester.h" | 47 #include "base/test/user_action_tester.h" |
| 46 #include "base/threading/thread_task_runner_handle.h" | 48 #include "base/threading/thread_task_runner_handle.h" |
| 47 #include "base/time/time.h" | 49 #include "base/time/time.h" |
| 48 #include "testing/gmock/include/gmock/gmock.h" | 50 #include "testing/gmock/include/gmock/gmock.h" |
| 49 #include "ui/app_list/presenter/app_list_presenter.h" | 51 #include "ui/app_list/presenter/app_list_presenter.h" |
| 50 #include "ui/aura/test/aura_test_base.h" | 52 #include "ui/aura/test/aura_test_base.h" |
| 51 #include "ui/aura/window.h" | 53 #include "ui/aura/window.h" |
| 52 #include "ui/aura/window_event_dispatcher.h" | 54 #include "ui/aura/window_event_dispatcher.h" |
| 53 #include "ui/compositor/layer.h" | 55 #include "ui/compositor/layer.h" |
| 54 #include "ui/events/event.h" | 56 #include "ui/events/event.h" |
| (...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2095 bool IsVisible() const override { return is_visible_; } | 2097 bool IsVisible() const override { return is_visible_; } |
| 2096 bool GetTargetVisibility() const override { return target_visibility_; } | 2098 bool GetTargetVisibility() const override { return target_visibility_; } |
| 2097 | 2099 |
| 2098 private: | 2100 private: |
| 2099 bool is_visible_ = false; | 2101 bool is_visible_ = false; |
| 2100 bool target_visibility_ = false; | 2102 bool target_visibility_ = false; |
| 2101 | 2103 |
| 2102 DISALLOW_COPY_AND_ASSIGN(TestAppListPresenter); | 2104 DISALLOW_COPY_AND_ASSIGN(TestAppListPresenter); |
| 2103 }; | 2105 }; |
| 2104 | 2106 |
| 2107 // An empty menu model for shell context menu just to have a menu. | |
| 2108 class TestShellMenuModel : public ui::SimpleMenuModel, | |
| 2109 public ui::SimpleMenuModel::Delegate { | |
| 2110 public: | |
| 2111 TestShellMenuModel() : ui::SimpleMenuModel(this) {} | |
| 2112 ~TestShellMenuModel() override {} | |
| 2113 | |
| 2114 private: | |
| 2115 // ui::SimpleMenuModel::Delegate: | |
| 2116 bool IsCommandIdChecked(int command_id) const override { return false; } | |
| 2117 bool IsCommandIdEnabled(int command_id) const override { return true; } | |
| 2118 void ExecuteCommand(int command_id, int event_flags) override {} | |
| 2119 | |
| 2120 DISALLOW_COPY_AND_ASSIGN(TestShellMenuModel); | |
| 2121 }; | |
| 2122 | |
| 2105 // A test ShellDelegate implementation that returns a TestAppListPresenter as | 2123 // A test ShellDelegate implementation that returns a TestAppListPresenter as |
| 2106 // the app list presenter. | 2124 // the app list presenter and a TestShellMenuModel for the shell context menu. |
| 2107 class TestAppListShellDelegate : public TestShellDelegate { | 2125 class TestShelfViewShellDelegate : public TestShellDelegate { |
| 2108 public: | 2126 public: |
| 2109 TestAppListShellDelegate() | 2127 TestShelfViewShellDelegate() |
| 2110 : app_list_presenter_(new TestAppListPresenter()) {} | 2128 : app_list_presenter_(new TestAppListPresenter()) {} |
| 2111 ~TestAppListShellDelegate() override {} | 2129 ~TestShelfViewShellDelegate() override {} |
| 2112 | 2130 |
| 2113 TestAppListPresenter* app_list_presenter() const { | 2131 TestAppListPresenter* app_list_presenter() const { |
| 2114 return app_list_presenter_.get(); | 2132 return app_list_presenter_.get(); |
| 2115 } | 2133 } |
| 2116 | 2134 |
| 2117 // TestShellDelegate: | 2135 // TestShellDelegate: |
| 2136 ui::MenuModel* CreateContextMenu(WmShelf* wm_shelf, | |
| 2137 const ShelfItem* item) override { | |
| 2138 return new TestShellMenuModel; | |
| 2139 } | |
| 2118 app_list::AppListPresenter* GetAppListPresenter() override { | 2140 app_list::AppListPresenter* GetAppListPresenter() override { |
| 2119 return app_list_presenter(); | 2141 return app_list_presenter(); |
| 2120 } | 2142 } |
| 2121 | 2143 |
| 2122 private: | 2144 private: |
| 2123 std::unique_ptr<TestAppListPresenter> app_list_presenter_; | 2145 std::unique_ptr<TestAppListPresenter> app_list_presenter_; |
| 2124 | 2146 |
| 2125 DISALLOW_COPY_AND_ASSIGN(TestAppListShellDelegate); | 2147 DISALLOW_COPY_AND_ASSIGN(TestShelfViewShellDelegate); |
| 2148 }; | |
| 2149 | |
| 2150 // A scoped wrapper around TestMockTimeTaskRunner that replaces message loop's | |
| 2151 // task runner with a TestMockTimeTaskRunner and resets it back at the end of | |
| 2152 // the scope. | |
| 2153 class ScopedMockTaskRunnerWrapper { | |
| 2154 public: | |
| 2155 ScopedMockTaskRunnerWrapper() { | |
| 2156 mock_task_runner_ = new base::TestMockTimeTaskRunner; | |
| 2157 previous_task_runner_ = base::MessageLoop::current()->task_runner(); | |
| 2158 base::MessageLoop::current()->SetTaskRunner(mock_task_runner_); | |
| 2159 } | |
| 2160 | |
| 2161 ~ScopedMockTaskRunnerWrapper() { | |
| 2162 mock_task_runner_->ClearPendingTasks(); | |
|
bruthig
2016/08/25 19:18:35
It might be a good idea to DCHECK_EQ(mock_task_run
mohsen
2016/08/30 18:03:32
Done.
| |
| 2163 base::MessageLoop::current()->SetTaskRunner(previous_task_runner_); | |
| 2164 } | |
| 2165 | |
| 2166 void FastForwardUntilNoTasksRemain() { | |
| 2167 mock_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 2168 } | |
| 2169 | |
| 2170 private: | |
| 2171 scoped_refptr<base::TestMockTimeTaskRunner> mock_task_runner_; | |
| 2172 scoped_refptr<base::SingleThreadTaskRunner> previous_task_runner_; | |
| 2173 | |
| 2174 DISALLOW_COPY_AND_ASSIGN(ScopedMockTaskRunnerWrapper); | |
| 2126 }; | 2175 }; |
| 2127 | 2176 |
| 2128 } // namespace | 2177 } // namespace |
| 2129 | 2178 |
| 2130 // Test fixture that forces material design mode in order to test ink drop | 2179 // Test fixture that forces material design mode in order to test ink drop |
| 2131 // ripples on shelf. | 2180 // ripples on shelf. |
| 2132 class ShelfViewInkDropTest : public ShelfViewTest { | 2181 class ShelfViewInkDropTest : public ShelfViewTest { |
| 2133 public: | 2182 public: |
| 2134 ShelfViewInkDropTest() {} | 2183 ShelfViewInkDropTest() {} |
| 2135 ~ShelfViewInkDropTest() override {} | 2184 ~ShelfViewInkDropTest() override {} |
| 2136 | 2185 |
| 2137 void SetUp() override { | 2186 void SetUp() override { |
| 2138 shell_delegate_ = new TestAppListShellDelegate; | 2187 shell_delegate_ = new TestShelfViewShellDelegate; |
| 2139 ash_test_helper()->set_test_shell_delegate(shell_delegate_); | 2188 ash_test_helper()->set_test_shell_delegate(shell_delegate_); |
| 2140 | 2189 |
| 2141 set_material_mode(ash::MaterialDesignController::MATERIAL_EXPERIMENTAL); | 2190 set_material_mode(ash::MaterialDesignController::MATERIAL_EXPERIMENTAL); |
| 2142 | 2191 |
| 2143 ShelfViewTest::SetUp(); | 2192 ShelfViewTest::SetUp(); |
| 2144 } | 2193 } |
| 2145 | 2194 |
| 2146 protected: | 2195 protected: |
| 2147 void InitAppListButtonInkDrop() { | 2196 void InitAppListButtonInkDrop() { |
| 2148 app_list_button_ = shelf_view_->GetAppListButton(); | 2197 app_list_button_ = shelf_view_->GetAppListButton(); |
| 2149 | 2198 |
| 2150 views::InkDropImpl* ink_drop_impl = | 2199 views::InkDropImpl* ink_drop_impl = |
| 2151 new views::InkDropImpl(app_list_button_); | 2200 new views::InkDropImpl(app_list_button_); |
| 2152 app_list_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | 2201 app_list_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); |
| 2153 views::test::InkDropHostViewTestApi(app_list_button_) | 2202 views::test::InkDropHostViewTestApi(app_list_button_) |
| 2154 .SetInkDrop(base::WrapUnique(app_list_button_ink_drop_), false); | 2203 .SetInkDrop(base::WrapUnique(app_list_button_ink_drop_), false); |
| 2155 } | 2204 } |
| 2156 | 2205 |
| 2157 void InitBrowserButtonInkDrop() { | 2206 void InitBrowserButtonInkDrop() { |
| 2158 browser_button_ = test_api_->GetButton(browser_index_); | 2207 browser_button_ = test_api_->GetButton(browser_index_); |
| 2159 | 2208 |
| 2160 views::InkDropImpl* ink_drop_impl = new views::InkDropImpl(browser_button_); | 2209 views::InkDropImpl* ink_drop_impl = new views::InkDropImpl(browser_button_); |
| 2161 browser_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | 2210 browser_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); |
| 2162 views::test::InkDropHostViewTestApi(browser_button_) | 2211 views::test::InkDropHostViewTestApi(browser_button_) |
| 2163 .SetInkDrop(base::WrapUnique(browser_button_ink_drop_)); | 2212 .SetInkDrop(base::WrapUnique(browser_button_ink_drop_)); |
| 2164 } | 2213 } |
| 2165 | 2214 |
| 2215 void InitOverflowButtonInkDrop() { | |
| 2216 overflow_button_ = test_api_->overflow_button(); | |
| 2217 | |
| 2218 views::InkDropImpl* ink_drop_impl = | |
| 2219 new views::InkDropImpl(overflow_button_); | |
| 2220 overflow_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | |
| 2221 views::test::InkDropHostViewTestApi(overflow_button_) | |
| 2222 .SetInkDrop(base::WrapUnique(overflow_button_ink_drop_)); | |
| 2223 } | |
| 2224 | |
| 2166 void ShowAppList() { | 2225 void ShowAppList() { |
| 2167 shell_delegate_->app_list_presenter()->Show(0); | 2226 shell_delegate_->app_list_presenter()->Show(0); |
| 2168 // Similar to real AppListPresenter, notify button that the app list is | 2227 // Similar to real AppListPresenter, notify button that the app list is |
| 2169 // shown. | 2228 // shown. |
| 2170 app_list_button_->OnAppListShown(); | 2229 app_list_button_->OnAppListShown(); |
| 2171 } | 2230 } |
| 2172 | 2231 |
| 2173 void DismissAppList() { | 2232 void DismissAppList() { |
| 2174 shell_delegate_->app_list_presenter()->Dismiss(); | 2233 shell_delegate_->app_list_presenter()->Dismiss(); |
| 2175 // Similar to real AppListPresenter, notify button that the app list is | 2234 // Similar to real AppListPresenter, notify button that the app list is |
| 2176 // dismissed. | 2235 // dismissed. |
| 2177 app_list_button_->OnAppListDismissed(); | 2236 app_list_button_->OnAppListDismissed(); |
| 2178 } | 2237 } |
| 2179 | 2238 |
| 2180 void FinishAppListVisibilityChange() { | 2239 void FinishAppListVisibilityChange() { |
| 2181 shell_delegate_->app_list_presenter()->FinishVisibilityChange(); | 2240 shell_delegate_->app_list_presenter()->FinishVisibilityChange(); |
| 2182 } | 2241 } |
| 2183 | 2242 |
| 2184 TestAppListShellDelegate* shell_delegate_ = nullptr; // Owned by Shell. | 2243 TestShelfViewShellDelegate* shell_delegate_ = nullptr; // Owned by Shell. |
| 2185 | 2244 |
| 2186 AppListButton* app_list_button_ = nullptr; | 2245 AppListButton* app_list_button_ = nullptr; |
| 2187 InkDropSpy* app_list_button_ink_drop_ = nullptr; | 2246 InkDropSpy* app_list_button_ink_drop_ = nullptr; |
| 2188 ShelfButton* browser_button_ = nullptr; | 2247 ShelfButton* browser_button_ = nullptr; |
| 2189 InkDropSpy* browser_button_ink_drop_ = nullptr; | 2248 InkDropSpy* browser_button_ink_drop_ = nullptr; |
| 2249 OverflowButton* overflow_button_ = nullptr; | |
| 2250 InkDropSpy* overflow_button_ink_drop_ = nullptr; | |
| 2190 | 2251 |
| 2191 private: | 2252 private: |
| 2192 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); | 2253 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); |
| 2193 }; | 2254 }; |
| 2194 | 2255 |
| 2195 // Tests that changing visibility of the app list transitions app list button's | 2256 // Tests that changing visibility of the app list transitions app list button's |
| 2196 // ink drop states correctly. | 2257 // ink drop states correctly. |
| 2197 TEST_F(ShelfViewInkDropTest, AppListButtonWhenVisibilityChanges) { | 2258 TEST_F(ShelfViewInkDropTest, AppListButtonWhenVisibilityChanges) { |
| 2198 InitAppListButtonInkDrop(); | 2259 InitAppListButtonInkDrop(); |
| 2199 | 2260 |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2572 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2633 ui::EF_LEFT_MOUSE_BUTTON, 0); |
| 2573 button->OnMouseReleased(release_event); | 2634 button->OnMouseReleased(release_event); |
| 2574 test_api_->CloseMenu(); | 2635 test_api_->CloseMenu(); |
| 2575 EXPECT_EQ(views::InkDropState::HIDDEN, | 2636 EXPECT_EQ(views::InkDropState::HIDDEN, |
| 2576 browser_button_ink_drop_->GetTargetInkDropState()); | 2637 browser_button_ink_drop_->GetTargetInkDropState()); |
| 2577 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | 2638 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
| 2578 ElementsAre(views::InkDropState::ACTIVATED, | 2639 ElementsAre(views::InkDropState::ACTIVATED, |
| 2579 views::InkDropState::DEACTIVATED)); | 2640 views::InkDropState::DEACTIVATED)); |
| 2580 } | 2641 } |
| 2581 | 2642 |
| 2643 // Tests ink drop state transitions for the overflow button when the overflow | |
| 2644 // bubble is shown or hidden. | |
| 2645 TEST_F(ShelfViewInkDropTest, OverflowButtonOnOverflowBubbleShowHide) { | |
| 2646 InitOverflowButtonInkDrop(); | |
| 2647 | |
| 2648 AddButtonsUntilOverflow(); | |
| 2649 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2650 EXPECT_FALSE(test_api_->overflow_bubble() && | |
|
bruthig
2016/08/25 19:18:35
I know you are just copying this style of expectat
mohsen
2016/08/30 18:03:32
I updated this for EXPECT_TRUE(foo && bar) cases,
bruthig
2016/09/01 16:12:54
Acknowledged.
| |
| 2651 test_api_->overflow_bubble()->IsShowing()); | |
| 2652 | |
| 2653 test_api_->ShowOverflowBubble(); | |
| 2654 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 2655 test_api_->overflow_bubble()->IsShowing()); | |
| 2656 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2657 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2658 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2659 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2660 | |
| 2661 test_api_->HideOverflowBubble(); | |
| 2662 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2663 test_api_->overflow_bubble()->IsShowing()); | |
| 2664 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2665 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2666 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
|
bruthig
2016/08/25 19:18:35
I really like how these expectations work with the
| |
| 2667 ElementsAre(views::InkDropState::DEACTIVATED)); | |
| 2668 } | |
| 2669 | |
| 2670 // Tests ink drop state transitions for the overflow button when the user clicks | |
| 2671 // on it. | |
| 2672 TEST_F(ShelfViewInkDropTest, OverflowButtonMouseActivate) { | |
| 2673 InitOverflowButtonInkDrop(); | |
| 2674 | |
| 2675 AddButtonsUntilOverflow(); | |
| 2676 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2677 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2678 test_api_->overflow_bubble()->IsShowing()); | |
| 2679 | |
| 2680 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2681 gfx::Point mouse_location = | |
| 2682 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2683 generator.MoveMouseTo(mouse_location); | |
| 2684 | |
| 2685 generator.PressLeftButton(); | |
| 2686 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2687 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2688 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2689 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2690 | |
| 2691 generator.ReleaseLeftButton(); | |
| 2692 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2693 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2694 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2695 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2696 | |
| 2697 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 2698 test_api_->overflow_bubble()->IsShowing()); | |
| 2699 } | |
| 2700 | |
| 2701 // Tests ink drop state transitions for the overflow button when the user | |
| 2702 // presses left mouse button on it and drags it out of the button bounds. | |
| 2703 TEST_F(ShelfViewInkDropTest, OverflowButtonMouseDragOut) { | |
| 2704 InitOverflowButtonInkDrop(); | |
| 2705 | |
| 2706 AddButtonsUntilOverflow(); | |
| 2707 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2708 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2709 test_api_->overflow_bubble()->IsShowing()); | |
| 2710 | |
| 2711 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2712 gfx::Point mouse_location = | |
| 2713 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2714 generator.MoveMouseTo(mouse_location); | |
| 2715 | |
| 2716 generator.PressLeftButton(); | |
| 2717 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2718 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2719 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2720 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2721 | |
| 2722 generator.MoveMouseBy(overflow_button_->width(), 0); | |
| 2723 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2724 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2725 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2726 ElementsAre(views::InkDropState::HIDDEN)); | |
| 2727 | |
| 2728 generator.ReleaseLeftButton(); | |
| 2729 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2730 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2731 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2732 IsEmpty()); | |
| 2733 | |
| 2734 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2735 test_api_->overflow_bubble()->IsShowing()); | |
| 2736 } | |
| 2737 | |
| 2738 // Tests ink drop state transitions for the overflow button when the user | |
| 2739 // presses left mouse button on it and drags it out of the button bounds and | |
| 2740 // back. | |
| 2741 TEST_F(ShelfViewInkDropTest, OverflowButtonMouseDragOutAndBack) { | |
| 2742 InitOverflowButtonInkDrop(); | |
| 2743 | |
| 2744 AddButtonsUntilOverflow(); | |
| 2745 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2746 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2747 test_api_->overflow_bubble()->IsShowing()); | |
| 2748 | |
| 2749 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2750 gfx::Point mouse_location = | |
| 2751 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2752 generator.MoveMouseTo(mouse_location); | |
| 2753 | |
| 2754 generator.PressLeftButton(); | |
| 2755 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2756 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2757 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2758 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2759 | |
| 2760 generator.MoveMouseBy(overflow_button_->width(), 0); | |
| 2761 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2762 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2763 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2764 ElementsAre(views::InkDropState::HIDDEN)); | |
| 2765 | |
| 2766 generator.MoveMouseBy(-overflow_button_->width(), 0); | |
| 2767 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2768 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2769 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2770 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2771 | |
| 2772 generator.ReleaseLeftButton(); | |
| 2773 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2774 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2775 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2776 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2777 | |
| 2778 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 2779 test_api_->overflow_bubble()->IsShowing()); | |
| 2780 } | |
| 2781 | |
| 2782 // Tests ink drop state transitions for the overflow button when the user right | |
| 2783 // clicks on the button to show the context menu. | |
| 2784 TEST_F(ShelfViewInkDropTest, OverflowButtonMouseContextMenu) { | |
| 2785 InitOverflowButtonInkDrop(); | |
| 2786 | |
| 2787 AddButtonsUntilOverflow(); | |
| 2788 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2789 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2790 test_api_->overflow_bubble()->IsShowing()); | |
| 2791 | |
| 2792 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2793 gfx::Point mouse_location = | |
| 2794 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2795 generator.MoveMouseTo(mouse_location); | |
| 2796 | |
| 2797 generator.PressRightButton(); | |
| 2798 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2799 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2800 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2801 IsEmpty()); | |
| 2802 | |
| 2803 generator.ReleaseRightButton(); | |
| 2804 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2805 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2806 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2807 IsEmpty()); | |
| 2808 | |
| 2809 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2810 test_api_->overflow_bubble()->IsShowing()); | |
| 2811 } | |
| 2812 | |
| 2813 // Tests ink drop state transitions for the overflow button when it is active | |
| 2814 // and the user clicks on it. | |
| 2815 TEST_F(ShelfViewInkDropTest, OverflowButtonActiveMouseDeactivate) { | |
| 2816 InitOverflowButtonInkDrop(); | |
| 2817 | |
| 2818 AddButtonsUntilOverflow(); | |
| 2819 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2820 | |
| 2821 test_api_->ShowOverflowBubble(); | |
| 2822 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 2823 test_api_->overflow_bubble()->IsShowing()); | |
| 2824 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2825 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2826 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2827 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2828 | |
| 2829 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2830 gfx::Point mouse_location = | |
| 2831 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2832 generator.MoveMouseTo(mouse_location); | |
| 2833 | |
| 2834 generator.PressLeftButton(); | |
| 2835 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2836 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2837 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2838 IsEmpty()); | |
| 2839 | |
| 2840 generator.ReleaseLeftButton(); | |
| 2841 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2842 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2843 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2844 ElementsAre(views::InkDropState::DEACTIVATED)); | |
| 2845 | |
| 2846 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2847 test_api_->overflow_bubble()->IsShowing()); | |
| 2848 } | |
| 2849 | |
| 2850 // Tests ink drop state transitions for the overflow button when it is active | |
| 2851 // and the user presses left mouse button on it and drags it out of the button | |
| 2852 // bounds. | |
| 2853 TEST_F(ShelfViewInkDropTest, OverflowButtonActiveMouseDragOut) { | |
| 2854 InitOverflowButtonInkDrop(); | |
| 2855 | |
| 2856 AddButtonsUntilOverflow(); | |
| 2857 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2858 | |
| 2859 test_api_->ShowOverflowBubble(); | |
| 2860 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 2861 test_api_->overflow_bubble()->IsShowing()); | |
| 2862 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2863 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2864 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2865 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2866 | |
| 2867 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2868 gfx::Point mouse_location = | |
| 2869 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2870 generator.MoveMouseTo(mouse_location); | |
| 2871 | |
| 2872 generator.PressLeftButton(); | |
| 2873 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2874 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2875 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2876 IsEmpty()); | |
| 2877 | |
| 2878 generator.MoveMouseBy(overflow_button_->width(), 0); | |
| 2879 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2880 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2881 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2882 IsEmpty()); | |
| 2883 | |
| 2884 generator.ReleaseLeftButton(); | |
| 2885 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2886 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2887 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2888 IsEmpty()); | |
| 2889 | |
| 2890 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 2891 test_api_->overflow_bubble()->IsShowing()); | |
| 2892 } | |
| 2893 | |
| 2894 // Tests ink drop state transitions for the overflow button when it is active | |
| 2895 // and the user presses left mouse button on it and drags it out of the button | |
| 2896 // bounds and back. | |
| 2897 TEST_F(ShelfViewInkDropTest, OverflowButtonActiveMouseDragOutAndBack) { | |
| 2898 InitOverflowButtonInkDrop(); | |
| 2899 | |
| 2900 AddButtonsUntilOverflow(); | |
| 2901 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2902 | |
| 2903 test_api_->ShowOverflowBubble(); | |
| 2904 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 2905 test_api_->overflow_bubble()->IsShowing()); | |
| 2906 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2907 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2908 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2909 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2910 | |
| 2911 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2912 gfx::Point mouse_location = | |
| 2913 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2914 generator.MoveMouseTo(mouse_location); | |
| 2915 | |
| 2916 generator.PressLeftButton(); | |
| 2917 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2918 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2919 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2920 IsEmpty()); | |
| 2921 | |
| 2922 generator.MoveMouseBy(overflow_button_->width(), 0); | |
| 2923 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2924 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2925 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2926 IsEmpty()); | |
| 2927 | |
| 2928 generator.MoveMouseBy(-overflow_button_->width(), 0); | |
| 2929 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2930 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2931 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2932 IsEmpty()); | |
| 2933 | |
| 2934 generator.ReleaseLeftButton(); | |
| 2935 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2936 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2937 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2938 ElementsAre(views::InkDropState::DEACTIVATED)); | |
| 2939 | |
| 2940 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2941 test_api_->overflow_bubble()->IsShowing()); | |
| 2942 } | |
| 2943 | |
| 2944 // Tests ink drop state transitions for the overflow button when it is active | |
| 2945 // and the user right clicks on the button to show the context menu. | |
| 2946 TEST_F(ShelfViewInkDropTest, OverflowButtonActiveMouseContextMenu) { | |
| 2947 InitOverflowButtonInkDrop(); | |
| 2948 | |
| 2949 AddButtonsUntilOverflow(); | |
| 2950 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2951 | |
| 2952 test_api_->ShowOverflowBubble(); | |
| 2953 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 2954 test_api_->overflow_bubble()->IsShowing()); | |
| 2955 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2956 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2957 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2958 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2959 | |
| 2960 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2961 gfx::Point mouse_location = | |
| 2962 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2963 generator.MoveMouseTo(mouse_location); | |
| 2964 | |
| 2965 generator.PressRightButton(); | |
| 2966 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2967 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2968 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2969 IsEmpty()); | |
| 2970 | |
| 2971 generator.ReleaseRightButton(); | |
| 2972 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2973 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2974 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2975 IsEmpty()); | |
| 2976 | |
| 2977 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 2978 test_api_->overflow_bubble()->IsShowing()); | |
| 2979 } | |
| 2980 | |
| 2981 #if !defined(OS_WIN) | |
| 2982 // There is no ink drop effect for gesture events on Windows. | |
| 2983 | |
| 2984 // Tests ink drop state transitions for the overflow button when the user taps | |
| 2985 // on it. | |
| 2986 TEST_F(ShelfViewInkDropTest, OverflowButtonTouchActivate) { | |
| 2987 InitOverflowButtonInkDrop(); | |
| 2988 | |
| 2989 AddButtonsUntilOverflow(); | |
| 2990 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2991 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2992 test_api_->overflow_bubble()->IsShowing()); | |
| 2993 | |
| 2994 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2995 gfx::Point touch_location = | |
| 2996 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2997 generator.set_current_location(touch_location); | |
| 2998 | |
| 2999 generator.PressTouch(); | |
| 3000 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 3001 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3002 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3003 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 3004 | |
| 3005 generator.ReleaseTouch(); | |
| 3006 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3007 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3008 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3009 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 3010 | |
| 3011 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 3012 test_api_->overflow_bubble()->IsShowing()); | |
| 3013 } | |
| 3014 | |
| 3015 // Tests ink drop state transitions for the overflow button when the user taps | |
| 3016 // down on it and drags it out of the button bounds. | |
| 3017 TEST_F(ShelfViewInkDropTest, OverflowButtonTouchDragOut) { | |
| 3018 InitOverflowButtonInkDrop(); | |
| 3019 | |
| 3020 AddButtonsUntilOverflow(); | |
| 3021 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 3022 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 3023 test_api_->overflow_bubble()->IsShowing()); | |
| 3024 | |
| 3025 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3026 gfx::Point touch_location = | |
| 3027 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 3028 generator.set_current_location(touch_location); | |
| 3029 | |
| 3030 generator.PressTouch(); | |
| 3031 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 3032 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3033 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3034 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 3035 | |
| 3036 touch_location.Offset(overflow_button_->width(), 0); | |
| 3037 generator.MoveTouch(touch_location); | |
| 3038 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3039 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3040 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3041 ElementsAre(views::InkDropState::HIDDEN)); | |
| 3042 | |
| 3043 generator.ReleaseTouch(); | |
| 3044 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3045 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3046 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3047 IsEmpty()); | |
| 3048 | |
| 3049 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 3050 test_api_->overflow_bubble()->IsShowing()); | |
| 3051 } | |
| 3052 | |
| 3053 // Tests ink drop state transitions for the overflow button when the user taps | |
| 3054 // down on it and drags it out of the button bounds and back. | |
| 3055 TEST_F(ShelfViewInkDropTest, OverflowButtonTouchDragOutAndBack) { | |
| 3056 InitOverflowButtonInkDrop(); | |
| 3057 | |
| 3058 AddButtonsUntilOverflow(); | |
| 3059 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 3060 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 3061 test_api_->overflow_bubble()->IsShowing()); | |
| 3062 | |
| 3063 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3064 gfx::Point touch_location = | |
| 3065 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 3066 generator.set_current_location(touch_location); | |
| 3067 | |
| 3068 generator.PressTouch(); | |
| 3069 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 3070 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3071 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3072 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 3073 | |
| 3074 touch_location.Offset(overflow_button_->width(), 0); | |
| 3075 generator.MoveTouch(touch_location); | |
| 3076 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3077 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3078 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3079 ElementsAre(views::InkDropState::HIDDEN)); | |
| 3080 | |
| 3081 touch_location.Offset(-overflow_button_->width(), 0); | |
| 3082 generator.MoveTouch(touch_location); | |
| 3083 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3084 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3085 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3086 IsEmpty()); | |
| 3087 | |
| 3088 generator.ReleaseTouch(); | |
| 3089 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3090 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3091 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3092 IsEmpty()); | |
| 3093 | |
| 3094 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 3095 test_api_->overflow_bubble()->IsShowing()); | |
| 3096 } | |
| 3097 | |
| 3098 // Tests ink drop state transitions for the overflow button when the user long | |
| 3099 // presses on the button to show the context menu. | |
| 3100 TEST_F(ShelfViewInkDropTest, OverflowButtonTouchContextMenu) { | |
| 3101 InitOverflowButtonInkDrop(); | |
| 3102 | |
| 3103 AddButtonsUntilOverflow(); | |
| 3104 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 3105 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 3106 test_api_->overflow_bubble()->IsShowing()); | |
| 3107 | |
| 3108 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3109 gfx::Point touch_location = | |
| 3110 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 3111 generator.set_current_location(touch_location); | |
| 3112 | |
| 3113 { | |
| 3114 RunAllPendingInMessageLoop(); | |
| 3115 ScopedMockTaskRunnerWrapper mock_task_runner; | |
| 3116 | |
| 3117 generator.PressTouch(); | |
| 3118 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 3119 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3120 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3121 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 3122 | |
| 3123 mock_task_runner.FastForwardUntilNoTasksRemain(); | |
| 3124 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3125 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3126 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3127 ElementsAre(views::InkDropState::ALTERNATE_ACTION_PENDING, | |
| 3128 views::InkDropState::HIDDEN)); | |
|
bruthig
2016/08/25 19:18:35
I kind of expect the ALTERNATE_ACTION_PENDING to b
mohsen
2016/08/30 18:03:32
Currently, ALTERNATE_ACTION_PENDING is used on a l
bruthig
2016/09/01 16:12:54
Seems reasonable, if we wanted it to perform an AL
| |
| 3129 | |
| 3130 generator.ReleaseTouch(); | |
| 3131 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3132 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3133 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3134 IsEmpty()); | |
| 3135 | |
| 3136 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 3137 test_api_->overflow_bubble()->IsShowing()); | |
| 3138 } | |
| 3139 } | |
| 3140 | |
| 3141 // Tests ink drop state transitions for the overflow button when it is active | |
| 3142 // and the user taps on it. | |
| 3143 TEST_F(ShelfViewInkDropTest, OverflowButtonActiveTouchDeactivate) { | |
| 3144 InitOverflowButtonInkDrop(); | |
| 3145 | |
| 3146 AddButtonsUntilOverflow(); | |
| 3147 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 3148 | |
| 3149 test_api_->ShowOverflowBubble(); | |
| 3150 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 3151 test_api_->overflow_bubble()->IsShowing()); | |
| 3152 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3153 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3154 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3155 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 3156 | |
| 3157 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3158 gfx::Point touch_location = | |
| 3159 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 3160 generator.set_current_location(touch_location); | |
| 3161 | |
| 3162 generator.PressTouch(); | |
| 3163 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3164 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3165 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3166 IsEmpty()); | |
| 3167 | |
| 3168 generator.ReleaseTouch(); | |
| 3169 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3170 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3171 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3172 ElementsAre(views::InkDropState::DEACTIVATED, | |
| 3173 views::InkDropState::HIDDEN)); | |
| 3174 | |
| 3175 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 3176 test_api_->overflow_bubble()->IsShowing()); | |
| 3177 } | |
| 3178 | |
| 3179 // Tests ink drop state transitions for the overflow button when it is active | |
| 3180 // and the user taps down on it and drags it out of the button bounds. | |
| 3181 TEST_F(ShelfViewInkDropTest, OverflowButtonActiveTouchDragOut) { | |
| 3182 InitOverflowButtonInkDrop(); | |
| 3183 | |
| 3184 AddButtonsUntilOverflow(); | |
| 3185 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 3186 | |
| 3187 test_api_->ShowOverflowBubble(); | |
| 3188 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 3189 test_api_->overflow_bubble()->IsShowing()); | |
| 3190 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3191 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3192 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3193 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 3194 | |
| 3195 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3196 gfx::Point touch_location = | |
| 3197 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 3198 generator.set_current_location(touch_location); | |
| 3199 | |
| 3200 generator.PressTouch(); | |
| 3201 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3202 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3203 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3204 IsEmpty()); | |
| 3205 | |
| 3206 touch_location.Offset(overflow_button_->width(), 0); | |
| 3207 generator.MoveTouch(touch_location); | |
| 3208 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3209 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3210 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3211 IsEmpty()); | |
| 3212 | |
| 3213 generator.ReleaseTouch(); | |
| 3214 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3215 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3216 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3217 IsEmpty()); | |
| 3218 | |
| 3219 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 3220 test_api_->overflow_bubble()->IsShowing()); | |
| 3221 } | |
| 3222 | |
| 3223 // Tests ink drop state transitions for the overflow button when it is active | |
| 3224 // and the user taps down on it and drags it out of the button bounds and back. | |
| 3225 TEST_F(ShelfViewInkDropTest, OverflowButtonActiveTouchDragOutAndBack) { | |
| 3226 InitOverflowButtonInkDrop(); | |
| 3227 | |
| 3228 AddButtonsUntilOverflow(); | |
| 3229 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 3230 | |
| 3231 test_api_->ShowOverflowBubble(); | |
| 3232 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 3233 test_api_->overflow_bubble()->IsShowing()); | |
| 3234 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3235 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3236 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3237 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 3238 | |
| 3239 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3240 gfx::Point touch_location = | |
| 3241 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 3242 generator.set_current_location(touch_location); | |
| 3243 | |
| 3244 generator.PressTouch(); | |
| 3245 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3246 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3247 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3248 IsEmpty()); | |
| 3249 | |
| 3250 touch_location.Offset(overflow_button_->width(), 0); | |
| 3251 generator.MoveTouch(touch_location); | |
| 3252 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3253 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3254 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3255 IsEmpty()); | |
| 3256 | |
| 3257 touch_location.Offset(-overflow_button_->width(), 0); | |
| 3258 generator.MoveTouch(touch_location); | |
| 3259 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3260 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3261 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3262 IsEmpty()); | |
| 3263 | |
| 3264 generator.ReleaseTouch(); | |
| 3265 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3266 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3267 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3268 IsEmpty()); | |
| 3269 | |
| 3270 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 3271 test_api_->overflow_bubble()->IsShowing()); | |
| 3272 } | |
| 3273 | |
| 3274 // Tests ink drop state transitions for the overflow button when it is active | |
| 3275 // and the user long presses on the button to show the context menu. | |
| 3276 TEST_F(ShelfViewInkDropTest, OverflowButtonActiveTouchContextMenu) { | |
| 3277 InitOverflowButtonInkDrop(); | |
| 3278 | |
| 3279 AddButtonsUntilOverflow(); | |
| 3280 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 3281 | |
| 3282 test_api_->ShowOverflowBubble(); | |
| 3283 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 3284 test_api_->overflow_bubble()->IsShowing()); | |
| 3285 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3286 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3287 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3288 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 3289 | |
| 3290 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3291 gfx::Point touch_location = | |
| 3292 overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 3293 generator.set_current_location(touch_location); | |
| 3294 | |
| 3295 { | |
| 3296 RunAllPendingInMessageLoop(); | |
| 3297 ScopedMockTaskRunnerWrapper mock_task_runner; | |
| 3298 | |
| 3299 generator.PressTouch(); | |
| 3300 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3301 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3302 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3303 IsEmpty()); | |
| 3304 | |
| 3305 mock_task_runner.FastForwardUntilNoTasksRemain(); | |
| 3306 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3307 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3308 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3309 IsEmpty()); | |
| 3310 | |
| 3311 generator.ReleaseTouch(); | |
| 3312 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3313 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3314 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3315 IsEmpty()); | |
| 3316 | |
| 3317 EXPECT_TRUE(test_api_->overflow_bubble() && | |
| 3318 test_api_->overflow_bubble()->IsShowing()); | |
| 3319 } | |
| 3320 } | |
| 3321 | |
| 3322 #endif // !defined(OS_WIN) | |
| 3323 | |
| 2582 } // namespace test | 3324 } // namespace test |
| 2583 } // namespace ash | 3325 } // namespace ash |
| OLD | NEW |