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

Side by Side Diff: ash/wm/toplevel_window_event_handler_unittest.cc

Issue 2550533002: Revert of Reenable Tabdragging tests failing because of IsWindowPositionManaged() (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/toplevel_window_event_handler.h" 5 #include "ash/wm/toplevel_window_event_handler.h"
6 6
7 #include "ash/common/wm/window_state.h" 7 #include "ash/common/wm/window_state.h"
8 #include "ash/common/wm/workspace_controller.h" 8 #include "ash/common/wm/workspace_controller.h"
9 #include "ash/public/cpp/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 TouchDragFromCenterBy(w1.get(), 100, 100); 106 TouchDragFromCenterBy(w1.get(), 100, 100);
107 // Position should have been offset by 100,100. 107 // Position should have been offset by 100,100.
108 EXPECT_EQ("200,200", w1->bounds().origin().ToString()); 108 EXPECT_EQ("200,200", w1->bounds().origin().ToString());
109 // Size should not have. 109 // Size should not have.
110 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString()); 110 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
111 } 111 }
112 112
113 namespace { 113 namespace {
114 114
115 void ContinueAndCompleteDrag(ui::test::EventGenerator* generator,
116 wm::WindowState* window_state,
117 aura::Window* window) {
118 ASSERT_TRUE(window->HasCapture());
119 ASSERT_FALSE(window_state->window_position_managed());
120 generator->DragMouseBy(100, 100);
121 generator->ReleaseLeftButton();
122 }
123
124 } // namespace
125
126 // Tests dragging restores expected window position auto manage property
127 // correctly.
128 TEST_F(ToplevelWindowEventHandlerTest, WindowPositionAutoManagement) {
129 std::unique_ptr<aura::Window> w1(CreateWindow(HTNOWHERE));
130 const gfx::Size size = w1->bounds().size();
131 wm::WindowState* window_state = ash::wm::GetWindowState(w1.get());
132 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get());
133
134 // Explicitly enable window position auto management, and expect it to be
135 // restored after drag completes.
136 window_state->set_window_position_managed(true);
137 generator.PressLeftButton();
138 aura::client::WindowMoveClient* move_client =
139 aura::client::GetWindowMoveClient(w1->GetRootWindow());
140 // generator.PressLeftButton();
141 base::ThreadTaskRunnerHandle::Get()->PostTask(
142 FROM_HERE,
143 base::Bind(&ContinueAndCompleteDrag, base::Unretained(&generator),
144 base::Unretained(window_state), base::Unretained(w1.get())));
145 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
146 move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100),
147 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
148 // Window position auto manage property should be restored to true.
149 EXPECT_TRUE(window_state->window_position_managed());
150 // Position should have been offset by 100,100.
151 EXPECT_EQ("100,100", w1->bounds().origin().ToString());
152 // Size should remain the same.
153 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
154
155 // Explicitly disable window position auto management, and expect it to be
156 // restored after drag completes.
157 window_state->set_window_position_managed(false);
158 generator.PressLeftButton();
159 base::ThreadTaskRunnerHandle::Get()->PostTask(
160 FROM_HERE,
161 base::Bind(&ContinueAndCompleteDrag, base::Unretained(&generator),
162 base::Unretained(window_state), base::Unretained(w1.get())));
163 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
164 move_client->RunMoveLoop(w1.get(), gfx::Vector2d(100, 100),
165 aura::client::WINDOW_MOVE_SOURCE_MOUSE));
166 // Window position auto manage property should be restored to true.
167 EXPECT_FALSE(window_state->window_position_managed());
168 // Position should have been offset by 100,100.
169 EXPECT_EQ("200,200", w1->bounds().origin().ToString());
170 // Size should remain the same.
171 EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
172 }
173
174 namespace {
175
176 class CancelDragObserver : public aura::WindowObserver { 115 class CancelDragObserver : public aura::WindowObserver {
177 public: 116 public:
178 CancelDragObserver() {} 117 CancelDragObserver() {}
179 ~CancelDragObserver() override {} 118 ~CancelDragObserver() override {}
180 119
181 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override { 120 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override {
182 aura::client::CaptureClient* client = 121 aura::client::CaptureClient* client =
183 aura::client::GetCaptureClient(params.target->GetRootWindow()); 122 aura::client::GetCaptureClient(params.target->GetRootWindow());
184 client->SetCapture(nullptr); 123 client->SetCapture(nullptr);
185 } 124 }
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, 760 EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
822 move_client->RunMoveLoop(window.get(), gfx::Vector2d(), 761 move_client->RunMoveLoop(window.get(), gfx::Vector2d(),
823 aura::client::WINDOW_MOVE_SOURCE_TOUCH)); 762 aura::client::WINDOW_MOVE_SOURCE_TOUCH));
824 } 763 }
825 764
826 // Showing the resize shadows when the mouse is over the window edges is tested 765 // Showing the resize shadows when the mouse is over the window edges is tested
827 // in resize_shadow_and_cursor_test.cc 766 // in resize_shadow_and_cursor_test.cc
828 767
829 } // namespace test 768 } // namespace test
830 } // namespace ash 769 } // namespace ash
OLDNEW
« 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