Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/workspace/workspace_layout_manager.h" | 5 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/display/display_layout.h" | 7 #include "ash/display/display_layout.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
| 11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/shell_observer.h" | |
| 14 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
| 15 #include "ash/wm/window_state.h" | 16 #include "ash/wm/window_state.h" |
| 16 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 17 #include "ui/aura/client/aura_constants.h" | 18 #include "ui/aura/client/aura_constants.h" |
| 18 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
| 19 #include "ui/aura/test/test_windows.h" | 20 #include "ui/aura/test/test_windows.h" |
| 20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 21 #include "ui/gfx/insets.h" | 22 #include "ui/gfx/insets.h" |
| 22 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 23 #include "ui/views/widget/widget_delegate.h" | 24 #include "ui/views/widget/widget_delegate.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 40 *show_state = ui::SHOW_STATE_MAXIMIZED; | 41 *show_state = ui::SHOW_STATE_MAXIMIZED; |
| 41 return true; | 42 return true; |
| 42 } | 43 } |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 const gfx::Rect initial_bounds_; | 46 const gfx::Rect initial_bounds_; |
| 46 | 47 |
| 47 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView); | 48 DISALLOW_COPY_AND_ASSIGN(MaximizeDelegateView); |
| 48 }; | 49 }; |
| 49 | 50 |
| 51 class TestShellObserver : public ShellObserver { | |
| 52 public: | |
| 53 TestShellObserver() : call_count_(0), | |
| 54 is_fullscreen_(false) { | |
| 55 Shell::GetInstance()->AddShellObserver(this); | |
| 56 } | |
| 57 | |
| 58 virtual ~TestShellObserver() { | |
| 59 Shell::GetInstance()->RemoveShellObserver(this); | |
| 60 } | |
| 61 | |
| 62 virtual void OnFullscreenStateChanged(bool is_fullscreen, | |
| 63 aura::Window* root_window) OVERRIDE { | |
| 64 call_count_++; | |
| 65 is_fullscreen_ = is_fullscreen; | |
| 66 } | |
| 67 | |
| 68 int call_count() { | |
|
oshima
2013/12/05 19:08:58
const
flackr
2013/12/05 19:30:21
Done.
| |
| 69 return call_count_; | |
| 70 } | |
| 71 | |
| 72 bool is_fullscreen() { | |
|
oshima
2013/12/05 19:08:58
ditto
flackr
2013/12/05 19:30:21
Done.
| |
| 73 return is_fullscreen_; | |
| 74 } | |
| 75 | |
| 76 private: | |
| 77 int call_count_; | |
| 78 bool is_fullscreen_; | |
| 79 }; | |
|
oshima
2013/12/05 19:08:58
DISALLOW_COPY_AND_ASSIGN
flackr
2013/12/05 19:30:21
Done.
| |
| 80 | |
| 50 } // namespace | 81 } // namespace |
| 51 | 82 |
| 52 typedef test::AshTestBase WorkspaceLayoutManagerTest; | 83 typedef test::AshTestBase WorkspaceLayoutManagerTest; |
| 53 | 84 |
| 54 // Verifies that a window containing a restore coordinate will be restored to | 85 // Verifies that a window containing a restore coordinate will be restored to |
| 55 // to the size prior to minimize, keeping the restore rectangle in tact (if | 86 // to the size prior to minimize, keeping the restore rectangle in tact (if |
| 56 // there is one). | 87 // there is one). |
| 57 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { | 88 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { |
| 58 scoped_ptr<aura::Window> window( | 89 scoped_ptr<aura::Window> window( |
| 59 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); | 90 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 431 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
| 401 window->bounds().ToString()); | 432 window->bounds().ToString()); |
| 402 | 433 |
| 403 // Directly setting the bounds triggers a slightly different code path. Verify | 434 // Directly setting the bounds triggers a slightly different code path. Verify |
| 404 // that too. | 435 // that too. |
| 405 window->SetBounds(window_bounds); | 436 window->SetBounds(window_bounds); |
| 406 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 437 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
| 407 window->bounds().ToString()); | 438 window->bounds().ToString()); |
| 408 } | 439 } |
| 409 | 440 |
| 441 TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) { | |
| 442 TestShellObserver observer; | |
| 443 scoped_ptr<aura::Window> window1( | |
| 444 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); | |
| 445 scoped_ptr<aura::Window> window2( | |
| 446 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); | |
| 447 wm::WindowState* window_state1 = wm::GetWindowState(window1.get()); | |
| 448 wm::WindowState* window_state2 = wm::GetWindowState(window2.get()); | |
| 449 window_state2->Activate(); | |
| 450 | |
| 451 window_state2->ToggleFullscreen(); | |
| 452 EXPECT_EQ(1, observer.call_count()); | |
| 453 EXPECT_TRUE(observer.is_fullscreen()); | |
| 454 | |
| 455 // When window1 moves to the front the fullscreen state should change. | |
| 456 window_state1->Activate(); | |
| 457 EXPECT_EQ(2, observer.call_count()); | |
| 458 EXPECT_FALSE(observer.is_fullscreen()); | |
| 459 | |
| 460 // It should change back if window2 becomes active again. | |
| 461 window_state2->Activate(); | |
| 462 EXPECT_EQ(3, observer.call_count()); | |
| 463 EXPECT_TRUE(observer.is_fullscreen()); | |
| 464 | |
| 465 window_state2->ToggleFullscreen(); | |
| 466 EXPECT_EQ(4, observer.call_count()); | |
| 467 EXPECT_FALSE(observer.is_fullscreen()); | |
| 468 } | |
| 469 | |
| 410 } // namespace ash | 470 } // namespace ash |
| OLD | NEW |