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

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

Issue 2739703003: Last sets of tests that can move to common_unittests (Closed)
Patch Set: comments Created 3 years, 9 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
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/common/wm/panels/panel_window_resizer.h" 5 #include "ash/common/wm/panels/panel_window_resizer.h"
6 6
7 #include "ash/common/shelf/shelf_layout_manager.h" 7 #include "ash/common/shelf/shelf_layout_manager.h"
8 #include "ash/common/shelf/shelf_model.h" 8 #include "ash/common/shelf/shelf_model.h"
9 #include "ash/common/shelf/shelf_widget.h" 9 #include "ash/common/shelf/shelf_widget.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 protected: 217 protected:
218 ui::wm::WindowType transient_window_type_; 218 ui::wm::WindowType transient_window_type_;
219 219
220 private: 220 private:
221 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTransientTest); 221 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTransientTest);
222 }; 222 };
223 223
224 // Verifies a window can be dragged from the panel and detached and then 224 // Verifies a window can be dragged from the panel and detached and then
225 // reattached. 225 // reattached.
226 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) { 226 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) {
227 // TODO: investigate failure. http://crbug.com/698888.
228 if (WmShell::Get()->IsRunningInMash())
229 return;
230
227 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 231 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
228 DetachReattachTest(window.get(), 0, -1); 232 DetachReattachTest(window.get(), 0, -1);
229 } 233 }
230 234
231 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) { 235 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) {
236 // TODO: investigate failure. http://crbug.com/698888.
237 if (WmShell::Get()->IsRunningInMash())
238 return;
239
232 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); 240 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT);
233 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 241 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
234 DetachReattachTest(window.get(), 1, 0); 242 DetachReattachTest(window.get(), 1, 0);
235 } 243 }
236 244
237 TEST_F(PanelWindowResizerTest, PanelDetachReattachRight) { 245 TEST_F(PanelWindowResizerTest, PanelDetachReattachRight) {
246 // TODO: investigate failure. http://crbug.com/698888.
247 if (WmShell::Get()->IsRunningInMash())
248 return;
249
238 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT); 250 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT);
239 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 251 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
240 DetachReattachTest(window.get(), -1, 0); 252 DetachReattachTest(window.get(), -1, 0);
241 } 253 }
242 254
243 // Tests that a drag continues when the shelf is hidden. This occurs as part of 255 // Tests that a drag continues when the shelf is hidden. This occurs as part of
244 // the animation when switching profiles. http://crbug.com/393047. 256 // the animation when switching profiles. http://crbug.com/393047.
245 TEST_F(PanelWindowResizerTest, DetachThenHideShelf) { 257 TEST_F(PanelWindowResizerTest, DetachThenHideShelf) {
246 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 258 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
247 wm::WindowState* state = wm::GetWindowState(window.get()); 259 wm::WindowState* state = wm::GetWindowState(window.get());
(...skipping 14 matching lines...) Expand all
262 DragEnd(); 274 DragEnd();
263 275
264 // When the drag ends the window should be detached and placed where it was 276 // When the drag ends the window should be detached and placed where it was
265 // dragged to. 277 // dragged to.
266 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 278 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
267 EXPECT_FALSE(state->IsMinimized()); 279 EXPECT_FALSE(state->IsMinimized());
268 EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString()); 280 EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString());
269 } 281 }
270 282
271 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) { 283 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) {
284 // TODO: investigate failure. http://crbug.com/698888.
285 if (WmShell::Get()->IsRunningInMash())
286 return;
287
272 UpdateDisplay("600x400,600x400"); 288 UpdateDisplay("600x400,600x400");
273 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 289 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
274 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(600, 0))); 290 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(600, 0)));
275 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 291 EXPECT_EQ(root_windows[1], window->GetRootWindow());
276 DetachReattachTest(window.get(), 0, -1); 292 DetachReattachTest(window.get(), 0, -1);
277 } 293 }
278 294
279 TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) { 295 TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) {
296 // TODO: investigate failure. http://crbug.com/698888.
297 if (WmShell::Get()->IsRunningInMash())
298 return;
299
280 UpdateDisplay("600x400,600x400"); 300 UpdateDisplay("600x400,600x400");
281 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 301 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
282 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 302 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
283 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 303 gfx::Rect initial_bounds = window->GetBoundsInScreen();
284 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 304 EXPECT_EQ(root_windows[0], window->GetRootWindow());
285 DragStart(window.get()); 305 DragStart(window.get());
286 DragMove(0, -100); 306 DragMove(0, -100);
287 DragEnd(); 307 DragEnd();
288 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 308 EXPECT_EQ(root_windows[0], window->GetRootWindow());
289 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); 309 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x());
290 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); 310 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y());
291 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); 311 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey));
292 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 312 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
293 313
294 DragStart(window.get()); 314 DragStart(window.get());
295 DragMove(500, 0); 315 DragMove(500, 0);
296 DragEnd(); 316 DragEnd();
297 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 317 EXPECT_EQ(root_windows[1], window->GetRootWindow());
298 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); 318 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
299 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); 319 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y());
300 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); 320 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey));
301 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 321 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
302 } 322 }
303 323
304 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) { 324 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) {
325 // TODO: investigate failure. http://crbug.com/698888.
326 if (WmShell::Get()->IsRunningInMash())
327 return;
328
305 UpdateDisplay("600x400,600x400"); 329 UpdateDisplay("600x400,600x400");
306 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 330 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
307 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 331 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
308 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 332 gfx::Rect initial_bounds = window->GetBoundsInScreen();
309 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 333 EXPECT_EQ(root_windows[0], window->GetRootWindow());
310 DragStart(window.get()); 334 DragStart(window.get());
311 DragMove(500, -100); 335 DragMove(500, -100);
312 DragEnd(); 336 DragEnd();
313 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 337 EXPECT_EQ(root_windows[1], window->GetRootWindow());
314 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); 338 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
315 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); 339 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y());
316 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); 340 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey));
317 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 341 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
318 } 342 }
319 343
320 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { 344 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) {
345 // TODO: investigate failure. http://crbug.com/698888.
346 if (WmShell::Get()->IsRunningInMash())
347 return;
348
321 UpdateDisplay("600x400,600x600"); 349 UpdateDisplay("600x400,600x600");
322 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 350 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
323 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 351 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
324 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 352 gfx::Rect initial_bounds = window->GetBoundsInScreen();
325 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 353 EXPECT_EQ(root_windows[0], window->GetRootWindow());
326 354
327 // Detach the window. 355 // Detach the window.
328 DragStart(window.get()); 356 DragStart(window.get());
329 DragMove(0, -100); 357 DragMove(0, -100);
330 DragEnd(); 358 DragEnd();
331 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 359 EXPECT_EQ(root_windows[0], window->GetRootWindow());
332 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); 360 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey));
333 361
334 // Drag the window just above the other display's launcher. 362 // Drag the window just above the other display's launcher.
335 DragStart(window.get()); 363 DragStart(window.get());
336 DragMove(500, 295); 364 DragMove(500, 295);
337 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); 365 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
338 366
339 // Should stick to other launcher. 367 // Should stick to other launcher.
340 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); 368 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y());
341 DragEnd(); 369 DragEnd();
342 370
343 // When dropped should move to second display's panel container. 371 // When dropped should move to second display's panel container.
344 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 372 EXPECT_EQ(root_windows[1], window->GetRootWindow());
345 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); 373 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey));
346 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 374 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
347 } 375 }
348 376
349 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { 377 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) {
378 // TODO: investigate failure. http://crbug.com/698888.
379 if (WmShell::Get()->IsRunningInMash())
380 return;
381
350 UpdateDisplay("600x400,600x600"); 382 UpdateDisplay("600x400,600x600");
351 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 383 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
352 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 384 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
353 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 385 gfx::Rect initial_bounds = window->GetBoundsInScreen();
354 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 386 EXPECT_EQ(root_windows[0], window->GetRootWindow());
355 387
356 // Drag the window just above the other display's launcher. 388 // Drag the window just above the other display's launcher.
357 DragStart(window.get()); 389 DragStart(window.get());
358 DragMove(500, 195); 390 DragMove(500, 195);
359 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); 391 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x());
360 392
361 // Should stick to other launcher. 393 // Should stick to other launcher.
362 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); 394 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y());
363 DragEnd(); 395 DragEnd();
364 396
365 // When dropped should move to second display's panel container. 397 // When dropped should move to second display's panel container.
366 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 398 EXPECT_EQ(root_windows[1], window->GetRootWindow());
367 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); 399 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey));
368 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); 400 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id());
369 } 401 }
370 402
371 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) { 403 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) {
404 // TODO: investigate failure. http://crbug.com/698888.
405 if (WmShell::Get()->IsRunningInMash())
406 return;
407
372 UpdateDisplay("600x400,600x600"); 408 UpdateDisplay("600x400,600x600");
373 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 409 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
374 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 410 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
375 std::unique_ptr<aura::Window> fullscreen( 411 std::unique_ptr<aura::Window> fullscreen(
376 CreateTestWindowInShellWithBounds(gfx::Rect(600, 0, 101, 101))); 412 CreateTestWindowInShellWithBounds(gfx::Rect(600, 0, 101, 101)));
377 wm::GetWindowState(fullscreen.get())->Activate(); 413 wm::GetWindowState(fullscreen.get())->Activate();
378 const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 414 const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
379 wm::GetWindowState(fullscreen.get())->OnWMEvent(&event); 415 wm::GetWindowState(fullscreen.get())->OnWMEvent(&event);
380 EXPECT_TRUE(wm::GetWindowState(fullscreen.get())->IsFullscreen()); 416 EXPECT_TRUE(wm::GetWindowState(fullscreen.get())->IsFullscreen());
381 417
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 484 }
449 485
450 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) { 486 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) {
451 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); 487 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT);
452 DragAlongShelfReorder(0, -1); 488 DragAlongShelfReorder(0, -1);
453 } 489 }
454 490
455 // Tests that panels can have transient children of different types. 491 // Tests that panels can have transient children of different types.
456 // The transient children should be reparented in sync with the panel. 492 // The transient children should be reparented in sync with the panel.
457 TEST_P(PanelWindowResizerTransientTest, PanelWithTransientChild) { 493 TEST_P(PanelWindowResizerTransientTest, PanelWithTransientChild) {
494 // TODO: investigate failure. http://crbug.com/698888.
495 if (WmShell::Get()->IsRunningInMash())
496 return;
497
458 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); 498 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0)));
459 std::unique_ptr<aura::Window> child( 499 std::unique_ptr<aura::Window> child(
460 CreateTestWindowInShellWithDelegateAndType( 500 CreateTestWindowInShellWithDelegateAndType(
461 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40))); 501 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40)));
462 ::wm::AddTransientChild(window.get(), child.get()); 502 ::wm::AddTransientChild(window.get(), child.get());
463 if (window->parent() != child->parent()) 503 if (window->parent() != child->parent())
464 window->parent()->AddChild(child.get()); 504 window->parent()->AddChild(child.get());
465 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); 505 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get()));
466 506
467 // Drag the child to the shelf. Its new position should not be overridden. 507 // Drag the child to the shelf. Its new position should not be overridden.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 INSTANTIATE_TEST_CASE_P(LtrRtl, 555 INSTANTIATE_TEST_CASE_P(LtrRtl,
516 PanelWindowResizerTextDirectionTest, 556 PanelWindowResizerTextDirectionTest,
517 testing::Bool()); 557 testing::Bool());
518 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, 558 INSTANTIATE_TEST_CASE_P(NormalPanelPopup,
519 PanelWindowResizerTransientTest, 559 PanelWindowResizerTransientTest,
520 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, 560 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
521 ui::wm::WINDOW_TYPE_PANEL, 561 ui::wm::WINDOW_TYPE_PANEL,
522 ui::wm::WINDOW_TYPE_POPUP)); 562 ui::wm::WINDOW_TYPE_POPUP));
523 563
524 } // namespace ash 564 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_layout_manager_unittest.cc ('k') | ash/wm/system_modal_container_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698