Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ash / shelf / shelf_layout_manager_unittest.cc
index 9ed79d7..928ff3e 100644 (file)
@@ -33,6 +33,7 @@
 #include "ui/compositor/layer.h"
 #include "ui/compositor/layer_animator.h"
 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
+#include "ui/events/gestures/gesture_configuration.h"
 #include "ui/gfx/animation/animation_container_element.h"
 #include "ui/gfx/display.h"
 #include "ui/gfx/screen.h"
@@ -1492,6 +1493,48 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
             display.work_area().y() - display.bounds().y());
 }
 
+TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) {
+  ShelfLayoutManager* shelf = GetShelfLayoutManager();
+  shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+  views::Widget* widget = new views::Widget;
+  views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+  params.bounds = gfx::Rect(0, 0, 200, 200);
+  params.context = CurrentContext();
+  widget->Init(params);
+  widget->Show();
+  widget->Maximize();
+
+  aura::Window* window = widget->GetNativeWindow();
+  shelf->LayoutShelf();
+
+  gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen();
+  gfx::Rect bounds_shelf = window->bounds();
+  EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+
+  shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+  shelf->LayoutShelf();
+  EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+
+  aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
+  generator.GestureEdgeSwipe();
+
+  EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+  EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
+
+  widget->SetFullscreen(true);
+  wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false);
+  shelf->UpdateVisibilityState();
+
+  gfx::Rect bounds_fullscreen = window->bounds();
+  EXPECT_TRUE(widget->IsFullscreen());
+  EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+
+  generator.GestureEdgeSwipe();
+  EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
+  EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
+  EXPECT_FALSE(widget->IsFullscreen());
+}
+
 #if defined(OS_WIN)
 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962
 #define MAYBE_GestureDrag DISABLED_GestureDrag
@@ -1500,6 +1543,9 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
 #endif
 
 TEST_F(ShelfLayoutManagerTest, MAYBE_GestureDrag) {
+  // Slop is an implementation detail of gesture recognition, and complicates
+  // these tests. Ignore it.
+  ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(0);
   ShelfLayoutManager* shelf = GetShelfLayoutManager();
   {
     SCOPED_TRACE("BOTTOM");