Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/wm/public/window_manager.h" | 5 #include "athena/wm/public/window_manager.h" |
| 6 | 6 |
| 7 #include "athena/screen/public/screen_manager.h" | 7 #include "athena/screen/public/screen_manager.h" |
| 8 #include "athena/test/base/athena_test_base.h" | 8 #include "athena/test/base/athena_test_base.h" |
| 9 #include "athena/test/base/test_windows.h" | 9 #include "athena/test/base/test_windows.h" |
| 10 #include "athena/wm/public/window_list_provider.h" | 10 #include "athena/wm/public/window_list_provider.h" |
| 11 #include "athena/wm/split_view_controller.h" | 11 #include "athena/wm/split_view_controller.h" |
| 12 #include "athena/wm/test/window_manager_impl_test_api.h" | 12 #include "athena/wm/test/window_manager_impl_test_api.h" |
| 13 #include "athena/wm/window_manager_impl.h" | 13 #include "athena/wm/window_manager_impl.h" |
| 14 #include "ui/aura/client/aura_constants.h" | |
| 14 #include "ui/aura/client/window_tree_client.h" | 15 #include "ui/aura/client/window_tree_client.h" |
| 15 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
| 16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 17 #include "ui/base/hit_test.h" | 18 #include "ui/base/hit_test.h" |
| 18 #include "ui/events/test/event_generator.h" | 19 #include "ui/events/test/event_generator.h" |
| 19 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
| 20 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 21 #include "ui/wm/core/window_util.h" | 22 #include "ui/wm/core/window_util.h" |
| 22 | 23 |
| 23 namespace athena { | 24 namespace athena { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 EXPECT_TRUE(w3->IsVisible()); | 95 EXPECT_TRUE(w3->IsVisible()); |
| 95 | 96 |
| 96 // Go into split-view mode. | 97 // Go into split-view mode. |
| 97 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); | 98 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); |
| 98 overview_delegate->OnSelectSplitViewWindow(w3.get(), nullptr, w3.get()); | 99 overview_delegate->OnSelectSplitViewWindow(w3.get(), nullptr, w3.get()); |
| 99 EXPECT_TRUE(w3->IsVisible()); | 100 EXPECT_TRUE(w3->IsVisible()); |
| 100 EXPECT_TRUE(w2->IsVisible()); | 101 EXPECT_TRUE(w2->IsVisible()); |
| 101 EXPECT_FALSE(w1->IsVisible()); | 102 EXPECT_FALSE(w1->IsVisible()); |
| 102 } | 103 } |
| 103 | 104 |
| 105 TEST_F(WindowManagerTest, OnSelectWindow) { | |
| 106 test::WindowManagerImplTestApi wm_api; | |
| 107 aura::test::TestWindowDelegate delegate1; | |
| 108 aura::test::TestWindowDelegate delegate2; | |
| 109 aura::test::TestWindowDelegate delegate3; | |
| 110 | |
| 111 // (w1): A window that sets a maximum size | |
| 112 delegate1.set_maximum_size(gfx::Size(300, 200)); | |
| 113 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate1)); | |
| 114 w1->SetBounds(gfx::Rect(0, 0, 300, 200)); | |
| 115 | |
| 116 // (w2): A window that doesn't set a max size and is maximizable | |
| 117 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate2)); | |
| 118 w2->SetBounds(gfx::Rect(0, 0, 300, 200)); | |
| 119 w2->SetProperty(aura::client::kCanMaximizeKey, true); | |
| 120 | |
| 121 // (w3): A window that doesn't set a max size but is NOT maximizable | |
| 122 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate3)); | |
| 123 w3->SetBounds(gfx::Rect(0, 0, 300, 200)); | |
| 124 w3->SetProperty(aura::client::kCanMaximizeKey, false); | |
| 125 | |
| 126 const gfx::Size old_bounds1 = w1->GetTargetBounds().size(); | |
| 127 const gfx::Size old_bounds2 = w2->GetTargetBounds().size(); | |
| 128 const gfx::Size old_bounds3 = w3->GetTargetBounds().size(); | |
| 129 const gfx::Size work_area = | |
| 130 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | |
| 131 | |
| 132 // Select w1, which has a max size, in the overview mode and make sure it's | |
| 133 // not maximized. | |
| 134 WindowManager::Get()->EnterOverview(); | |
| 135 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); | |
| 136 overview_delegate->OnSelectWindow(w1.get()); | |
| 137 const gfx::Size new_bounds1 = w1->GetTargetBounds().size(); | |
| 138 EXPECT_EQ(new_bounds1.ToString(), old_bounds1.ToString()); | |
| 139 EXPECT_NE(work_area.ToString(), new_bounds1.ToString()); | |
| 140 | |
| 141 // Select w2, which has no max size & can be maximized, in the overview | |
| 142 // mode and make sure it's actually maximized. | |
| 143 WindowManager::Get()->EnterOverview(); | |
| 144 overview_delegate->OnSelectWindow(w2.get()); | |
| 145 const gfx::Size new_bounds2 = w2->GetTargetBounds().size(); | |
| 146 EXPECT_NE(new_bounds2.ToString(), old_bounds2.ToString()); | |
| 147 EXPECT_EQ(work_area.ToString(), new_bounds2.ToString()); | |
| 148 | |
| 149 // Select w3, which has no max size & cannot be maximized, in the overview | |
| 150 // mode and make sure it's not maximized. | |
| 151 WindowManager::Get()->EnterOverview(); | |
| 152 overview_delegate->OnSelectWindow(w3.get()); | |
| 153 const gfx::Size new_bounds3 = w3->GetTargetBounds().size(); | |
| 154 EXPECT_EQ(new_bounds3.ToString(), old_bounds3.ToString()); | |
| 155 EXPECT_NE(work_area.ToString(), new_bounds3.ToString()); | |
| 156 } | |
| 157 | |
| 104 TEST_F(WindowManagerTest, NewWindowFromOverview) { | 158 TEST_F(WindowManagerTest, NewWindowFromOverview) { |
| 105 aura::test::TestWindowDelegate delegate; | 159 aura::test::TestWindowDelegate delegate; |
| 106 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); | 160 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
| 107 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); | 161 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
| 108 | 162 |
| 109 WindowManager::Get()->EnterOverview(); | 163 WindowManager::Get()->EnterOverview(); |
| 110 EXPECT_TRUE(w1->IsVisible()); | 164 EXPECT_TRUE(w1->IsVisible()); |
| 111 EXPECT_TRUE(w2->IsVisible()); | 165 EXPECT_TRUE(w2->IsVisible()); |
| 112 | 166 |
| 113 // Test that opening a new window exits overview mode. The new window could | 167 // Test that opening a new window exits overview mode. The new window could |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 EXPECT_TRUE(WindowManager::Get()->IsOverviewModeActive()); | 379 EXPECT_TRUE(WindowManager::Get()->IsOverviewModeActive()); |
| 326 generator.PressKey(ui::VKEY_ESCAPE, ui::EF_NONE); | 380 generator.PressKey(ui::VKEY_ESCAPE, ui::EF_NONE); |
| 327 EXPECT_FALSE(WindowManager::Get()->IsOverviewModeActive()); | 381 EXPECT_FALSE(WindowManager::Get()->IsOverviewModeActive()); |
| 328 } | 382 } |
| 329 | 383 |
| 330 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { | 384 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { |
| 331 test::WindowManagerImplTestApi wm_api; | 385 test::WindowManagerImplTestApi wm_api; |
| 332 | 386 |
| 333 aura::test::TestWindowDelegate delegate; | 387 aura::test::TestWindowDelegate delegate; |
| 334 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); | 388 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
| 389 w1->SetProperty(aura::client::kCanMaximizeKey, true); | |
| 335 | 390 |
| 336 // Splitview mode needs at least two windows. | 391 // Splitview mode needs at least two windows. |
| 337 wm_api.wm()->ToggleSplitView(); | 392 wm_api.wm()->ToggleSplitView(); |
| 338 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 393 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 339 | 394 |
| 340 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); | 395 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
| 396 w2->SetProperty(aura::client::kCanMaximizeKey, true); | |
|
oshima
2014/10/25 01:35:43
you can set this in CreateAndActivateWindow
afakhry
2014/10/27 16:10:05
I wanted to do this, but I was afraid that it migh
afakhry
2014/10/27 16:10:05
Done.
| |
| 341 w2->Show(); | 397 w2->Show(); |
| 342 | 398 |
| 343 wm_api.wm()->ToggleSplitView(); | 399 wm_api.wm()->ToggleSplitView(); |
| 344 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 400 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 345 int width = | 401 int width = |
| 346 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width(); | 402 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width(); |
| 347 | 403 |
| 348 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 404 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
| 349 EXPECT_GE(width / 2, w1->bounds().width()); | 405 EXPECT_GE(width / 2, w1->bounds().width()); |
| 350 | 406 |
| 351 // Toggle back to normal mode. | 407 // Toggle back to normal mode. |
| 352 wm_api.wm()->ToggleSplitView(); | 408 wm_api.wm()->ToggleSplitView(); |
| 353 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); | 409 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); |
| 354 | 410 |
| 411 // w2 is the top window, it should be resized to max width and must be visible | |
| 412 // w1 should be hidden. | |
| 413 EXPECT_EQ(width, w2->bounds().width()); | |
| 414 EXPECT_TRUE(w2->IsVisible()); | |
| 415 EXPECT_FALSE(w1->IsVisible()); | |
| 416 | |
| 417 // Expect w1 to be visible and maximized when activated. | |
| 418 w1->Show(); | |
|
oshima
2014/10/25 01:35:43
I assume wm::ActivateWindow(w1.get()) didn't work,
afakhry
2014/10/27 16:10:05
It actually works but it doesn't make the window v
oshima
2014/10/27 18:20:53
That's what I expected and meant by "doesn't work"
afakhry
2014/10/27 18:57:24
Done.
| |
| 355 EXPECT_EQ(width, w1->bounds().width()); | 419 EXPECT_EQ(width, w1->bounds().width()); |
| 356 EXPECT_EQ(width, w2->bounds().width()); | 420 EXPECT_TRUE(w1->IsVisible()); |
| 357 } | 421 } |
| 358 | 422 |
| 359 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { | 423 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { |
| 360 test::WindowManagerImplTestApi wm_api; | 424 test::WindowManagerImplTestApi wm_api; |
| 361 | 425 |
| 362 aura::test::TestWindowDelegate delegate; | 426 aura::test::TestWindowDelegate delegate; |
| 363 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); | 427 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
| 364 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); | 428 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
| 365 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); | 429 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); |
| 366 | 430 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 387 aura::test::TestWindowDelegate delegate; | 451 aura::test::TestWindowDelegate delegate; |
| 388 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); | 452 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
| 389 WindowManager::Get()->EnterOverview(); | 453 WindowManager::Get()->EnterOverview(); |
| 390 | 454 |
| 391 ui::test::EventGenerator generator(root_window()); | 455 ui::test::EventGenerator generator(root_window()); |
| 392 generator.MoveMouseTo(1, 1); | 456 generator.MoveMouseTo(1, 1); |
| 393 generator.ClickLeftButton(); | 457 generator.ClickLeftButton(); |
| 394 } | 458 } |
| 395 | 459 |
| 396 } // namespace athena | 460 } // namespace athena |
| OLD | NEW |