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() const { |
| 69 return call_count_; |
| 70 } |
| 71 |
| 72 bool is_fullscreen() const { |
| 73 return is_fullscreen_; |
| 74 } |
| 75 |
| 76 private: |
| 77 int call_count_; |
| 78 bool is_fullscreen_; |
| 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(TestShellObserver); |
| 81 }; |
| 82 |
50 } // namespace | 83 } // namespace |
51 | 84 |
52 typedef test::AshTestBase WorkspaceLayoutManagerTest; | 85 typedef test::AshTestBase WorkspaceLayoutManagerTest; |
53 | 86 |
54 // Verifies that a window containing a restore coordinate will be restored to | 87 // 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 | 88 // to the size prior to minimize, keeping the restore rectangle in tact (if |
56 // there is one). | 89 // there is one). |
57 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { | 90 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { |
58 scoped_ptr<aura::Window> window( | 91 scoped_ptr<aura::Window> window( |
59 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); | 92 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(), | 433 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
401 window->bounds().ToString()); | 434 window->bounds().ToString()); |
402 | 435 |
403 // Directly setting the bounds triggers a slightly different code path. Verify | 436 // Directly setting the bounds triggers a slightly different code path. Verify |
404 // that too. | 437 // that too. |
405 window->SetBounds(window_bounds); | 438 window->SetBounds(window_bounds); |
406 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 439 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
407 window->bounds().ToString()); | 440 window->bounds().ToString()); |
408 } | 441 } |
409 | 442 |
| 443 TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) { |
| 444 TestShellObserver observer; |
| 445 scoped_ptr<aura::Window> window1( |
| 446 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); |
| 447 scoped_ptr<aura::Window> window2( |
| 448 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); |
| 449 wm::WindowState* window_state1 = wm::GetWindowState(window1.get()); |
| 450 wm::WindowState* window_state2 = wm::GetWindowState(window2.get()); |
| 451 window_state2->Activate(); |
| 452 |
| 453 window_state2->ToggleFullscreen(); |
| 454 EXPECT_EQ(1, observer.call_count()); |
| 455 EXPECT_TRUE(observer.is_fullscreen()); |
| 456 |
| 457 // When window1 moves to the front the fullscreen state should change. |
| 458 window_state1->Activate(); |
| 459 EXPECT_EQ(2, observer.call_count()); |
| 460 EXPECT_FALSE(observer.is_fullscreen()); |
| 461 |
| 462 // It should change back if window2 becomes active again. |
| 463 window_state2->Activate(); |
| 464 EXPECT_EQ(3, observer.call_count()); |
| 465 EXPECT_TRUE(observer.is_fullscreen()); |
| 466 |
| 467 window_state2->ToggleFullscreen(); |
| 468 EXPECT_EQ(4, observer.call_count()); |
| 469 EXPECT_FALSE(observer.is_fullscreen()); |
| 470 |
| 471 window_state2->ToggleFullscreen(); |
| 472 EXPECT_EQ(5, observer.call_count()); |
| 473 EXPECT_TRUE(observer.is_fullscreen()); |
| 474 |
| 475 // Closing the window should change the fullscreen state. |
| 476 window2.reset(); |
| 477 EXPECT_EQ(6, observer.call_count()); |
| 478 EXPECT_FALSE(observer.is_fullscreen()); |
| 479 } |
| 480 |
410 } // namespace ash | 481 } // namespace ash |
OLD | NEW |