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

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

Issue 2576913002: Use mojo app list interfaces for mash and classic ash. (Closed)
Patch Set: Fix AppListPresenterImplTest. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/shelf/shelf_view.h" 5 #include "ash/common/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 30 matching lines...) Expand all
41 #include "base/macros.h" 41 #include "base/macros.h"
42 #include "base/memory/ptr_util.h" 42 #include "base/memory/ptr_util.h"
43 #include "base/run_loop.h" 43 #include "base/run_loop.h"
44 #include "base/strings/string_number_conversions.h" 44 #include "base/strings/string_number_conversions.h"
45 #include "base/strings/utf_string_conversions.h" 45 #include "base/strings/utf_string_conversions.h"
46 #include "base/test/histogram_tester.h" 46 #include "base/test/histogram_tester.h"
47 #include "base/test/scoped_mock_time_message_loop_task_runner.h" 47 #include "base/test/scoped_mock_time_message_loop_task_runner.h"
48 #include "base/test/user_action_tester.h" 48 #include "base/test/user_action_tester.h"
49 #include "base/time/time.h" 49 #include "base/time/time.h"
50 #include "testing/gmock/include/gmock/gmock.h" 50 #include "testing/gmock/include/gmock/gmock.h"
51 #include "ui/app_list/presenter/app_list_presenter.h" 51 #include "ui/app_list/presenter/app_list.h"
52 #include "ui/aura/test/aura_test_base.h" 52 #include "ui/aura/test/aura_test_base.h"
53 #include "ui/aura/window.h" 53 #include "ui/aura/window.h"
54 #include "ui/aura/window_event_dispatcher.h" 54 #include "ui/aura/window_event_dispatcher.h"
55 #include "ui/compositor/layer.h" 55 #include "ui/compositor/layer.h"
56 #include "ui/events/event.h" 56 #include "ui/events/event.h"
57 #include "ui/events/event_constants.h" 57 #include "ui/events/event_constants.h"
58 #include "ui/events/event_utils.h" 58 #include "ui/events/event_utils.h"
59 #include "ui/events/test/event_generator.h" 59 #include "ui/events/test/event_generator.h"
60 #include "ui/gfx/geometry/point.h" 60 #include "ui/gfx/geometry/point.h"
61 #include "ui/views/animation/ink_drop_impl.h" 61 #include "ui/views/animation/ink_drop_impl.h"
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 gfx::Point(all_area.right(), all_area.y()))); 1463 gfx::Point(all_area.right(), all_area.y())));
1464 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( 1464 EXPECT_TRUE(shelf_view_->ShouldHideTooltip(
1465 gfx::Point(all_area.x() - 1, all_area.y()))); 1465 gfx::Point(all_area.x() - 1, all_area.y())));
1466 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( 1466 EXPECT_TRUE(shelf_view_->ShouldHideTooltip(
1467 gfx::Point(all_area.x(), all_area.y() - 1))); 1467 gfx::Point(all_area.x(), all_area.y() - 1)));
1468 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( 1468 EXPECT_TRUE(shelf_view_->ShouldHideTooltip(
1469 gfx::Point(all_area.x(), all_area.bottom()))); 1469 gfx::Point(all_area.x(), all_area.bottom())));
1470 } 1470 }
1471 1471
1472 TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) { 1472 TEST_F(ShelfViewTest, ShouldHideTooltipWithAppListWindowTest) {
1473 WmShell::Get()->ShowAppList(); 1473 // Trigger mock notifications that the app list was shown.
1474 ASSERT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); 1474 WmShell::Get()->app_list()->OnTargetVisibilityChanged(true);
1475 WmShell::Get()->app_list()->OnVisibilityChanged(true);
1476 AppListButton* app_list_button = shelf_view_->GetAppListButton();
1477 app_list_button->OnAppListShown();
mfomitchev 2016/12/22 18:27:11 I am not sure if we actually have any tests that v
msw 2016/12/23 03:59:34 I added an integration interactive ui test to chec
mfomitchev 2016/12/23 16:49:27 Sorry, I don't think this actually tests that OnAp
msw 2016/12/23 17:34:27 Done. (in the new AppListTest.PressAppListButtonTo
1475 1478
1476 // The tooltip shouldn't hide if the mouse is on normal buttons. 1479 // The tooltip shouldn't hide if the mouse is on normal buttons.
1477 for (int i = 1; i < test_api_->GetButtonCount(); i++) { 1480 for (int i = 1; i < test_api_->GetButtonCount(); i++) {
1478 ShelfButton* button = test_api_->GetButton(i); 1481 ShelfButton* button = test_api_->GetButton(i);
1479 if (!button) 1482 if (!button)
1480 continue; 1483 continue;
1481 1484
1482 EXPECT_FALSE(shelf_view_->ShouldHideTooltip( 1485 EXPECT_FALSE(shelf_view_->ShouldHideTooltip(
1483 button->GetMirroredBounds().CenterPoint())) 1486 button->GetMirroredBounds().CenterPoint()))
1484 << "ShelfView tries to hide on button " << i; 1487 << "ShelfView tries to hide on button " << i;
1485 } 1488 }
1486 1489
1487 // The tooltip should hide on the app-list button. 1490 // The tooltip should hide on the app list button if the app list is visible.
1488 AppListButton* app_list_button = shelf_view_->GetAppListButton();
1489 EXPECT_TRUE(shelf_view_->ShouldHideTooltip( 1491 EXPECT_TRUE(shelf_view_->ShouldHideTooltip(
1490 app_list_button->GetMirroredBounds().CenterPoint())); 1492 app_list_button->GetMirroredBounds().CenterPoint()));
1491 } 1493 }
1492 1494
1493 // Test that by moving the mouse cursor off the button onto the bubble it closes 1495 // Test that by moving the mouse cursor off the button onto the bubble it closes
1494 // the bubble. 1496 // the bubble.
1495 TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) { 1497 TEST_F(ShelfViewTest, ShouldHideTooltipWhenHoveringOnTooltip) {
1496 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); 1498 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager();
1497 tooltip_manager->set_timer_delay_for_test(0); 1499 tooltip_manager->set_timer_delay_for_test(0);
1498 ui::test::EventGenerator& generator = GetEventGenerator(); 1500 ui::test::EventGenerator& generator = GetEventGenerator();
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 2047
2046 private: 2048 private:
2047 // TestShelfItemDelegate: 2049 // TestShelfItemDelegate:
2048 ShelfMenuModel* CreateApplicationMenu(int event_flags) override { 2050 ShelfMenuModel* CreateApplicationMenu(int event_flags) override {
2049 return new TestShelfMenuModel; 2051 return new TestShelfMenuModel;
2050 } 2052 }
2051 2053
2052 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate); 2054 DISALLOW_COPY_AND_ASSIGN(ListMenuShelfItemDelegate);
2053 }; 2055 };
2054 2056
2055 // A test implementation for AppListPresenter that does not change visibility
2056 // state immediately to simulate an in-flight animation. Calling
2057 // FinishVisibilityChange() will change the visibility to the requested one,
2058 // simulating end of the animation. Similar to the actual AppListPresenter, this
2059 // class toggles app list visibility based on the actual visibility rather than
2060 // the target visibility (which might be different due to in-flight animation).
2061 class TestAppListPresenter : public app_list::AppListPresenter {
2062 public:
2063 TestAppListPresenter() {}
2064 ~TestAppListPresenter() override {}
2065
2066 void FinishVisibilityChange() { is_visible_ = target_visibility_; }
2067
2068 // app_list::AppListPresenter:
2069 void Show(int64_t display_id) override { target_visibility_ = true; }
2070 void Dismiss() override { target_visibility_ = false; }
2071 void ToggleAppList(int64_t display_id) override {
2072 if (is_visible_)
2073 Dismiss();
2074 else
2075 Show(display_id);
2076 }
2077 bool IsVisible() const override { return is_visible_; }
2078 bool GetTargetVisibility() const override { return target_visibility_; }
2079
2080 private:
2081 bool is_visible_ = false;
2082 bool target_visibility_ = false;
2083
2084 DISALLOW_COPY_AND_ASSIGN(TestAppListPresenter);
2085 };
2086
2087 // A test ShellDelegate implementation that returns a TestAppListPresenter as
2088 // the app list presenter.
2089 class TestAppListShellDelegate : public TestShellDelegate {
2090 public:
2091 TestAppListShellDelegate()
2092 : app_list_presenter_(new TestAppListPresenter()) {}
2093 ~TestAppListShellDelegate() override {}
2094
2095 TestAppListPresenter* app_list_presenter() const {
2096 return app_list_presenter_.get();
2097 }
2098
2099 // TestShellDelegate:
2100 app_list::AppListPresenter* GetAppListPresenter() override {
2101 return app_list_presenter();
2102 }
2103
2104 private:
2105 std::unique_ptr<TestAppListPresenter> app_list_presenter_;
2106
2107 DISALLOW_COPY_AND_ASSIGN(TestAppListShellDelegate);
2108 };
2109
2110 } // namespace 2057 } // namespace
2111 2058
2112 // Test fixture that forces material design mode in order to test ink drop 2059 // Test fixture that forces material design mode in order to test ink drop
2113 // ripples on shelf. 2060 // ripples on shelf.
2114 class ShelfViewInkDropTest : public ShelfViewTest { 2061 class ShelfViewInkDropTest : public ShelfViewTest {
2115 public: 2062 public:
2116 ShelfViewInkDropTest() {} 2063 ShelfViewInkDropTest() {}
2117 ~ShelfViewInkDropTest() override {} 2064 ~ShelfViewInkDropTest() override {}
2118 2065
2119 void SetUp() override { 2066 void SetUp() override {
2120 ash_test_helper()->set_test_shell_delegate(CreateTestShellDelegate()); 2067 ash_test_helper()->set_test_shell_delegate(CreateTestShellDelegate());
2121 2068
2122 set_material_mode(ash::MaterialDesignController::MATERIAL_EXPERIMENTAL); 2069 set_material_mode(ash::MaterialDesignController::MATERIAL_EXPERIMENTAL);
2123 2070
2124 ShelfViewTest::SetUp(); 2071 ShelfViewTest::SetUp();
2125 } 2072 }
2126 2073
2127 protected: 2074 protected:
2128 // Gives subclasses a chance to return a custom test shell delegate to install 2075 // Gives subclasses a chance to return a custom test shell delegate to install
2129 // before calling base class's SetUp(). Shell will take ownership of the 2076 // before calling base class's SetUp(). Shell will take ownership of the
2130 // returned object. 2077 // returned object.
2131 virtual TestShellDelegate* CreateTestShellDelegate() { 2078 virtual TestShellDelegate* CreateTestShellDelegate() {
2132 shell_delegate_ = new TestAppListShellDelegate; 2079 return new TestShellDelegate;
2133 return shell_delegate_;
2134 } 2080 }
2135 2081
2136 void InitAppListButtonInkDrop() { 2082 void InitAppListButtonInkDrop() {
2137 app_list_button_ = shelf_view_->GetAppListButton(); 2083 app_list_button_ = shelf_view_->GetAppListButton();
2138 2084
2139 auto app_list_button_ink_drop = 2085 auto app_list_button_ink_drop =
2140 base::MakeUnique<InkDropSpy>(base::MakeUnique<views::InkDropImpl>( 2086 base::MakeUnique<InkDropSpy>(base::MakeUnique<views::InkDropImpl>(
2141 app_list_button_, app_list_button_->size())); 2087 app_list_button_, app_list_button_->size()));
2142 app_list_button_ink_drop_ = app_list_button_ink_drop.get(); 2088 app_list_button_ink_drop_ = app_list_button_ink_drop.get();
2143 views::test::InkDropHostViewTestApi(app_list_button_) 2089 views::test::InkDropHostViewTestApi(app_list_button_)
2144 .SetInkDrop(std::move(app_list_button_ink_drop), false); 2090 .SetInkDrop(std::move(app_list_button_ink_drop), false);
2145 } 2091 }
2146 2092
2147 void InitBrowserButtonInkDrop() { 2093 void InitBrowserButtonInkDrop() {
2148 browser_button_ = test_api_->GetButton(browser_index_); 2094 browser_button_ = test_api_->GetButton(browser_index_);
2149 2095
2150 auto browser_button_ink_drop = 2096 auto browser_button_ink_drop =
2151 base::MakeUnique<InkDropSpy>(base::MakeUnique<views::InkDropImpl>( 2097 base::MakeUnique<InkDropSpy>(base::MakeUnique<views::InkDropImpl>(
2152 browser_button_, browser_button_->size())); 2098 browser_button_, browser_button_->size()));
2153 browser_button_ink_drop_ = browser_button_ink_drop.get(); 2099 browser_button_ink_drop_ = browser_button_ink_drop.get();
2154 views::test::InkDropHostViewTestApi(browser_button_) 2100 views::test::InkDropHostViewTestApi(browser_button_)
2155 .SetInkDrop(std::move(browser_button_ink_drop)); 2101 .SetInkDrop(std::move(browser_button_ink_drop));
2156 } 2102 }
2157 2103
2158 void ShowAppList() { 2104 void ShowAppList() {
2159 DCHECK(shelf_delegate_); 2105 // Trigger a mock notification that the app list was shown.
2160 shell_delegate_->app_list_presenter()->Show(0); 2106 WmShell::Get()->app_list()->OnTargetVisibilityChanged(true);
2161 // Similar to real AppListPresenter, notify button that the app list is
2162 // shown.
2163 app_list_button_->OnAppListShown(); 2107 app_list_button_->OnAppListShown();
2164 } 2108 }
2165 2109
2166 void DismissAppList() { 2110 void DismissAppList() {
2167 DCHECK(shelf_delegate_); 2111 // Trigger a mock notification that the app list was dismissed.
2168 shell_delegate_->app_list_presenter()->Dismiss(); 2112 WmShell::Get()->app_list()->OnTargetVisibilityChanged(false);
2169 // Similar to real AppListPresenter, notify button that the app list is
2170 // dismissed.
2171 app_list_button_->OnAppListDismissed(); 2113 app_list_button_->OnAppListDismissed();
2172 } 2114 }
2173 2115
2174 void FinishAppListVisibilityChange() { 2116 void FinishAppListVisibilityChange() {
2175 DCHECK(shelf_delegate_); 2117 // Trigger a mock notification that the app list finished animating.
2176 shell_delegate_->app_list_presenter()->FinishVisibilityChange(); 2118 app_list::AppList* app_list = WmShell::Get()->app_list();
2119 app_list->OnVisibilityChanged(app_list->GetTargetVisibility());
2177 } 2120 }
2178 2121
2179 TestAppListShellDelegate* shell_delegate_ = nullptr; // Owned by Shell.
2180
2181 AppListButton* app_list_button_ = nullptr; 2122 AppListButton* app_list_button_ = nullptr;
2182 InkDropSpy* app_list_button_ink_drop_ = nullptr; 2123 InkDropSpy* app_list_button_ink_drop_ = nullptr;
2183 ShelfButton* browser_button_ = nullptr; 2124 ShelfButton* browser_button_ = nullptr;
2184 InkDropSpy* browser_button_ink_drop_ = nullptr; 2125 InkDropSpy* browser_button_ink_drop_ = nullptr;
2185 2126
2186 private: 2127 private:
2187 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest); 2128 DISALLOW_COPY_AND_ASSIGN(ShelfViewInkDropTest);
2188 }; 2129 };
2189 2130
2190 // Tests that changing visibility of the app list transitions app list button's 2131 // Tests that changing visibility of the app list transitions app list button's
(...skipping 21 matching lines...) Expand all
2212 // that mouse drag and mouse release does not affect the ink drop state. 2153 // that mouse drag and mouse release does not affect the ink drop state.
2213 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenHidden) { 2154 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenHidden) {
2214 InitAppListButtonInkDrop(); 2155 InitAppListButtonInkDrop();
2215 2156
2216 ui::test::EventGenerator& generator = GetEventGenerator(); 2157 ui::test::EventGenerator& generator = GetEventGenerator();
2217 generator.MoveMouseTo(app_list_button_->GetBoundsInScreen().CenterPoint()); 2158 generator.MoveMouseTo(app_list_button_->GetBoundsInScreen().CenterPoint());
2218 2159
2219 // Mouse press on the button, which shows the app list, should end up in the 2160 // Mouse press on the button, which shows the app list, should end up in the
2220 // activated state. 2161 // activated state.
2221 generator.PressLeftButton(); 2162 generator.PressLeftButton();
2222 // Similar to real AppListPresenter, notify button that the app list is shown. 2163 // Trigger a mock button notification that the app list was shown.
2223 app_list_button_->OnAppListShown(); 2164 app_list_button_->OnAppListShown();
2224 FinishAppListVisibilityChange(); 2165 FinishAppListVisibilityChange();
2225 EXPECT_EQ(views::InkDropState::ACTIVATED, 2166 EXPECT_EQ(views::InkDropState::ACTIVATED,
2226 app_list_button_ink_drop_->GetTargetInkDropState()); 2167 app_list_button_ink_drop_->GetTargetInkDropState());
2227 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2168 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2228 ElementsAre(views::InkDropState::ACTION_PENDING, 2169 ElementsAre(views::InkDropState::ACTION_PENDING,
2229 views::InkDropState::ACTIVATED)); 2170 views::InkDropState::ACTIVATED));
2230 2171
2231 // Dragging mouse out and back and releasing the button should not change the 2172 // Dragging mouse out and back and releasing the button should not change the
2232 // ink drop state. 2173 // ink drop state.
2233 generator.MoveMouseBy(app_list_button_->width(), 0); 2174 generator.MoveMouseBy(app_list_button_->width(), 0);
2234 generator.MoveMouseBy(-app_list_button_->width(), 0); 2175 generator.MoveMouseBy(-app_list_button_->width(), 0);
2235 generator.ReleaseLeftButton(); 2176 generator.ReleaseLeftButton();
2236 EXPECT_EQ(views::InkDropState::ACTIVATED, 2177 EXPECT_EQ(views::InkDropState::ACTIVATED,
2237 app_list_button_ink_drop_->GetTargetInkDropState()); 2178 app_list_button_ink_drop_->GetTargetInkDropState());
2238 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2179 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2239 IsEmpty()); 2180 IsEmpty());
2240 } 2181 }
2241 2182
2242 // Tests that when the app list is visible, mouse press on the app list button, 2183 // Tests that when the app list is visible, mouse press on the app list button,
2243 // which dismisses the app list, transitions ink drop states correctly. Also, 2184 // which dismisses the app list, transitions ink drop states correctly. Also,
2244 // tests that mouse drag and mouse release does not affect the ink drop state. 2185 // tests that mouse drag and mouse release does not affect the ink drop state.
2245 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenVisible) { 2186 TEST_F(ShelfViewInkDropTest, AppListButtonMouseEventsWhenVisible) {
2246 InitAppListButtonInkDrop(); 2187 InitAppListButtonInkDrop();
2247 2188
2248 // Show the app list.
2249 ShowAppList(); 2189 ShowAppList();
2250 FinishAppListVisibilityChange(); 2190 FinishAppListVisibilityChange();
2251 EXPECT_EQ(views::InkDropState::ACTIVATED, 2191 EXPECT_EQ(views::InkDropState::ACTIVATED,
2252 app_list_button_ink_drop_->GetTargetInkDropState()); 2192 app_list_button_ink_drop_->GetTargetInkDropState());
2253 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2193 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2254 ElementsAre(views::InkDropState::ACTIVATED)); 2194 ElementsAre(views::InkDropState::ACTIVATED));
2255 2195
2256 ui::test::EventGenerator& generator = GetEventGenerator(); 2196 ui::test::EventGenerator& generator = GetEventGenerator();
2257 generator.MoveMouseTo(app_list_button_->GetBoundsInScreen().CenterPoint()); 2197 generator.MoveMouseTo(app_list_button_->GetBoundsInScreen().CenterPoint());
2258 2198
2259 // Mouse press on the button, which dismisses the app list, should end up in 2199 // Mouse press on the button, which dismisses the app list, should end up in
2260 // the hidden state. 2200 // the hidden state.
2261 // Dismiss app list similar to pre-target handler in real AppListPresenter.
2262 DismissAppList(); 2201 DismissAppList();
2263 generator.PressLeftButton(); 2202 generator.PressLeftButton();
2264 FinishAppListVisibilityChange(); 2203 FinishAppListVisibilityChange();
2265 EXPECT_EQ(views::InkDropState::HIDDEN, 2204 EXPECT_EQ(views::InkDropState::HIDDEN,
2266 app_list_button_ink_drop_->GetTargetInkDropState()); 2205 app_list_button_ink_drop_->GetTargetInkDropState());
2267 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2206 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2268 ElementsAre(views::InkDropState::DEACTIVATED)); 2207 ElementsAre(views::InkDropState::DEACTIVATED));
2269 2208
2270 // Dragging mouse out and back and releasing the button should not change the 2209 // Dragging mouse out and back and releasing the button should not change the
2271 // ink drop state. 2210 // ink drop state.
(...skipping 19 matching lines...) Expand all
2291 // Touch press on the button should end up in the pending state. 2230 // Touch press on the button should end up in the pending state.
2292 generator.PressTouch(); 2231 generator.PressTouch();
2293 EXPECT_EQ(views::InkDropState::ACTION_PENDING, 2232 EXPECT_EQ(views::InkDropState::ACTION_PENDING,
2294 app_list_button_ink_drop_->GetTargetInkDropState()); 2233 app_list_button_ink_drop_->GetTargetInkDropState());
2295 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2234 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2296 ElementsAre(views::InkDropState::ACTION_PENDING)); 2235 ElementsAre(views::InkDropState::ACTION_PENDING));
2297 2236
2298 // Touch release on the button, which shows the app list, should end up in the 2237 // Touch release on the button, which shows the app list, should end up in the
2299 // activated state. 2238 // activated state.
2300 generator.ReleaseTouch(); 2239 generator.ReleaseTouch();
2301 // Similar to real AppListPresenter, notify button that the app list is shown. 2240 // Trigger a mock button notification that the app list was shown.
2302 app_list_button_->OnAppListShown(); 2241 app_list_button_->OnAppListShown();
2303 FinishAppListVisibilityChange(); 2242 FinishAppListVisibilityChange();
2304 EXPECT_EQ(views::InkDropState::ACTIVATED, 2243 EXPECT_EQ(views::InkDropState::ACTIVATED,
2305 app_list_button_ink_drop_->GetTargetInkDropState()); 2244 app_list_button_ink_drop_->GetTargetInkDropState());
2306 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2245 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2307 ElementsAre(views::InkDropState::ACTIVATED)); 2246 ElementsAre(views::InkDropState::ACTIVATED));
2308 } 2247 }
2309 2248
2310 // Tests that when the app list is visible, tapping on the app list button 2249 // Tests that when the app list is visible, tapping on the app list button
2311 // transitions ink drop states correctly. 2250 // transitions ink drop states correctly.
2312 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapWhenVisible) { 2251 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapWhenVisible) {
2313 InitAppListButtonInkDrop(); 2252 InitAppListButtonInkDrop();
2314 2253
2315 // Show the app list.
2316 ShowAppList(); 2254 ShowAppList();
2317 FinishAppListVisibilityChange(); 2255 FinishAppListVisibilityChange();
2318 EXPECT_EQ(views::InkDropState::ACTIVATED, 2256 EXPECT_EQ(views::InkDropState::ACTIVATED,
2319 app_list_button_ink_drop_->GetTargetInkDropState()); 2257 app_list_button_ink_drop_->GetTargetInkDropState());
2320 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2258 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2321 ElementsAre(views::InkDropState::ACTIVATED)); 2259 ElementsAre(views::InkDropState::ACTIVATED));
2322 2260
2323 ui::test::EventGenerator& generator = GetEventGenerator(); 2261 ui::test::EventGenerator& generator = GetEventGenerator();
2324 generator.MoveMouseTo(app_list_button_->GetBoundsInScreen().CenterPoint()); 2262 generator.MoveMouseTo(app_list_button_->GetBoundsInScreen().CenterPoint());
2325 2263
2326 // Touch press on the button, which dismisses the app list, should end up in 2264 // Touch press on the button, which dismisses the app list, should end up in
2327 // the hidden state. 2265 // the hidden state.
2328 // Dismiss app list similar to pre-target handler in real AppListPresenter.
2329 DismissAppList(); 2266 DismissAppList();
2330 generator.PressTouch(); 2267 generator.PressTouch();
2331 EXPECT_EQ(views::InkDropState::HIDDEN, 2268 EXPECT_EQ(views::InkDropState::HIDDEN,
2332 app_list_button_ink_drop_->GetTargetInkDropState()); 2269 app_list_button_ink_drop_->GetTargetInkDropState());
2333 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2270 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2334 ElementsAre(views::InkDropState::DEACTIVATED)); 2271 ElementsAre(views::InkDropState::DEACTIVATED));
2335 2272
2336 // Touch release on the button should not change the ink drop state. 2273 // Touch release on the button should not change the ink drop state.
2337 generator.ReleaseTouch(); 2274 generator.ReleaseTouch();
2338 FinishAppListVisibilityChange(); 2275 FinishAppListVisibilityChange();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 app_list_button_ink_drop_->GetTargetInkDropState()); 2310 app_list_button_ink_drop_->GetTargetInkDropState());
2374 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2311 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2375 IsEmpty()); 2312 IsEmpty());
2376 } 2313 }
2377 2314
2378 // Tests that when the app list is visible, tapping down on the app list button 2315 // Tests that when the app list is visible, tapping down on the app list button
2379 // and dragging the touch point transitions ink drop states correctly. 2316 // and dragging the touch point transitions ink drop states correctly.
2380 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDragWhenVisible) { 2317 TEST_F(ShelfViewInkDropTest, AppListButtonGestureTapDragWhenVisible) {
2381 InitAppListButtonInkDrop(); 2318 InitAppListButtonInkDrop();
2382 2319
2383 // Show the app list.
2384 ShowAppList(); 2320 ShowAppList();
2385 FinishAppListVisibilityChange(); 2321 FinishAppListVisibilityChange();
2386 EXPECT_EQ(views::InkDropState::ACTIVATED, 2322 EXPECT_EQ(views::InkDropState::ACTIVATED,
2387 app_list_button_ink_drop_->GetTargetInkDropState()); 2323 app_list_button_ink_drop_->GetTargetInkDropState());
2388 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2324 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2389 ElementsAre(views::InkDropState::ACTIVATED)); 2325 ElementsAre(views::InkDropState::ACTIVATED));
2390 2326
2391 ui::test::EventGenerator& generator = GetEventGenerator(); 2327 ui::test::EventGenerator& generator = GetEventGenerator();
2392 gfx::Point touch_location = 2328 gfx::Point touch_location =
2393 app_list_button_->GetBoundsInScreen().CenterPoint(); 2329 app_list_button_->GetBoundsInScreen().CenterPoint();
2394 generator.MoveMouseTo(touch_location); 2330 generator.MoveMouseTo(touch_location);
2395 2331
2396 // Touch press on the button, which dismisses the app list, should end up in 2332 // Touch press on the button, which dismisses the app list, should end up in
2397 // the hidden state. 2333 // the hidden state.
2398 // Dismiss app list similar to pre-target handler in real AppListPresenter.
2399 DismissAppList(); 2334 DismissAppList();
2400 generator.PressTouch(); 2335 generator.PressTouch();
2401 EXPECT_EQ(views::InkDropState::HIDDEN, 2336 EXPECT_EQ(views::InkDropState::HIDDEN,
2402 app_list_button_ink_drop_->GetTargetInkDropState()); 2337 app_list_button_ink_drop_->GetTargetInkDropState());
2403 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(), 2338 EXPECT_THAT(app_list_button_ink_drop_->GetAndResetRequestedStates(),
2404 ElementsAre(views::InkDropState::DEACTIVATED)); 2339 ElementsAre(views::InkDropState::DEACTIVATED));
2405 2340
2406 // Dragging the touch point and releasing should not change the ink drop 2341 // Dragging the touch point and releasing should not change the ink drop
2407 // state. 2342 // state.
2408 touch_location.Offset(app_list_button_->width(), 0); 2343 touch_location.Offset(app_list_button_->width(), 0);
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
3128 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), 3063 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
3129 IsEmpty()); 3064 IsEmpty());
3130 3065
3131 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); 3066 ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
3132 } 3067 }
3133 3068
3134 #endif // !defined(OS_WIN) 3069 #endif // !defined(OS_WIN)
3135 3070
3136 } // namespace test 3071 } // namespace test
3137 } // namespace ash 3072 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698