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

Unified Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 2824233003: Disallow toggling of shelf auto-hide with touch when there are no windows open (Closed)
Patch Set: Add UT. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ash/shelf/shelf_layout_manager.cc ('K') | « ash/shelf/shelf_layout_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_layout_manager_unittest.cc
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index cc45d218af4efb3071168b040daf9831155ce992..d772f52872375997834486d5ced5dc0887b039ca 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -550,10 +550,11 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString());
- // Close actually, otherwise further event may be affected since widget
+ // Minimize actually, otherwise further event may be affected since widget
// is fullscreen status.
- widget->Close();
+ widget->Minimize();
RunAllPendingInMessageLoop();
+ EXPECT_FALSE(layout_manager->HasVisibleWindow());
// The shelf should be shown because there are no more visible windows.
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
@@ -570,6 +571,64 @@ void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
+ EXPECT_EQ(shelf_shown.ToString(),
+ GetShelfWidget()->GetWindowBoundsInScreen().ToString());
+
+ // Swipe-down to hide. This should have no effect because there are no visible
+ // windows.
+ end = start + delta;
+ generator.GestureScrollSequenceWithCallback(
+ start, end, kTimeDelta, kNumScrollSteps,
+ base::Bind(&ShelfDragCallback::ProcessScroll,
+ base::Unretained(&handler)));
+ EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
+ EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
+ EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
+ EXPECT_EQ(shelf_shown.ToString(),
+ GetShelfWidget()->GetWindowBoundsInScreen().ToString());
+
+ widget->Restore();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(layout_manager->HasVisibleWindow());
+
+ // Swipe up on the shelf. This should show the shelf and disable auto-hide
+ // since there is one visible window.
+ end = below_start - delta;
+ generator.GestureScrollSequenceWithCallback(
+ below_start, end, kTimeDelta, kNumScrollSteps,
+ base::Bind(&ShelfDragCallback::ProcessScroll,
+ base::Unretained(&handler)));
+ EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
+ EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
+
+ // Close the widget to make sure the swiping on the shelf will not take
+ // effect.
+ widget->Close();
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(layout_manager->HasVisibleWindow());
+
+ // Swipe-up to hide. This should have no effect because there are no visible
+ // windows.
+ generator.GestureScrollSequenceWithCallback(
+ below_start, end, kTimeDelta, kNumScrollSteps,
+ base::Bind(&ShelfDragCallback::ProcessScroll,
+ base::Unretained(&handler)));
+ EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
+ EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
+ EXPECT_EQ(shelf_shown.ToString(),
+ GetShelfWidget()->GetWindowBoundsInScreen().ToString());
+
+ // Swipe-down to hide. This should have no effect because there are no visible
+ // windows.
xiaoyinh(OOO Sep 11-29) 2017/04/21 04:13:12 nit: EXPECT_FALSE(layout_manager->HasVisibleWindow
minch1 2017/04/21 16:42:42 No window opened after line 608. I think maybe the
+ end = start + delta;
+ generator.GestureScrollSequenceWithCallback(
+ start, end, kTimeDelta, kNumScrollSteps,
+ base::Bind(&ShelfDragCallback::ProcessScroll,
+ base::Unretained(&handler)));
+ EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
+ EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
+ EXPECT_EQ(shelf_shown.ToString(),
+ GetShelfWidget()->GetWindowBoundsInScreen().ToString());
}
// Makes sure SetVisible updates work area and widget appropriately.
« ash/shelf/shelf_layout_manager.cc ('K') | « ash/shelf/shelf_layout_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698