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 "ash/wm/window_state.h" | 5 #include "ash/wm/window_state.h" |
6 | 6 |
7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
11 #include "ash/wm/wm_event.h" | 11 #include "ash/wm/wm_event.h" |
12 #include "ui/aura/client/aura_constants.h" | |
12 #include "ui/aura/test/test_window_delegate.h" | 13 #include "ui/aura/test/test_window_delegate.h" |
13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
14 | 15 |
15 namespace ash { | 16 namespace ash { |
16 namespace wm { | 17 namespace wm { |
17 namespace { | 18 namespace { |
18 | 19 |
19 class AlwaysMaximizeTestState : public WindowState::State { | 20 class AlwaysMaximizeTestState : public WindowState::State { |
20 public: | 21 public: |
21 explicit AlwaysMaximizeTestState(WindowStateType initial_state_type) | 22 explicit AlwaysMaximizeTestState(WindowStateType initial_state_type) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 WindowState* window_state = GetWindowState(window.get()); | 118 WindowState* window_state = GetWindowState(window.get()); |
118 EXPECT_TRUE(window_state->CanSnap()); | 119 EXPECT_TRUE(window_state->CanSnap()); |
119 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); | 120 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); |
120 window_state->OnWMEvent(&snap_right); | 121 window_state->OnWMEvent(&snap_right); |
121 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x() + 1, | 122 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x() + 1, |
122 kWorkAreaBounds.y(), | 123 kWorkAreaBounds.y(), |
123 kWorkAreaBounds.width() - 1, | 124 kWorkAreaBounds.width() - 1, |
124 kWorkAreaBounds.height()); | 125 kWorkAreaBounds.height()); |
125 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); | 126 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
126 | 127 |
127 // It should not be possible to snap a window with a maximum size. | 128 // It should not be possible to snap a window that cannot maximize. |
128 delegate.set_minimum_size(gfx::Size()); | 129 window->SetProperty(aura::client::kCanMaximizeKey, false); |
oshima
2014/09/10 15:59:32
and keep this scenario.
jackhou1
2014/09/11 00:16:54
Done.
| |
129 delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, INT_MAX)); | |
130 EXPECT_FALSE(window_state->CanSnap()); | 130 EXPECT_FALSE(window_state->CanSnap()); |
131 } | 131 } |
132 | 132 |
133 // Test that the minimum size specified by aura::WindowDelegate gets respected. | 133 // Test that the minimum size specified by aura::WindowDelegate gets respected. |
134 TEST_F(WindowStateTest, TestRespectMinimumSize) { | 134 TEST_F(WindowStateTest, TestRespectMinimumSize) { |
135 if (!SupportsHostWindowResize()) | 135 if (!SupportsHostWindowResize()) |
136 return; | 136 return; |
137 | 137 |
138 UpdateDisplay("0+0-1024x768"); | 138 UpdateDisplay("0+0-1024x768"); |
139 | 139 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 EXPECT_FALSE(window_state->IsMaximized()); | 330 EXPECT_FALSE(window_state->IsMaximized()); |
331 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); | 331 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); |
332 EXPECT_TRUE(work_area.Contains(window->bounds())); | 332 EXPECT_TRUE(work_area.Contains(window->bounds())); |
333 } | 333 } |
334 | 334 |
335 // TODO(skuhne): Add more unit test to verify the correctness for the restore | 335 // TODO(skuhne): Add more unit test to verify the correctness for the restore |
336 // operation. | 336 // operation. |
337 | 337 |
338 } // namespace wm | 338 } // namespace wm |
339 } // namespace ash | 339 } // namespace ash |
OLD | NEW |