#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"
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_;
}
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());
window4_->set_id(4);
}
- virtual void TearDown() OVERRIDE {
+ virtual void TearDown() override {
window_.reset();
window2_.reset();
window3_.reset();
point_in_parent,
window_component,
aura::client::WINDOW_MOVE_SOURCE_MOUSE).release();
- workspace_resizer_ = WorkspaceWindowResizer::instance_;
+ workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest();
return resizer;
}
WorkspaceWindowResizer* CreateWorkspaceResizerForTest(
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());
// 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());
{
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));
// 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.
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();
}
{
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.
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.
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.
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.