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/base_layout_manager.h" | 5 #include "ash/wm/base_layout_manager.h" |
6 | 6 |
7 #include "ash/screen_ash.h" | 7 #include "ash/screen_ash.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 private: | 45 private: |
46 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManagerTest); | 46 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManagerTest); |
47 }; | 47 }; |
48 | 48 |
49 // Tests normal->maximize->normal. | 49 // Tests normal->maximize->normal. |
50 TEST_F(BaseLayoutManagerTest, Maximize) { | 50 TEST_F(BaseLayoutManagerTest, Maximize) { |
51 gfx::Rect bounds(100, 100, 200, 200); | 51 gfx::Rect bounds(100, 100, 200, 200); |
52 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 52 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
53 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 53 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
54 // Maximized window fills the work area, not the whole monitor. | 54 // Maximized window fills the work area, not the whole monitor. |
55 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), | 55 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString(), |
56 window->bounds()); | 56 window->bounds().ToString()); |
57 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 57 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
58 EXPECT_EQ(bounds, window->bounds()); | 58 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
59 } | 59 } |
60 | 60 |
61 // Tests normal->minimize->normal. | 61 // Tests normal->minimize->normal. |
62 TEST_F(BaseLayoutManagerTest, Minimize) { | 62 TEST_F(BaseLayoutManagerTest, Minimize) { |
63 gfx::Rect bounds(100, 100, 200, 200); | 63 gfx::Rect bounds(100, 100, 200, 200); |
64 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 64 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
65 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 65 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
66 // Note: Currently minimize doesn't do anything except set the state. | 66 // Note: Currently minimize doesn't do anything except set the state. |
67 // See crbug.com/104571. | 67 // See crbug.com/104571. |
68 EXPECT_EQ(bounds, window->bounds()); | 68 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
69 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 69 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
70 EXPECT_EQ(bounds, window->bounds()); | 70 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
71 } | 71 } |
72 | 72 |
73 // Tests maximized window size during root window resize. | 73 // Tests maximized window size during root window resize. |
74 TEST_F(BaseLayoutManagerTest, MaximizeRootWindowResize) { | 74 TEST_F(BaseLayoutManagerTest, MaximizeRootWindowResize) { |
75 gfx::Rect bounds(100, 100, 200, 200); | 75 gfx::Rect bounds(100, 100, 200, 200); |
76 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 76 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
77 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 77 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
78 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), | 78 gfx::Rect initial_work_area_bounds = |
79 window->bounds()); | 79 ScreenAsh::GetMaximizedWindowBounds(window.get()); |
| 80 EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString()); |
80 // Enlarge the root window. We should still match the work area size. | 81 // Enlarge the root window. We should still match the work area size. |
81 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); | 82 Shell::GetRootWindow()->SetHostSize(gfx::Size(900, 700)); |
82 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), | 83 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString(), |
83 window->bounds()); | 84 window->bounds().ToString()); |
| 85 EXPECT_NE(initial_work_area_bounds.ToString(), |
| 86 ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString()); |
84 } | 87 } |
85 | 88 |
86 // Tests normal->fullscreen->normal. | 89 // Tests normal->fullscreen->normal. |
87 TEST_F(BaseLayoutManagerTest, Fullscreen) { | 90 TEST_F(BaseLayoutManagerTest, Fullscreen) { |
88 gfx::Rect bounds(100, 100, 200, 200); | 91 gfx::Rect bounds(100, 100, 200, 200); |
89 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 92 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
90 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 93 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
91 // Fullscreen window fills the whole monitor. | 94 // Fullscreen window fills the whole monitor. |
92 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), | 95 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()).ToString(), |
93 window->bounds()); | 96 window->bounds().ToString()); |
94 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 97 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
95 EXPECT_EQ(bounds, window->bounds()); | 98 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
96 } | 99 } |
97 | 100 |
98 // Tests fullscreen window size during root window resize. | 101 // Tests fullscreen window size during root window resize. |
99 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { | 102 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { |
100 gfx::Rect bounds(100, 100, 200, 200); | 103 gfx::Rect bounds(100, 100, 200, 200); |
101 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 104 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
102 // Fullscreen window fills the whole monitor. | 105 // Fullscreen window fills the whole monitor. |
103 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 106 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
104 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), | 107 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()).ToString(), |
105 window->bounds()); | 108 window->bounds().ToString()); |
106 // Enlarge the root window. We should still match the monitor size. | 109 // Enlarge the root window. We should still match the monitor size. |
107 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); | 110 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); |
108 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), | 111 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()).ToString(), |
109 window->bounds()); | 112 window->bounds().ToString()); |
110 } | 113 } |
111 | 114 |
112 // Fails on Mac only. Need to be implemented. http://crbug.com/111279. | 115 // Fails on Mac only. Need to be implemented. http://crbug.com/111279. |
113 #if defined(OS_MACOSX) | 116 #if defined(OS_MACOSX) |
114 #define MAYBE_RootWindowResizeShrinksWindows \ | 117 #define MAYBE_RootWindowResizeShrinksWindows \ |
115 FAILS_RootWindowResizeShrinksWindows | 118 FAILS_RootWindowResizeShrinksWindows |
116 #else | 119 #else |
117 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows | 120 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows |
118 #endif | 121 #endif |
119 // Tests that when the screen gets smaller the windows aren't bigger than | 122 // Tests that when the screen gets smaller the windows aren't bigger than |
(...skipping 21 matching lines...) Expand all Loading... |
141 // Enlarging the root window does not change the window bounds. | 144 // Enlarging the root window does not change the window bounds. |
142 gfx::Rect old_bounds = window->bounds(); | 145 gfx::Rect old_bounds = window->bounds(); |
143 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); | 146 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); |
144 EXPECT_EQ(old_bounds.width(), window->bounds().width()); | 147 EXPECT_EQ(old_bounds.width(), window->bounds().width()); |
145 EXPECT_EQ(old_bounds.height(), window->bounds().height()); | 148 EXPECT_EQ(old_bounds.height(), window->bounds().height()); |
146 } | 149 } |
147 | 150 |
148 } // namespace | 151 } // namespace |
149 | 152 |
150 } // namespace ash | 153 } // namespace ash |
OLD | NEW |