OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/workspace/workspace_manager.h" | 5 #include "ash/wm/workspace/workspace_manager.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/activation_controller.h" | 10 #include "ash/wm/activation_controller.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 w1->Show(); | 293 w1->Show(); |
294 | 294 |
295 EXPECT_TRUE(manager_->IsManagedWindow(w1.get())); | 295 EXPECT_TRUE(manager_->IsManagedWindow(w1.get())); |
296 // Setting the bounds should go through since the window is in the normal | 296 // Setting the bounds should go through since the window is in the normal |
297 // workspace. | 297 // workspace. |
298 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); | 298 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); |
299 EXPECT_EQ(200, w1->bounds().width()); | 299 EXPECT_EQ(200, w1->bounds().width()); |
300 EXPECT_EQ(500, w1->bounds().height()); | 300 EXPECT_EQ(500, w1->bounds().height()); |
301 } | 301 } |
302 | 302 |
303 // Assertions around open new windows maximized. | |
304 TEST_F(WorkspaceManagerTest, OpenNewWindowsMaximized) { | |
305 scoped_ptr<Window> w1(CreateTestWindowUnparented()); | |
306 | |
307 // Default is true for open new windows maximized. | |
308 EXPECT_TRUE(manager_->open_new_windows_maximized()); | |
309 // SHOW_STATE_DEFAULT should end up maximized. | |
310 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); | |
311 w1->SetBounds(gfx::Rect(50, 51, 52, 53)); | |
312 w1->SetParent(GetViewport()); | |
313 // Maximized state and bounds should be set as soon as w1 is added to the | |
314 // parent. | |
315 EXPECT_TRUE(wm::IsWindowMaximized(w1.get())); | |
316 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(w1.get()), | |
317 w1->bounds()); | |
318 w1->Show(); | |
319 EXPECT_TRUE(wm::IsWindowMaximized(w1.get())); | |
320 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(w1.get()), | |
321 w1->bounds()); | |
322 // Restored bounds should be saved. | |
323 ASSERT_TRUE(GetRestoreBounds(w1.get())); | |
324 EXPECT_EQ(gfx::Rect(50, 51, 52, 53), *GetRestoreBounds(w1.get())); | |
325 | |
326 // Show state normal should end up normal. | |
327 scoped_ptr<Window> w2(CreateTestWindow()); | |
328 w2->SetBounds(gfx::Rect(60, 61, 62, 63)); | |
329 w2->Show(); | |
330 EXPECT_EQ(gfx::Rect(60, 61, 62, 63), w2->bounds()); | |
331 EXPECT_EQ(ui::SHOW_STATE_NORMAL, | |
332 w2->GetProperty(aura::client::kShowStateKey)); | |
333 | |
334 // If open news windows maximized is false, SHOW_STATE_DEFAULT should end as | |
335 // SHOW_STATE_NORMAL. | |
336 manager_->set_open_new_windows_maximized(false); | |
337 scoped_ptr<Window> w3(CreateTestWindowUnparented()); | |
338 // Show state default should end up normal when open new windows maximized is | |
339 // false. | |
340 w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); | |
341 w3->SetBounds(gfx::Rect(70, 71, 72, 73)); | |
342 w3->SetParent(GetViewport()); | |
343 w3->Show(); | |
344 EXPECT_EQ(gfx::Rect(70, 71, 72, 73), w3->bounds()); | |
345 EXPECT_EQ(ui::SHOW_STATE_NORMAL, | |
346 w3->GetProperty(aura::client::kShowStateKey)); | |
347 } | |
348 | |
349 // Assertions around grid size. | 303 // Assertions around grid size. |
350 TEST_F(WorkspaceManagerTest, SnapToGrid) { | 304 TEST_F(WorkspaceManagerTest, SnapToGrid) { |
351 manager_->set_grid_size(8); | 305 manager_->set_grid_size(8); |
352 | 306 |
353 // Verify snap to grid when bounds are set before parented. | 307 // Verify snap to grid when bounds are set before parented. |
354 scoped_ptr<Window> w1(CreateTestWindowUnparented()); | 308 scoped_ptr<Window> w1(CreateTestWindowUnparented()); |
355 w1->SetBounds(gfx::Rect(1, 6, 25, 30)); | 309 w1->SetBounds(gfx::Rect(1, 6, 25, 30)); |
356 w1->SetParent(GetViewport()); | 310 w1->SetParent(GetViewport()); |
357 EXPECT_EQ(gfx::Rect(0, 8, 24, 32), w1->bounds()); | 311 EXPECT_EQ(gfx::Rect(0, 8, 24, 32), w1->bounds()); |
358 } | 312 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 ASSERT_EQ(1u, workspaces()[0]->windows().size()); | 345 ASSERT_EQ(1u, workspaces()[0]->windows().size()); |
392 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]); | 346 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]); |
393 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); | 347 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); |
394 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); | 348 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); |
395 ASSERT_TRUE(GetRestoreBounds(w1.get())); | 349 ASSERT_TRUE(GetRestoreBounds(w1.get())); |
396 EXPECT_EQ(gfx::Rect(0, 0, 250, 251), *GetRestoreBounds(w1.get())); | 350 EXPECT_EQ(gfx::Rect(0, 0, 250, 251), *GetRestoreBounds(w1.get())); |
397 } | 351 } |
398 | 352 |
399 } // namespace internal | 353 } // namespace internal |
400 } // namespace ash | 354 } // namespace ash |
OLD | NEW |