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

Unified Diff: ash/wm/toplevel_window_event_handler_unittest.cc

Issue 2494713003: Reenable Tabdragging tests failing because of IsWindowPositionManaged() (Closed)
Patch Set: Adding a better ash test. Created 4 years, 1 month 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
« no previous file with comments | « ash/wm/toplevel_window_event_handler.cc ('k') | chrome/browser/ui/views/tabs/tab_drag_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/toplevel_window_event_handler_unittest.cc
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc
index b7c26120d6ecc16f5d91f17c475087f30f1ee2a9..e139fda0e91dea4713f7c0a86105fb239dc08487 100644
--- a/ash/wm/toplevel_window_event_handler_unittest.cc
+++ b/ash/wm/toplevel_window_event_handler_unittest.cc
@@ -112,6 +112,67 @@ TEST_F(ToplevelWindowEventHandlerTest, Caption) {
namespace {
+void ContinueAndCompleteDrag(ui::test::EventGenerator* generator,
+ wm::WindowState* window_state,
+ aura::Window* window) {
+ ASSERT_TRUE(window->HasCapture());
+ ASSERT_FALSE(window_state->window_position_managed());
+ generator->DragMouseBy(100, 100);
+ generator->ReleaseLeftButton();
+}
+
+} // namespace
+
+// Tests dragging restores expected window position auto manage property
+// correctly.
+TEST_F(ToplevelWindowEventHandlerTest, WindowPositionAutoManagement) {
+ std::unique_ptr<aura::Window> w1(CreateWindow(HTNOWHERE));
+ const gfx::Size size = w1->bounds().size();
+ wm::WindowState* window_state = ash::wm::GetWindowState(w1.get());
+ ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get());
+
+ // Explicitly enable window position auto management, and expect it to be
+ // restored after drag completes.
+ window_state->set_window_position_managed(true);
+ generator.PressLeftButton();
+ aura::client::WindowMoveClient* move_client =
+ aura::client::GetWindowMoveClient(w1->GetRootWindow());
+ // generator.PressLeftButton();
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(&ContinueAndCompleteDrag, base::Unretained(&generator),
+ base::Unretained(window_state), base::Unretained(w1.get())));
+ EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
+ move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100),
+ aura::client::WINDOW_MOVE_SOURCE_MOUSE));
+ // Window position auto manage property should be restored to true.
+ EXPECT_TRUE(window_state->window_position_managed());
+ // Position should have been offset by 100,100.
+ EXPECT_EQ("100,100", w1->bounds().origin().ToString());
+ // Size should remain the same.
+ EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
+
+ // Explicitly disable window position auto management, and expect it to be
+ // restored after drag completes.
+ window_state->set_window_position_managed(false);
+ generator.PressLeftButton();
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(&ContinueAndCompleteDrag, base::Unretained(&generator),
+ base::Unretained(window_state), base::Unretained(w1.get())));
+ EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
+ move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100),
+ aura::client::WINDOW_MOVE_SOURCE_MOUSE));
+ // Window position auto manage property should be restored to true.
+ EXPECT_FALSE(window_state->window_position_managed());
+ // Position should have been offset by 100,100.
+ EXPECT_EQ("200,200", w1->bounds().origin().ToString());
+ // Size should remain the same.
+ EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
+}
+
+namespace {
+
class CancelDragObserver : public aura::WindowObserver {
public:
CancelDragObserver() {}
« no previous file with comments | « ash/wm/toplevel_window_event_handler.cc ('k') | chrome/browser/ui/views/tabs/tab_drag_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698