OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_controller.h" | 5 #include "ash/wm/workspace_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 bool GetWindowOverlapsShelf() { | 153 bool GetWindowOverlapsShelf() { |
154 return shelf_layout_manager()->window_overlaps_shelf(); | 154 return shelf_layout_manager()->window_overlaps_shelf(); |
155 } | 155 } |
156 | 156 |
157 private: | 157 private: |
158 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTest); | 158 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTest); |
159 }; | 159 }; |
160 | 160 |
161 // Assertions around adding a normal window. | 161 // Assertions around adding a normal window. |
162 TEST_F(WorkspaceControllerTest, AddNormalWindowWhenEmpty) { | 162 TEST_F(WorkspaceControllerTest, AddNormalWindowWhenEmpty) { |
163 scoped_ptr<Window> w1(CreateTestWindow()); | 163 std::unique_ptr<Window> w1(CreateTestWindow()); |
164 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 164 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
165 | 165 |
166 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 166 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
167 | 167 |
168 EXPECT_FALSE(window_state->HasRestoreBounds()); | 168 EXPECT_FALSE(window_state->HasRestoreBounds()); |
169 | 169 |
170 w1->Show(); | 170 w1->Show(); |
171 | 171 |
172 EXPECT_FALSE(window_state->HasRestoreBounds()); | 172 EXPECT_FALSE(window_state->HasRestoreBounds()); |
173 | 173 |
174 ASSERT_TRUE(w1->layer() != NULL); | 174 ASSERT_TRUE(w1->layer() != NULL); |
175 EXPECT_TRUE(w1->layer()->visible()); | 175 EXPECT_TRUE(w1->layer()->visible()); |
176 | 176 |
177 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); | 177 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); |
178 | 178 |
179 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); | 179 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); |
180 } | 180 } |
181 | 181 |
182 // Assertions around maximizing/unmaximizing. | 182 // Assertions around maximizing/unmaximizing. |
183 TEST_F(WorkspaceControllerTest, SingleMaximizeWindow) { | 183 TEST_F(WorkspaceControllerTest, SingleMaximizeWindow) { |
184 scoped_ptr<Window> w1(CreateTestWindow()); | 184 std::unique_ptr<Window> w1(CreateTestWindow()); |
185 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 185 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
186 | 186 |
187 w1->Show(); | 187 w1->Show(); |
188 wm::ActivateWindow(w1.get()); | 188 wm::ActivateWindow(w1.get()); |
189 | 189 |
190 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 190 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
191 | 191 |
192 ASSERT_TRUE(w1->layer() != NULL); | 192 ASSERT_TRUE(w1->layer() != NULL); |
193 EXPECT_TRUE(w1->layer()->visible()); | 193 EXPECT_TRUE(w1->layer()->visible()); |
194 | 194 |
(...skipping 12 matching lines...) Expand all Loading... |
207 | 207 |
208 // Restore the window. | 208 // Restore the window. |
209 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 209 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
210 | 210 |
211 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); | 211 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); |
212 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); | 212 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); |
213 } | 213 } |
214 | 214 |
215 // Assertions around two windows and toggling one to be fullscreen. | 215 // Assertions around two windows and toggling one to be fullscreen. |
216 TEST_F(WorkspaceControllerTest, FullscreenWithNormalWindow) { | 216 TEST_F(WorkspaceControllerTest, FullscreenWithNormalWindow) { |
217 scoped_ptr<Window> w1(CreateTestWindow()); | 217 std::unique_ptr<Window> w1(CreateTestWindow()); |
218 scoped_ptr<Window> w2(CreateTestWindow()); | 218 std::unique_ptr<Window> w2(CreateTestWindow()); |
219 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 219 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
220 w1->Show(); | 220 w1->Show(); |
221 | 221 |
222 ASSERT_TRUE(w1->layer() != NULL); | 222 ASSERT_TRUE(w1->layer() != NULL); |
223 EXPECT_TRUE(w1->layer()->visible()); | 223 EXPECT_TRUE(w1->layer()->visible()); |
224 | 224 |
225 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); | 225 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); |
226 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 226 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
227 w2->Show(); | 227 w2->Show(); |
228 wm::ActivateWindow(w2.get()); | 228 wm::ActivateWindow(w2.get()); |
229 | 229 |
230 // Both windows should be in the same workspace. | 230 // Both windows should be in the same workspace. |
231 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); | 231 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); |
232 EXPECT_EQ(w2.get(), GetDesktop()->children()[1]); | 232 EXPECT_EQ(w2.get(), GetDesktop()->children()[1]); |
233 | 233 |
234 gfx::Rect work_area( | 234 gfx::Rect work_area( |
235 ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get())); | 235 ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get())); |
236 EXPECT_EQ(work_area.width(), w2->bounds().width()); | 236 EXPECT_EQ(work_area.width(), w2->bounds().width()); |
237 EXPECT_EQ(work_area.height(), w2->bounds().height()); | 237 EXPECT_EQ(work_area.height(), w2->bounds().height()); |
238 | 238 |
239 // Restore w2, which should then go back to one workspace. | 239 // Restore w2, which should then go back to one workspace. |
240 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 240 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
241 EXPECT_EQ(50, w2->bounds().width()); | 241 EXPECT_EQ(50, w2->bounds().width()); |
242 EXPECT_EQ(51, w2->bounds().height()); | 242 EXPECT_EQ(51, w2->bounds().height()); |
243 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 243 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
244 } | 244 } |
245 | 245 |
246 // Makes sure requests to change the bounds of a normal window go through. | 246 // Makes sure requests to change the bounds of a normal window go through. |
247 TEST_F(WorkspaceControllerTest, ChangeBoundsOfNormalWindow) { | 247 TEST_F(WorkspaceControllerTest, ChangeBoundsOfNormalWindow) { |
248 scoped_ptr<Window> w1(CreateTestWindow()); | 248 std::unique_ptr<Window> w1(CreateTestWindow()); |
249 w1->Show(); | 249 w1->Show(); |
250 | 250 |
251 // Setting the bounds should go through since the window is in the normal | 251 // Setting the bounds should go through since the window is in the normal |
252 // workspace. | 252 // workspace. |
253 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); | 253 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); |
254 EXPECT_EQ(200, w1->bounds().width()); | 254 EXPECT_EQ(200, w1->bounds().width()); |
255 EXPECT_EQ(500, w1->bounds().height()); | 255 EXPECT_EQ(500, w1->bounds().height()); |
256 } | 256 } |
257 | 257 |
258 // Verifies the bounds is not altered when showing and grid is enabled. | 258 // Verifies the bounds is not altered when showing and grid is enabled. |
259 TEST_F(WorkspaceControllerTest, SnapToGrid) { | 259 TEST_F(WorkspaceControllerTest, SnapToGrid) { |
260 scoped_ptr<Window> w1(CreateTestWindowUnparented()); | 260 std::unique_ptr<Window> w1(CreateTestWindowUnparented()); |
261 w1->SetBounds(gfx::Rect(1, 6, 25, 30)); | 261 w1->SetBounds(gfx::Rect(1, 6, 25, 30)); |
262 ParentWindowInPrimaryRootWindow(w1.get()); | 262 ParentWindowInPrimaryRootWindow(w1.get()); |
263 // We are not aligning this anymore this way. When the window gets shown | 263 // We are not aligning this anymore this way. When the window gets shown |
264 // the window is expected to be handled differently, but this cannot be | 264 // the window is expected to be handled differently, but this cannot be |
265 // tested with this test. So the result of this test should be that the | 265 // tested with this test. So the result of this test should be that the |
266 // bounds are exactly as passed in. | 266 // bounds are exactly as passed in. |
267 EXPECT_EQ("1,6 25x30", w1->bounds().ToString()); | 267 EXPECT_EQ("1,6 25x30", w1->bounds().ToString()); |
268 } | 268 } |
269 | 269 |
270 // Assertions around a fullscreen window. | 270 // Assertions around a fullscreen window. |
271 TEST_F(WorkspaceControllerTest, SingleFullscreenWindow) { | 271 TEST_F(WorkspaceControllerTest, SingleFullscreenWindow) { |
272 scoped_ptr<Window> w1(CreateTestWindow()); | 272 std::unique_ptr<Window> w1(CreateTestWindow()); |
273 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 273 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
274 // Make the window fullscreen. | 274 // Make the window fullscreen. |
275 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 275 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
276 w1->Show(); | 276 w1->Show(); |
277 wm::ActivateWindow(w1.get()); | 277 wm::ActivateWindow(w1.get()); |
278 | 278 |
279 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); | 279 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); |
280 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); | 280 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); |
281 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); | 281 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); |
282 | 282 |
(...skipping 12 matching lines...) Expand all Loading... |
295 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); | 295 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); |
296 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); | 296 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); |
297 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 297 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
298 | 298 |
299 ASSERT_TRUE(window_state->HasRestoreBounds()); | 299 ASSERT_TRUE(window_state->HasRestoreBounds()); |
300 EXPECT_EQ("0,0 250x251", window_state->GetRestoreBoundsInScreen().ToString()); | 300 EXPECT_EQ("0,0 250x251", window_state->GetRestoreBoundsInScreen().ToString()); |
301 } | 301 } |
302 | 302 |
303 // Assertions around minimizing a single window. | 303 // Assertions around minimizing a single window. |
304 TEST_F(WorkspaceControllerTest, MinimizeSingleWindow) { | 304 TEST_F(WorkspaceControllerTest, MinimizeSingleWindow) { |
305 scoped_ptr<Window> w1(CreateTestWindow()); | 305 std::unique_ptr<Window> w1(CreateTestWindow()); |
306 | 306 |
307 w1->Show(); | 307 w1->Show(); |
308 | 308 |
309 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 309 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
310 EXPECT_FALSE(w1->layer()->IsDrawn()); | 310 EXPECT_FALSE(w1->layer()->IsDrawn()); |
311 EXPECT_TRUE(w1->layer()->GetTargetTransform().IsIdentity()); | 311 EXPECT_TRUE(w1->layer()->GetTargetTransform().IsIdentity()); |
312 | 312 |
313 // Show the window. | 313 // Show the window. |
314 w1->Show(); | 314 w1->Show(); |
315 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsNormalStateType()); | 315 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsNormalStateType()); |
316 EXPECT_TRUE(w1->layer()->IsDrawn()); | 316 EXPECT_TRUE(w1->layer()->IsDrawn()); |
317 } | 317 } |
318 | 318 |
319 // Assertions around minimizing a fullscreen window. | 319 // Assertions around minimizing a fullscreen window. |
320 TEST_F(WorkspaceControllerTest, MinimizeFullscreenWindow) { | 320 TEST_F(WorkspaceControllerTest, MinimizeFullscreenWindow) { |
321 // Two windows, w1 normal, w2 fullscreen. | 321 // Two windows, w1 normal, w2 fullscreen. |
322 scoped_ptr<Window> w1(CreateTestWindow()); | 322 std::unique_ptr<Window> w1(CreateTestWindow()); |
323 scoped_ptr<Window> w2(CreateTestWindow()); | 323 std::unique_ptr<Window> w2(CreateTestWindow()); |
324 w1->Show(); | 324 w1->Show(); |
325 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 325 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
326 w2->Show(); | 326 w2->Show(); |
327 | 327 |
328 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); | 328 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); |
329 wm::WindowState* w2_state = wm::GetWindowState(w2.get()); | 329 wm::WindowState* w2_state = wm::GetWindowState(w2.get()); |
330 | 330 |
331 w2_state->Activate(); | 331 w2_state->Activate(); |
332 | 332 |
333 // Minimize w2. | 333 // Minimize w2. |
(...skipping 30 matching lines...) Expand all Loading... |
364 | 364 |
365 // Verifies ShelfLayoutManager's visibility/auto-hide state is correctly | 365 // Verifies ShelfLayoutManager's visibility/auto-hide state is correctly |
366 // updated. | 366 // updated. |
367 TEST_F(WorkspaceControllerTest, ShelfStateUpdated) { | 367 TEST_F(WorkspaceControllerTest, ShelfStateUpdated) { |
368 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 368 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
369 // it isn't over the shelf. | 369 // it isn't over the shelf. |
370 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 370 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
371 gfx::Point()); | 371 gfx::Point()); |
372 generator.MoveMouseTo(0, 0); | 372 generator.MoveMouseTo(0, 0); |
373 | 373 |
374 scoped_ptr<Window> w1(CreateTestWindow()); | 374 std::unique_ptr<Window> w1(CreateTestWindow()); |
375 const gfx::Rect w1_bounds(0, 1, 101, 102); | 375 const gfx::Rect w1_bounds(0, 1, 101, 102); |
376 ShelfLayoutManager* shelf = shelf_layout_manager(); | 376 ShelfLayoutManager* shelf = shelf_layout_manager(); |
377 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 377 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
378 const gfx::Rect touches_shelf_bounds( | 378 const gfx::Rect touches_shelf_bounds( |
379 0, shelf->GetIdealBounds().y() - 10, 101, 102); | 379 0, shelf->GetIdealBounds().y() - 10, 101, 102); |
380 // Move |w1| to overlap the shelf. | 380 // Move |w1| to overlap the shelf. |
381 w1->SetBounds(touches_shelf_bounds); | 381 w1->SetBounds(touches_shelf_bounds); |
382 EXPECT_FALSE(GetWindowOverlapsShelf()); | 382 EXPECT_FALSE(GetWindowOverlapsShelf()); |
383 | 383 |
384 // A visible ignored window should not trigger the overlap. | 384 // A visible ignored window should not trigger the overlap. |
385 scoped_ptr<Window> w_ignored(CreateTestWindow()); | 385 std::unique_ptr<Window> w_ignored(CreateTestWindow()); |
386 w_ignored->SetBounds(touches_shelf_bounds); | 386 w_ignored->SetBounds(touches_shelf_bounds); |
387 wm::GetWindowState(&(*w_ignored))->set_ignored_by_shelf(true); | 387 wm::GetWindowState(&(*w_ignored))->set_ignored_by_shelf(true); |
388 w_ignored->Show(); | 388 w_ignored->Show(); |
389 EXPECT_FALSE(GetWindowOverlapsShelf()); | 389 EXPECT_FALSE(GetWindowOverlapsShelf()); |
390 | 390 |
391 // Make it visible, since visible shelf overlaps should be true. | 391 // Make it visible, since visible shelf overlaps should be true. |
392 w1->Show(); | 392 w1->Show(); |
393 EXPECT_TRUE(GetWindowOverlapsShelf()); | 393 EXPECT_TRUE(GetWindowOverlapsShelf()); |
394 | 394 |
395 wm::ActivateWindow(w1.get()); | 395 wm::ActivateWindow(w1.get()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 EXPECT_EQ("0,1 101x102", restore.ToString()); | 446 EXPECT_EQ("0,1 101x102", restore.ToString()); |
447 window_state->ClearRestoreBounds(); | 447 window_state->ClearRestoreBounds(); |
448 w1->SetBounds(restore); | 448 w1->SetBounds(restore); |
449 | 449 |
450 // Restore. | 450 // Restore. |
451 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 451 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
452 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 452 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
453 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 453 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
454 | 454 |
455 // Create another window, maximized. | 455 // Create another window, maximized. |
456 scoped_ptr<Window> w2(CreateTestWindow()); | 456 std::unique_ptr<Window> w2(CreateTestWindow()); |
457 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 457 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
458 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 458 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
459 w2->Show(); | 459 w2->Show(); |
460 wm::ActivateWindow(w2.get()); | 460 wm::ActivateWindow(w2.get()); |
461 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 461 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
462 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 462 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
463 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 463 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
464 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent( | 464 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent( |
465 w2->parent()).ToString(), | 465 w2->parent()).ToString(), |
466 w2->bounds().ToString()); | 466 w2->bounds().ToString()); |
(...skipping 30 matching lines...) Expand all Loading... |
497 EXPECT_FALSE(GetWindowOverlapsShelf()); | 497 EXPECT_FALSE(GetWindowOverlapsShelf()); |
498 | 498 |
499 // Restore w2. | 499 // Restore w2. |
500 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 500 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
501 EXPECT_TRUE(GetWindowOverlapsShelf()); | 501 EXPECT_TRUE(GetWindowOverlapsShelf()); |
502 } | 502 } |
503 | 503 |
504 // Verifies going from maximized to minimized sets the right state for painting | 504 // Verifies going from maximized to minimized sets the right state for painting |
505 // the background of the launcher. | 505 // the background of the launcher. |
506 TEST_F(WorkspaceControllerTest, MinimizeResetsVisibility) { | 506 TEST_F(WorkspaceControllerTest, MinimizeResetsVisibility) { |
507 scoped_ptr<Window> w1(CreateTestWindow()); | 507 std::unique_ptr<Window> w1(CreateTestWindow()); |
508 w1->Show(); | 508 w1->Show(); |
509 wm::ActivateWindow(w1.get()); | 509 wm::ActivateWindow(w1.get()); |
510 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 510 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
511 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType()); | 511 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType()); |
512 | 512 |
513 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 513 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
514 EXPECT_EQ(SHELF_VISIBLE, | 514 EXPECT_EQ(SHELF_VISIBLE, |
515 shelf_layout_manager()->visibility_state()); | 515 shelf_layout_manager()->visibility_state()); |
516 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType()); | 516 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType()); |
517 } | 517 } |
518 | 518 |
519 // Verifies window visibility during various workspace changes. | 519 // Verifies window visibility during various workspace changes. |
520 TEST_F(WorkspaceControllerTest, VisibilityTests) { | 520 TEST_F(WorkspaceControllerTest, VisibilityTests) { |
521 scoped_ptr<Window> w1(CreateTestWindow()); | 521 std::unique_ptr<Window> w1(CreateTestWindow()); |
522 w1->Show(); | 522 w1->Show(); |
523 EXPECT_TRUE(w1->IsVisible()); | 523 EXPECT_TRUE(w1->IsVisible()); |
524 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 524 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
525 | 525 |
526 // Create another window, activate it and make it fullscreen. | 526 // Create another window, activate it and make it fullscreen. |
527 scoped_ptr<Window> w2(CreateTestWindow()); | 527 std::unique_ptr<Window> w2(CreateTestWindow()); |
528 w2->Show(); | 528 w2->Show(); |
529 wm::ActivateWindow(w2.get()); | 529 wm::ActivateWindow(w2.get()); |
530 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 530 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
531 EXPECT_TRUE(w2->IsVisible()); | 531 EXPECT_TRUE(w2->IsVisible()); |
532 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); | 532 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); |
533 EXPECT_TRUE(w1->IsVisible()); | 533 EXPECT_TRUE(w1->IsVisible()); |
534 | 534 |
535 // Switch to w1. |w1| should be visible on top of |w2|. | 535 // Switch to w1. |w1| should be visible on top of |w2|. |
536 wm::ActivateWindow(w1.get()); | 536 wm::ActivateWindow(w1.get()); |
537 EXPECT_TRUE(w1->IsVisible()); | 537 EXPECT_TRUE(w1->IsVisible()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 572 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
573 EXPECT_TRUE(w1->IsVisible()); | 573 EXPECT_TRUE(w1->IsVisible()); |
574 } | 574 } |
575 | 575 |
576 // Verifies windows that are offscreen don't move when switching workspaces. | 576 // Verifies windows that are offscreen don't move when switching workspaces. |
577 TEST_F(WorkspaceControllerTest, DontMoveOnSwitch) { | 577 TEST_F(WorkspaceControllerTest, DontMoveOnSwitch) { |
578 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 578 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
579 gfx::Point()); | 579 gfx::Point()); |
580 generator.MoveMouseTo(0, 0); | 580 generator.MoveMouseTo(0, 0); |
581 | 581 |
582 scoped_ptr<Window> w1(CreateTestWindow()); | 582 std::unique_ptr<Window> w1(CreateTestWindow()); |
583 ShelfLayoutManager* shelf = shelf_layout_manager(); | 583 ShelfLayoutManager* shelf = shelf_layout_manager(); |
584 const gfx::Rect touches_shelf_bounds( | 584 const gfx::Rect touches_shelf_bounds( |
585 0, shelf->GetIdealBounds().y() - 10, 101, 102); | 585 0, shelf->GetIdealBounds().y() - 10, 101, 102); |
586 // Move |w1| to overlap the shelf. | 586 // Move |w1| to overlap the shelf. |
587 w1->SetBounds(touches_shelf_bounds); | 587 w1->SetBounds(touches_shelf_bounds); |
588 w1->Show(); | 588 w1->Show(); |
589 wm::ActivateWindow(w1.get()); | 589 wm::ActivateWindow(w1.get()); |
590 | 590 |
591 // Create another window and maximize it. | 591 // Create another window and maximize it. |
592 scoped_ptr<Window> w2(CreateTestWindow()); | 592 std::unique_ptr<Window> w2(CreateTestWindow()); |
593 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 593 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
594 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 594 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
595 w2->Show(); | 595 w2->Show(); |
596 wm::ActivateWindow(w2.get()); | 596 wm::ActivateWindow(w2.get()); |
597 | 597 |
598 // Switch to w1. | 598 // Switch to w1. |
599 wm::ActivateWindow(w1.get()); | 599 wm::ActivateWindow(w1.get()); |
600 EXPECT_EQ(touches_shelf_bounds.ToString(), w1->bounds().ToString()); | 600 EXPECT_EQ(touches_shelf_bounds.ToString(), w1->bounds().ToString()); |
601 } | 601 } |
602 | 602 |
603 // Verifies that windows that are completely offscreen move when switching | 603 // Verifies that windows that are completely offscreen move when switching |
604 // workspaces. | 604 // workspaces. |
605 TEST_F(WorkspaceControllerTest, MoveOnSwitch) { | 605 TEST_F(WorkspaceControllerTest, MoveOnSwitch) { |
606 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 606 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
607 gfx::Point()); | 607 gfx::Point()); |
608 generator.MoveMouseTo(0, 0); | 608 generator.MoveMouseTo(0, 0); |
609 | 609 |
610 scoped_ptr<Window> w1(CreateTestWindow()); | 610 std::unique_ptr<Window> w1(CreateTestWindow()); |
611 ShelfLayoutManager* shelf = shelf_layout_manager(); | 611 ShelfLayoutManager* shelf = shelf_layout_manager(); |
612 const gfx::Rect w1_bounds(0, shelf->GetIdealBounds().y(), 100, 200); | 612 const gfx::Rect w1_bounds(0, shelf->GetIdealBounds().y(), 100, 200); |
613 // Move |w1| so that the top edge is the same as the top edge of the shelf. | 613 // Move |w1| so that the top edge is the same as the top edge of the shelf. |
614 w1->SetBounds(w1_bounds); | 614 w1->SetBounds(w1_bounds); |
615 w1->Show(); | 615 w1->Show(); |
616 wm::ActivateWindow(w1.get()); | 616 wm::ActivateWindow(w1.get()); |
617 EXPECT_EQ(w1_bounds.ToString(), w1->bounds().ToString()); | 617 EXPECT_EQ(w1_bounds.ToString(), w1->bounds().ToString()); |
618 | 618 |
619 // Create another window and maximize it. | 619 // Create another window and maximize it. |
620 scoped_ptr<Window> w2(CreateTestWindow()); | 620 std::unique_ptr<Window> w2(CreateTestWindow()); |
621 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 621 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
622 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 622 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
623 w2->Show(); | 623 w2->Show(); |
624 wm::ActivateWindow(w2.get()); | 624 wm::ActivateWindow(w2.get()); |
625 | 625 |
626 // Increase the size of the WorkAreaInsets. This would make |w1| fall | 626 // Increase the size of the WorkAreaInsets. This would make |w1| fall |
627 // completely out of the display work area. | 627 // completely out of the display work area. |
628 gfx::Insets insets = | 628 gfx::Insets insets = |
629 gfx::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); | 629 gfx::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); |
630 insets.Set(0, 0, insets.bottom() + 30, 0); | 630 insets.Set(0, 0, insets.bottom() + 30, 0); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 // . minimize a maximized window. | 666 // . minimize a maximized window. |
667 // . remove the window (which happens when switching displays). | 667 // . remove the window (which happens when switching displays). |
668 // . add the window back. | 668 // . add the window back. |
669 // . show the window and during the bounds change activate it. | 669 // . show the window and during the bounds change activate it. |
670 TEST_F(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { | 670 TEST_F(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { |
671 // Force the shelf | 671 // Force the shelf |
672 ShelfLayoutManager* shelf = shelf_layout_manager(); | 672 ShelfLayoutManager* shelf = shelf_layout_manager(); |
673 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 673 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
674 | 674 |
675 DontCrashOnChangeAndActivateDelegate delegate; | 675 DontCrashOnChangeAndActivateDelegate delegate; |
676 scoped_ptr<Window> w1(CreateTestWindowInShellWithDelegate( | 676 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate( |
677 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); | 677 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); |
678 | 678 |
679 w1->Show(); | 679 w1->Show(); |
680 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); | 680 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); |
681 w1_state->Activate(); | 681 w1_state->Activate(); |
682 w1_state->Maximize(); | 682 w1_state->Maximize(); |
683 w1_state->Minimize(); | 683 w1_state->Minimize(); |
684 | 684 |
685 w1->parent()->RemoveChild(w1.get()); | 685 w1->parent()->RemoveChild(w1.get()); |
686 | 686 |
687 // Do this so that when we Show() the window a resize occurs and we make the | 687 // Do this so that when we Show() the window a resize occurs and we make the |
688 // window active. | 688 // window active. |
689 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 689 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
690 | 690 |
691 ParentWindowInPrimaryRootWindow(w1.get()); | 691 ParentWindowInPrimaryRootWindow(w1.get()); |
692 delegate.set_window(w1.get()); | 692 delegate.set_window(w1.get()); |
693 w1->Show(); | 693 w1->Show(); |
694 } | 694 } |
695 | 695 |
696 // Verifies a window with a transient parent not managed by workspace works. | 696 // Verifies a window with a transient parent not managed by workspace works. |
697 TEST_F(WorkspaceControllerTest, TransientParent) { | 697 TEST_F(WorkspaceControllerTest, TransientParent) { |
698 // Normal window with no transient parent. | 698 // Normal window with no transient parent. |
699 scoped_ptr<Window> w2(CreateTestWindow()); | 699 std::unique_ptr<Window> w2(CreateTestWindow()); |
700 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 700 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
701 w2->Show(); | 701 w2->Show(); |
702 wm::ActivateWindow(w2.get()); | 702 wm::ActivateWindow(w2.get()); |
703 | 703 |
704 // Window with a transient parent. We set the transient parent to the root, | 704 // Window with a transient parent. We set the transient parent to the root, |
705 // which would never happen but is enough to exercise the bug. | 705 // which would never happen but is enough to exercise the bug. |
706 scoped_ptr<Window> w1(CreateTestWindowUnparented()); | 706 std::unique_ptr<Window> w1(CreateTestWindowUnparented()); |
707 ::wm::AddTransientChild( | 707 ::wm::AddTransientChild( |
708 Shell::GetInstance()->GetPrimaryRootWindow(), w1.get()); | 708 Shell::GetInstance()->GetPrimaryRootWindow(), w1.get()); |
709 w1->SetBounds(gfx::Rect(10, 11, 250, 251)); | 709 w1->SetBounds(gfx::Rect(10, 11, 250, 251)); |
710 ParentWindowInPrimaryRootWindow(w1.get()); | 710 ParentWindowInPrimaryRootWindow(w1.get()); |
711 w1->Show(); | 711 w1->Show(); |
712 wm::ActivateWindow(w1.get()); | 712 wm::ActivateWindow(w1.get()); |
713 | 713 |
714 // The window with the transient parent should get added to the same parent as | 714 // The window with the transient parent should get added to the same parent as |
715 // the normal window. | 715 // the normal window. |
716 EXPECT_EQ(w2->parent(), w1->parent()); | 716 EXPECT_EQ(w2->parent(), w1->parent()); |
717 } | 717 } |
718 | 718 |
719 // Test the placement of newly created windows. | 719 // Test the placement of newly created windows. |
720 TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnCreate) { | 720 TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnCreate) { |
721 if (!SupportsHostWindowResize()) | 721 if (!SupportsHostWindowResize()) |
722 return; | 722 return; |
723 UpdateDisplay("1600x1200"); | 723 UpdateDisplay("1600x1200"); |
724 // Creating a popup handler here to make sure it does not interfere with the | 724 // Creating a popup handler here to make sure it does not interfere with the |
725 // existing windows. | 725 // existing windows. |
726 gfx::Rect source_browser_bounds(16, 32, 640, 320); | 726 gfx::Rect source_browser_bounds(16, 32, 640, 320); |
727 scoped_ptr<aura::Window> browser_window(CreateBrowserLikeWindow( | 727 std::unique_ptr<aura::Window> browser_window( |
728 source_browser_bounds)); | 728 CreateBrowserLikeWindow(source_browser_bounds)); |
729 | 729 |
730 // Creating a popup to make sure it does not interfere with the positioning. | 730 // Creating a popup to make sure it does not interfere with the positioning. |
731 scoped_ptr<aura::Window> browser_popup(CreatePopupLikeWindow( | 731 std::unique_ptr<aura::Window> browser_popup( |
732 gfx::Rect(16, 32, 128, 256))); | 732 CreatePopupLikeWindow(gfx::Rect(16, 32, 128, 256))); |
733 | 733 |
734 browser_window->Show(); | 734 browser_window->Show(); |
735 browser_popup->Show(); | 735 browser_popup->Show(); |
736 | 736 |
737 { // With a shown window it's size should get returned. | 737 { // With a shown window it's size should get returned. |
738 scoped_ptr<aura::Window> new_browser_window(CreateBrowserLikeWindow( | 738 std::unique_ptr<aura::Window> new_browser_window( |
739 source_browser_bounds)); | 739 CreateBrowserLikeWindow(source_browser_bounds)); |
740 // The position should be right flush. | 740 // The position should be right flush. |
741 EXPECT_EQ("960,32 640x320", new_browser_window->bounds().ToString()); | 741 EXPECT_EQ("960,32 640x320", new_browser_window->bounds().ToString()); |
742 } | 742 } |
743 | 743 |
744 { // With the window shown - but more on the right side then on the left | 744 { // With the window shown - but more on the right side then on the left |
745 // side (and partially out of the screen), it should default to the other | 745 // side (and partially out of the screen), it should default to the other |
746 // side and inside the screen. | 746 // side and inside the screen. |
747 gfx::Rect source_browser_bounds(gfx::Rect(1000, 600, 640, 320)); | 747 gfx::Rect source_browser_bounds(gfx::Rect(1000, 600, 640, 320)); |
748 browser_window->SetBounds(source_browser_bounds); | 748 browser_window->SetBounds(source_browser_bounds); |
749 | 749 |
750 scoped_ptr<aura::Window> new_browser_window(CreateBrowserLikeWindow( | 750 std::unique_ptr<aura::Window> new_browser_window( |
751 source_browser_bounds)); | 751 CreateBrowserLikeWindow(source_browser_bounds)); |
752 // The position should be left & bottom flush. | 752 // The position should be left & bottom flush. |
753 EXPECT_EQ("0,600 640x320", new_browser_window->bounds().ToString()); | 753 EXPECT_EQ("0,600 640x320", new_browser_window->bounds().ToString()); |
754 | 754 |
755 // If the other window was already beyond the point to get right flush | 755 // If the other window was already beyond the point to get right flush |
756 // it will remain where it is. | 756 // it will remain where it is. |
757 EXPECT_EQ("1000,600 640x320", browser_window->bounds().ToString()); | 757 EXPECT_EQ("1000,600 640x320", browser_window->bounds().ToString()); |
758 } | 758 } |
759 | 759 |
760 { // Make sure that popups do not get changed. | 760 { // Make sure that popups do not get changed. |
761 scoped_ptr<aura::Window> new_popup_window(CreatePopupLikeWindow( | 761 std::unique_ptr<aura::Window> new_popup_window( |
762 gfx::Rect(50, 100, 300, 150))); | 762 CreatePopupLikeWindow(gfx::Rect(50, 100, 300, 150))); |
763 EXPECT_EQ("50,100 300x150", new_popup_window->bounds().ToString()); | 763 EXPECT_EQ("50,100 300x150", new_popup_window->bounds().ToString()); |
764 } | 764 } |
765 | 765 |
766 browser_window->Hide(); | 766 browser_window->Hide(); |
767 { // If a window is there but not shown the default should be centered. | 767 { // If a window is there but not shown the default should be centered. |
768 scoped_ptr<aura::Window> new_browser_window(CreateBrowserLikeWindow( | 768 std::unique_ptr<aura::Window> new_browser_window( |
769 gfx::Rect(50, 100, 300, 150))); | 769 CreateBrowserLikeWindow(gfx::Rect(50, 100, 300, 150))); |
770 EXPECT_EQ("650,100 300x150", new_browser_window->bounds().ToString()); | 770 EXPECT_EQ("650,100 300x150", new_browser_window->bounds().ToString()); |
771 } | 771 } |
772 } | 772 } |
773 | 773 |
774 // Test that adding a second window shifts both the first window and its | 774 // Test that adding a second window shifts both the first window and its |
775 // transient child. | 775 // transient child. |
776 TEST_F(WorkspaceControllerTest, AutoPlacingMovesTransientChild) { | 776 TEST_F(WorkspaceControllerTest, AutoPlacingMovesTransientChild) { |
777 // Create an auto-positioned window. | 777 // Create an auto-positioned window. |
778 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 778 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
779 gfx::Rect desktop_area = window1->parent()->bounds(); | 779 gfx::Rect desktop_area = window1->parent()->bounds(); |
780 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 780 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
781 // Hide and then show |window1| to trigger auto-positioning logic. | 781 // Hide and then show |window1| to trigger auto-positioning logic. |
782 window1->Hide(); | 782 window1->Hide(); |
783 window1->SetBounds(gfx::Rect(16, 32, 300, 300)); | 783 window1->SetBounds(gfx::Rect(16, 32, 300, 300)); |
784 window1->Show(); | 784 window1->Show(); |
785 | 785 |
786 // |window1| should be horizontally centered. | 786 // |window1| should be horizontally centered. |
787 int x_window1 = (desktop_area.width() - 300) / 2; | 787 int x_window1 = (desktop_area.width() - 300) / 2; |
788 EXPECT_EQ(base::IntToString(x_window1) + ",32 300x300", | 788 EXPECT_EQ(base::IntToString(x_window1) + ",32 300x300", |
789 window1->bounds().ToString()); | 789 window1->bounds().ToString()); |
790 | 790 |
791 // Create a |child| window and make it a transient child of |window1|. | 791 // Create a |child| window and make it a transient child of |window1|. |
792 scoped_ptr<Window> child(CreateTestWindowUnparented()); | 792 std::unique_ptr<Window> child(CreateTestWindowUnparented()); |
793 ::wm::AddTransientChild(window1.get(), child.get()); | 793 ::wm::AddTransientChild(window1.get(), child.get()); |
794 const int x_child = x_window1 + 50; | 794 const int x_child = x_window1 + 50; |
795 child->SetBounds(gfx::Rect(x_child, 20, 200, 200)); | 795 child->SetBounds(gfx::Rect(x_child, 20, 200, 200)); |
796 ParentWindowInPrimaryRootWindow(child.get()); | 796 ParentWindowInPrimaryRootWindow(child.get()); |
797 child->Show(); | 797 child->Show(); |
798 wm::ActivateWindow(child.get()); | 798 wm::ActivateWindow(child.get()); |
799 | 799 |
800 // The |child| should be where it was created. | 800 // The |child| should be where it was created. |
801 EXPECT_EQ(base::IntToString(x_child) + ",20 200x200", | 801 EXPECT_EQ(base::IntToString(x_child) + ",20 200x200", |
802 child->bounds().ToString()); | 802 child->bounds().ToString()); |
803 | 803 |
804 // Create and show a second window forcing the first window and its child to | 804 // Create and show a second window forcing the first window and its child to |
805 // move. | 805 // move. |
806 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 806 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
807 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 807 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
808 // Hide and then show |window2| to trigger auto-positioning logic. | 808 // Hide and then show |window2| to trigger auto-positioning logic. |
809 window2->Hide(); | 809 window2->Hide(); |
810 window2->SetBounds(gfx::Rect(32, 48, 250, 250)); | 810 window2->SetBounds(gfx::Rect(32, 48, 250, 250)); |
811 window2->Show(); | 811 window2->Show(); |
812 | 812 |
813 // Check that both |window1| and |child| have moved left. | 813 // Check that both |window1| and |child| have moved left. |
814 EXPECT_EQ("0,32 300x300", window1->bounds().ToString()); | 814 EXPECT_EQ("0,32 300x300", window1->bounds().ToString()); |
815 int x = x_child - x_window1; | 815 int x = x_child - x_window1; |
816 EXPECT_EQ(base::IntToString(x) + ",20 200x200", child->bounds().ToString()); | 816 EXPECT_EQ(base::IntToString(x) + ",20 200x200", child->bounds().ToString()); |
817 // Check that |window2| has moved right. | 817 // Check that |window2| has moved right. |
818 x = desktop_area.width() - window2->bounds().width(); | 818 x = desktop_area.width() - window2->bounds().width(); |
819 EXPECT_EQ(base::IntToString(x) + ",48 250x250", window2->bounds().ToString()); | 819 EXPECT_EQ(base::IntToString(x) + ",48 250x250", window2->bounds().ToString()); |
820 } | 820 } |
821 | 821 |
822 // Test the basic auto placement of one and or two windows in a "simulated | 822 // Test the basic auto placement of one and or two windows in a "simulated |
823 // session" of sequential window operations. | 823 // session" of sequential window operations. |
824 TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) { | 824 TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) { |
825 // Test 1: In case there is no manageable window, no window should shift. | 825 // Test 1: In case there is no manageable window, no window should shift. |
826 | 826 |
827 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 827 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
828 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 828 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
829 gfx::Rect desktop_area = window1->parent()->bounds(); | 829 gfx::Rect desktop_area = window1->parent()->bounds(); |
830 | 830 |
831 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 831 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
832 // Trigger the auto window placement function by making it visible. | 832 // Trigger the auto window placement function by making it visible. |
833 // Note that the bounds are getting changed while it is invisible. | 833 // Note that the bounds are getting changed while it is invisible. |
834 window2->Hide(); | 834 window2->Hide(); |
835 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 835 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
836 window2->Show(); | 836 window2->Show(); |
837 | 837 |
838 // Check the initial position of the windows is unchanged. | 838 // Check the initial position of the windows is unchanged. |
839 EXPECT_EQ("16,32 640x320", window1->bounds().ToString()); | 839 EXPECT_EQ("16,32 640x320", window1->bounds().ToString()); |
840 EXPECT_EQ("32,48 256x512", window2->bounds().ToString()); | 840 EXPECT_EQ("32,48 256x512", window2->bounds().ToString()); |
841 | 841 |
842 // Remove the second window and make sure that the first window | 842 // Remove the second window and make sure that the first window |
843 // does NOT get centered. | 843 // does NOT get centered. |
844 window2.reset(); | 844 window2.reset(); |
845 EXPECT_EQ("16,32 640x320", window1->bounds().ToString()); | 845 EXPECT_EQ("16,32 640x320", window1->bounds().ToString()); |
846 | 846 |
847 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 847 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
848 // Test 2: Set up two managed windows and check their auto positioning. | 848 // Test 2: Set up two managed windows and check their auto positioning. |
849 window1_state->set_window_position_managed(true); | 849 window1_state->set_window_position_managed(true); |
850 | 850 |
851 scoped_ptr<aura::Window> window3(CreateTestWindowInShellWithId(2)); | 851 std::unique_ptr<aura::Window> window3(CreateTestWindowInShellWithId(2)); |
852 wm::GetWindowState(window3.get())->set_window_position_managed(true); | 852 wm::GetWindowState(window3.get())->set_window_position_managed(true); |
853 // To avoid any auto window manager changes due to SetBounds, the window | 853 // To avoid any auto window manager changes due to SetBounds, the window |
854 // gets first hidden and then shown again. | 854 // gets first hidden and then shown again. |
855 window3->Hide(); | 855 window3->Hide(); |
856 window3->SetBounds(gfx::Rect(32, 48, 256, 512)); | 856 window3->SetBounds(gfx::Rect(32, 48, 256, 512)); |
857 window3->Show(); | 857 window3->Show(); |
858 // |window1| should be flush left and |window3| flush right. | 858 // |window1| should be flush left and |window3| flush right. |
859 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); | 859 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); |
860 EXPECT_EQ(base::IntToString( | 860 EXPECT_EQ(base::IntToString( |
861 desktop_area.width() - window3->bounds().width()) + | 861 desktop_area.width() - window3->bounds().width()) + |
862 ",48 256x512", window3->bounds().ToString()); | 862 ",48 256x512", window3->bounds().ToString()); |
863 | 863 |
864 // After removing |window3|, |window1| should be centered again. | 864 // After removing |window3|, |window1| should be centered again. |
865 window3.reset(); | 865 window3.reset(); |
866 EXPECT_EQ( | 866 EXPECT_EQ( |
867 base::IntToString( | 867 base::IntToString( |
868 (desktop_area.width() - window1->bounds().width()) / 2) + | 868 (desktop_area.width() - window1->bounds().width()) / 2) + |
869 ",32 640x320", window1->bounds().ToString()); | 869 ",32 640x320", window1->bounds().ToString()); |
870 | 870 |
871 // Test 3: Set up a manageable and a non manageable window and check | 871 // Test 3: Set up a manageable and a non manageable window and check |
872 // positioning. | 872 // positioning. |
873 scoped_ptr<aura::Window> window4(CreateTestWindowInShellWithId(3)); | 873 std::unique_ptr<aura::Window> window4(CreateTestWindowInShellWithId(3)); |
874 // To avoid any auto window manager changes due to SetBounds, the window | 874 // To avoid any auto window manager changes due to SetBounds, the window |
875 // gets first hidden and then shown again. | 875 // gets first hidden and then shown again. |
876 window1->Hide(); | 876 window1->Hide(); |
877 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 877 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
878 window4->SetBounds(gfx::Rect(32, 48, 256, 512)); | 878 window4->SetBounds(gfx::Rect(32, 48, 256, 512)); |
879 window1->Show(); | 879 window1->Show(); |
880 // |window1| should be centered and |window4| untouched. | 880 // |window1| should be centered and |window4| untouched. |
881 EXPECT_EQ( | 881 EXPECT_EQ( |
882 base::IntToString( | 882 base::IntToString( |
883 (desktop_area.width() - window1->bounds().width()) / 2) + | 883 (desktop_area.width() - window1->bounds().width()) / 2) + |
884 ",32 640x320", window1->bounds().ToString()); | 884 ",32 640x320", window1->bounds().ToString()); |
885 EXPECT_EQ("32,48 256x512", window4->bounds().ToString()); | 885 EXPECT_EQ("32,48 256x512", window4->bounds().ToString()); |
886 | 886 |
887 // Test4: A single manageable window should get centered. | 887 // Test4: A single manageable window should get centered. |
888 window4.reset(); | 888 window4.reset(); |
889 window1_state->set_bounds_changed_by_user(false); | 889 window1_state->set_bounds_changed_by_user(false); |
890 // Trigger the auto window placement function by showing (and hiding) it. | 890 // Trigger the auto window placement function by showing (and hiding) it. |
891 window1->Hide(); | 891 window1->Hide(); |
892 window1->Show(); | 892 window1->Show(); |
893 // |window1| should be centered. | 893 // |window1| should be centered. |
894 EXPECT_EQ( | 894 EXPECT_EQ( |
895 base::IntToString( | 895 base::IntToString( |
896 (desktop_area.width() - window1->bounds().width()) / 2) + | 896 (desktop_area.width() - window1->bounds().width()) / 2) + |
897 ",32 640x320", window1->bounds().ToString()); | 897 ",32 640x320", window1->bounds().ToString()); |
898 } | 898 } |
899 | 899 |
900 // Test the proper usage of user window movement interaction. | 900 // Test the proper usage of user window movement interaction. |
901 TEST_F(WorkspaceControllerTest, TestUserMovedWindowRepositioning) { | 901 TEST_F(WorkspaceControllerTest, TestUserMovedWindowRepositioning) { |
902 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 902 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
903 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 903 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
904 gfx::Rect desktop_area = window1->parent()->bounds(); | 904 gfx::Rect desktop_area = window1->parent()->bounds(); |
905 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 905 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
906 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 906 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
907 window1->Hide(); | 907 window1->Hide(); |
908 window2->Hide(); | 908 window2->Hide(); |
909 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 909 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
910 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); | 910 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
911 | 911 |
912 window1_state->set_window_position_managed(true); | 912 window1_state->set_window_position_managed(true); |
913 window2_state->set_window_position_managed(true); | 913 window2_state->set_window_position_managed(true); |
914 EXPECT_FALSE(window1_state->bounds_changed_by_user()); | 914 EXPECT_FALSE(window1_state->bounds_changed_by_user()); |
915 EXPECT_FALSE(window2_state->bounds_changed_by_user()); | 915 EXPECT_FALSE(window2_state->bounds_changed_by_user()); |
(...skipping 22 matching lines...) Expand all Loading... |
938 | 938 |
939 // Going back to one shown window should keep the state. | 939 // Going back to one shown window should keep the state. |
940 window1_state->set_bounds_changed_by_user(true); | 940 window1_state->set_bounds_changed_by_user(true); |
941 window2->Hide(); | 941 window2->Hide(); |
942 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); | 942 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); |
943 EXPECT_TRUE(window1_state->bounds_changed_by_user()); | 943 EXPECT_TRUE(window1_state->bounds_changed_by_user()); |
944 } | 944 } |
945 | 945 |
946 // Test if the single window will be restored at original position. | 946 // Test if the single window will be restored at original position. |
947 TEST_F(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) { | 947 TEST_F(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) { |
948 scoped_ptr<aura::Window> window1( | 948 std::unique_ptr<aura::Window> window1( |
949 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); | 949 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); |
950 scoped_ptr<aura::Window> window2( | 950 std::unique_ptr<aura::Window> window2( |
951 CreateTestWindowInShellWithBounds(gfx::Rect(110, 110, 100, 100))); | 951 CreateTestWindowInShellWithBounds(gfx::Rect(110, 110, 100, 100))); |
952 scoped_ptr<aura::Window> window3( | 952 std::unique_ptr<aura::Window> window3( |
953 CreateTestWindowInShellWithBounds(gfx::Rect(120, 120, 100, 100))); | 953 CreateTestWindowInShellWithBounds(gfx::Rect(120, 120, 100, 100))); |
954 window1->Hide(); | 954 window1->Hide(); |
955 window2->Hide(); | 955 window2->Hide(); |
956 window3->Hide(); | 956 window3->Hide(); |
957 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 957 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
958 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 958 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
959 wm::GetWindowState(window3.get())->set_window_position_managed(true); | 959 wm::GetWindowState(window3.get())->set_window_position_managed(true); |
960 | 960 |
961 window1->Show(); | 961 window1->Show(); |
962 wm::ActivateWindow(window1.get()); | 962 wm::ActivateWindow(window1.get()); |
(...skipping 24 matching lines...) Expand all Loading... |
987 window3->bounds().right()); | 987 window3->bounds().right()); |
988 | 988 |
989 // Being a single window will retore the original location. | 989 // Being a single window will retore the original location. |
990 window2->Hide(); | 990 window2->Hide(); |
991 EXPECT_EQ("120,120 100x100", window3->bounds().ToString()); | 991 EXPECT_EQ("120,120 100x100", window3->bounds().ToString()); |
992 } | 992 } |
993 | 993 |
994 // Test that user placed windows go back to their user placement after the user | 994 // Test that user placed windows go back to their user placement after the user |
995 // closes all other windows. | 995 // closes all other windows. |
996 TEST_F(WorkspaceControllerTest, TestUserHandledWindowRestore) { | 996 TEST_F(WorkspaceControllerTest, TestUserHandledWindowRestore) { |
997 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 997 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
998 gfx::Rect user_pos = gfx::Rect(16, 42, 640, 320); | 998 gfx::Rect user_pos = gfx::Rect(16, 42, 640, 320); |
999 window1->SetBounds(user_pos); | 999 window1->SetBounds(user_pos); |
1000 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 1000 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
1001 | 1001 |
1002 window1_state->SetPreAutoManageWindowBounds(user_pos); | 1002 window1_state->SetPreAutoManageWindowBounds(user_pos); |
1003 gfx::Rect desktop_area = window1->parent()->bounds(); | 1003 gfx::Rect desktop_area = window1->parent()->bounds(); |
1004 | 1004 |
1005 // Create a second window to let the auto manager kick in. | 1005 // Create a second window to let the auto manager kick in. |
1006 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 1006 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
1007 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 1007 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
1008 window1->Hide(); | 1008 window1->Hide(); |
1009 window2->Hide(); | 1009 window2->Hide(); |
1010 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 1010 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
1011 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 1011 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
1012 window1->Show(); | 1012 window1->Show(); |
1013 EXPECT_EQ(user_pos.ToString(), window1->bounds().ToString()); | 1013 EXPECT_EQ(user_pos.ToString(), window1->bounds().ToString()); |
1014 window2->Show(); | 1014 window2->Show(); |
1015 | 1015 |
1016 // |window1| should be flush left and |window2| flush right. | 1016 // |window1| should be flush left and |window2| flush right. |
(...skipping 12 matching lines...) Expand all Loading... |
1029 window1_state->pre_auto_manage_window_bounds()->ToString()); | 1029 window1_state->pre_auto_manage_window_bounds()->ToString()); |
1030 } | 1030 } |
1031 | 1031 |
1032 // Solo window should be restored to the bounds where a user moved to. | 1032 // Solo window should be restored to the bounds where a user moved to. |
1033 TEST_F(WorkspaceControllerTest, TestRestoreToUserModifiedBounds) { | 1033 TEST_F(WorkspaceControllerTest, TestRestoreToUserModifiedBounds) { |
1034 if (!SupportsHostWindowResize()) | 1034 if (!SupportsHostWindowResize()) |
1035 return; | 1035 return; |
1036 | 1036 |
1037 UpdateDisplay("400x300"); | 1037 UpdateDisplay("400x300"); |
1038 gfx::Rect default_bounds(10, 0, 100, 100); | 1038 gfx::Rect default_bounds(10, 0, 100, 100); |
1039 scoped_ptr<aura::Window> window1( | 1039 std::unique_ptr<aura::Window> window1( |
1040 CreateTestWindowInShellWithBounds(default_bounds)); | 1040 CreateTestWindowInShellWithBounds(default_bounds)); |
1041 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 1041 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
1042 window1->Hide(); | 1042 window1->Hide(); |
1043 window1_state->set_window_position_managed(true); | 1043 window1_state->set_window_position_managed(true); |
1044 window1->Show(); | 1044 window1->Show(); |
1045 // First window is centered. | 1045 // First window is centered. |
1046 EXPECT_EQ("150,0 100x100", window1->bounds().ToString()); | 1046 EXPECT_EQ("150,0 100x100", window1->bounds().ToString()); |
1047 scoped_ptr<aura::Window> window2( | 1047 std::unique_ptr<aura::Window> window2( |
1048 CreateTestWindowInShellWithBounds(default_bounds)); | 1048 CreateTestWindowInShellWithBounds(default_bounds)); |
1049 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); | 1049 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
1050 window2->Hide(); | 1050 window2->Hide(); |
1051 window2_state->set_window_position_managed(true); | 1051 window2_state->set_window_position_managed(true); |
1052 window2->Show(); | 1052 window2->Show(); |
1053 | 1053 |
1054 // Auto positioning pushes windows to each sides. | 1054 // Auto positioning pushes windows to each sides. |
1055 EXPECT_EQ("0,0 100x100", window1->bounds().ToString()); | 1055 EXPECT_EQ("0,0 100x100", window1->bounds().ToString()); |
1056 EXPECT_EQ("300,0 100x100", window2->bounds().ToString()); | 1056 EXPECT_EQ("300,0 100x100", window2->bounds().ToString()); |
1057 | 1057 |
1058 window2->Hide(); | 1058 window2->Hide(); |
1059 // Restores to the center. | 1059 // Restores to the center. |
1060 EXPECT_EQ("150,0 100x100", window1->bounds().ToString()); | 1060 EXPECT_EQ("150,0 100x100", window1->bounds().ToString()); |
1061 | 1061 |
1062 // A user moved the window. | 1062 // A user moved the window. |
1063 scoped_ptr<WindowResizer> resizer(CreateWindowResizer( | 1063 std::unique_ptr<WindowResizer> resizer( |
1064 window1.get(), | 1064 CreateWindowResizer(window1.get(), gfx::Point(), HTCAPTION, |
1065 gfx::Point(), | 1065 aura::client::WINDOW_MOVE_SOURCE_MOUSE) |
1066 HTCAPTION, | 1066 .release()); |
1067 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release()); | |
1068 gfx::Point location = resizer->GetInitialLocation(); | 1067 gfx::Point location = resizer->GetInitialLocation(); |
1069 location.Offset(-50, 0); | 1068 location.Offset(-50, 0); |
1070 resizer->Drag(location, 0); | 1069 resizer->Drag(location, 0); |
1071 resizer->CompleteDrag(); | 1070 resizer->CompleteDrag(); |
1072 | 1071 |
1073 window1_state->set_bounds_changed_by_user(true); | 1072 window1_state->set_bounds_changed_by_user(true); |
1074 window1->SetBounds(gfx::Rect(100, 0, 100, 100)); | 1073 window1->SetBounds(gfx::Rect(100, 0, 100, 100)); |
1075 | 1074 |
1076 window2->Show(); | 1075 window2->Show(); |
1077 EXPECT_EQ("0,0 100x100", window1->bounds().ToString()); | 1076 EXPECT_EQ("0,0 100x100", window1->bounds().ToString()); |
1078 EXPECT_EQ("300,0 100x100", window2->bounds().ToString()); | 1077 EXPECT_EQ("300,0 100x100", window2->bounds().ToString()); |
1079 | 1078 |
1080 // Window 1 should be restored to the user modified bounds. | 1079 // Window 1 should be restored to the user modified bounds. |
1081 window2->Hide(); | 1080 window2->Hide(); |
1082 EXPECT_EQ("100,0 100x100", window1->bounds().ToString()); | 1081 EXPECT_EQ("100,0 100x100", window1->bounds().ToString()); |
1083 } | 1082 } |
1084 | 1083 |
1085 // Test that a window from normal to minimize will repos the remaining. | 1084 // Test that a window from normal to minimize will repos the remaining. |
1086 TEST_F(WorkspaceControllerTest, ToMinimizeRepositionsRemaining) { | 1085 TEST_F(WorkspaceControllerTest, ToMinimizeRepositionsRemaining) { |
1087 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1086 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
1088 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 1087 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
1089 window1_state->set_window_position_managed(true); | 1088 window1_state->set_window_position_managed(true); |
1090 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 1089 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
1091 gfx::Rect desktop_area = window1->parent()->bounds(); | 1090 gfx::Rect desktop_area = window1->parent()->bounds(); |
1092 | 1091 |
1093 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 1092 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
1094 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); | 1093 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
1095 window2_state->set_window_position_managed(true); | 1094 window2_state->set_window_position_managed(true); |
1096 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 1095 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
1097 | 1096 |
1098 window1_state->Minimize(); | 1097 window1_state->Minimize(); |
1099 | 1098 |
1100 // |window2| should be centered now. | 1099 // |window2| should be centered now. |
1101 EXPECT_TRUE(window2->IsVisible()); | 1100 EXPECT_TRUE(window2->IsVisible()); |
1102 EXPECT_TRUE(window2_state->IsNormalStateType()); | 1101 EXPECT_TRUE(window2_state->IsNormalStateType()); |
1103 EXPECT_EQ(base::IntToString( | 1102 EXPECT_EQ(base::IntToString( |
1104 (desktop_area.width() - window2->bounds().width()) / 2) + | 1103 (desktop_area.width() - window2->bounds().width()) / 2) + |
1105 ",48 256x512", window2->bounds().ToString()); | 1104 ",48 256x512", window2->bounds().ToString()); |
1106 | 1105 |
1107 window1_state->Restore(); | 1106 window1_state->Restore(); |
1108 // |window1| should be flush right and |window3| flush left. | 1107 // |window1| should be flush right and |window3| flush left. |
1109 EXPECT_EQ(base::IntToString( | 1108 EXPECT_EQ(base::IntToString( |
1110 desktop_area.width() - window1->bounds().width()) + | 1109 desktop_area.width() - window1->bounds().width()) + |
1111 ",32 640x320", window1->bounds().ToString()); | 1110 ",32 640x320", window1->bounds().ToString()); |
1112 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); | 1111 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); |
1113 } | 1112 } |
1114 | 1113 |
1115 // Test that minimizing an initially maximized window will repos the remaining. | 1114 // Test that minimizing an initially maximized window will repos the remaining. |
1116 TEST_F(WorkspaceControllerTest, MaxToMinRepositionsRemaining) { | 1115 TEST_F(WorkspaceControllerTest, MaxToMinRepositionsRemaining) { |
1117 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1116 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
1118 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 1117 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
1119 window1_state->set_window_position_managed(true); | 1118 window1_state->set_window_position_managed(true); |
1120 gfx::Rect desktop_area = window1->parent()->bounds(); | 1119 gfx::Rect desktop_area = window1->parent()->bounds(); |
1121 | 1120 |
1122 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 1121 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
1123 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); | 1122 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
1124 window2_state->set_window_position_managed(true); | 1123 window2_state->set_window_position_managed(true); |
1125 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 1124 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
1126 | 1125 |
1127 window1_state->Maximize(); | 1126 window1_state->Maximize(); |
1128 window1_state->Minimize(); | 1127 window1_state->Minimize(); |
1129 | 1128 |
1130 // |window2| should be centered now. | 1129 // |window2| should be centered now. |
1131 EXPECT_TRUE(window2->IsVisible()); | 1130 EXPECT_TRUE(window2->IsVisible()); |
1132 EXPECT_TRUE(window2_state->IsNormalStateType()); | 1131 EXPECT_TRUE(window2_state->IsNormalStateType()); |
1133 EXPECT_EQ(base::IntToString( | 1132 EXPECT_EQ(base::IntToString( |
1134 (desktop_area.width() - window2->bounds().width()) / 2) + | 1133 (desktop_area.width() - window2->bounds().width()) / 2) + |
1135 ",48 256x512", window2->bounds().ToString()); | 1134 ",48 256x512", window2->bounds().ToString()); |
1136 } | 1135 } |
1137 | 1136 |
1138 // Test that nomral, maximize, minimizing will repos the remaining. | 1137 // Test that nomral, maximize, minimizing will repos the remaining. |
1139 TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) { | 1138 TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) { |
1140 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1139 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
1141 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 1140 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
1142 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 1141 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
1143 window1_state->set_window_position_managed(true); | 1142 window1_state->set_window_position_managed(true); |
1144 gfx::Rect desktop_area = window1->parent()->bounds(); | 1143 gfx::Rect desktop_area = window1->parent()->bounds(); |
1145 | 1144 |
1146 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 1145 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
1147 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); | 1146 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
1148 window2_state->set_window_position_managed(true); | 1147 window2_state->set_window_position_managed(true); |
1149 window2->SetBounds(gfx::Rect(32, 40, 256, 512)); | 1148 window2->SetBounds(gfx::Rect(32, 40, 256, 512)); |
1150 | 1149 |
1151 // Trigger the auto window placement function by showing (and hiding) it. | 1150 // Trigger the auto window placement function by showing (and hiding) it. |
1152 window1->Hide(); | 1151 window1->Hide(); |
1153 window1->Show(); | 1152 window1->Show(); |
1154 | 1153 |
1155 // |window1| should be flush right and |window3| flush left. | 1154 // |window1| should be flush right and |window3| flush left. |
1156 EXPECT_EQ(base::IntToString( | 1155 EXPECT_EQ(base::IntToString( |
1157 desktop_area.width() - window1->bounds().width()) + | 1156 desktop_area.width() - window1->bounds().width()) + |
1158 ",32 640x320", window1->bounds().ToString()); | 1157 ",32 640x320", window1->bounds().ToString()); |
1159 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); | 1158 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); |
1160 | 1159 |
1161 window1_state->Maximize(); | 1160 window1_state->Maximize(); |
1162 window1_state->Minimize(); | 1161 window1_state->Minimize(); |
1163 | 1162 |
1164 // |window2| should be centered now. | 1163 // |window2| should be centered now. |
1165 EXPECT_TRUE(window2->IsVisible()); | 1164 EXPECT_TRUE(window2->IsVisible()); |
1166 EXPECT_TRUE(window2_state->IsNormalStateType()); | 1165 EXPECT_TRUE(window2_state->IsNormalStateType()); |
1167 EXPECT_EQ(base::IntToString( | 1166 EXPECT_EQ(base::IntToString( |
1168 (desktop_area.width() - window2->bounds().width()) / 2) + | 1167 (desktop_area.width() - window2->bounds().width()) / 2) + |
1169 ",40 256x512", window2->bounds().ToString()); | 1168 ",40 256x512", window2->bounds().ToString()); |
1170 } | 1169 } |
1171 | 1170 |
1172 // Test that nomral, maximize, normal will repos the remaining. | 1171 // Test that nomral, maximize, normal will repos the remaining. |
1173 TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) { | 1172 TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) { |
1174 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1173 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
1175 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 1174 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
1176 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 1175 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
1177 window1_state->set_window_position_managed(true); | 1176 window1_state->set_window_position_managed(true); |
1178 gfx::Rect desktop_area = window1->parent()->bounds(); | 1177 gfx::Rect desktop_area = window1->parent()->bounds(); |
1179 | 1178 |
1180 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 1179 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
1181 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 1180 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
1182 window2->SetBounds(gfx::Rect(32, 40, 256, 512)); | 1181 window2->SetBounds(gfx::Rect(32, 40, 256, 512)); |
1183 | 1182 |
1184 // Trigger the auto window placement function by showing (and hiding) it. | 1183 // Trigger the auto window placement function by showing (and hiding) it. |
1185 window1->Hide(); | 1184 window1->Hide(); |
1186 window1->Show(); | 1185 window1->Show(); |
1187 | 1186 |
1188 // |window1| should be flush right and |window3| flush left. | 1187 // |window1| should be flush right and |window3| flush left. |
1189 EXPECT_EQ(base::IntToString( | 1188 EXPECT_EQ(base::IntToString( |
1190 desktop_area.width() - window1->bounds().width()) + | 1189 desktop_area.width() - window1->bounds().width()) + |
1191 ",32 640x320", window1->bounds().ToString()); | 1190 ",32 640x320", window1->bounds().ToString()); |
1192 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); | 1191 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); |
1193 | 1192 |
1194 window1_state->Maximize(); | 1193 window1_state->Maximize(); |
1195 window1_state->Restore(); | 1194 window1_state->Restore(); |
1196 | 1195 |
1197 // |window1| should be flush right and |window2| flush left. | 1196 // |window1| should be flush right and |window2| flush left. |
1198 EXPECT_EQ(base::IntToString( | 1197 EXPECT_EQ(base::IntToString( |
1199 desktop_area.width() - window1->bounds().width()) + | 1198 desktop_area.width() - window1->bounds().width()) + |
1200 ",32 640x320", window1->bounds().ToString()); | 1199 ",32 640x320", window1->bounds().ToString()); |
1201 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); | 1200 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); |
1202 } | 1201 } |
1203 | 1202 |
1204 // Test that animations are triggered. | 1203 // Test that animations are triggered. |
1205 TEST_F(WorkspaceControllerTest, AnimatedNormToMaxToNormRepositionsRemaining) { | 1204 TEST_F(WorkspaceControllerTest, AnimatedNormToMaxToNormRepositionsRemaining) { |
1206 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 1205 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
1207 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 1206 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
1208 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1207 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
1209 window1->Hide(); | 1208 window1->Hide(); |
1210 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 1209 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
1211 gfx::Rect desktop_area = window1->parent()->bounds(); | 1210 gfx::Rect desktop_area = window1->parent()->bounds(); |
1212 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 1211 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
1213 window2->Hide(); | 1212 window2->Hide(); |
1214 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 1213 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
1215 | 1214 |
1216 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 1215 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
1217 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 1216 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
1218 // Make sure nothing is animating. | 1217 // Make sure nothing is animating. |
1219 window1->layer()->GetAnimator()->StopAnimating(); | 1218 window1->layer()->GetAnimator()->StopAnimating(); |
1220 window2->layer()->GetAnimator()->StopAnimating(); | 1219 window2->layer()->GetAnimator()->StopAnimating(); |
1221 window2->Show(); | 1220 window2->Show(); |
1222 | 1221 |
(...skipping 14 matching lines...) Expand all Loading... |
1237 ",32 640x320", window1->bounds().ToString()); | 1236 ",32 640x320", window1->bounds().ToString()); |
1238 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); | 1237 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); |
1239 } | 1238 } |
1240 | 1239 |
1241 // This tests simulates a browser and an app and verifies the ordering of the | 1240 // This tests simulates a browser and an app and verifies the ordering of the |
1242 // windows and layers doesn't get out of sync as various operations occur. Its | 1241 // windows and layers doesn't get out of sync as various operations occur. Its |
1243 // really testing code in FocusController, but easier to simulate here. Just as | 1242 // really testing code in FocusController, but easier to simulate here. Just as |
1244 // with a real browser the browser here has a transient child window | 1243 // with a real browser the browser here has a transient child window |
1245 // (corresponds to the status bubble). | 1244 // (corresponds to the status bubble). |
1246 TEST_F(WorkspaceControllerTest, VerifyLayerOrdering) { | 1245 TEST_F(WorkspaceControllerTest, VerifyLayerOrdering) { |
1247 scoped_ptr<Window> browser(aura::test::CreateTestWindowWithDelegate( | 1246 std::unique_ptr<Window> browser(aura::test::CreateTestWindowWithDelegate( |
1248 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL)); | 1247 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL)); |
1249 browser->SetName("browser"); | 1248 browser->SetName("browser"); |
1250 ParentWindowInPrimaryRootWindow(browser.get()); | 1249 ParentWindowInPrimaryRootWindow(browser.get()); |
1251 browser->Show(); | 1250 browser->Show(); |
1252 wm::ActivateWindow(browser.get()); | 1251 wm::ActivateWindow(browser.get()); |
1253 | 1252 |
1254 // |status_bubble| is made a transient child of |browser| and as a result | 1253 // |status_bubble| is made a transient child of |browser| and as a result |
1255 // owned by |browser|. | 1254 // owned by |browser|. |
1256 aura::test::TestWindowDelegate* status_bubble_delegate = | 1255 aura::test::TestWindowDelegate* status_bubble_delegate = |
1257 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(); | 1256 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(); |
1258 status_bubble_delegate->set_can_focus(false); | 1257 status_bubble_delegate->set_can_focus(false); |
1259 Window* status_bubble = | 1258 Window* status_bubble = |
1260 aura::test::CreateTestWindowWithDelegate(status_bubble_delegate, | 1259 aura::test::CreateTestWindowWithDelegate(status_bubble_delegate, |
1261 ui::wm::WINDOW_TYPE_POPUP, | 1260 ui::wm::WINDOW_TYPE_POPUP, |
1262 gfx::Rect(5, 6, 7, 8), | 1261 gfx::Rect(5, 6, 7, 8), |
1263 NULL); | 1262 NULL); |
1264 ::wm::AddTransientChild(browser.get(), status_bubble); | 1263 ::wm::AddTransientChild(browser.get(), status_bubble); |
1265 ParentWindowInPrimaryRootWindow(status_bubble); | 1264 ParentWindowInPrimaryRootWindow(status_bubble); |
1266 status_bubble->SetName("status_bubble"); | 1265 status_bubble->SetName("status_bubble"); |
1267 | 1266 |
1268 scoped_ptr<Window> app(aura::test::CreateTestWindowWithDelegate( | 1267 std::unique_ptr<Window> app(aura::test::CreateTestWindowWithDelegate( |
1269 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL)); | 1268 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL)); |
1270 app->SetName("app"); | 1269 app->SetName("app"); |
1271 ParentWindowInPrimaryRootWindow(app.get()); | 1270 ParentWindowInPrimaryRootWindow(app.get()); |
1272 | 1271 |
1273 aura::Window* parent = browser->parent(); | 1272 aura::Window* parent = browser->parent(); |
1274 | 1273 |
1275 app->Show(); | 1274 app->Show(); |
1276 wm::ActivateWindow(app.get()); | 1275 wm::ActivateWindow(app.get()); |
1277 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent)); | 1276 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent)); |
1278 | 1277 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 | 1345 |
1347 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver); | 1346 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver); |
1348 }; | 1347 }; |
1349 | 1348 |
1350 } // namespace | 1349 } // namespace |
1351 | 1350 |
1352 // Verifies that a new maximized window becomes visible after its activation | 1351 // Verifies that a new maximized window becomes visible after its activation |
1353 // is requested, even though it does not become activated because a system | 1352 // is requested, even though it does not become activated because a system |
1354 // modal window is active. | 1353 // modal window is active. |
1355 TEST_F(WorkspaceControllerTest, SwitchFromModal) { | 1354 TEST_F(WorkspaceControllerTest, SwitchFromModal) { |
1356 scoped_ptr<Window> modal_window(CreateTestWindowUnparented()); | 1355 std::unique_ptr<Window> modal_window(CreateTestWindowUnparented()); |
1357 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); | 1356 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); |
1358 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 1357 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
1359 ParentWindowInPrimaryRootWindow(modal_window.get()); | 1358 ParentWindowInPrimaryRootWindow(modal_window.get()); |
1360 modal_window->Show(); | 1359 modal_window->Show(); |
1361 wm::ActivateWindow(modal_window.get()); | 1360 wm::ActivateWindow(modal_window.get()); |
1362 | 1361 |
1363 scoped_ptr<Window> maximized_window(CreateTestWindow()); | 1362 std::unique_ptr<Window> maximized_window(CreateTestWindow()); |
1364 maximized_window->SetProperty( | 1363 maximized_window->SetProperty( |
1365 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1364 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
1366 maximized_window->Show(); | 1365 maximized_window->Show(); |
1367 wm::ActivateWindow(maximized_window.get()); | 1366 wm::ActivateWindow(maximized_window.get()); |
1368 EXPECT_TRUE(maximized_window->IsVisible()); | 1367 EXPECT_TRUE(maximized_window->IsVisible()); |
1369 } | 1368 } |
1370 | 1369 |
1371 namespace { | 1370 namespace { |
1372 | 1371 |
1373 // Subclass of WorkspaceControllerTest that runs tests with docked windows | 1372 // Subclass of WorkspaceControllerTest that runs tests with docked windows |
1374 // enabled and disabled. | 1373 // enabled and disabled. |
1375 class WorkspaceControllerTestDragging : public WorkspaceControllerTest { | 1374 class WorkspaceControllerTestDragging : public WorkspaceControllerTest { |
1376 public: | 1375 public: |
1377 WorkspaceControllerTestDragging() {} | 1376 WorkspaceControllerTestDragging() {} |
1378 ~WorkspaceControllerTestDragging() override {} | 1377 ~WorkspaceControllerTestDragging() override {} |
1379 | 1378 |
1380 private: | 1379 private: |
1381 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging); | 1380 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging); |
1382 }; | 1381 }; |
1383 | 1382 |
1384 } // namespace | 1383 } // namespace |
1385 | 1384 |
1386 // Verifies that when dragging a window over the shelf overlap is detected | 1385 // Verifies that when dragging a window over the shelf overlap is detected |
1387 // during and after the drag. | 1386 // during and after the drag. |
1388 TEST_F(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { | 1387 TEST_F(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { |
1389 aura::test::TestWindowDelegate delegate; | 1388 aura::test::TestWindowDelegate delegate; |
1390 delegate.set_window_component(HTCAPTION); | 1389 delegate.set_window_component(HTCAPTION); |
1391 scoped_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( | 1390 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
1392 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); | 1391 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
1393 ParentWindowInPrimaryRootWindow(w1.get()); | 1392 ParentWindowInPrimaryRootWindow(w1.get()); |
1394 | 1393 |
1395 ShelfLayoutManager* shelf = shelf_layout_manager(); | 1394 ShelfLayoutManager* shelf = shelf_layout_manager(); |
1396 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1395 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1397 | 1396 |
1398 // Drag near the shelf. | 1397 // Drag near the shelf. |
1399 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1398 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1400 gfx::Point()); | 1399 gfx::Point()); |
1401 generator.MoveMouseTo(10, 10); | 1400 generator.MoveMouseTo(10, 10); |
1402 generator.PressLeftButton(); | 1401 generator.PressLeftButton(); |
1403 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 70); | 1402 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 70); |
1404 | 1403 |
1405 // Shelf should not be in overlapped state. | 1404 // Shelf should not be in overlapped state. |
1406 EXPECT_FALSE(GetWindowOverlapsShelf()); | 1405 EXPECT_FALSE(GetWindowOverlapsShelf()); |
1407 | 1406 |
1408 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20); | 1407 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20); |
1409 | 1408 |
1410 // Shelf should detect overlap. Overlap state stays after mouse is released. | 1409 // Shelf should detect overlap. Overlap state stays after mouse is released. |
1411 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1410 EXPECT_TRUE(GetWindowOverlapsShelf()); |
1412 generator.ReleaseLeftButton(); | 1411 generator.ReleaseLeftButton(); |
1413 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1412 EXPECT_TRUE(GetWindowOverlapsShelf()); |
1414 } | 1413 } |
1415 | 1414 |
1416 // Verifies that when dragging a window autohidden shelf stays hidden during | 1415 // Verifies that when dragging a window autohidden shelf stays hidden during |
1417 // and after the drag. | 1416 // and after the drag. |
1418 TEST_F(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) { | 1417 TEST_F(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) { |
1419 aura::test::TestWindowDelegate delegate; | 1418 aura::test::TestWindowDelegate delegate; |
1420 delegate.set_window_component(HTCAPTION); | 1419 delegate.set_window_component(HTCAPTION); |
1421 scoped_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( | 1420 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
1422 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); | 1421 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
1423 ParentWindowInPrimaryRootWindow(w1.get()); | 1422 ParentWindowInPrimaryRootWindow(w1.get()); |
1424 | 1423 |
1425 ShelfLayoutManager* shelf = shelf_layout_manager(); | 1424 ShelfLayoutManager* shelf = shelf_layout_manager(); |
1426 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1425 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1427 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1426 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
1428 | 1427 |
1429 // Drag very little. | 1428 // Drag very little. |
1430 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1429 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1431 gfx::Point()); | 1430 gfx::Point()); |
1432 generator.MoveMouseTo(10, 10); | 1431 generator.MoveMouseTo(10, 10); |
1433 generator.PressLeftButton(); | 1432 generator.PressLeftButton(); |
1434 generator.MoveMouseTo(12, 12); | 1433 generator.MoveMouseTo(12, 12); |
1435 | 1434 |
1436 // Shelf should be hidden during and after the drag. | 1435 // Shelf should be hidden during and after the drag. |
1437 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1436 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
1438 generator.ReleaseLeftButton(); | 1437 generator.ReleaseLeftButton(); |
1439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 1438 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
1440 } | 1439 } |
1441 | 1440 |
1442 // Verifies that events are targeted properly just outside the window edges. | 1441 // Verifies that events are targeted properly just outside the window edges. |
1443 TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) { | 1442 TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) { |
1444 aura::test::TestWindowDelegate d_first, d_second; | 1443 aura::test::TestWindowDelegate d_first, d_second; |
1445 scoped_ptr<Window> first(aura::test::CreateTestWindowWithDelegate(&d_first, | 1444 std::unique_ptr<Window> first(aura::test::CreateTestWindowWithDelegate( |
1446 123, gfx::Rect(20, 10, 100, 50), NULL)); | 1445 &d_first, 123, gfx::Rect(20, 10, 100, 50), NULL)); |
1447 ParentWindowInPrimaryRootWindow(first.get()); | 1446 ParentWindowInPrimaryRootWindow(first.get()); |
1448 first->Show(); | 1447 first->Show(); |
1449 | 1448 |
1450 scoped_ptr<Window> second(aura::test::CreateTestWindowWithDelegate(&d_second, | 1449 std::unique_ptr<Window> second(aura::test::CreateTestWindowWithDelegate( |
1451 234, gfx::Rect(30, 40, 40, 10), NULL)); | 1450 &d_second, 234, gfx::Rect(30, 40, 40, 10), NULL)); |
1452 ParentWindowInPrimaryRootWindow(second.get()); | 1451 ParentWindowInPrimaryRootWindow(second.get()); |
1453 second->Show(); | 1452 second->Show(); |
1454 | 1453 |
1455 ui::EventTarget* root = first->GetRootWindow(); | 1454 ui::EventTarget* root = first->GetRootWindow(); |
1456 ui::EventTargeter* targeter = root->GetEventTargeter(); | 1455 ui::EventTargeter* targeter = root->GetEventTargeter(); |
1457 | 1456 |
1458 // The windows overlap, and |second| is on top of |first|. Events targeted | 1457 // The windows overlap, and |second| is on top of |first|. Events targeted |
1459 // slightly outside the edges of the |second| window should still be targeted | 1458 // slightly outside the edges of the |second| window should still be targeted |
1460 // to |second| to allow resizing the windows easily. | 1459 // to |second| to allow resizing the windows easily. |
1461 | 1460 |
(...skipping 30 matching lines...) Expand all Loading... |
1492 // should no longer be targeted. | 1491 // should no longer be targeted. |
1493 gfx::Transform transform; | 1492 gfx::Transform transform; |
1494 transform.Translate(70, 40); | 1493 transform.Translate(70, 40); |
1495 second->SetTransform(transform); | 1494 second->SetTransform(transform); |
1496 } | 1495 } |
1497 } | 1496 } |
1498 | 1497 |
1499 // Verifies mouse event targeting just outside the window edges for panels. | 1498 // Verifies mouse event targeting just outside the window edges for panels. |
1500 TEST_F(WorkspaceControllerTest, WindowEdgeMouseHitTestPanel) { | 1499 TEST_F(WorkspaceControllerTest, WindowEdgeMouseHitTestPanel) { |
1501 aura::test::TestWindowDelegate delegate; | 1500 aura::test::TestWindowDelegate delegate; |
1502 scoped_ptr<Window> window(CreateTestPanel(&delegate, | 1501 std::unique_ptr<Window> window( |
1503 gfx::Rect(20, 10, 100, 50))); | 1502 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); |
1504 ui::EventTarget* root = window->GetRootWindow(); | 1503 ui::EventTarget* root = window->GetRootWindow(); |
1505 ui::EventTargeter* targeter = root->GetEventTargeter(); | 1504 ui::EventTargeter* targeter = root->GetEventTargeter(); |
1506 const gfx::Rect bounds = window->bounds(); | 1505 const gfx::Rect bounds = window->bounds(); |
1507 const int kNumPoints = 5; | 1506 const int kNumPoints = 5; |
1508 struct { | 1507 struct { |
1509 const char* direction; | 1508 const char* direction; |
1510 gfx::Point location; | 1509 gfx::Point location; |
1511 bool is_target_hit; | 1510 bool is_target_hit; |
1512 } points[kNumPoints] = { | 1511 } points[kNumPoints] = { |
1513 { "left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true }, | 1512 { "left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true }, |
(...skipping 14 matching lines...) Expand all Loading... |
1528 EXPECT_NE(window.get(), target); | 1527 EXPECT_NE(window.get(), target); |
1529 } | 1528 } |
1530 } | 1529 } |
1531 | 1530 |
1532 // Verifies touch event targeting just outside the window edges for panels. | 1531 // Verifies touch event targeting just outside the window edges for panels. |
1533 // The shelf is aligned to the bottom by default, and so touches just below | 1532 // The shelf is aligned to the bottom by default, and so touches just below |
1534 // the bottom edge of the panel should not target the panel itself because | 1533 // the bottom edge of the panel should not target the panel itself because |
1535 // an AttachedPanelWindowTargeter is installed on the panel container. | 1534 // an AttachedPanelWindowTargeter is installed on the panel container. |
1536 TEST_F(WorkspaceControllerTest, WindowEdgeTouchHitTestPanel) { | 1535 TEST_F(WorkspaceControllerTest, WindowEdgeTouchHitTestPanel) { |
1537 aura::test::TestWindowDelegate delegate; | 1536 aura::test::TestWindowDelegate delegate; |
1538 scoped_ptr<Window> window(CreateTestPanel(&delegate, | 1537 std::unique_ptr<Window> window( |
1539 gfx::Rect(20, 10, 100, 50))); | 1538 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); |
1540 ui::EventTarget* root = window->GetRootWindow(); | 1539 ui::EventTarget* root = window->GetRootWindow(); |
1541 ui::EventTargeter* targeter = root->GetEventTargeter(); | 1540 ui::EventTargeter* targeter = root->GetEventTargeter(); |
1542 const gfx::Rect bounds = window->bounds(); | 1541 const gfx::Rect bounds = window->bounds(); |
1543 const int kNumPoints = 5; | 1542 const int kNumPoints = 5; |
1544 struct { | 1543 struct { |
1545 const char* direction; | 1544 const char* direction; |
1546 gfx::Point location; | 1545 gfx::Point location; |
1547 bool is_target_hit; | 1546 bool is_target_hit; |
1548 } points[kNumPoints] = { | 1547 } points[kNumPoints] = { |
1549 { "left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true }, | 1548 { "left", gfx::Point(bounds.x() - 2, bounds.y() + 10), true }, |
(...skipping 14 matching lines...) Expand all Loading... |
1564 EXPECT_NE(window.get(), target); | 1563 EXPECT_NE(window.get(), target); |
1565 } | 1564 } |
1566 } | 1565 } |
1567 | 1566 |
1568 // Verifies events targeting just outside the window edges for docked windows. | 1567 // Verifies events targeting just outside the window edges for docked windows. |
1569 TEST_F(WorkspaceControllerTest, WindowEdgeHitTestDocked) { | 1568 TEST_F(WorkspaceControllerTest, WindowEdgeHitTestDocked) { |
1570 aura::test::TestWindowDelegate delegate; | 1569 aura::test::TestWindowDelegate delegate; |
1571 // Make window smaller than the minimum docked area so that the window edges | 1570 // Make window smaller than the minimum docked area so that the window edges |
1572 // are exposed. | 1571 // are exposed. |
1573 delegate.set_maximum_size(gfx::Size(180, 200)); | 1572 delegate.set_maximum_size(gfx::Size(180, 200)); |
1574 scoped_ptr<Window> window(aura::test::CreateTestWindowWithDelegate(&delegate, | 1573 std::unique_ptr<Window> window(aura::test::CreateTestWindowWithDelegate( |
1575 123, gfx::Rect(20, 10, 100, 50), NULL)); | 1574 &delegate, 123, gfx::Rect(20, 10, 100, 50), NULL)); |
1576 ParentWindowInPrimaryRootWindow(window.get()); | 1575 ParentWindowInPrimaryRootWindow(window.get()); |
1577 aura::Window* docked_container = Shell::GetContainer( | 1576 aura::Window* docked_container = Shell::GetContainer( |
1578 window->GetRootWindow(), kShellWindowId_DockedContainer); | 1577 window->GetRootWindow(), kShellWindowId_DockedContainer); |
1579 docked_container->AddChild(window.get()); | 1578 docked_container->AddChild(window.get()); |
1580 window->Show(); | 1579 window->Show(); |
1581 ui::EventTarget* root = window->GetRootWindow(); | 1580 ui::EventTarget* root = window->GetRootWindow(); |
1582 ui::EventTargeter* targeter = root->GetEventTargeter(); | 1581 ui::EventTargeter* targeter = root->GetEventTargeter(); |
1583 const gfx::Rect bounds = window->bounds(); | 1582 const gfx::Rect bounds = window->bounds(); |
1584 const int kNumPoints = 5; | 1583 const int kNumPoints = 5; |
1585 struct { | 1584 struct { |
(...skipping 22 matching lines...) Expand all Loading... |
1608 ui::EventTimeForNow()); | 1607 ui::EventTimeForNow()); |
1609 target = targeter->FindTargetForEvent(root, &touch); | 1608 target = targeter->FindTargetForEvent(root, &touch); |
1610 if (points[i].is_target_hit) | 1609 if (points[i].is_target_hit) |
1611 EXPECT_EQ(window.get(), target); | 1610 EXPECT_EQ(window.get(), target); |
1612 else | 1611 else |
1613 EXPECT_NE(window.get(), target); | 1612 EXPECT_NE(window.get(), target); |
1614 } | 1613 } |
1615 } | 1614 } |
1616 | 1615 |
1617 } // namespace ash | 1616 } // namespace ash |
OLD | NEW |