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

Side by Side Diff: ash/wm/panels/panel_window_resizer_unittest.cc

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 months 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
« no previous file with comments | « ash/wm/panels/panel_window_resizer.h ('k') | ash/wm/resize_shadow.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/panels/panel_window_resizer.h" 5 #include "ash/wm/panels/panel_window_resizer.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shelf/shelf.h" 8 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_model.h" 10 #include "ash/shelf/shelf_model.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ++iter, ++panel_index) { 136 ++iter, ++panel_index) {
137 ShelfID id = GetShelfIDForWindow(*iter); 137 ShelfID id = GetShelfIDForWindow(*iter);
138 EXPECT_EQ(id, model_->items()[panel_index].id); 138 EXPECT_EQ(id, model_->items()[panel_index].id);
139 } 139 }
140 } 140 }
141 141
142 // Test dragging panel window along the shelf and verify that panel icons 142 // Test dragging panel window along the shelf and verify that panel icons
143 // are reordered appropriately. 143 // are reordered appropriately.
144 void DragAlongShelfReorder(int dx, int dy) { 144 void DragAlongShelfReorder(int dx, int dy) {
145 gfx::Point origin(0, 0); 145 gfx::Point origin(0, 0);
146 scoped_ptr<aura::Window> w1(CreatePanelWindow(origin)); 146 std::unique_ptr<aura::Window> w1(CreatePanelWindow(origin));
147 scoped_ptr<aura::Window> w2(CreatePanelWindow(origin)); 147 std::unique_ptr<aura::Window> w2(CreatePanelWindow(origin));
148 std::vector<aura::Window*> window_order_original; 148 std::vector<aura::Window*> window_order_original;
149 std::vector<aura::Window*> window_order_swapped; 149 std::vector<aura::Window*> window_order_swapped;
150 window_order_original.push_back(w1.get()); 150 window_order_original.push_back(w1.get());
151 window_order_original.push_back(w2.get()); 151 window_order_original.push_back(w2.get());
152 window_order_swapped.push_back(w2.get()); 152 window_order_swapped.push_back(w2.get());
153 window_order_swapped.push_back(w1.get()); 153 window_order_swapped.push_back(w1.get());
154 TestWindowOrder(window_order_original); 154 TestWindowOrder(window_order_original);
155 155
156 // Drag window #2 to the beginning of the shelf. 156 // Drag window #2 to the beginning of the shelf.
157 DragStart(w2.get()); 157 DragStart(w2.get());
158 DragMove(400 * dx, 400 * dy); 158 DragMove(400 * dx, 400 * dy);
159 TestWindowOrder(window_order_swapped); 159 TestWindowOrder(window_order_swapped);
160 DragEnd(); 160 DragEnd();
161 161
162 // Expect swapped window order. 162 // Expect swapped window order.
163 TestWindowOrder(window_order_swapped); 163 TestWindowOrder(window_order_swapped);
164 164
165 // Drag window #2 back to the end. 165 // Drag window #2 back to the end.
166 DragStart(w2.get()); 166 DragStart(w2.get());
167 DragMove(-400 * dx, -400 * dy); 167 DragMove(-400 * dx, -400 * dy);
168 TestWindowOrder(window_order_original); 168 TestWindowOrder(window_order_original);
169 DragEnd(); 169 DragEnd();
170 170
171 // Expect original order. 171 // Expect original order.
172 TestWindowOrder(window_order_original); 172 TestWindowOrder(window_order_original);
173 } 173 }
174 174
175 private: 175 private:
176 scoped_ptr<WindowResizer> resizer_; 176 std::unique_ptr<WindowResizer> resizer_;
177 ShelfModel* model_; 177 ShelfModel* model_;
178 test::TestShelfDelegate* shelf_delegate_; 178 test::TestShelfDelegate* shelf_delegate_;
179 179
180 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest); 180 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest);
181 }; 181 };
182 182
183 class PanelWindowResizerTextDirectionTest 183 class PanelWindowResizerTextDirectionTest
184 : public PanelWindowResizerTest, 184 : public PanelWindowResizerTest,
185 public testing::WithParamInterface<bool> { 185 public testing::WithParamInterface<bool> {
186 public: 186 public:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 private: 223 private:
224 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTransientTest); 224 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTransientTest);
225 }; 225 };
226 226
227 // Verifies a window can be dragged from the panel and detached and then 227 // Verifies a window can be dragged from the panel and detached and then
228 // reattached. 228 // reattached.
229 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) { 229 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) {
230 if (!SupportsHostWindowResize()) 230 if (!SupportsHostWindowResize())
231 return; 231 return;
232 232
233 scoped_ptr<aura::Window> window( 233 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
234 CreatePanelWindow(gfx::Point(0, 0))); 234 DetachReattachTest(window.get(), 0, -1);
235 DetachReattachTest(window.get(), 0, -1);
236 } 235 }
237 236
238 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) { 237 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) {
239 if (!SupportsHostWindowResize()) 238 if (!SupportsHostWindowResize())
240 return; 239 return;
241 240
242 ash::Shell* shell = ash::Shell::GetInstance(); 241 ash::Shell* shell = ash::Shell::GetInstance();
243 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); 242 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow());
244 scoped_ptr<aura::Window> window( 243 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
245 CreatePanelWindow(gfx::Point(0, 0)));
246 DetachReattachTest(window.get(), 1, 0); 244 DetachReattachTest(window.get(), 1, 0);
247 } 245 }
248 246
249 TEST_F(PanelWindowResizerTest, PanelDetachReattachRight) { 247 TEST_F(PanelWindowResizerTest, PanelDetachReattachRight) {
250 if (!SupportsHostWindowResize()) 248 if (!SupportsHostWindowResize())
251 return; 249 return;
252 250
253 ash::Shell* shell = ash::Shell::GetInstance(); 251 ash::Shell* shell = ash::Shell::GetInstance();
254 shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, 252 shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT,
255 shell->GetPrimaryRootWindow()); 253 shell->GetPrimaryRootWindow());
256 scoped_ptr<aura::Window> window( 254 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
257 CreatePanelWindow(gfx::Point(0, 0)));
258 DetachReattachTest(window.get(), -1, 0); 255 DetachReattachTest(window.get(), -1, 0);
259 } 256 }
260 257
261 // Tests that a drag continues when the shelf is hidden. This occurs as part of 258 // Tests that a drag continues when the shelf is hidden. This occurs as part of
262 // the animation when switching profiles. http://crbug.com/393047. 259 // the animation when switching profiles. http://crbug.com/393047.
263 TEST_F(PanelWindowResizerTest, DetachThenHideShelf) { 260 TEST_F(PanelWindowResizerTest, DetachThenHideShelf) {
264 if (!SupportsHostWindowResize()) 261 if (!SupportsHostWindowResize())
265 return; 262 return;
266 scoped_ptr<aura::Window> window( 263 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
267 CreatePanelWindow(gfx::Point(0, 0)));
268 wm::WindowState* state = wm::GetWindowState(window.get()); 264 wm::WindowState* state = wm::GetWindowState(window.get());
269 gfx::Rect expected_bounds = window->GetBoundsInScreen(); 265 gfx::Rect expected_bounds = window->GetBoundsInScreen();
270 expected_bounds.set_y(expected_bounds.y() - 100); 266 expected_bounds.set_y(expected_bounds.y() - 100);
271 DragStart(window.get()); 267 DragStart(window.get());
272 DragMove(0, -100); 268 DragMove(0, -100);
273 EXPECT_FALSE(state->IsMinimized()); 269 EXPECT_FALSE(state->IsMinimized());
274 270
275 // Hide the shelf. This minimizes all attached windows but should ignore 271 // Hide the shelf. This minimizes all attached windows but should ignore
276 // the dragged window. 272 // the dragged window.
277 ShelfLayoutManager* shelf = RootWindowController::ForWindow(window.get())-> 273 ShelfLayoutManager* shelf = RootWindowController::ForWindow(window.get())->
(...skipping 11 matching lines...) Expand all
289 EXPECT_FALSE(state->IsMinimized()); 285 EXPECT_FALSE(state->IsMinimized());
290 EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString()); 286 EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString());
291 } 287 }
292 288
293 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) { 289 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) {
294 if (!SupportsMultipleDisplays()) 290 if (!SupportsMultipleDisplays())
295 return; 291 return;
296 292
297 UpdateDisplay("600x400,600x400"); 293 UpdateDisplay("600x400,600x400");
298 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 294 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
299 scoped_ptr<aura::Window> window( 295 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(600, 0)));
300 CreatePanelWindow(gfx::Point(600, 0)));
301 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 296 EXPECT_EQ(root_windows[1], window->GetRootWindow());
302 DetachReattachTest(window.get(), 0, -1); 297 DetachReattachTest(window.get(), 0, -1);
303 } 298 }
304 299
305 TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) { 300 TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) {
306 if (!SupportsMultipleDisplays()) 301 if (!SupportsMultipleDisplays())
307 return; 302 return;
308 303
309 UpdateDisplay("600x400,600x400"); 304 UpdateDisplay("600x400,600x400");
310 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 305 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
311 scoped_ptr<aura::Window> window( 306 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
312 CreatePanelWindow(gfx::Point(0, 0)));
313 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 307 gfx::Rect initial_bounds = window->GetBoundsInScreen();
314 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 308 EXPECT_EQ(root_windows[0], window->GetRootWindow());
315 DragStart(window.get()); 309 DragStart(window.get());
316 DragMove(0, -100); 310 DragMove(0, -100);
317 DragEnd(); 311 DragEnd();
318 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 312 EXPECT_EQ(root_windows[0], window->GetRootWindow());
319 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); 313 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x());
320 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); 314 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y());
321 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); 315 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
322 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 316 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
323 317
324 DragStart(window.get()); 318 DragStart(window.get());
325 DragMove(500, 0); 319 DragMove(500, 0);
326 DragEnd(); 320 DragEnd();
327 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 321 EXPECT_EQ(root_windows[1], window->GetRootWindow());
328 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); 322 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
329 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); 323 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y());
330 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); 324 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
331 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 325 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
332 } 326 }
333 327
334 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) { 328 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) {
335 if (!SupportsMultipleDisplays()) 329 if (!SupportsMultipleDisplays())
336 return; 330 return;
337 331
338 UpdateDisplay("600x400,600x400"); 332 UpdateDisplay("600x400,600x400");
339 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 333 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
340 scoped_ptr<aura::Window> window( 334 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
341 CreatePanelWindow(gfx::Point(0, 0)));
342 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 335 gfx::Rect initial_bounds = window->GetBoundsInScreen();
343 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 336 EXPECT_EQ(root_windows[0], window->GetRootWindow());
344 DragStart(window.get()); 337 DragStart(window.get());
345 DragMove(500, -100); 338 DragMove(500, -100);
346 DragEnd(); 339 DragEnd();
347 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 340 EXPECT_EQ(root_windows[1], window->GetRootWindow());
348 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); 341 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
349 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); 342 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y());
350 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); 343 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
351 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 344 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
352 } 345 }
353 346
354 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { 347 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) {
355 if (!SupportsMultipleDisplays()) 348 if (!SupportsMultipleDisplays())
356 return; 349 return;
357 350
358 UpdateDisplay("600x400,600x600"); 351 UpdateDisplay("600x400,600x600");
359 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 352 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
360 scoped_ptr<aura::Window> window( 353 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
361 CreatePanelWindow(gfx::Point(0, 0)));
362 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 354 gfx::Rect initial_bounds = window->GetBoundsInScreen();
363 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 355 EXPECT_EQ(root_windows[0], window->GetRootWindow());
364 356
365 // Detach the window. 357 // Detach the window.
366 DragStart(window.get()); 358 DragStart(window.get());
367 DragMove(0, -100); 359 DragMove(0, -100);
368 DragEnd(); 360 DragEnd();
369 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 361 EXPECT_EQ(root_windows[0], window->GetRootWindow());
370 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); 362 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
371 363
(...skipping 11 matching lines...) Expand all
383 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); 375 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
384 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 376 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
385 } 377 }
386 378
387 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { 379 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) {
388 if (!SupportsMultipleDisplays()) 380 if (!SupportsMultipleDisplays())
389 return; 381 return;
390 382
391 UpdateDisplay("600x400,600x600"); 383 UpdateDisplay("600x400,600x600");
392 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 384 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
393 scoped_ptr<aura::Window> window( 385 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
394 CreatePanelWindow(gfx::Point(0, 0)));
395 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 386 gfx::Rect initial_bounds = window->GetBoundsInScreen();
396 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 387 EXPECT_EQ(root_windows[0], window->GetRootWindow());
397 388
398 // Drag the window just above the other display's launcher. 389 // Drag the window just above the other display's launcher.
399 DragStart(window.get()); 390 DragStart(window.get());
400 DragMove(500, 195); 391 DragMove(500, 195);
401 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); 392 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
402 393
403 // Should stick to other launcher. 394 // Should stick to other launcher.
404 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); 395 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y());
405 DragEnd(); 396 DragEnd();
406 397
407 // When dropped should move to second display's panel container. 398 // When dropped should move to second display's panel container.
408 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 399 EXPECT_EQ(root_windows[1], window->GetRootWindow());
409 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); 400 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
410 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 401 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
411 } 402 }
412 403
413 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) { 404 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) {
414 if (!SupportsMultipleDisplays()) 405 if (!SupportsMultipleDisplays())
415 return; 406 return;
416 407
417 UpdateDisplay("600x400,600x600"); 408 UpdateDisplay("600x400,600x600");
418 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 409 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
419 scoped_ptr<aura::Window> window( 410 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
420 CreatePanelWindow(gfx::Point(0, 0))); 411 std::unique_ptr<aura::Window> fullscreen(
421 scoped_ptr<aura::Window> fullscreen(
422 CreateTestWindowInShellWithBounds(gfx::Rect(600, 0, 101, 101))); 412 CreateTestWindowInShellWithBounds(gfx::Rect(600, 0, 101, 101)));
423 wm::GetWindowState(fullscreen.get())->Activate(); 413 wm::GetWindowState(fullscreen.get())->Activate();
424 const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 414 const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
425 wm::GetWindowState(fullscreen.get())->OnWMEvent(&event); 415 wm::GetWindowState(fullscreen.get())->OnWMEvent(&event);
426 EXPECT_TRUE(wm::GetWindowState(fullscreen.get())->IsFullscreen()); 416 EXPECT_TRUE(wm::GetWindowState(fullscreen.get())->IsFullscreen());
427 417
428 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 418 gfx::Rect initial_bounds = window->GetBoundsInScreen();
429 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 419 EXPECT_EQ(root_windows[0], window->GetRootWindow());
430 420
431 // Activate and drag the window to the other display's launcher. 421 // Activate and drag the window to the other display's launcher.
432 wm::GetWindowState(window.get())->Activate(); 422 wm::GetWindowState(window.get())->Activate();
433 DragStart(window.get()); 423 DragStart(window.get());
434 DragMove(500, 250); 424 DragMove(500, 250);
435 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); 425 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
436 EXPECT_GT(window->GetBoundsInScreen().y(), 426 EXPECT_GT(window->GetBoundsInScreen().y(),
437 initial_bounds.y() + 200); 427 initial_bounds.y() + 200);
438 DragEnd(); 428 DragEnd();
439 429
440 // When dropped should move to second display's panel container. 430 // When dropped should move to second display's panel container.
441 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 431 EXPECT_EQ(root_windows[1], window->GetRootWindow());
442 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); 432 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
443 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 433 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
444 EXPECT_TRUE(window->IsVisible()); 434 EXPECT_TRUE(window->IsVisible());
445 EXPECT_TRUE(wm::GetWindowState(window.get())->IsActive()); 435 EXPECT_TRUE(wm::GetWindowState(window.get())->IsActive());
446 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); 436 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y());
447 } 437 }
448 438
449 TEST_F(PanelWindowResizerTest, RevertDragRestoresAttachment) { 439 TEST_F(PanelWindowResizerTest, RevertDragRestoresAttachment) {
450 scoped_ptr<aura::Window> window( 440 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
451 CreatePanelWindow(gfx::Point(0, 0)));
452 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); 441 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
453 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 442 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
454 DragStart(window.get()); 443 DragStart(window.get());
455 DragMove(0, -100); 444 DragMove(0, -100);
456 DragRevert(); 445 DragRevert();
457 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached()); 446 EXPECT_TRUE(wm::GetWindowState(window.get())->panel_attached());
458 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 447 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
459 448
460 // Detach panel. 449 // Detach panel.
461 DragStart(window.get()); 450 DragStart(window.get());
462 DragMove(0, -100); 451 DragMove(0, -100);
463 DragEnd(); 452 DragEnd();
464 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); 453 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
465 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 454 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
466 455
467 // Drag back to launcher. 456 // Drag back to launcher.
468 DragStart(window.get()); 457 DragStart(window.get());
469 DragMove(0, 100); 458 DragMove(0, 100);
470 459
471 // When the drag is reverted it should remain detached. 460 // When the drag is reverted it should remain detached.
472 DragRevert(); 461 DragRevert();
473 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached()); 462 EXPECT_FALSE(wm::GetWindowState(window.get())->panel_attached());
474 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 463 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
475 } 464 }
476 465
477 TEST_F(PanelWindowResizerTest, DragMovesToPanelLayer) { 466 TEST_F(PanelWindowResizerTest, DragMovesToPanelLayer) {
478 scoped_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 467 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
479 DragStart(window.get()); 468 DragStart(window.get());
480 DragMove(0, -100); 469 DragMove(0, -100);
481 DragEnd(); 470 DragEnd();
482 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 471 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
483 472
484 // While moving the panel window should be moved to the panel container. 473 // While moving the panel window should be moved to the panel container.
485 DragStart(window.get()); 474 DragStart(window.get());
486 DragMove(20, 0); 475 DragMove(20, 0);
487 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 476 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
488 DragEnd(); 477 DragEnd();
(...skipping 17 matching lines...) Expand all
506 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow()); 495 shell->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, shell->GetPrimaryRootWindow());
507 DragAlongShelfReorder(0, -1); 496 DragAlongShelfReorder(0, -1);
508 } 497 }
509 498
510 // Tests that panels can have transient children of different types. 499 // Tests that panels can have transient children of different types.
511 // The transient children should be reparented in sync with the panel. 500 // The transient children should be reparented in sync with the panel.
512 TEST_P(PanelWindowResizerTransientTest, PanelWithTransientChild) { 501 TEST_P(PanelWindowResizerTransientTest, PanelWithTransientChild) {
513 if (!SupportsHostWindowResize()) 502 if (!SupportsHostWindowResize())
514 return; 503 return;
515 504
516 scoped_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 505 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
517 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType( 506 std::unique_ptr<aura::Window> child(
518 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40))); 507 CreateTestWindowInShellWithDelegateAndType(
508 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40)));
519 ::wm::AddTransientChild(window.get(), child.get()); 509 ::wm::AddTransientChild(window.get(), child.get());
520 if (window->parent() != child->parent()) 510 if (window->parent() != child->parent())
521 window->parent()->AddChild(child.get()); 511 window->parent()->AddChild(child.get());
522 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); 512 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get()));
523 513
524 // Drag the child to the shelf. Its new position should not be overridden. 514 // Drag the child to the shelf. Its new position should not be overridden.
525 const gfx::Rect attached_bounds(window->GetBoundsInScreen()); 515 const gfx::Rect attached_bounds(window->GetBoundsInScreen());
526 const int dy = window->GetBoundsInScreen().bottom() - 516 const int dy = window->GetBoundsInScreen().bottom() -
527 child->GetBoundsInScreen().bottom(); 517 child->GetBoundsInScreen().bottom();
528 DragStart(child.get()); 518 DragStart(child.get());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 561
572 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest, 562 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelWindowResizerTextDirectionTest,
573 testing::Bool()); 563 testing::Bool());
574 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, 564 INSTANTIATE_TEST_CASE_P(NormalPanelPopup,
575 PanelWindowResizerTransientTest, 565 PanelWindowResizerTransientTest,
576 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, 566 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
577 ui::wm::WINDOW_TYPE_PANEL, 567 ui::wm::WINDOW_TYPE_PANEL,
578 ui::wm::WINDOW_TYPE_POPUP)); 568 ui::wm::WINDOW_TYPE_POPUP));
579 569
580 } // namespace ash 570 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_window_resizer.h ('k') | ash/wm/resize_shadow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698