Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ash / wm / workspace / workspace_window_resizer_unittest.cc
index 791e843..1f5c208 100644 (file)
@@ -4,8 +4,6 @@
 
 #include "ash/wm/workspace/workspace_window_resizer.h"
 
-#include "ash/ash_constants.h"
-#include "ash/ash_switches.h"
 #include "ash/display/display_manager.h"
 #include "ash/root_window_controller.h"
 #include "ash/screen_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "ui/aura/client/aura_constants.h"
-#include "ui/aura/test/event_generator.h"
 #include "ui/aura/test/test_window_delegate.h"
 #include "ui/aura/window_event_dispatcher.h"
 #include "ui/base/hit_test.h"
-#include "ui/events/gestures/gesture_configuration.h"
+#include "ui/events/gesture_detection/gesture_configuration.h"
+#include "ui/events/test/event_generator.h"
 #include "ui/gfx/insets.h"
 #include "ui/gfx/screen.h"
 #include "ui/views/widget/widget.h"
@@ -53,11 +51,11 @@ class TestWindowDelegate : public aura::test::TestWindowDelegate {
 
  private:
   // Overridden from aura::Test::TestWindowDelegate:
-  virtual gfx::Size GetMinimumSize() const OVERRIDE {
+  virtual gfx::Size GetMinimumSize() const override {
     return min_size_;
   }
 
-  virtual gfx::Size GetMaximumSize() const OVERRIDE {
+  virtual gfx::Size GetMaximumSize() const override {
     return max_size_;
   }
 
@@ -74,11 +72,12 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
   WorkspaceWindowResizerTest() : workspace_resizer_(NULL) {}
   virtual ~WorkspaceWindowResizerTest() {}
 
-  virtual void SetUp() OVERRIDE {
+  virtual void SetUp() override {
     AshTestBase::SetUp();
     UpdateDisplay(base::StringPrintf("800x%d", kRootHeight));
     // Ignore the touch slop region.
-    ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(0);
+    ui::GestureConfiguration::GetInstance()
+        ->set_max_touch_move_in_pixels_for_click(0);
 
     aura::Window* root = Shell::GetPrimaryRootWindow();
     gfx::Rect root_bounds(root->bounds());
@@ -114,7 +113,7 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
     window4_->set_id(4);
   }
 
-  virtual void TearDown() OVERRIDE {
+  virtual void TearDown() override {
     window_.reset();
     window2_.reset();
     window3_.reset();
@@ -150,7 +149,7 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
         point_in_parent,
         window_component,
         aura::client::WINDOW_MOVE_SOURCE_MOUSE).release();
-    workspace_resizer_ = WorkspaceWindowResizer::instance_;
+    workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest();
     return resizer;
   }
   WorkspaceWindowResizer* CreateWorkspaceResizerForTest(
@@ -516,7 +515,7 @@ TEST_F(WorkspaceWindowResizerTest, MouseMoveWithTouchDrag) {
   window2_->SetBounds(gfx::Rect(400, 200, 100, 200));
 
   Shell* shell = Shell::GetInstance();
-  aura::test::EventGenerator generator(window_->GetRootWindow());
+  ui::test::EventGenerator generator(window_->GetRootWindow());
 
   // The cursor should not be locked initially.
   EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked());
@@ -558,6 +557,7 @@ TEST_F(WorkspaceWindowResizerTest, Edge) {
   // http://crbug.com/292238.
   // Window is wide enough not to get docked right away.
   window_->SetBounds(gfx::Rect(20, 30, 400, 60));
+  window_->SetProperty(aura::client::kCanMaximizeKey, true);
   wm::WindowState* window_state = wm::GetWindowState(window_.get());
 
   {
@@ -1183,6 +1183,22 @@ TEST_F(WorkspaceWindowResizerTest, CtrlDragResizeToExactPosition) {
   EXPECT_EQ("96,112 330x172", window_->bounds().ToString());
 }
 
+// Verifies that a dragged, non-snapped window will clear restore bounds.
+TEST_F(WorkspaceWindowResizerTest, RestoreClearedOnResize) {
+  window_->SetBounds(gfx::Rect(10, 10, 100, 100));
+  wm::WindowState* window_state = wm::GetWindowState(window_.get());
+  window_state->SetRestoreBoundsInScreen(gfx::Rect(50, 50, 50, 50));
+  scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+      window_.get(), gfx::Point(), HTBOTTOMRIGHT));
+  ASSERT_TRUE(resizer.get());
+  // Drag the window to new position by adding (20, 30) to original point,
+  // the original restore bound should be cleared.
+  resizer->Drag(CalculateDragPoint(*resizer, 20, 30), 0);
+  resizer->CompleteDrag();
+  EXPECT_EQ("10,10 120x130", window_->bounds().ToString());
+  EXPECT_FALSE(window_state->HasRestoreBounds());
+}
+
 // Verifies that a dragged window will restore to its pre-maximized size.
 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) {
   window_->SetBounds(gfx::Rect(0, 0, 1000, 1000));
@@ -1401,6 +1417,7 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_LEFT) {
 // Test that the user user moved window flag is getting properly set.
 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) {
   window_->SetBounds(gfx::Rect( 0,  50, 400, 200));
+  window_->SetProperty(aura::client::kCanMaximizeKey, true);
 
   std::vector<aura::Window*> no_attached_windows;
   // Check that an abort doesn't change anything.
@@ -1477,10 +1494,7 @@ TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) {
     scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
         window_.get(), gfx::Point(), HTCAPTION));
     resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
-    if (switches::UseDockedWindows())
-      EXPECT_TRUE(snap_phantom_window_controller());
-    else
-      EXPECT_FALSE(snap_phantom_window_controller());
+    EXPECT_TRUE(snap_phantom_window_controller());
     resizer->RevertDrag();
   }
   {
@@ -1744,8 +1758,8 @@ TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_RIGHT) {
   EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(),
             touch_resize_window_->bounds().ToString());
 
-  aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
-                                       touch_resize_window_.get());
+  ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
+                                     touch_resize_window_.get());
 
   // Drag out of the right border a bit and check if the border is aligned with
   // the touch point.
@@ -1778,8 +1792,8 @@ TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_LEFT) {
   EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(),
             touch_resize_window_->bounds().ToString());
 
-  aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
-                                       touch_resize_window_.get());
+  ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
+                                     touch_resize_window_.get());
 
   // Drag out of the left border a bit and check if the border is aligned with
   // the touch point.
@@ -1812,8 +1826,8 @@ TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_TOP) {
   EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(),
             touch_resize_window_->bounds().ToString());
 
-  aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
-                                       touch_resize_window_.get());
+  ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
+                                     touch_resize_window_.get());
 
   // Drag out of the top border a bit and check if the border is aligned with
   // the touch point.
@@ -1846,8 +1860,8 @@ TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_BOTTOM) {
   EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(),
             touch_resize_window_->bounds().ToString());
 
-  aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
-                                       touch_resize_window_.get());
+  ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
+                                     touch_resize_window_.get());
 
   // Drag out of the bottom border a bit and check if the border is aligned with
   // the touch point.