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

Side by Side Diff: ash/mus/workspace/workspace_layout_manager_unittest.cc

Issue 2035543004: Shuffles and renames ash/common/wm classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: random changes for chrome tests Created 4 years, 6 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) 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/common/wm/workspace/workspace_layout_manager.h" 5 #include "ash/common/wm/workspace/workspace_layout_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/wm/fullscreen_window_finder.h" 10 #include "ash/common/wm/fullscreen_window_finder.h"
11 #include "ash/common/wm/window_state.h" 11 #include "ash/common/wm/window_state.h"
12 #include "ash/common/wm/wm_event.h" 12 #include "ash/common/wm/wm_event.h"
13 #include "ash/common/wm/wm_root_window_controller_observer.h"
14 #include "ash/common/wm/wm_screen_util.h" 13 #include "ash/common/wm/wm_screen_util.h"
14 #include "ash/common/wm_root_window_controller_observer.h"
15 #include "ash/mus/bridge/wm_root_window_controller_mus.h" 15 #include "ash/mus/bridge/wm_root_window_controller_mus.h"
16 #include "ash/mus/bridge/wm_window_mus.h" 16 #include "ash/mus/bridge/wm_window_mus.h"
17 #include "ash/mus/test/wm_test_base.h" 17 #include "ash/mus/test/wm_test_base.h"
18 #include "components/mus/public/cpp/tests/test_window.h" 18 #include "components/mus/public/cpp/tests/test_window.h"
19 #include "ui/display/display.h" 19 #include "ui/display/display.h"
20 20
21 namespace ash { 21 namespace ash {
22 namespace mus { 22 namespace mus {
23 namespace { 23 namespace {
24 24
(...skipping 14 matching lines...) Expand all
39 return true; 39 return true;
40 } 40 }
41 41
42 private: 42 private:
43 const gfx::Rect initial_bounds_; 43 const gfx::Rect initial_bounds_;
44 44
45 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView); 45 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView);
46 }; 46 };
47 */ 47 */
48 48
49 class FullscreenObserver : public wm::WmRootWindowControllerObserver { 49 class FullscreenObserver : public WmRootWindowControllerObserver {
50 public: 50 public:
51 explicit FullscreenObserver( 51 explicit FullscreenObserver(WmRootWindowController* root_window_controller)
52 wm::WmRootWindowController* root_window_controller)
53 : root_window_controller_(root_window_controller), 52 : root_window_controller_(root_window_controller),
54 call_count_(0), 53 call_count_(0),
55 is_fullscreen_(false) { 54 is_fullscreen_(false) {
56 root_window_controller_->AddObserver(this); 55 root_window_controller_->AddObserver(this);
57 } 56 }
58 57
59 ~FullscreenObserver() override { 58 ~FullscreenObserver() override {
60 root_window_controller_->RemoveObserver(this); 59 root_window_controller_->RemoveObserver(this);
61 } 60 }
62 61
63 void OnFullscreenStateChanged(bool is_fullscreen) override { 62 void OnFullscreenStateChanged(bool is_fullscreen) override {
64 call_count_++; 63 call_count_++;
65 is_fullscreen_ = is_fullscreen; 64 is_fullscreen_ = is_fullscreen;
66 } 65 }
67 66
68 int call_count() const { return call_count_; } 67 int call_count() const { return call_count_; }
69 68
70 bool is_fullscreen() const { return is_fullscreen_; } 69 bool is_fullscreen() const { return is_fullscreen_; }
71 70
72 private: 71 private:
73 wm::WmRootWindowController* root_window_controller_; 72 WmRootWindowController* root_window_controller_;
74 int call_count_; 73 int call_count_;
75 bool is_fullscreen_; 74 bool is_fullscreen_;
76 75
77 DISALLOW_COPY_AND_ASSIGN(FullscreenObserver); 76 DISALLOW_COPY_AND_ASSIGN(FullscreenObserver);
78 }; 77 };
79 78
80 } // namespace 79 } // namespace
81 80
82 using WorkspaceLayoutManagerTest = WmTestBase; 81 using WorkspaceLayoutManagerTest = WmTestBase;
83 82
84 // Verifies that a window containing a restore coordinate will be restored to 83 // Verifies that a window containing a restore coordinate will be restored to
85 // to the size prior to minimize, keeping the restore rectangle in tact (if 84 // to the size prior to minimize, keeping the restore rectangle in tact (if
86 // there is one). 85 // there is one).
87 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { 86 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
88 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(1, 2, 3, 4)); 87 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(1, 2, 3, 4));
89 wm::WmWindow* window = WmWindowMus::Get(mus_window); 88 WmWindow* window = WmWindowMus::Get(mus_window);
90 gfx::Rect bounds(10, 15, 25, 35); 89 gfx::Rect bounds(10, 15, 25, 35);
91 window->SetBounds(bounds); 90 window->SetBounds(bounds);
92 91
93 wm::WindowState* window_state = window->GetWindowState(); 92 wm::WindowState* window_state = window->GetWindowState();
94 93
95 // This will not be used for un-minimizing window. 94 // This will not be used for un-minimizing window.
96 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); 95 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100));
97 window_state->Minimize(); 96 window_state->Minimize();
98 window_state->Restore(); 97 window_state->Restore();
99 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); 98 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString());
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 window_state->Maximize(); 344 window_state->Maximize();
346 EXPECT_EQ("10,20 30x40", 345 EXPECT_EQ("10,20 30x40",
347 window_state->GetRestoreBoundsInScreen().ToString()); 346 window_state->GetRestoreBoundsInScreen().ToString());
348 window->RemoveObserver(&window_observer); 347 window->RemoveObserver(&window_observer);
349 } 348 }
350 */ 349 */
351 350
352 // Verifies when a window is maximized all descendant windows have a size. 351 // Verifies when a window is maximized all descendant windows have a size.
353 TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) { 352 TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) {
354 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(10, 20, 30, 40)); 353 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(10, 20, 30, 40));
355 wm::WmWindow* window = WmWindowMus::Get(mus_window); 354 WmWindow* window = WmWindowMus::Get(mus_window);
356 355
357 wm::WindowState* window_state = window->GetWindowState(); 356 wm::WindowState* window_state = window->GetWindowState();
358 window_state->Activate(); 357 window_state->Activate();
359 ::mus::Window* child_window = 358 ::mus::Window* child_window =
360 CreateChildTestWindow(mus_window, gfx::Rect(5, 6, 7, 8)); 359 CreateChildTestWindow(mus_window, gfx::Rect(5, 6, 7, 8));
361 window_state->Maximize(); 360 window_state->Maximize();
362 EXPECT_EQ("5,6 7x8", child_window->bounds().ToString()); 361 EXPECT_EQ("5,6 7x8", child_window->bounds().ToString());
363 } 362 }
364 363
365 // Verifies a window created with maximized state has the maximized 364 // Verifies a window created with maximized state has the maximized
366 // bounds. 365 // bounds.
367 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { 366 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) {
368 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect()); 367 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect());
369 WmWindowMus* window = WmWindowMus::Get(mus_window); 368 WmWindowMus* window = WmWindowMus::Get(mus_window);
370 window->GetWindowState()->Maximize(); 369 window->GetWindowState()->Maximize();
371 gfx::Rect work_area(GetPrimaryDisplay().work_area()); 370 gfx::Rect work_area(GetPrimaryDisplay().work_area());
372 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); 371 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString());
373 } 372 }
374 373
375 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { 374 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) {
376 // Normal window bounds shouldn't be changed. 375 // Normal window bounds shouldn't be changed.
377 gfx::Rect window_bounds(100, 100, 200, 200); 376 gfx::Rect window_bounds(100, 100, 200, 200);
378 ::mus::Window* mus_window = CreateTestWindow(window_bounds); 377 ::mus::Window* mus_window = CreateTestWindow(window_bounds);
379 wm::WmWindow* window = WmWindowMus::Get(mus_window); 378 WmWindow* window = WmWindowMus::Get(mus_window);
380 EXPECT_EQ(window_bounds, mus_window->bounds()); 379 EXPECT_EQ(window_bounds, mus_window->bounds());
381 380
382 // If the window is out of the workspace, it would be moved on screen. 381 // If the window is out of the workspace, it would be moved on screen.
383 gfx::Rect root_window_bounds = GetPrimaryRootWindow()->bounds(); 382 gfx::Rect root_window_bounds = GetPrimaryRootWindow()->bounds();
384 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height()); 383 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height());
385 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds)); 384 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds));
386 ::mus::Window* out_mus_window = CreateTestWindow(window_bounds); 385 ::mus::Window* out_mus_window = CreateTestWindow(window_bounds);
387 wm::WmWindow* out_window = WmWindowMus::Get(out_mus_window); 386 WmWindow* out_window = WmWindowMus::Get(out_mus_window);
388 EXPECT_EQ(window_bounds.size(), out_mus_window->bounds().size()); 387 EXPECT_EQ(window_bounds.size(), out_mus_window->bounds().size());
389 gfx::Rect bounds = out_mus_window->bounds(); 388 gfx::Rect bounds = out_mus_window->bounds();
390 bounds.Intersect(root_window_bounds); 389 bounds.Intersect(root_window_bounds);
391 390
392 // 30% of the window edge must be visible. 391 // 30% of the window edge must be visible.
393 EXPECT_GT(bounds.width(), out_mus_window->bounds().width() * 0.29); 392 EXPECT_GT(bounds.width(), out_mus_window->bounds().width() * 0.29);
394 EXPECT_GT(bounds.height(), out_mus_window->bounds().height() * 0.29); 393 EXPECT_GT(bounds.height(), out_mus_window->bounds().height() * 0.29);
395 394
396 ::mus::Window* mus_parent = out_mus_window->parent(); 395 ::mus::Window* mus_parent = out_mus_window->parent();
397 mus_parent->RemoveChild(out_mus_window); 396 mus_parent->RemoveChild(out_mus_window);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 EXPECT_EQ(6, observer.call_count()); 490 EXPECT_EQ(6, observer.call_count());
492 EXPECT_FALSE(observer.is_fullscreen()); 491 EXPECT_FALSE(observer.is_fullscreen());
493 } 492 }
494 // Following "Solo" tests were originally written for BaseLayoutManager. 493 // Following "Solo" tests were originally written for BaseLayoutManager.
495 using WorkspaceLayoutManagerSoloTest = WmTestBase; 494 using WorkspaceLayoutManagerSoloTest = WmTestBase;
496 495
497 // Tests normal->maximize->normal. 496 // Tests normal->maximize->normal.
498 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { 497 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) {
499 gfx::Rect bounds(100, 100, 200, 200); 498 gfx::Rect bounds(100, 100, 200, 200);
500 ::mus::Window* mus_window = CreateTestWindow(bounds); 499 ::mus::Window* mus_window = CreateTestWindow(bounds);
501 wm::WmWindow* window = WmWindowMus::Get(mus_window); 500 WmWindow* window = WmWindowMus::Get(mus_window);
502 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); 501 window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
503 // Maximized window fills the work area, not the whole display. 502 // Maximized window fills the work area, not the whole display.
504 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(), 503 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
505 mus_window->bounds().ToString()); 504 mus_window->bounds().ToString());
506 window->SetShowState(ui::SHOW_STATE_NORMAL); 505 window->SetShowState(ui::SHOW_STATE_NORMAL);
507 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString()); 506 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString());
508 } 507 }
509 508
510 // Tests normal->minimize->normal. 509 // Tests normal->minimize->normal.
511 TEST_F(WorkspaceLayoutManagerSoloTest, Minimize) { 510 TEST_F(WorkspaceLayoutManagerSoloTest, Minimize) {
512 gfx::Rect bounds(100, 100, 200, 200); 511 gfx::Rect bounds(100, 100, 200, 200);
513 ::mus::Window* mus_window = CreateTestWindow(bounds); 512 ::mus::Window* mus_window = CreateTestWindow(bounds);
514 wm::WmWindow* window = WmWindowMus::Get(mus_window); 513 WmWindow* window = WmWindowMus::Get(mus_window);
515 window->SetShowState(ui::SHOW_STATE_MINIMIZED); 514 window->SetShowState(ui::SHOW_STATE_MINIMIZED);
516 // Note: Currently minimize doesn't do anything except set the state. 515 // Note: Currently minimize doesn't do anything except set the state.
517 // See crbug.com/104571. 516 // See crbug.com/104571.
518 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString()); 517 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString());
519 window->SetShowState(ui::SHOW_STATE_NORMAL); 518 window->SetShowState(ui::SHOW_STATE_NORMAL);
520 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString()); 519 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString());
521 } 520 }
522 521
523 // A WindowObserver which sets the focus when the window becomes visible. 522 // A WindowObserver which sets the focus when the window becomes visible.
524 class FocusObserver : public ::mus::WindowObserver { 523 class FocusObserver : public ::mus::WindowObserver {
(...skipping 25 matching lines...) Expand all
550 }; 549 };
551 550
552 // Make sure that the window's show state is correct in 551 // Make sure that the window's show state is correct in
553 // |mus::WindowObserver::OnWindowVisibilityChanged|, and setting 552 // |mus::WindowObserver::OnWindowVisibilityChanged|, and setting
554 // focus in this callback doesn't cause DCHECK error. See 553 // focus in this callback doesn't cause DCHECK error. See
555 // crbug.com/168383. 554 // crbug.com/168383.
556 // NOTE: this was adapted from the ash test of the same name, I suspect this 555 // NOTE: this was adapted from the ash test of the same name, I suspect this
557 // test isn't particularly useful for mash. 556 // test isn't particularly useful for mash.
558 TEST_F(WorkspaceLayoutManagerSoloTest, FocusDuringUnminimize) { 557 TEST_F(WorkspaceLayoutManagerSoloTest, FocusDuringUnminimize) {
559 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(100, 100, 100, 100)); 558 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(100, 100, 100, 100));
560 wm::WmWindow* window = WmWindowMus::Get(mus_window); 559 WmWindow* window = WmWindowMus::Get(mus_window);
561 FocusObserver observer(mus_window); 560 FocusObserver observer(mus_window);
562 window->SetShowState(ui::SHOW_STATE_MINIMIZED); 561 window->SetShowState(ui::SHOW_STATE_MINIMIZED);
563 EXPECT_FALSE(window->IsVisible()); 562 EXPECT_FALSE(window->IsVisible());
564 EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, observer.GetShowStateAndReset()); 563 EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, observer.GetShowStateAndReset());
565 window->Show(); 564 window->Show();
566 EXPECT_TRUE(window->IsVisible()); 565 EXPECT_TRUE(window->IsVisible());
567 EXPECT_EQ(ui::SHOW_STATE_NORMAL, observer.GetShowStateAndReset()); 566 EXPECT_EQ(ui::SHOW_STATE_NORMAL, observer.GetShowStateAndReset());
568 } 567 }
569 568
570 // Tests maximized window size during root window resize. 569 // Tests maximized window size during root window resize.
571 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeRootWindowResize) { 570 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeRootWindowResize) {
572 gfx::Rect bounds(100, 100, 200, 200); 571 gfx::Rect bounds(100, 100, 200, 200);
573 ::mus::Window* mus_window = CreateTestWindow(bounds); 572 ::mus::Window* mus_window = CreateTestWindow(bounds);
574 wm::WmWindow* window = WmWindowMus::Get(mus_window); 573 WmWindow* window = WmWindowMus::Get(mus_window);
575 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); 574 window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
576 gfx::Rect initial_work_area_bounds = 575 gfx::Rect initial_work_area_bounds =
577 wm::GetMaximizedWindowBoundsInParent(window); 576 wm::GetMaximizedWindowBoundsInParent(window);
578 EXPECT_EQ(initial_work_area_bounds.ToString(), 577 EXPECT_EQ(initial_work_area_bounds.ToString(),
579 mus_window->bounds().ToString()); 578 mus_window->bounds().ToString());
580 // Enlarge the root window. We should still match the work area size. 579 // Enlarge the root window. We should still match the work area size.
581 UpdateDisplay("900x700"); 580 UpdateDisplay("900x700");
582 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(), 581 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
583 mus_window->bounds().ToString()); 582 mus_window->bounds().ToString());
584 EXPECT_NE(initial_work_area_bounds.ToString(), 583 EXPECT_NE(initial_work_area_bounds.ToString(),
585 wm::GetMaximizedWindowBoundsInParent(window).ToString()); 584 wm::GetMaximizedWindowBoundsInParent(window).ToString());
586 } 585 }
587 586
588 // Tests normal->fullscreen->normal. 587 // Tests normal->fullscreen->normal.
589 TEST_F(WorkspaceLayoutManagerSoloTest, Fullscreen) { 588 TEST_F(WorkspaceLayoutManagerSoloTest, Fullscreen) {
590 gfx::Rect bounds(100, 100, 200, 200); 589 gfx::Rect bounds(100, 100, 200, 200);
591 ::mus::Window* mus_window = CreateTestWindow(bounds); 590 ::mus::Window* mus_window = CreateTestWindow(bounds);
592 wm::WmWindow* window = WmWindowMus::Get(mus_window); 591 WmWindow* window = WmWindowMus::Get(mus_window);
593 window->SetShowState(ui::SHOW_STATE_FULLSCREEN); 592 window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
594 // Fullscreen window fills the whole display. 593 // Fullscreen window fills the whole display.
595 EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(), 594 EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(),
596 mus_window->bounds().ToString()); 595 mus_window->bounds().ToString());
597 window->SetShowState(ui::SHOW_STATE_NORMAL); 596 window->SetShowState(ui::SHOW_STATE_NORMAL);
598 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString()); 597 EXPECT_EQ(bounds.ToString(), mus_window->bounds().ToString());
599 } 598 }
600 599
601 // Tests that fullscreen window causes always_on_top windows to stack below. 600 // Tests that fullscreen window causes always_on_top windows to stack below.
602 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenSuspendsAlwaysOnTop) { 601 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenSuspendsAlwaysOnTop) {
603 gfx::Rect bounds(100, 100, 200, 200); 602 gfx::Rect bounds(100, 100, 200, 200);
604 ::mus::Window* mus_fullscreen_window = CreateTestWindow(bounds); 603 ::mus::Window* mus_fullscreen_window = CreateTestWindow(bounds);
605 WmWindowMus* fullscreen_window = WmWindowMus::Get(mus_fullscreen_window); 604 WmWindowMus* fullscreen_window = WmWindowMus::Get(mus_fullscreen_window);
606 ::mus::Window* mus_always_on_top_window1 = CreateTestWindow(bounds); 605 ::mus::Window* mus_always_on_top_window1 = CreateTestWindow(bounds);
607 WmWindowMus* always_on_top_window1 = 606 WmWindowMus* always_on_top_window1 =
608 WmWindowMus::Get(mus_always_on_top_window1); 607 WmWindowMus::Get(mus_always_on_top_window1);
609 ::mus::Window* mus_always_on_top_window2 = CreateTestWindow(bounds); 608 ::mus::Window* mus_always_on_top_window2 = CreateTestWindow(bounds);
610 WmWindowMus* always_on_top_window2 = 609 WmWindowMus* always_on_top_window2 =
611 WmWindowMus::Get(mus_always_on_top_window2); 610 WmWindowMus::Get(mus_always_on_top_window2);
612 always_on_top_window1->SetAlwaysOnTop(true); 611 always_on_top_window1->SetAlwaysOnTop(true);
613 always_on_top_window2->SetAlwaysOnTop(true); 612 always_on_top_window2->SetAlwaysOnTop(true);
614 // Making a window fullscreen temporarily suspends always on top state. 613 // Making a window fullscreen temporarily suspends always on top state.
615 fullscreen_window->SetShowState(ui::SHOW_STATE_FULLSCREEN); 614 fullscreen_window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
616 EXPECT_FALSE(always_on_top_window1->IsAlwaysOnTop()); 615 EXPECT_FALSE(always_on_top_window1->IsAlwaysOnTop());
617 EXPECT_FALSE(always_on_top_window2->IsAlwaysOnTop()); 616 EXPECT_FALSE(always_on_top_window2->IsAlwaysOnTop());
618 EXPECT_TRUE(GetWindowForFullscreenMode(fullscreen_window)); 617 EXPECT_TRUE(wm::GetWindowForFullscreenMode(fullscreen_window));
619 // Making fullscreen window normal restores always on top windows. 618 // Making fullscreen window normal restores always on top windows.
620 fullscreen_window->SetShowState(ui::SHOW_STATE_NORMAL); 619 fullscreen_window->SetShowState(ui::SHOW_STATE_NORMAL);
621 EXPECT_TRUE(always_on_top_window1->IsAlwaysOnTop()); 620 EXPECT_TRUE(always_on_top_window1->IsAlwaysOnTop());
622 EXPECT_TRUE(always_on_top_window2->IsAlwaysOnTop()); 621 EXPECT_TRUE(always_on_top_window2->IsAlwaysOnTop());
623 EXPECT_FALSE(GetWindowForFullscreenMode(fullscreen_window)); 622 EXPECT_FALSE(wm::GetWindowForFullscreenMode(fullscreen_window));
624 } 623 }
625 624
626 // Tests fullscreen window size during root window resize. 625 // Tests fullscreen window size during root window resize.
627 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenRootWindowResize) { 626 TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenRootWindowResize) {
628 gfx::Rect bounds(100, 100, 200, 200); 627 gfx::Rect bounds(100, 100, 200, 200);
629 ::mus::Window* mus_window = CreateTestWindow(bounds); 628 ::mus::Window* mus_window = CreateTestWindow(bounds);
630 wm::WmWindow* window = WmWindowMus::Get(mus_window); 629 WmWindow* window = WmWindowMus::Get(mus_window);
631 // Fullscreen window fills the whole display. 630 // Fullscreen window fills the whole display.
632 window->SetShowState(ui::SHOW_STATE_FULLSCREEN); 631 window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
633 EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(), 632 EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(),
634 mus_window->bounds().ToString()); 633 mus_window->bounds().ToString());
635 // Enlarge the root window. We should still match the display size. 634 // Enlarge the root window. We should still match the display size.
636 UpdateDisplay("1001x1201"); 635 UpdateDisplay("1001x1201");
637 EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(), 636 EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(),
638 mus_window->bounds().ToString()); 637 mus_window->bounds().ToString());
639 } 638 }
640 639
641 // Tests that when the screen gets smaller the windows aren't bigger than 640 // Tests that when the screen gets smaller the windows aren't bigger than
642 // the screen. 641 // the screen.
643 TEST_F(WorkspaceLayoutManagerSoloTest, RootWindowResizeShrinksWindows) { 642 TEST_F(WorkspaceLayoutManagerSoloTest, RootWindowResizeShrinksWindows) {
644 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(10, 20, 500, 400)); 643 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(10, 20, 500, 400));
645 wm::WmWindow* window = WmWindowMus::Get(mus_window); 644 WmWindow* window = WmWindowMus::Get(mus_window);
646 gfx::Rect work_area = window->GetDisplayNearestWindow().work_area(); 645 gfx::Rect work_area = window->GetDisplayNearestWindow().work_area();
647 // Invariant: Window is smaller than work area. 646 // Invariant: Window is smaller than work area.
648 EXPECT_LE(mus_window->bounds().width(), work_area.width()); 647 EXPECT_LE(mus_window->bounds().width(), work_area.width());
649 EXPECT_LE(mus_window->bounds().height(), work_area.height()); 648 EXPECT_LE(mus_window->bounds().height(), work_area.height());
650 649
651 // Make the root window narrower than our window. 650 // Make the root window narrower than our window.
652 UpdateDisplay("300x400"); 651 UpdateDisplay("300x400");
653 work_area = window->GetDisplayNearestWindow().work_area(); 652 work_area = window->GetDisplayNearestWindow().work_area();
654 EXPECT_LE(mus_window->bounds().width(), work_area.width()); 653 EXPECT_LE(mus_window->bounds().width(), work_area.width());
655 EXPECT_LE(mus_window->bounds().height(), work_area.height()); 654 EXPECT_LE(mus_window->bounds().height(), work_area.height());
656 655
657 // Make the root window shorter than our window. 656 // Make the root window shorter than our window.
658 UpdateDisplay("300x200"); 657 UpdateDisplay("300x200");
659 work_area = window->GetDisplayNearestWindow().work_area(); 658 work_area = window->GetDisplayNearestWindow().work_area();
660 EXPECT_LE(mus_window->bounds().width(), work_area.width()); 659 EXPECT_LE(mus_window->bounds().width(), work_area.width());
661 EXPECT_LE(mus_window->bounds().height(), work_area.height()); 660 EXPECT_LE(mus_window->bounds().height(), work_area.height());
662 661
663 // Enlarging the root window does not change the window bounds. 662 // Enlarging the root window does not change the window bounds.
664 gfx::Rect old_bounds = mus_window->bounds(); 663 gfx::Rect old_bounds = mus_window->bounds();
665 UpdateDisplay("800x600"); 664 UpdateDisplay("800x600");
666 EXPECT_EQ(old_bounds.width(), mus_window->bounds().width()); 665 EXPECT_EQ(old_bounds.width(), mus_window->bounds().width());
667 EXPECT_EQ(old_bounds.height(), mus_window->bounds().height()); 666 EXPECT_EQ(old_bounds.height(), mus_window->bounds().height());
668 } 667 }
669 668
670 // Verifies maximizing sets the restore bounds, and restoring 669 // Verifies maximizing sets the restore bounds, and restoring
671 // restores the bounds. 670 // restores the bounds.
672 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeSetsRestoreBounds) { 671 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeSetsRestoreBounds) {
673 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(10, 20, 30, 40)); 672 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(10, 20, 30, 40));
674 wm::WmWindow* window = WmWindowMus::Get(mus_window); 673 WmWindow* window = WmWindowMus::Get(mus_window);
675 wm::WindowState* window_state = window->GetWindowState(); 674 wm::WindowState* window_state = window->GetWindowState();
676 675
677 // Maximize it, which will keep the previous restore bounds. 676 // Maximize it, which will keep the previous restore bounds.
678 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); 677 window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
679 EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInParent().ToString()); 678 EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInParent().ToString());
680 679
681 // Restore it, which should restore bounds and reset restore bounds. 680 // Restore it, which should restore bounds and reset restore bounds.
682 window->SetShowState(ui::SHOW_STATE_NORMAL); 681 window->SetShowState(ui::SHOW_STATE_NORMAL);
683 EXPECT_EQ("10,20 30x40", mus_window->bounds().ToString()); 682 EXPECT_EQ("10,20 30x40", mus_window->bounds().ToString());
684 EXPECT_FALSE(window_state->HasRestoreBounds()); 683 EXPECT_FALSE(window_state->HasRestoreBounds());
685 } 684 }
686 685
687 // Verifies maximizing keeps the restore bounds if set. 686 // Verifies maximizing keeps the restore bounds if set.
688 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeResetsRestoreBounds) { 687 TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeResetsRestoreBounds) {
689 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(1, 2, 3, 4)); 688 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(1, 2, 3, 4));
690 wm::WmWindow* window = WmWindowMus::Get(mus_window); 689 WmWindow* window = WmWindowMus::Get(mus_window);
691 690
692 wm::WindowState* window_state = window->GetWindowState(); 691 wm::WindowState* window_state = window->GetWindowState();
693 window_state->SetRestoreBoundsInParent(gfx::Rect(10, 11, 12, 13)); 692 window_state->SetRestoreBoundsInParent(gfx::Rect(10, 11, 12, 13));
694 693
695 // Maximize it, which will keep the previous restore bounds. 694 // Maximize it, which will keep the previous restore bounds.
696 window->SetShowState(ui::SHOW_STATE_MAXIMIZED); 695 window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
697 EXPECT_EQ("10,11 12x13", window_state->GetRestoreBoundsInParent().ToString()); 696 EXPECT_EQ("10,11 12x13", window_state->GetRestoreBoundsInParent().ToString());
698 } 697 }
699 698
700 // Verifies that the restore bounds do not get reset when restoring to a 699 // Verifies that the restore bounds do not get reset when restoring to a
701 // maximzied state from a minimized state. 700 // maximzied state from a minimized state.
702 TEST_F(WorkspaceLayoutManagerSoloTest, 701 TEST_F(WorkspaceLayoutManagerSoloTest,
703 BoundsAfterRestoringToMaximizeFromMinimize) { 702 BoundsAfterRestoringToMaximizeFromMinimize) {
704 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(1, 2, 3, 4)); 703 ::mus::Window* mus_window = CreateTestWindow(gfx::Rect(1, 2, 3, 4));
705 wm::WmWindow* window = WmWindowMus::Get(mus_window); 704 WmWindow* window = WmWindowMus::Get(mus_window);
706 gfx::Rect bounds(10, 15, 25, 35); 705 gfx::Rect bounds(10, 15, 25, 35);
707 window->SetBounds(bounds); 706 window->SetBounds(bounds);
708 707
709 wm::WindowState* window_state = window->GetWindowState(); 708 wm::WindowState* window_state = window->GetWindowState();
710 // Maximize it, which should reset restore bounds. 709 // Maximize it, which should reset restore bounds.
711 window_state->Maximize(); 710 window_state->Maximize();
712 EXPECT_EQ(bounds.ToString(), 711 EXPECT_EQ(bounds.ToString(),
713 window_state->GetRestoreBoundsInParent().ToString()); 712 window_state->GetRestoreBoundsInParent().ToString());
714 // Minimize the window. The restore bounds should not change. 713 // Minimize the window. The restore bounds should not change.
715 window_state->Minimize(); 714 window_state->Minimize();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 761
763 // TODO(sky): these are commented out until maximize mode ported. 762 // TODO(sky): these are commented out until maximize mode ported.
764 // http://crbug.com/612629. 763 // http://crbug.com/612629.
765 764
766 // Following tests are written to test the backdrop functionality. 765 // Following tests are written to test the backdrop functionality.
767 766
768 namespace { 767 namespace {
769 768
770 WorkspaceLayoutManager* GetWorkspaceLayoutManager(aura::Window* container) { 769 WorkspaceLayoutManager* GetWorkspaceLayoutManager(aura::Window* container) {
771 return static_cast<WorkspaceLayoutManager*>( 770 return static_cast<WorkspaceLayoutManager*>(
772 wm::WmWindowAura::Get(container)->GetLayoutManager()); 771 WmWindowAura::Get(container)->GetLayoutManager());
773 } 772 }
774 773
775 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase { 774 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase {
776 public: 775 public:
777 WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {} 776 WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {}
778 ~WorkspaceLayoutManagerBackdropTest() override {} 777 ~WorkspaceLayoutManagerBackdropTest() override {}
779 778
780 void SetUp() override { 779 void SetUp() override {
781 test::AshTestBase::SetUp(); 780 test::AshTestBase::SetUp();
782 UpdateDisplay("800x600"); 781 UpdateDisplay("800x600");
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 occluded_window_bounds.width(), 1095 occluded_window_bounds.width(),
1097 occluded_window_bounds.height()).ToString(), 1096 occluded_window_bounds.height()).ToString(),
1098 window->bounds().ToString()); 1097 window->bounds().ToString());
1099 HideKeyboard(); 1098 HideKeyboard();
1100 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); 1099 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString());
1101 } 1100 }
1102 */ 1101 */
1103 1102
1104 } // namespace mus 1103 } // namespace mus
1105 } // namespace ash 1104 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698