Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view_unittest.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/test/test_shell_delegate.h" 9 #include "ash/test/test_shell_delegate.h"
10 #include "ash/wm/window_resizer.h" 10 #include "ash/wm/window_resizer.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 gfx::Rect TestBrowserWindowAura::GetBounds() const { 69 gfx::Rect TestBrowserWindowAura::GetBounds() const {
70 return native_window_->bounds(); 70 return native_window_->bounds();
71 } 71 }
72 72
73 int AlignToGridRoundDown(int location, int grid_size) { 73 int AlignToGridRoundDown(int location, int grid_size) {
74 if (grid_size <= 1 || location % grid_size == 0) 74 if (grid_size <= 1 || location % grid_size == 0)
75 return location; 75 return location;
76 return location / grid_size * grid_size; 76 return location / grid_size * grid_size;
77 } 77 }
78 78
79 // A special test class for use with browser creation - it will create a
80 // browser thread and deletes it after all other things have been destroyed.
81 class WindowSizerTestWithBrowser : public WindowSizerTest {
82 public:
83 WindowSizerTestWithBrowser();
84 virtual ~WindowSizerTestWithBrowser();
85
86 private:
87 // Note: It is important to delete the thread after the browser instances got
88 // deleted. For this we transfer the thread here.
89 scoped_ptr<content::TestBrowserThread> ui_thread_;
90
91 DISALLOW_COPY_AND_ASSIGN(WindowSizerTestWithBrowser);
92 };
93
94 // The class function definitions from window_sizer_common_unittest.h
95 WindowSizerTestWithBrowser::WindowSizerTestWithBrowser() {
96 // Set up a UI message thread.
97 base::MessageLoopForUI* ui_loop = message_loop();
98 ui_thread_.reset(
99 new content::TestBrowserThread(content::BrowserThread::UI, ui_loop));
100 }
101
102 WindowSizerTestWithBrowser::~WindowSizerTestWithBrowser() {
103 }
104
105 } // namespace 79 } // namespace
106 80
107 // Test that the window is sized appropriately for the first run experience 81 // Test that the window is sized appropriately for the first run experience
108 // where the default window bounds calculation is invoked. 82 // where the default window bounds calculation is invoked.
109 TEST_F(WindowSizerTest, DefaultSizeCase) { 83 TEST_F(WindowSizerTest, DefaultSizeCase) {
110 int grid = WindowSizer::kDesktopBorderSize; 84 int grid = WindowSizer::kDesktopBorderSize;
111 { // 4:3 monitor case, 1024x768, no taskbar 85 { // 4:3 monitor case, 1024x768, no taskbar
112 gfx::Rect window_bounds; 86 gfx::Rect window_bounds;
113 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), gfx::Rect(), 87 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), gfx::Rect(),
114 gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds); 88 gfx::Rect(), DEFAULT, NULL, gfx::Rect(), &window_bounds);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 NULL, gfx::Rect(), &window_bounds); 423 NULL, gfx::Rect(), &window_bounds);
450 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 424 EXPECT_EQ(gfx::Rect(994 /* not 995 */,
451 738 /* not 739 */, 425 738 /* not 739 */,
452 500, 426 500,
453 400).ToString(), 427 400).ToString(),
454 window_bounds.ToString()); 428 window_bounds.ToString());
455 } 429 }
456 } 430 }
457 431
458 // Test the placement of newly created windows. 432 // Test the placement of newly created windows.
459 TEST_F(WindowSizerTestWithBrowser, PlaceNewWindows) { 433 TEST_F(WindowSizerTest, PlaceNewWindows) {
460 // Create a dummy window. 434 // Create a dummy window.
461 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 435 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
462 window->SetBounds(gfx::Rect(16, 32, 640, 320)); 436 window->SetBounds(gfx::Rect(16, 32, 640, 320));
463 437
464 scoped_ptr<aura::Window> popup(CreateTestWindowInShellWithId(1)); 438 scoped_ptr<aura::Window> popup(CreateTestWindowInShellWithId(1));
465 popup->SetBounds(gfx::Rect(16, 32, 128, 256)); 439 popup->SetBounds(gfx::Rect(16, 32, 128, 256));
466 440
467 scoped_ptr<aura::Window> panel(CreateTestWindowInShellWithId(2)); 441 scoped_ptr<aura::Window> panel(CreateTestWindowInShellWithId(2));
468 panel->SetBounds(gfx::Rect(32, 48, 256, 512)); 442 panel->SetBounds(gfx::Rect(32, 48, 256, 512));
469 443
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 std::min(WindowSizer::kMaximumWindowWidth, 543 std::min(WindowSizer::kMaximumWindowWidth,
570 1600 - 2 * WindowSizer::kDesktopBorderSize), 544 1600 - 2 * WindowSizer::kDesktopBorderSize),
571 1200 - WindowSizer::kDesktopBorderSize).ToString(), 545 1200 - WindowSizer::kDesktopBorderSize).ToString(),
572 window_bounds.ToString()); 546 window_bounds.ToString());
573 } 547 }
574 } 548 }
575 549
576 // Test the placement of newly created windows on an empty desktop. 550 // Test the placement of newly created windows on an empty desktop.
577 // This test supplements "PlaceNewWindows" by testing the creation of a newly 551 // This test supplements "PlaceNewWindows" by testing the creation of a newly
578 // created browser window on an empty desktop. 552 // created browser window on an empty desktop.
579 TEST_F(WindowSizerTestWithBrowser, PlaceNewBrowserWindowOnEmptyDesktop) { 553 TEST_F(WindowSizerTest, PlaceNewBrowserWindowOnEmptyDesktop) {
580 // Create a browser which we can use to pass into the GetWindowBounds 554 // Create a browser which we can use to pass into the GetWindowBounds
581 // function. 555 // function.
582 scoped_ptr<TestingProfile> profile(new TestingProfile()); 556 scoped_ptr<TestingProfile> profile(new TestingProfile());
583 Browser::CreateParams native_params(profile.get(), 557 Browser::CreateParams native_params(profile.get(),
584 chrome::HOST_DESKTOP_TYPE_ASH); 558 chrome::HOST_DESKTOP_TYPE_ASH);
585 scoped_ptr<Browser> browser( 559 scoped_ptr<Browser> browser(
586 chrome::CreateBrowserWithTestWindowForParams(&native_params)); 560 chrome::CreateBrowserWithTestWindowForParams(&native_params));
587 561
588 // A common screen size for Chrome OS devices where this behavior is 562 // A common screen size for Chrome OS devices where this behavior is
589 // desirable. 563 // desirable.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 619 }
646 620
647 #if defined(OS_CHROMEOS) 621 #if defined(OS_CHROMEOS)
648 #define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplay s 622 #define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplay s
649 #else 623 #else
650 // No multiple displays on windows ash. 624 // No multiple displays on windows ash.
651 #define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultip leDisplays 625 #define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultip leDisplays
652 #endif 626 #endif
653 627
654 // Test the placement of newly created windows on multiple dislays. 628 // Test the placement of newly created windows on multiple dislays.
655 TEST_F(WindowSizerTestWithBrowser, MAYBE_PlaceNewWindowsOnMultipleDisplays) { 629 TEST_F(WindowSizerTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) {
656 UpdateDisplay("1600x1200,1600x1200"); 630 UpdateDisplay("1600x1200,1600x1200");
657 const gfx::Rect secondary(1600, 0, 1600, 1200); 631 const gfx::Rect secondary(1600, 0, 1600, 1200);
658 632
659 ash::Shell::GetInstance()->set_active_root_window( 633 ash::Shell::GetInstance()->set_active_root_window(
660 ash::Shell::GetPrimaryRootWindow()); 634 ash::Shell::GetPrimaryRootWindow());
661 635
662 scoped_ptr<TestingProfile> profile(new TestingProfile()); 636 scoped_ptr<TestingProfile> profile(new TestingProfile());
663 637
664 // Create browser windows that are used as reference. 638 // Create browser windows that are used as reference.
665 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 639 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 708
735 gfx::Rect window_bounds; 709 gfx::Rect window_bounds;
736 GetWindowBounds(p1600x1200, p1600x1200, secondary, 710 GetWindowBounds(p1600x1200, p1600x1200, secondary,
737 gfx::Rect(), secondary, 711 gfx::Rect(), secondary,
738 PERSISTED, new_browser.get(), gfx::Rect(), &window_bounds); 712 PERSISTED, new_browser.get(), gfx::Rect(), &window_bounds);
739 EXPECT_EQ("0,10 300x300", window_bounds.ToString()); 713 EXPECT_EQ("0,10 300x300", window_bounds.ToString());
740 } 714 }
741 } 715 }
742 716
743 // Test that the show state is properly returned for non default cases. 717 // Test that the show state is properly returned for non default cases.
744 TEST_F(WindowSizerTestWithBrowser, TestShowState) { 718 TEST_F(WindowSizerTest, TestShowState) {
745 // Creating a browser & window to play with. 719 // Creating a browser & window to play with.
746 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 720 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
747 window->SetBounds(gfx::Rect(16, 32, 640, 320)); 721 window->SetBounds(gfx::Rect(16, 32, 640, 320));
748 722
749 scoped_ptr<TestingProfile> profile(new TestingProfile()); 723 scoped_ptr<TestingProfile> profile(new TestingProfile());
750 724
751 scoped_ptr<BrowserWindow> browser_window( 725 scoped_ptr<BrowserWindow> browser_window(
752 new TestBrowserWindowAura(window.get())); 726 new TestBrowserWindowAura(window.get()));
753 Browser::CreateParams window_params(Browser::TYPE_TABBED, profile.get(), 727 Browser::CreateParams window_params(Browser::TYPE_TABBED, profile.get(),
754 chrome::HOST_DESKTOP_TYPE_ASH); 728 chrome::HOST_DESKTOP_TYPE_ASH);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, 813 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED,
840 ui::SHOW_STATE_DEFAULT, 814 ui::SHOW_STATE_DEFAULT,
841 BOTH, 815 BOTH,
842 browser2.get(), 816 browser2.get(),
843 tiny_screen)); 817 tiny_screen));
844 818
845 } 819 }
846 } 820 }
847 821
848 // Test that the default show state override behavior is properly handled. 822 // Test that the default show state override behavior is properly handled.
849 TEST_F(WindowSizerTestWithBrowser, TestShowStateDefaults) { 823 TEST_F(WindowSizerTest, TestShowStateDefaults) {
850 // Creating a browser & window to play with. 824 // Creating a browser & window to play with.
851 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); 825 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
852 window->SetBounds(gfx::Rect(16, 32, 640, 320)); 826 window->SetBounds(gfx::Rect(16, 32, 640, 320));
853 827
854 scoped_ptr<TestingProfile> profile(new TestingProfile()); 828 scoped_ptr<TestingProfile> profile(new TestingProfile());
855 829
856 scoped_ptr<BrowserWindow> browser_window( 830 scoped_ptr<BrowserWindow> browser_window(
857 new TestBrowserWindowAura(window.get())); 831 new TestBrowserWindowAura(window.get()));
858 Browser::CreateParams window_params(Browser::TYPE_TABBED, profile.get(), 832 Browser::CreateParams window_params(Browser::TYPE_TABBED, profile.get(),
859 chrome::HOST_DESKTOP_TYPE_ASH); 833 chrome::HOST_DESKTOP_TYPE_ASH);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 browser.get(), 883 browser.get(),
910 p1600x1200), ui::SHOW_STATE_MAXIMIZED); 884 p1600x1200), ui::SHOW_STATE_MAXIMIZED);
911 885
912 // The popup should favor the initial show state over the command line. 886 // The popup should favor the initial show state over the command line.
913 EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL, 887 EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL,
914 ui::SHOW_STATE_NORMAL, 888 ui::SHOW_STATE_NORMAL,
915 BOTH, 889 BOTH,
916 popup_browser.get(), 890 popup_browser.get(),
917 p1600x1200), ui::SHOW_STATE_NORMAL); 891 p1600x1200), ui::SHOW_STATE_NORMAL);
918 } 892 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view_unittest.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698