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_menu_model.h" | 18 #include "ash/common/shelf/shelf_menu_model.h" |
| 18 #include "ash/common/shelf/shelf_model.h" | 19 #include "ash/common/shelf/shelf_model.h" |
| 19 #include "ash/common/shelf/shelf_tooltip_manager.h" | 20 #include "ash/common/shelf/shelf_tooltip_manager.h" |
| 20 #include "ash/common/shelf/shelf_widget.h" | 21 #include "ash/common/shelf/shelf_widget.h" |
| 21 #include "ash/common/shelf/wm_shelf.h" | 22 #include "ash/common/shelf/wm_shelf.h" |
| 22 #include "ash/common/shelf/wm_shelf_observer.h" | 23 #include "ash/common/shelf/wm_shelf_observer.h" |
| 23 #include "ash/common/shell_window_ids.h" | 24 #include "ash/common/shell_window_ids.h" |
| 24 #include "ash/common/system/web_notification/web_notification_tray.h" | 25 #include "ash/common/system/web_notification/web_notification_tray.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 36 #include "ash/test/test_shelf_item_delegate.h" | 37 #include "ash/test/test_shelf_item_delegate.h" |
| 37 #include "ash/test/test_shell_delegate.h" | 38 #include "ash/test/test_shell_delegate.h" |
| 38 #include "ash/test/test_system_tray_delegate.h" | 39 #include "ash/test/test_system_tray_delegate.h" |
| 39 #include "base/i18n/rtl.h" | 40 #include "base/i18n/rtl.h" |
| 40 #include "base/macros.h" | 41 #include "base/macros.h" |
| 41 #include "base/memory/ptr_util.h" | 42 #include "base/memory/ptr_util.h" |
| 42 #include "base/run_loop.h" | 43 #include "base/run_loop.h" |
| 43 #include "base/strings/string_number_conversions.h" | 44 #include "base/strings/string_number_conversions.h" |
| 44 #include "base/strings/utf_string_conversions.h" | 45 #include "base/strings/utf_string_conversions.h" |
| 45 #include "base/test/histogram_tester.h" | 46 #include "base/test/histogram_tester.h" |
| 47 #include "base/test/test_mock_time_task_runner.h" | |
| 46 #include "base/test/user_action_tester.h" | 48 #include "base/test/user_action_tester.h" |
| 47 #include "base/threading/thread_task_runner_handle.h" | 49 #include "base/threading/thread_task_runner_handle.h" |
| 48 #include "base/time/time.h" | 50 #include "base/time/time.h" |
| 49 #include "testing/gmock/include/gmock/gmock.h" | 51 #include "testing/gmock/include/gmock/gmock.h" |
| 50 #include "ui/app_list/presenter/app_list_presenter.h" | 52 #include "ui/app_list/presenter/app_list_presenter.h" |
| 51 #include "ui/aura/test/aura_test_base.h" | 53 #include "ui/aura/test/aura_test_base.h" |
| 52 #include "ui/aura/window.h" | 54 #include "ui/aura/window.h" |
| 53 #include "ui/aura/window_event_dispatcher.h" | 55 #include "ui/aura/window_event_dispatcher.h" |
| 54 #include "ui/compositor/layer.h" | 56 #include "ui/compositor/layer.h" |
| 55 #include "ui/events/event.h" | 57 #include "ui/events/event.h" |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 EXPECT_EQ(total_item_count, model_->item_count()); | 666 EXPECT_EQ(total_item_count, model_->item_count()); |
| 665 EXPECT_EQ(last_visible_item_id_in_shelf, | 667 EXPECT_EQ(last_visible_item_id_in_shelf, |
| 666 GetItemId(test_api_for_overflow.GetFirstVisibleIndex())); | 668 GetItemId(test_api_for_overflow.GetFirstVisibleIndex())); |
| 667 EXPECT_EQ(second_last_visible_item_id_in_shelf, | 669 EXPECT_EQ(second_last_visible_item_id_in_shelf, |
| 668 GetItemId(test_api_->GetLastVisibleIndex())); | 670 GetItemId(test_api_->GetLastVisibleIndex())); |
| 669 EXPECT_EQ(first_visible_item_id_in_overflow, | 671 EXPECT_EQ(first_visible_item_id_in_overflow, |
| 670 GetItemId(test_api_for_overflow.GetFirstVisibleIndex() + 1)); | 672 GetItemId(test_api_for_overflow.GetFirstVisibleIndex() + 1)); |
| 671 EXPECT_EQ(second_last_visible_item_id_in_overflow, | 673 EXPECT_EQ(second_last_visible_item_id_in_overflow, |
| 672 GetItemId(test_api_for_overflow.GetLastVisibleIndex())); | 674 GetItemId(test_api_for_overflow.GetLastVisibleIndex())); |
| 673 } | 675 } |
| 676 test_api_->HideOverflowBubble(); | |
| 674 } | 677 } |
| 675 | 678 |
| 676 // Returns the item's ShelfID at |index|. | 679 // Returns the item's ShelfID at |index|. |
| 677 ShelfID GetItemId(int index) { | 680 ShelfID GetItemId(int index) { |
| 678 DCHECK_GE(index, 0); | 681 DCHECK_GE(index, 0); |
| 679 return model_->items()[index].id; | 682 return model_->items()[index].id; |
| 680 } | 683 } |
| 681 | 684 |
| 682 void ReplaceShelfDelegate() { | 685 void ReplaceShelfDelegate() { |
| 683 shelf_delegate_ = new TestShelfDelegateForShelfView(); | 686 shelf_delegate_ = new TestShelfDelegateForShelfView(); |
| (...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2122 } // namespace | 2125 } // namespace |
| 2123 | 2126 |
| 2124 // Test fixture that forces material design mode in order to test ink drop | 2127 // Test fixture that forces material design mode in order to test ink drop |
| 2125 // ripples on shelf. | 2128 // ripples on shelf. |
| 2126 class ShelfViewInkDropTest : public ShelfViewTest { | 2129 class ShelfViewInkDropTest : public ShelfViewTest { |
| 2127 public: | 2130 public: |
| 2128 ShelfViewInkDropTest() {} | 2131 ShelfViewInkDropTest() {} |
| 2129 ~ShelfViewInkDropTest() override {} | 2132 ~ShelfViewInkDropTest() override {} |
| 2130 | 2133 |
| 2131 void SetUp() override { | 2134 void SetUp() override { |
| 2132 shell_delegate_ = new TestAppListShellDelegate; | 2135 if (!ash_test_helper()->test_shell_delegate()) { |
|
James Cook
2016/09/12 02:54:47
This is odd. I see from the discussion that a subc
mohsen
2016/09/14 18:34:42
Done.
| |
| 2133 ash_test_helper()->set_test_shell_delegate(shell_delegate_); | 2136 shell_delegate_ = new TestAppListShellDelegate; |
| 2137 ash_test_helper()->set_test_shell_delegate(shell_delegate_); | |
| 2138 } | |
| 2134 | 2139 |
| 2135 set_material_mode(ash::MaterialDesignController::MATERIAL_EXPERIMENTAL); | 2140 set_material_mode(ash::MaterialDesignController::MATERIAL_EXPERIMENTAL); |
| 2136 | 2141 |
| 2137 ShelfViewTest::SetUp(); | 2142 ShelfViewTest::SetUp(); |
| 2138 } | 2143 } |
| 2139 | 2144 |
| 2140 protected: | 2145 protected: |
| 2141 void InitAppListButtonInkDrop() { | 2146 void InitAppListButtonInkDrop() { |
| 2142 app_list_button_ = shelf_view_->GetAppListButton(); | 2147 app_list_button_ = shelf_view_->GetAppListButton(); |
| 2143 | 2148 |
| 2144 views::InkDropImpl* ink_drop_impl = | 2149 views::InkDropImpl* ink_drop_impl = |
| 2145 new views::InkDropImpl(app_list_button_); | 2150 new views::InkDropImpl(app_list_button_); |
| 2146 app_list_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | 2151 app_list_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); |
| 2147 views::test::InkDropHostViewTestApi(app_list_button_) | 2152 views::test::InkDropHostViewTestApi(app_list_button_) |
| 2148 .SetInkDrop(base::WrapUnique(app_list_button_ink_drop_), false); | 2153 .SetInkDrop(base::WrapUnique(app_list_button_ink_drop_), false); |
| 2149 } | 2154 } |
| 2150 | 2155 |
| 2151 void InitBrowserButtonInkDrop() { | 2156 void InitBrowserButtonInkDrop() { |
| 2152 browser_button_ = test_api_->GetButton(browser_index_); | 2157 browser_button_ = test_api_->GetButton(browser_index_); |
| 2153 | 2158 |
| 2154 views::InkDropImpl* ink_drop_impl = new views::InkDropImpl(browser_button_); | 2159 views::InkDropImpl* ink_drop_impl = new views::InkDropImpl(browser_button_); |
| 2155 browser_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | 2160 browser_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); |
| 2156 views::test::InkDropHostViewTestApi(browser_button_) | 2161 views::test::InkDropHostViewTestApi(browser_button_) |
| 2157 .SetInkDrop(base::WrapUnique(browser_button_ink_drop_)); | 2162 .SetInkDrop(base::WrapUnique(browser_button_ink_drop_)); |
| 2158 } | 2163 } |
| 2159 | 2164 |
| 2160 void ShowAppList() { | 2165 void ShowAppList() { |
| 2166 DCHECK(shelf_delegate_); | |
| 2161 shell_delegate_->app_list_presenter()->Show(0); | 2167 shell_delegate_->app_list_presenter()->Show(0); |
| 2162 // Similar to real AppListPresenter, notify button that the app list is | 2168 // Similar to real AppListPresenter, notify button that the app list is |
| 2163 // shown. | 2169 // shown. |
| 2164 app_list_button_->OnAppListShown(); | 2170 app_list_button_->OnAppListShown(); |
| 2165 } | 2171 } |
| 2166 | 2172 |
| 2167 void DismissAppList() { | 2173 void DismissAppList() { |
| 2174 DCHECK(shelf_delegate_); | |
| 2168 shell_delegate_->app_list_presenter()->Dismiss(); | 2175 shell_delegate_->app_list_presenter()->Dismiss(); |
| 2169 // Similar to real AppListPresenter, notify button that the app list is | 2176 // Similar to real AppListPresenter, notify button that the app list is |
| 2170 // dismissed. | 2177 // dismissed. |
| 2171 app_list_button_->OnAppListDismissed(); | 2178 app_list_button_->OnAppListDismissed(); |
| 2172 } | 2179 } |
| 2173 | 2180 |
| 2174 void FinishAppListVisibilityChange() { | 2181 void FinishAppListVisibilityChange() { |
| 2182 DCHECK(shelf_delegate_); | |
| 2175 shell_delegate_->app_list_presenter()->FinishVisibilityChange(); | 2183 shell_delegate_->app_list_presenter()->FinishVisibilityChange(); |
| 2176 } | 2184 } |
| 2177 | 2185 |
| 2178 TestAppListShellDelegate* shell_delegate_ = nullptr; // Owned by Shell. | 2186 TestAppListShellDelegate* shell_delegate_ = nullptr; // Owned by Shell. |
| 2179 | 2187 |
| 2180 AppListButton* app_list_button_ = nullptr; | 2188 AppListButton* app_list_button_ = nullptr; |
| 2181 InkDropSpy* app_list_button_ink_drop_ = nullptr; | 2189 InkDropSpy* app_list_button_ink_drop_ = nullptr; |
| 2182 ShelfButton* browser_button_ = nullptr; | 2190 ShelfButton* browser_button_ = nullptr; |
| 2183 InkDropSpy* browser_button_ink_drop_ = nullptr; | 2191 InkDropSpy* browser_button_ink_drop_ = nullptr; |
| 2184 | 2192 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2566 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2574 ui::EF_LEFT_MOUSE_BUTTON, 0); |
| 2567 button->OnMouseReleased(release_event); | 2575 button->OnMouseReleased(release_event); |
| 2568 test_api_->CloseMenu(); | 2576 test_api_->CloseMenu(); |
| 2569 EXPECT_EQ(views::InkDropState::HIDDEN, | 2577 EXPECT_EQ(views::InkDropState::HIDDEN, |
| 2570 browser_button_ink_drop_->GetTargetInkDropState()); | 2578 browser_button_ink_drop_->GetTargetInkDropState()); |
| 2571 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | 2579 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
| 2572 ElementsAre(views::InkDropState::ACTIVATED, | 2580 ElementsAre(views::InkDropState::ACTIVATED, |
| 2573 views::InkDropState::DEACTIVATED)); | 2581 views::InkDropState::DEACTIVATED)); |
| 2574 } | 2582 } |
| 2575 | 2583 |
| 2584 namespace { | |
| 2585 | |
| 2586 // An empty menu model for shell context menu just to have a menu. | |
| 2587 class TestShellMenuModel : public ui::SimpleMenuModel, | |
| 2588 public ui::SimpleMenuModel::Delegate { | |
| 2589 public: | |
| 2590 TestShellMenuModel() : ui::SimpleMenuModel(this) {} | |
| 2591 ~TestShellMenuModel() override {} | |
| 2592 | |
| 2593 private: | |
| 2594 // ui::SimpleMenuModel::Delegate: | |
| 2595 bool IsCommandIdChecked(int command_id) const override { return false; } | |
| 2596 bool IsCommandIdEnabled(int command_id) const override { return true; } | |
| 2597 void ExecuteCommand(int command_id, int event_flags) override {} | |
| 2598 | |
| 2599 DISALLOW_COPY_AND_ASSIGN(TestShellMenuModel); | |
| 2600 }; | |
| 2601 | |
| 2602 // A test ShellDelegate implementation for overflow button tests that returns a | |
| 2603 // TestShelfMenuModel for the shell context menu. | |
| 2604 class TestOverflowButtonShellDelegate : public TestShellDelegate { | |
| 2605 public: | |
| 2606 TestOverflowButtonShellDelegate() {} | |
| 2607 ~TestOverflowButtonShellDelegate() override {} | |
| 2608 | |
| 2609 // TestShellDelegate: | |
| 2610 ui::MenuModel* CreateContextMenu(WmShelf* wm_shelf, | |
| 2611 const ShelfItem* item) override { | |
| 2612 // Caller takes ownership of the returned object. | |
| 2613 return new TestShellMenuModel; | |
| 2614 } | |
| 2615 | |
| 2616 private: | |
| 2617 DISALLOW_COPY_AND_ASSIGN(TestOverflowButtonShellDelegate); | |
| 2618 }; | |
| 2619 | |
| 2620 // A scoped wrapper around TestMockTimeTaskRunner that replaces message loop's | |
| 2621 // task runner with a TestMockTimeTaskRunner and resets it back at the end of | |
| 2622 // the scope. | |
| 2623 class ScopedMockTaskRunnerWrapper { | |
| 2624 public: | |
| 2625 ScopedMockTaskRunnerWrapper() { | |
| 2626 mock_task_runner_ = new base::TestMockTimeTaskRunner; | |
| 2627 previous_task_runner_ = base::MessageLoop::current()->task_runner(); | |
| 2628 base::MessageLoop::current()->SetTaskRunner(mock_task_runner_); | |
| 2629 } | |
| 2630 | |
| 2631 ~ScopedMockTaskRunnerWrapper() { | |
| 2632 DCHECK_EQ(mock_task_runner_, base::MessageLoop::current()->task_runner()); | |
| 2633 mock_task_runner_->ClearPendingTasks(); | |
| 2634 base::MessageLoop::current()->SetTaskRunner(previous_task_runner_); | |
| 2635 } | |
| 2636 | |
| 2637 void FastForwardUntilNoTasksRemain() { | |
| 2638 mock_task_runner_->FastForwardUntilNoTasksRemain(); | |
| 2639 } | |
| 2640 | |
| 2641 private: | |
| 2642 scoped_refptr<base::TestMockTimeTaskRunner> mock_task_runner_; | |
| 2643 scoped_refptr<base::SingleThreadTaskRunner> previous_task_runner_; | |
| 2644 | |
| 2645 DISALLOW_COPY_AND_ASSIGN(ScopedMockTaskRunnerWrapper); | |
| 2646 }; | |
| 2647 | |
| 2648 } // namespace | |
| 2649 | |
| 2650 // Test fixture for testing material design ink drop on overflow button. | |
| 2651 class OverflowButtonInkDropTest : public ShelfViewInkDropTest { | |
| 2652 public: | |
| 2653 OverflowButtonInkDropTest() {} | |
| 2654 ~OverflowButtonInkDropTest() override {} | |
| 2655 | |
| 2656 void SetUp() override { | |
| 2657 // Shell takes ownership of the test shell delegate. | |
| 2658 ash_test_helper()->set_test_shell_delegate( | |
| 2659 new TestOverflowButtonShellDelegate); | |
| 2660 | |
| 2661 ShelfViewInkDropTest::SetUp(); | |
| 2662 | |
| 2663 InitOverflowButtonInkDrop(); | |
| 2664 | |
| 2665 AddButtonsUntilOverflow(); | |
| 2666 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | |
| 2667 EXPECT_FALSE(test_api_->overflow_bubble() && | |
|
James Cook
2016/09/12 02:54:47
this is odd. I think you should ASSERT_TRUE(test_a
mohsen
2016/09/14 18:34:43
I think overflow_bubble is not necessarily existin
| |
| 2668 test_api_->overflow_bubble()->IsShowing()); | |
| 2669 } | |
| 2670 | |
| 2671 protected: | |
| 2672 gfx::Point GetScreenPointInsideOverflowButton() const { | |
| 2673 return overflow_button_->GetBoundsInScreen().CenterPoint(); | |
| 2674 } | |
| 2675 | |
| 2676 gfx::Point GetScreenPointOutsideOverflowButton() const { | |
| 2677 gfx::Point point = GetScreenPointInsideOverflowButton(); | |
| 2678 point.Offset(overflow_button_->width(), 0); | |
| 2679 return point; | |
| 2680 } | |
| 2681 | |
| 2682 OverflowButton* overflow_button_ = nullptr; | |
| 2683 InkDropSpy* overflow_button_ink_drop_ = nullptr; | |
| 2684 | |
| 2685 private: | |
| 2686 void InitOverflowButtonInkDrop() { | |
|
James Cook
2016/09/12 02:54:47
nit: I think it would be clearer to just inline th
mohsen
2016/09/14 18:34:42
Done.
| |
| 2687 overflow_button_ = test_api_->overflow_button(); | |
| 2688 | |
| 2689 views::InkDropImpl* ink_drop_impl = | |
| 2690 new views::InkDropImpl(overflow_button_); | |
| 2691 overflow_button_ink_drop_ = new InkDropSpy(base::WrapUnique(ink_drop_impl)); | |
|
James Cook
2016/09/12 02:54:47
nit: either base::MakeUnique<>, or inline the call
mohsen
2016/09/14 18:34:43
Not sure what you exactly mean. I updated these li
James Cook
2016/09/14 21:50:05
Yes. MakeUnique<Foo> makes me happy. WrapUnique(ne
| |
| 2692 views::test::InkDropHostViewTestApi(overflow_button_) | |
| 2693 .SetInkDrop(base::WrapUnique(overflow_button_ink_drop_)); | |
| 2694 } | |
| 2695 | |
| 2696 DISALLOW_COPY_AND_ASSIGN(OverflowButtonInkDropTest); | |
| 2697 }; | |
| 2698 | |
| 2699 // Tests ink drop state transitions for the overflow button when the overflow | |
| 2700 // bubble is shown or hidden. | |
| 2701 TEST_F(OverflowButtonInkDropTest, OnOverflowBubbleShowHide) { | |
| 2702 test_api_->ShowOverflowBubble(); | |
| 2703 ASSERT_TRUE(test_api_->overflow_bubble()); | |
| 2704 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 2705 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2706 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2707 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2708 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2709 | |
| 2710 test_api_->HideOverflowBubble(); | |
| 2711 EXPECT_FALSE(test_api_->overflow_bubble() && | |
|
James Cook
2016/09/12 02:54:47
I don't think you need the part before the &&. If
mohsen
2016/09/14 18:34:43
Fixed.
| |
| 2712 test_api_->overflow_bubble()->IsShowing()); | |
| 2713 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2714 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2715 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2716 ElementsAre(views::InkDropState::DEACTIVATED)); | |
| 2717 } | |
| 2718 | |
| 2719 // Tests ink drop state transitions for the overflow button when the user clicks | |
| 2720 // on it. | |
| 2721 TEST_F(OverflowButtonInkDropTest, MouseActivate) { | |
| 2722 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2723 gfx::Point mouse_location = GetScreenPointInsideOverflowButton(); | |
| 2724 generator.MoveMouseTo(mouse_location); | |
| 2725 | |
| 2726 generator.PressLeftButton(); | |
| 2727 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2728 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2729 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2730 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2731 | |
| 2732 generator.ReleaseLeftButton(); | |
| 2733 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2734 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2735 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2736 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2737 | |
| 2738 ASSERT_TRUE(test_api_->overflow_bubble()); | |
| 2739 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 2740 } | |
| 2741 | |
| 2742 // Tests ink drop state transitions for the overflow button when the user | |
| 2743 // presses left mouse button on it and drags it out of the button bounds. | |
| 2744 TEST_F(OverflowButtonInkDropTest, MouseDragOut) { | |
| 2745 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2746 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); | |
| 2747 | |
| 2748 generator.PressLeftButton(); | |
| 2749 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2750 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2751 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2752 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2753 | |
| 2754 generator.MoveMouseTo(GetScreenPointOutsideOverflowButton()); | |
| 2755 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2756 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2757 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2758 ElementsAre(views::InkDropState::HIDDEN)); | |
| 2759 | |
| 2760 generator.ReleaseLeftButton(); | |
| 2761 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2762 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2763 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2764 IsEmpty()); | |
| 2765 | |
| 2766 EXPECT_FALSE(test_api_->overflow_bubble() && | |
|
James Cook
2016/09/12 02:54:47
ditto
mohsen
2016/09/14 18:34:43
Fixed.
| |
| 2767 test_api_->overflow_bubble()->IsShowing()); | |
| 2768 } | |
| 2769 | |
| 2770 // Tests ink drop state transitions for the overflow button when the user | |
| 2771 // presses left mouse button on it and drags it out of the button bounds and | |
| 2772 // back. | |
| 2773 TEST_F(OverflowButtonInkDropTest, MouseDragOutAndBack) { | |
| 2774 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2775 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); | |
| 2776 | |
| 2777 generator.PressLeftButton(); | |
| 2778 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2779 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2780 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2781 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2782 | |
| 2783 generator.MoveMouseTo(GetScreenPointOutsideOverflowButton()); | |
| 2784 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2785 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2786 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2787 ElementsAre(views::InkDropState::HIDDEN)); | |
| 2788 | |
| 2789 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); | |
|
James Cook
2016/09/12 02:54:47
btw, I like how you used GetScreenPointInside and
mohsen
2016/09/14 18:34:42
Thanks :-)
| |
| 2790 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2791 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2792 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2793 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2794 | |
| 2795 generator.ReleaseLeftButton(); | |
| 2796 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2797 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2798 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2799 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2800 | |
| 2801 ASSERT_TRUE(test_api_->overflow_bubble()); | |
| 2802 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 2803 } | |
| 2804 | |
| 2805 // Tests ink drop state transitions for the overflow button when the user right | |
| 2806 // clicks on the button to show the context menu. | |
| 2807 TEST_F(OverflowButtonInkDropTest, MouseContextMenu) { | |
| 2808 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2809 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); | |
| 2810 | |
| 2811 generator.PressRightButton(); | |
| 2812 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2813 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2814 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2815 IsEmpty()); | |
| 2816 | |
| 2817 generator.ReleaseRightButton(); | |
| 2818 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2819 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2820 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2821 IsEmpty()); | |
| 2822 | |
| 2823 EXPECT_FALSE(test_api_->overflow_bubble() && | |
|
James Cook
2016/09/12 02:54:47
ditto
mohsen
2016/09/14 18:34:43
Fixed.
| |
| 2824 test_api_->overflow_bubble()->IsShowing()); | |
| 2825 } | |
| 2826 | |
| 2827 #if !defined(OS_WIN) | |
| 2828 // There is no ink drop effect for gesture events on Windows. | |
|
James Cook
2016/09/12 02:54:47
nit: move comment above #if
mohsen
2016/09/14 18:34:42
Done. Also in other similar places in this file.
| |
| 2829 | |
| 2830 // Tests ink drop state transitions for the overflow button when the user taps | |
| 2831 // on it. | |
| 2832 TEST_F(OverflowButtonInkDropTest, TouchActivate) { | |
| 2833 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2834 generator.set_current_location(GetScreenPointInsideOverflowButton()); | |
| 2835 | |
| 2836 generator.PressTouch(); | |
| 2837 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2838 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2839 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2840 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2841 | |
| 2842 generator.ReleaseTouch(); | |
| 2843 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2844 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2845 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2846 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2847 | |
| 2848 ASSERT_TRUE(test_api_->overflow_bubble()); | |
| 2849 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 2850 } | |
| 2851 | |
| 2852 // Tests ink drop state transitions for the overflow button when the user taps | |
| 2853 // down on it and drags it out of the button bounds. | |
| 2854 TEST_F(OverflowButtonInkDropTest, TouchDragOut) { | |
| 2855 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2856 generator.set_current_location(GetScreenPointInsideOverflowButton()); | |
| 2857 | |
| 2858 generator.PressTouch(); | |
| 2859 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2860 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2861 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2862 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2863 | |
| 2864 generator.MoveTouch(GetScreenPointOutsideOverflowButton()); | |
| 2865 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2866 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2867 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2868 ElementsAre(views::InkDropState::HIDDEN)); | |
| 2869 | |
| 2870 generator.ReleaseTouch(); | |
| 2871 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2872 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2873 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2874 IsEmpty()); | |
| 2875 | |
| 2876 EXPECT_FALSE(test_api_->overflow_bubble() && | |
|
James Cook
2016/09/12 02:54:47
ditto
mohsen
2016/09/14 18:34:43
Fixed.
| |
| 2877 test_api_->overflow_bubble()->IsShowing()); | |
| 2878 } | |
| 2879 | |
| 2880 // Tests ink drop state transitions for the overflow button when the user taps | |
| 2881 // down on it and drags it out of the button bounds and back. | |
| 2882 TEST_F(OverflowButtonInkDropTest, TouchDragOutAndBack) { | |
| 2883 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2884 generator.set_current_location(GetScreenPointInsideOverflowButton()); | |
| 2885 | |
| 2886 generator.PressTouch(); | |
| 2887 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2888 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2889 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2890 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2891 | |
| 2892 generator.MoveTouch(GetScreenPointOutsideOverflowButton()); | |
| 2893 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2894 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2895 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2896 ElementsAre(views::InkDropState::HIDDEN)); | |
| 2897 | |
| 2898 generator.MoveTouch(GetScreenPointInsideOverflowButton()); | |
| 2899 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2900 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2901 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2902 IsEmpty()); | |
| 2903 | |
| 2904 generator.ReleaseTouch(); | |
| 2905 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2906 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2907 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2908 IsEmpty()); | |
| 2909 | |
| 2910 EXPECT_FALSE(test_api_->overflow_bubble() && | |
|
James Cook
2016/09/12 02:54:47
ditto and below
mohsen
2016/09/14 18:34:43
Fixed.
| |
| 2911 test_api_->overflow_bubble()->IsShowing()); | |
| 2912 } | |
| 2913 | |
| 2914 // Tests ink drop state transitions for the overflow button when the user long | |
| 2915 // presses on the button to show the context menu. | |
| 2916 TEST_F(OverflowButtonInkDropTest, TouchContextMenu) { | |
| 2917 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2918 generator.set_current_location(GetScreenPointInsideOverflowButton()); | |
| 2919 | |
| 2920 { | |
| 2921 RunAllPendingInMessageLoop(); | |
|
James Cook
2016/09/12 02:54:47
super nit: Move this above { so the first line has
mohsen
2016/09/14 18:34:43
Right. Done.
| |
| 2922 ScopedMockTaskRunnerWrapper mock_task_runner; | |
| 2923 | |
| 2924 generator.PressTouch(); | |
| 2925 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | |
| 2926 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2927 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2928 ElementsAre(views::InkDropState::ACTION_PENDING)); | |
| 2929 | |
| 2930 mock_task_runner.FastForwardUntilNoTasksRemain(); | |
| 2931 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2932 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2933 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2934 ElementsAre(views::InkDropState::ALTERNATE_ACTION_PENDING, | |
| 2935 views::InkDropState::HIDDEN)); | |
| 2936 | |
| 2937 generator.ReleaseTouch(); | |
| 2938 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2939 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2940 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2941 IsEmpty()); | |
| 2942 | |
| 2943 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2944 test_api_->overflow_bubble()->IsShowing()); | |
| 2945 } | |
| 2946 } | |
| 2947 | |
| 2948 #endif // !defined(OS_WIN) | |
| 2949 | |
| 2950 // Test fixture for testing material design ink drop on overflow button when it | |
| 2951 // is active. | |
| 2952 class OverflowButtonActiveInkDropTest : public OverflowButtonInkDropTest { | |
| 2953 public: | |
| 2954 OverflowButtonActiveInkDropTest() {} | |
| 2955 ~OverflowButtonActiveInkDropTest() override {} | |
| 2956 | |
| 2957 void SetUp() override { | |
| 2958 OverflowButtonInkDropTest::SetUp(); | |
| 2959 | |
| 2960 test_api_->ShowOverflowBubble(); | |
| 2961 ASSERT_TRUE(test_api_->overflow_bubble()); | |
| 2962 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 2963 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2964 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2965 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2966 ElementsAre(views::InkDropState::ACTIVATED)); | |
| 2967 } | |
| 2968 | |
| 2969 private: | |
| 2970 DISALLOW_COPY_AND_ASSIGN(OverflowButtonActiveInkDropTest); | |
| 2971 }; | |
| 2972 | |
| 2973 // Tests ink drop state transitions for the overflow button when it is active | |
| 2974 // and the user clicks on it. | |
| 2975 TEST_F(OverflowButtonActiveInkDropTest, MouseDeactivate) { | |
| 2976 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 2977 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); | |
| 2978 | |
| 2979 generator.PressLeftButton(); | |
| 2980 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 2981 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2982 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2983 IsEmpty()); | |
| 2984 | |
| 2985 generator.ReleaseLeftButton(); | |
| 2986 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 2987 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 2988 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 2989 ElementsAre(views::InkDropState::DEACTIVATED)); | |
| 2990 | |
| 2991 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 2992 test_api_->overflow_bubble()->IsShowing()); | |
| 2993 } | |
| 2994 | |
| 2995 // Tests ink drop state transitions for the overflow button when it is active | |
| 2996 // and the user presses left mouse button on it and drags it out of the button | |
| 2997 // bounds. | |
| 2998 TEST_F(OverflowButtonActiveInkDropTest, MouseDragOut) { | |
| 2999 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3000 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); | |
| 3001 | |
| 3002 generator.PressLeftButton(); | |
| 3003 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3004 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3005 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3006 IsEmpty()); | |
| 3007 | |
| 3008 generator.MoveMouseTo(GetScreenPointOutsideOverflowButton()); | |
| 3009 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3010 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3011 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3012 IsEmpty()); | |
| 3013 | |
| 3014 generator.ReleaseLeftButton(); | |
| 3015 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3016 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3017 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3018 IsEmpty()); | |
| 3019 | |
| 3020 ASSERT_TRUE(test_api_->overflow_bubble()); | |
| 3021 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 3022 } | |
| 3023 | |
| 3024 // Tests ink drop state transitions for the overflow button when it is active | |
| 3025 // and the user presses left mouse button on it and drags it out of the button | |
| 3026 // bounds and back. | |
| 3027 TEST_F(OverflowButtonActiveInkDropTest, MouseDragOutAndBack) { | |
| 3028 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3029 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); | |
| 3030 | |
| 3031 generator.PressLeftButton(); | |
| 3032 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3033 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3034 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3035 IsEmpty()); | |
| 3036 | |
| 3037 generator.MoveMouseTo(GetScreenPointOutsideOverflowButton()); | |
| 3038 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3039 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3040 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3041 IsEmpty()); | |
| 3042 | |
| 3043 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); | |
| 3044 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3045 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3046 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3047 IsEmpty()); | |
| 3048 | |
| 3049 generator.ReleaseLeftButton(); | |
| 3050 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3051 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3052 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3053 ElementsAre(views::InkDropState::DEACTIVATED)); | |
| 3054 | |
| 3055 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 3056 test_api_->overflow_bubble()->IsShowing()); | |
| 3057 } | |
| 3058 | |
| 3059 // Tests ink drop state transitions for the overflow button when it is active | |
| 3060 // and the user right clicks on the button to show the context menu. | |
| 3061 TEST_F(OverflowButtonActiveInkDropTest, MouseContextMenu) { | |
| 3062 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3063 generator.MoveMouseTo(GetScreenPointInsideOverflowButton()); | |
| 3064 | |
| 3065 generator.PressRightButton(); | |
| 3066 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3067 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3068 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3069 IsEmpty()); | |
| 3070 | |
| 3071 generator.ReleaseRightButton(); | |
| 3072 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3073 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3074 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3075 IsEmpty()); | |
| 3076 | |
| 3077 ASSERT_TRUE(test_api_->overflow_bubble()); | |
| 3078 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 3079 } | |
| 3080 | |
| 3081 #if !defined(OS_WIN) | |
| 3082 // There is no ink drop effect for gesture events on Windows. | |
|
James Cook
2016/09/12 02:54:47
ditto
mohsen
2016/09/14 18:34:43
Done.
| |
| 3083 | |
| 3084 // Tests ink drop state transitions for the overflow button when it is active | |
| 3085 // and the user taps on it. | |
| 3086 TEST_F(OverflowButtonActiveInkDropTest, TouchDeactivate) { | |
| 3087 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3088 generator.set_current_location(GetScreenPointInsideOverflowButton()); | |
| 3089 | |
| 3090 generator.PressTouch(); | |
| 3091 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3092 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3093 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3094 IsEmpty()); | |
| 3095 | |
| 3096 generator.ReleaseTouch(); | |
| 3097 EXPECT_EQ(views::InkDropState::HIDDEN, | |
| 3098 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3099 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3100 ElementsAre(views::InkDropState::DEACTIVATED, | |
| 3101 views::InkDropState::HIDDEN)); | |
| 3102 | |
| 3103 EXPECT_FALSE(test_api_->overflow_bubble() && | |
| 3104 test_api_->overflow_bubble()->IsShowing()); | |
| 3105 } | |
| 3106 | |
| 3107 // Tests ink drop state transitions for the overflow button when it is active | |
| 3108 // and the user taps down on it and drags it out of the button bounds. | |
| 3109 TEST_F(OverflowButtonActiveInkDropTest, TouchDragOut) { | |
| 3110 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3111 generator.set_current_location(GetScreenPointInsideOverflowButton()); | |
| 3112 | |
| 3113 generator.PressTouch(); | |
| 3114 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3115 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3116 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3117 IsEmpty()); | |
| 3118 | |
| 3119 generator.MoveTouch(GetScreenPointOutsideOverflowButton()); | |
| 3120 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3121 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3122 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3123 IsEmpty()); | |
| 3124 | |
| 3125 generator.ReleaseTouch(); | |
| 3126 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3127 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3128 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3129 IsEmpty()); | |
| 3130 | |
| 3131 ASSERT_TRUE(test_api_->overflow_bubble()); | |
|
James Cook
2016/09/12 02:54:47
having seen many of these lines, it might be easie
mohsen
2016/09/14 18:34:42
Fixed.
| |
| 3132 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 3133 } | |
| 3134 | |
| 3135 // Tests ink drop state transitions for the overflow button when it is active | |
| 3136 // and the user taps down on it and drags it out of the button bounds and back. | |
| 3137 TEST_F(OverflowButtonActiveInkDropTest, TouchDragOutAndBack) { | |
| 3138 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3139 generator.set_current_location(GetScreenPointInsideOverflowButton()); | |
| 3140 | |
| 3141 generator.PressTouch(); | |
| 3142 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3143 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3144 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3145 IsEmpty()); | |
| 3146 | |
| 3147 generator.MoveTouch(GetScreenPointOutsideOverflowButton()); | |
| 3148 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3149 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3150 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3151 IsEmpty()); | |
| 3152 | |
| 3153 generator.MoveTouch(GetScreenPointInsideOverflowButton()); | |
| 3154 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3155 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3156 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3157 IsEmpty()); | |
| 3158 | |
| 3159 generator.ReleaseTouch(); | |
| 3160 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3161 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3162 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3163 IsEmpty()); | |
| 3164 | |
| 3165 ASSERT_TRUE(test_api_->overflow_bubble()); | |
| 3166 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 3167 } | |
| 3168 | |
| 3169 // Tests ink drop state transitions for the overflow button when it is active | |
| 3170 // and the user long presses on the button to show the context menu. | |
| 3171 TEST_F(OverflowButtonActiveInkDropTest, TouchContextMenu) { | |
| 3172 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 3173 generator.set_current_location(GetScreenPointInsideOverflowButton()); | |
| 3174 | |
| 3175 { | |
| 3176 RunAllPendingInMessageLoop(); | |
| 3177 ScopedMockTaskRunnerWrapper mock_task_runner; | |
| 3178 | |
| 3179 generator.PressTouch(); | |
| 3180 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3181 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3182 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3183 IsEmpty()); | |
| 3184 | |
| 3185 mock_task_runner.FastForwardUntilNoTasksRemain(); | |
| 3186 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3187 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3188 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3189 IsEmpty()); | |
| 3190 | |
| 3191 generator.ReleaseTouch(); | |
| 3192 EXPECT_EQ(views::InkDropState::ACTIVATED, | |
| 3193 overflow_button_ink_drop_->GetTargetInkDropState()); | |
| 3194 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | |
| 3195 IsEmpty()); | |
| 3196 | |
| 3197 ASSERT_TRUE(test_api_->overflow_bubble()); | |
| 3198 EXPECT_TRUE(test_api_->overflow_bubble()->IsShowing()); | |
| 3199 } | |
| 3200 } | |
| 3201 | |
| 3202 #endif // !defined(OS_WIN) | |
|
James Cook
2016/09/12 02:54:47
Very thorough tests.
mohsen
2016/09/14 18:34:42
Thanks :-)
| |
| 3203 | |
| 2576 } // namespace test | 3204 } // namespace test |
| 2577 } // namespace ash | 3205 } // namespace ash |
| OLD | NEW |