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 "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" | 5 #include "ash/screen_ash.h" |
6 | |
7 #include "ash/shell.h" | 6 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
9 #include "ash/test/test_shell_delegate.h" | 8 #include "ash/test/test_shell_delegate.h" |
10 #include "ash/wm/window_resizer.h" | 9 #include "ash/wm/window_resizer.h" |
11 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
13 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" | |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
16 #include "content/public/test/render_view_test.h" | 16 #include "content/public/test/render_view_test.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "ui/aura/client/activation_client.h" | 18 #include "ui/aura/client/activation_client.h" |
19 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
20 #include "ui/aura/env.h" | 20 #include "ui/aura/env.h" |
21 #include "ui/aura/root_window.h" | 21 #include "ui/aura/root_window.h" |
22 #include "ui/aura/test/test_windows.h" | 22 #include "ui/aura/test/test_windows.h" |
23 | 23 |
24 typedef ash::test::AshTestBase WindowSizerTest; | 24 typedef ash::test::AshTestBase WindowSizerAshTest; |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // A browser window proxy which is able to associate an aura native window with | 28 // A browser window proxy which is able to associate an aura native window with |
29 // it. | 29 // it. |
30 class TestBrowserWindowAura : public TestBrowserWindow { | 30 class TestBrowserWindowAura : public TestBrowserWindow { |
31 public: | 31 public: |
32 // |native_window| will still be owned by the caller after the constructor | 32 // |native_window| will still be owned by the caller after the constructor |
33 // was called. | 33 // was called. |
34 explicit TestBrowserWindowAura(aura::Window* native_window) | 34 explicit TestBrowserWindowAura(aura::Window* native_window) |
(...skipping 19 matching lines...) Expand all Loading... | |
54 virtual gfx::Rect GetBounds() const OVERRIDE { | 54 virtual gfx::Rect GetBounds() const OVERRIDE { |
55 return native_window_->bounds(); | 55 return native_window_->bounds(); |
56 } | 56 } |
57 | 57 |
58 Browser* browser() { return browser_.get(); } | 58 Browser* browser() { return browser_.get(); } |
59 | 59 |
60 void CreateBrowser(const Browser::CreateParams& params) { | 60 void CreateBrowser(const Browser::CreateParams& params) { |
61 Browser::CreateParams create_params = params; | 61 Browser::CreateParams create_params = params; |
62 create_params.window = this; | 62 create_params.window = this; |
63 browser_.reset(new Browser(create_params)); | 63 browser_.reset(new Browser(create_params)); |
64 if (browser_->is_type_tabbed() || browser_->is_app()) | |
65 ash::wm::SetWindowPositionManaged(native_window_.get(), true); | |
64 } | 66 } |
65 | 67 |
66 private: | 68 private: |
67 scoped_ptr<Browser> browser_; | 69 scoped_ptr<Browser> browser_; |
68 scoped_ptr<aura::Window> native_window_; | 70 scoped_ptr<aura::Window> native_window_; |
69 | 71 |
70 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura); | 72 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura); |
71 }; | 73 }; |
72 | 74 |
73 int AlignToGridRoundDown(int location, int grid_size) { | 75 int AlignToGridRoundDown(int location, int grid_size) { |
(...skipping 11 matching lines...) Expand all Loading... | |
85 scoped_ptr<TestBrowserWindowAura> browser_window( | 87 scoped_ptr<TestBrowserWindowAura> browser_window( |
86 new TestBrowserWindowAura(window)); | 88 new TestBrowserWindowAura(window)); |
87 browser_window->CreateBrowser(params); | 89 browser_window->CreateBrowser(params); |
88 return browser_window.Pass(); | 90 return browser_window.Pass(); |
89 } | 91 } |
90 | 92 |
91 } // namespace | 93 } // namespace |
92 | 94 |
93 // Test that the window is sized appropriately for the first run experience | 95 // Test that the window is sized appropriately for the first run experience |
94 // where the default window bounds calculation is invoked. | 96 // where the default window bounds calculation is invoked. |
95 TEST_F(WindowSizerTest, DefaultSizeCase) { | 97 TEST_F(WindowSizerAshTest, DefaultSizeCase) { |
96 int grid = WindowSizer::kDesktopBorderSize; | 98 int grid = WindowSizer::kDesktopBorderSize; |
97 { // 4:3 monitor case, 1024x768, no taskbar | 99 { // 4:3 monitor case, 1024x768, no taskbar |
98 gfx::Rect window_bounds; | 100 gfx::Rect window_bounds; |
99 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), gfx::Rect(), | 101 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), gfx::Rect(), |
100 gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds); | 102 gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds); |
101 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 103 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
102 WindowSizer::kDesktopBorderSize, | 104 WindowSizer::kDesktopBorderSize, |
103 1024 - WindowSizer::kDesktopBorderSize * 2, | 105 1024 - WindowSizer::kDesktopBorderSize * 2, |
104 768 - WindowSizer::kDesktopBorderSize), | 106 768 - WindowSizer::kDesktopBorderSize), |
105 window_bounds); | 107 window_bounds); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 EXPECT_EQ(gfx::Rect((1920 - WindowSizer::kMaximumWindowWidth) / 2, | 209 EXPECT_EQ(gfx::Rect((1920 - WindowSizer::kMaximumWindowWidth) / 2, |
208 WindowSizer::kDesktopBorderSize, | 210 WindowSizer::kDesktopBorderSize, |
209 WindowSizer::kMaximumWindowWidth, | 211 WindowSizer::kMaximumWindowWidth, |
210 1200 - WindowSizer::kDesktopBorderSize), | 212 1200 - WindowSizer::kDesktopBorderSize), |
211 window_bounds); | 213 window_bounds); |
212 } | 214 } |
213 } | 215 } |
214 | 216 |
215 // Test that the next opened window is positioned appropriately given the | 217 // Test that the next opened window is positioned appropriately given the |
216 // bounds of an existing window of the same type. | 218 // bounds of an existing window of the same type. |
217 TEST_F(WindowSizerTest, LastWindowBoundsCase) { | 219 TEST_F(WindowSizerAshTest, LastWindowBoundsCase) { |
218 { // normal, in the middle of the screen somewhere. | 220 { // normal, in the middle of the screen somewhere. |
219 gfx::Rect window_bounds; | 221 gfx::Rect window_bounds; |
220 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), | 222 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), |
221 gfx::Rect(WindowSizer::kDesktopBorderSize, | 223 gfx::Rect(WindowSizer::kDesktopBorderSize, |
222 WindowSizer::kDesktopBorderSize, 500, 400), | 224 WindowSizer::kDesktopBorderSize, 500, 400), |
223 gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), | 225 gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), |
224 &window_bounds); | 226 &window_bounds); |
225 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 227 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
226 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 228 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
227 500, 400).ToString(), | 229 500, 400).ToString(), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), | 267 gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), |
266 &window_bounds); | 268 &window_bounds); |
267 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 269 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
268 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 270 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
269 500, 400).ToString(), | 271 500, 400).ToString(), |
270 window_bounds.ToString()); | 272 window_bounds.ToString()); |
271 } | 273 } |
272 } | 274 } |
273 | 275 |
274 // Test that the window opened is sized appropriately given persisted sizes. | 276 // Test that the window opened is sized appropriately given persisted sizes. |
275 TEST_F(WindowSizerTest, PersistedBoundsCase) { | 277 TEST_F(WindowSizerAshTest, PersistedBoundsCase) { |
276 { // normal, in the middle of the screen somewhere. | 278 { // normal, in the middle of the screen somewhere. |
277 gfx::Rect initial_bounds(WindowSizer::kDesktopBorderSize, | 279 gfx::Rect initial_bounds(WindowSizer::kDesktopBorderSize, |
278 WindowSizer::kDesktopBorderSize, 500, 400); | 280 WindowSizer::kDesktopBorderSize, 500, 400); |
279 | 281 |
280 gfx::Rect window_bounds; | 282 gfx::Rect window_bounds; |
281 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), initial_bounds, | 283 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), initial_bounds, |
282 gfx::Rect(), PERSISTED, NULL, gfx::Rect(), &window_bounds); | 284 gfx::Rect(), PERSISTED, NULL, gfx::Rect(), &window_bounds); |
283 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); | 285 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); |
284 } | 286 } |
285 | 287 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 window_bounds.ToString()); | 362 window_bounds.ToString()); |
361 } | 363 } |
362 } | 364 } |
363 | 365 |
364 ////////////////////////////////////////////////////////////////////////////// | 366 ////////////////////////////////////////////////////////////////////////////// |
365 // The following unittests have different results on Mac/non-Mac because we | 367 // The following unittests have different results on Mac/non-Mac because we |
366 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests | 368 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests |
367 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on | 369 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on |
368 // other platforms. | 370 // other platforms. |
369 | 371 |
370 TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) { | 372 TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) { |
371 { // taskbar on left. | 373 { // taskbar on left. |
372 gfx::Rect window_bounds; | 374 gfx::Rect window_bounds; |
373 GetWindowBounds(p1024x768, taskbar_left_work_area, gfx::Rect(), | 375 GetWindowBounds(p1024x768, taskbar_left_work_area, gfx::Rect(), |
374 gfx::Rect(WindowSizer::kDesktopBorderSize, | 376 gfx::Rect(WindowSizer::kDesktopBorderSize, |
375 WindowSizer::kDesktopBorderSize, 500, 400), | 377 WindowSizer::kDesktopBorderSize, 500, 400), |
376 gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), | 378 gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), |
377 &window_bounds); | 379 &window_bounds); |
378 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 380 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
379 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 381 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
380 500, 400).ToString(), | 382 500, 400).ToString(), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 NULL, gfx::Rect(), &window_bounds); | 437 NULL, gfx::Rect(), &window_bounds); |
436 EXPECT_EQ(gfx::Rect(994 /* not 995 */, | 438 EXPECT_EQ(gfx::Rect(994 /* not 995 */, |
437 738 /* not 739 */, | 439 738 /* not 739 */, |
438 500, | 440 500, |
439 400).ToString(), | 441 400).ToString(), |
440 window_bounds.ToString()); | 442 window_bounds.ToString()); |
441 } | 443 } |
442 } | 444 } |
443 | 445 |
444 // Test the placement of newly created windows. | 446 // Test the placement of newly created windows. |
445 TEST_F(WindowSizerTest, PlaceNewWindows) { | 447 TEST_F(WindowSizerAshTest, PlaceNewWindows) { |
446 // Create a browser which we can use to pass into the GetWindowBounds | 448 // Create a browser which we can use to pass into the GetWindowBounds |
447 // function. | 449 // function. |
448 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 450 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
449 // Creating a popup handler here to make sure it does not interfere with the | 451 // Creating a popup handler here to make sure it does not interfere with the |
450 // existing windows. | 452 // existing windows. |
451 Browser::CreateParams native_params(profile.get(), | 453 Browser::CreateParams native_params(profile.get(), |
452 chrome::HOST_DESKTOP_TYPE_ASH); | 454 chrome::HOST_DESKTOP_TYPE_ASH); |
453 scoped_ptr<Browser> browser( | 455 scoped_ptr<Browser> browser( |
454 chrome::CreateBrowserWithTestWindowForParams(&native_params)); | 456 chrome::CreateBrowserWithTestWindowForParams(&native_params)); |
455 | 457 |
(...skipping 10 matching lines...) Expand all Loading... | |
466 gfx::Rect(16, 32, 128, 256), | 468 gfx::Rect(16, 32, 128, 256), |
467 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 469 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
468 chrome::HOST_DESKTOP_TYPE_ASH))); | 470 chrome::HOST_DESKTOP_TYPE_ASH))); |
469 | 471 |
470 // Creating a panel to make sure it does not interfere with the positioning. | 472 // Creating a panel to make sure it does not interfere with the positioning. |
471 scoped_ptr<BrowserWindow> browser_panel(CreateTestBrowserWindow( | 473 scoped_ptr<BrowserWindow> browser_panel(CreateTestBrowserWindow( |
472 CreateTestWindowInShellWithId(2), | 474 CreateTestWindowInShellWithId(2), |
473 gfx::Rect(32, 48, 256, 512), | 475 gfx::Rect(32, 48, 256, 512), |
474 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 476 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
475 chrome::HOST_DESKTOP_TYPE_ASH))); | 477 chrome::HOST_DESKTOP_TYPE_ASH))); |
476 | |
477 browser_window->Show(); | 478 browser_window->Show(); |
478 { // With a shown window it's size should get returned. | |
479 gfx::Rect window_bounds; | |
480 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), | |
481 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, | |
482 PERSISTED, browser.get(), gfx::Rect(), &window_bounds); | |
483 // The position should be right flush. | |
484 EXPECT_EQ("960,32 640x320", window_bounds.ToString()); | |
485 } | |
486 | |
487 { // With the window shown - but more on the right side then on the left | |
488 // side (and partially out of the screen), it should default to the other | |
489 // side and inside the screen. | |
490 browser_window->GetNativeWindow()->SetBounds( | |
491 gfx::Rect(1000, 600, 640, 320)); | |
492 gfx::Rect window_bounds; | |
493 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), | |
494 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, | |
495 PERSISTED, browser.get(), gfx::Rect(), &window_bounds); | |
496 // The position should be left & bottom flush. | |
497 EXPECT_EQ("0,600 640x320", window_bounds.ToString()); | |
498 } | |
499 | |
500 { // If the second windows right side is already over the right side of the | |
501 // screen, it will not move back into the screen. | |
502 browser_window->GetNativeWindow()->SetBounds( | |
503 gfx::Rect(1000, 600, 640, 320)); | |
504 gfx::Rect window_bounds; | |
505 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), | |
506 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, | |
507 PERSISTED, browser.get(), gfx::Rect(), &window_bounds); | |
508 // The position should be left & bottom flush. | |
509 EXPECT_EQ("0,600 640x320", window_bounds.ToString()); | |
510 // If the other window was already beyond the point to get right flush | |
511 // it will remain where it is. | |
512 EXPECT_EQ("1000,600 640x320", | |
513 browser_window->GetNativeWindow()->bounds().ToString()); | |
514 } | |
515 | |
516 { // Make sure that popups do not get changed. | 479 { // Make sure that popups do not get changed. |
517 gfx::Rect window_bounds; | 480 gfx::Rect window_bounds; |
518 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), | 481 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), |
519 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, | 482 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, |
520 PERSISTED, browser_popup->browser(), | 483 PERSISTED, browser_popup->browser(), |
521 gfx::Rect(), &window_bounds); | 484 gfx::Rect(), &window_bounds); |
522 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); | 485 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); |
523 } | 486 } |
524 | 487 |
525 browser_window->Hide(); | 488 browser_window->Hide(); |
(...skipping 18 matching lines...) Expand all Loading... | |
544 std::min(WindowSizer::kMaximumWindowWidth, | 507 std::min(WindowSizer::kMaximumWindowWidth, |
545 1600 - 2 * WindowSizer::kDesktopBorderSize), | 508 1600 - 2 * WindowSizer::kDesktopBorderSize), |
546 1200 - WindowSizer::kDesktopBorderSize).ToString(), | 509 1200 - WindowSizer::kDesktopBorderSize).ToString(), |
547 window_bounds.ToString()); | 510 window_bounds.ToString()); |
548 } | 511 } |
549 } | 512 } |
550 | 513 |
551 // Test the placement of newly created windows on an empty desktop. | 514 // Test the placement of newly created windows on an empty desktop. |
552 // This test supplements "PlaceNewWindows" by testing the creation of a newly | 515 // This test supplements "PlaceNewWindows" by testing the creation of a newly |
553 // created browser window on an empty desktop. | 516 // created browser window on an empty desktop. |
554 TEST_F(WindowSizerTest, PlaceNewBrowserWindowOnEmptyDesktop) { | 517 TEST_F(WindowSizerAshTest, PlaceNewBrowserWindowOnEmptyDesktop) { |
555 // Create a browser which we can use to pass into the GetWindowBounds | 518 // Create a browser which we can use to pass into the GetWindowBounds |
556 // function. | 519 // function. |
557 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 520 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
558 Browser::CreateParams native_params(profile.get(), | 521 Browser::CreateParams native_params(profile.get(), |
559 chrome::HOST_DESKTOP_TYPE_ASH); | 522 chrome::HOST_DESKTOP_TYPE_ASH); |
560 scoped_ptr<Browser> browser( | 523 scoped_ptr<Browser> browser( |
561 chrome::CreateBrowserWithTestWindowForParams(&native_params)); | 524 chrome::CreateBrowserWithTestWindowForParams(&native_params)); |
562 | 525 |
563 // A common screen size for Chrome OS devices where this behavior is | 526 // A common screen size for Chrome OS devices where this behavior is |
564 // desirable. | 527 // desirable. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 } | 583 } |
621 | 584 |
622 #if defined(OS_CHROMEOS) | 585 #if defined(OS_CHROMEOS) |
623 #define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplay s | 586 #define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplay s |
624 #else | 587 #else |
625 // No multiple displays on windows ash. | 588 // No multiple displays on windows ash. |
626 #define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultip leDisplays | 589 #define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultip leDisplays |
627 #endif | 590 #endif |
628 | 591 |
629 // Test the placement of newly created windows on multiple dislays. | 592 // Test the placement of newly created windows on multiple dislays. |
630 TEST_F(WindowSizerTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { | 593 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { |
631 UpdateDisplay("1600x1200,1600x1200"); | 594 UpdateDisplay("1600x1200,1600x1200"); |
632 const gfx::Rect secondary(1600, 0, 1600, 1200); | 595 gfx::Rect primary_bounds = ash::Shell::GetInstance()->GetScreen()-> |
596 GetPrimaryDisplay().bounds(); | |
597 gfx::Rect secondary_bounds = ash::ScreenAsh::GetSecondaryDisplay().bounds(); | |
633 | 598 |
634 ash::Shell::GetInstance()->set_active_root_window( | 599 ash::Shell::GetInstance()->set_active_root_window( |
635 ash::Shell::GetPrimaryRootWindow()); | 600 ash::Shell::GetPrimaryRootWindow()); |
636 | 601 |
637 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 602 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
638 | 603 |
639 // Create browser windows that are used as reference. | 604 // Create browser windows that are used as reference. |
640 scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( | 605 scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( |
641 CreateTestWindowInShellWithId(0), | 606 CreateTestWindowInShellWithId(0), |
642 gfx::Rect(10, 10, 200, 200), | 607 gfx::Rect(10, 10, 200, 200), |
643 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); | 608 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
644 browser_window->Show(); | 609 browser_window->Show(); |
645 EXPECT_EQ(browser_window->GetNativeWindow()->GetRootWindow(), | 610 EXPECT_EQ(browser_window->GetNativeWindow()->GetRootWindow(), |
646 ash::Shell::GetActiveRootWindow()); | 611 ash::Shell::GetActiveRootWindow()); |
647 | 612 |
648 scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow( | 613 scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow( |
649 CreateTestWindowInShellWithId(1), | 614 CreateTestWindowInShellWithId(1), |
650 gfx::Rect(1600 - 200, 10, 300, 300), | 615 gfx::Rect(400, 10, 300, 300), |
651 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); | 616 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
652 another_browser_window->Show(); | 617 another_browser_window->Show(); |
653 | 618 |
654 // Creating a new window to verify the new placement. | 619 // Creating a new window to verify the new placement. |
655 scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow( | 620 scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow( |
656 CreateTestWindowInShellWithId(0), | 621 CreateTestWindowInShellWithId(0), |
657 gfx::Rect(), | 622 gfx::Rect(), |
658 Browser::CreateParams(profile.get(), | 623 Browser::CreateParams(profile.get(), |
659 chrome::HOST_DESKTOP_TYPE_ASH))); | 624 chrome::HOST_DESKTOP_TYPE_ASH))); |
660 | 625 |
661 // Make sure the primary root is active. | 626 // Make sure the primary root is active. |
662 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), | 627 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), |
663 ash::Shell::GetActiveRootWindow()); | 628 ash::Shell::GetActiveRootWindow()); |
664 | 629 |
665 // First new window should be in the primary. | 630 // First new window should be in the primary. |
666 { | 631 { |
667 gfx::Rect window_bounds; | 632 gfx::Rect window_bounds; |
668 GetWindowBounds(p1600x1200, p1600x1200, secondary, | 633 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
669 gfx::Rect(), secondary, | 634 gfx::Rect(), secondary_bounds, |
670 PERSISTED, new_browser_window->browser(), | 635 PERSISTED, new_browser_window->browser(), |
671 gfx::Rect(), &window_bounds); | 636 gfx::Rect(), &window_bounds); |
672 EXPECT_EQ("0,10 300x300", window_bounds.ToString()); | 637 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); |
673 } | 638 } |
674 | 639 |
675 // Move the window to the right side of the secondary display and create a new | 640 // Move the window to the right side of the secondary display and create a new |
676 // window. It should be opened then on the left side on the secondary display. | 641 // window. It should be opened then on the secondary display. |
677 { | 642 { |
678 gfx::Display second_display = ash::Shell::GetScreen()-> | 643 gfx::Display second_display = ash::Shell::GetScreen()-> |
679 GetDisplayNearestPoint(gfx::Point(1600 + 100,10)); | 644 GetDisplayNearestPoint(gfx::Point(1600 + 100,10)); |
680 browser_window->GetNativeWindow()->SetBoundsInScreen( | 645 browser_window->GetNativeWindow()->SetBoundsInScreen( |
681 gfx::Rect(secondary.CenterPoint().x() + 300, 10, 200, 200), | 646 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), |
Mr4D (OOO till 08-26)
2013/08/28 21:58:15
[this is one comment for multiple lines [615, 637,
oshima
2013/08/29 09:18:04
This is because I removed the code from GetBoundsO
Mr4D (OOO till 08-26)
2013/08/29 15:58:15
Okay - lets keep the TODO for the moment then.
| |
682 second_display); | 647 second_display); |
683 browser_window->Activate(); | 648 browser_window->Activate(); |
684 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), | 649 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), |
685 ash::Shell::GetActiveRootWindow()); | 650 ash::Shell::GetActiveRootWindow()); |
686 | |
687 gfx::Rect window_bounds; | 651 gfx::Rect window_bounds; |
688 GetWindowBounds(p1600x1200, p1600x1200, secondary, | 652 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
689 gfx::Rect(), secondary, | 653 gfx::Rect(), secondary_bounds, |
690 PERSISTED, new_browser_window->browser(), | 654 PERSISTED, new_browser_window->browser(), |
691 gfx::Rect(), &window_bounds); | 655 gfx::Rect(), &window_bounds); |
692 EXPECT_EQ("1600,10 200x200", window_bounds.ToString()); | 656 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); |
693 } | 657 } |
694 | 658 |
695 // Activate another window in the primary display and create a new window. | 659 // Activate another window in the primary display and create a new window. |
696 // It should be created in the primary display. | 660 // It should be created in the primary display. |
697 { | 661 { |
698 another_browser_window->Activate(); | 662 another_browser_window->Activate(); |
699 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), | 663 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), |
700 ash::Shell::GetActiveRootWindow()); | 664 ash::Shell::GetActiveRootWindow()); |
701 | 665 |
702 gfx::Rect window_bounds; | 666 gfx::Rect window_bounds; |
703 GetWindowBounds(p1600x1200, p1600x1200, secondary, | 667 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
704 gfx::Rect(), secondary, | 668 gfx::Rect(), secondary_bounds, |
705 PERSISTED, new_browser_window->browser(), | 669 PERSISTED, new_browser_window->browser(), |
706 gfx::Rect(), &window_bounds); | 670 gfx::Rect(), &window_bounds); |
707 EXPECT_EQ("0,10 300x300", window_bounds.ToString()); | 671 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); |
708 } | 672 } |
709 } | 673 } |
710 | 674 |
711 // Test that the show state is properly returned for non default cases. | 675 // Test that the show state is properly returned for non default cases. |
712 TEST_F(WindowSizerTest, TestShowState) { | 676 TEST_F(WindowSizerAshTest, TestShowState) { |
713 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 677 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
714 | 678 |
715 // Creating a browser & window to play with. | 679 // Creating a browser & window to play with. |
716 scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( | 680 scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( |
717 CreateTestWindowInShellWithId(0), | 681 CreateTestWindowInShellWithId(0), |
718 gfx::Rect(16, 32, 640, 320), | 682 gfx::Rect(16, 32, 640, 320), |
719 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), | 683 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), |
720 chrome::HOST_DESKTOP_TYPE_ASH))); | 684 chrome::HOST_DESKTOP_TYPE_ASH))); |
721 | 685 |
722 // Create also a popup browser since that behaves different. | 686 // Create also a popup browser since that behaves different. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, | 759 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, |
796 ui::SHOW_STATE_DEFAULT, | 760 ui::SHOW_STATE_DEFAULT, |
797 BOTH, | 761 BOTH, |
798 browser_window2->browser(), | 762 browser_window2->browser(), |
799 tiny_screen)); | 763 tiny_screen)); |
800 | 764 |
801 } | 765 } |
802 } | 766 } |
803 | 767 |
804 // Test that the default show state override behavior is properly handled. | 768 // Test that the default show state override behavior is properly handled. |
805 TEST_F(WindowSizerTest, TestShowStateDefaults) { | 769 TEST_F(WindowSizerAshTest, TestShowStateDefaults) { |
806 // Creating a browser & window to play with. | 770 // Creating a browser & window to play with. |
807 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 771 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
808 | 772 |
809 scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( | 773 scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( |
810 CreateTestWindowInShellWithId(0), | 774 CreateTestWindowInShellWithId(0), |
811 gfx::Rect(16, 32, 640, 320), | 775 gfx::Rect(16, 32, 640, 320), |
812 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), | 776 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), |
813 chrome::HOST_DESKTOP_TYPE_ASH))); | 777 chrome::HOST_DESKTOP_TYPE_ASH))); |
814 | 778 |
815 // Create also a popup browser since that behaves slightly different for | 779 // Create also a popup browser since that behaves slightly different for |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 browser_window->browser(), | 821 browser_window->browser(), |
858 p1600x1200), ui::SHOW_STATE_MAXIMIZED); | 822 p1600x1200), ui::SHOW_STATE_MAXIMIZED); |
859 | 823 |
860 // The popup should favor the initial show state over the command line. | 824 // The popup should favor the initial show state over the command line. |
861 EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL, | 825 EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL, |
862 ui::SHOW_STATE_NORMAL, | 826 ui::SHOW_STATE_NORMAL, |
863 BOTH, | 827 BOTH, |
864 browser_popup->browser(), | 828 browser_popup->browser(), |
865 p1600x1200), ui::SHOW_STATE_NORMAL); | 829 p1600x1200), ui::SHOW_STATE_NORMAL); |
866 } | 830 } |
OLD | NEW |