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

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

Issue 10692195: Consolidate Browser Creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
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.h" 5 #include "chrome/browser/ui/window_sizer/window_sizer.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
11 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "ash/test/test_shell_delegate.h" 12 #include "ash/test/test_shell_delegate.h"
13 #include "ash/wm/window_resizer.h" 13 #include "ash/wm/window_resizer.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" 17 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "chrome/test/base/test_browser_window.h" 19 #include "chrome/test/base/test_browser_window.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/test/render_view_test.h" 21 #include "content/public/test/render_view_test.h"
22 #include "content/public/test/test_browser_thread.h" 22 #include "content/public/test/test_browser_thread.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
25 #include "ui/aura/env.h" 25 #include "ui/aura/env.h"
26 #include "ui/aura/root_window.h" 26 #include "ui/aura/root_window.h"
27 #include "ui/aura/test/test_windows.h" 27 #include "ui/aura/test/test_windows.h"
28 28
29
30 namespace { 29 namespace {
31 30
32 typedef ash::test::AshTestBase WindowSizerTest; 31 typedef ash::test::AshTestBase WindowSizerTest;
33 32
34 // A special test class for use with browser creation - it will create a 33 // A special test class for use with browser creation - it will create a
35 // browser thread and deletes it after all other things have been destroyed. 34 // browser thread and deletes it after all other things have been destroyed.
36 class WindowSizerTestWithBrowser : public WindowSizerTest { 35 class WindowSizerTestWithBrowser : public WindowSizerTest {
37 public: 36 public:
38 WindowSizerTestWithBrowser(); 37 WindowSizerTestWithBrowser();
39 virtual ~WindowSizerTestWithBrowser(); 38 virtual ~WindowSizerTestWithBrowser();
(...skipping 13 matching lines...) Expand all
53 new content::TestBrowserThread(content::BrowserThread::UI, ui_loop)); 52 new content::TestBrowserThread(content::BrowserThread::UI, ui_loop));
54 } 53 }
55 54
56 WindowSizerTestWithBrowser::~WindowSizerTestWithBrowser() { 55 WindowSizerTestWithBrowser::~WindowSizerTestWithBrowser() {
57 } 56 }
58 57
59 // A browser window proxy which is able to associate an aura native window with 58 // A browser window proxy which is able to associate an aura native window with
60 // it. 59 // it.
61 class TestBrowserWindowAura : public TestBrowserWindow { 60 class TestBrowserWindowAura : public TestBrowserWindow {
62 public: 61 public:
63 TestBrowserWindowAura(Browser* browser, aura::Window* native_window); 62 explicit TestBrowserWindowAura(aura::Window* native_window);
64 virtual ~TestBrowserWindowAura(); 63 virtual ~TestBrowserWindowAura();
65 64
66 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE { 65 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE {
67 return native_window_; 66 return native_window_;
68 } 67 }
69 68
70 private: 69 private:
71 gfx::NativeWindow native_window_; 70 gfx::NativeWindow native_window_;
72 71
73 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura); 72 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura);
74 }; 73 };
75 74
76 } // namespace 75 } // namespace
77 76
78 TestBrowserWindowAura::TestBrowserWindowAura( 77 TestBrowserWindowAura::TestBrowserWindowAura(aura::Window *native_window)
79 Browser* browser, 78 : native_window_(native_window) {
80 aura::Window *native_window)
81 : TestBrowserWindow(browser),
82 native_window_(native_window) {
83 } 79 }
84 80
85 TestBrowserWindowAura::~TestBrowserWindowAura() {} 81 TestBrowserWindowAura::~TestBrowserWindowAura() {}
86 82
87 // Test that the window is sized appropriately for the first run experience 83 // Test that the window is sized appropriately for the first run experience
88 // where the default window bounds calculation is invoked. 84 // where the default window bounds calculation is invoked.
89 TEST_F(WindowSizerTest, DefaultSizeCase) { 85 TEST_F(WindowSizerTest, DefaultSizeCase) {
90 int grid = ash::Shell::GetInstance()->GetGridSize(); 86 int grid = ash::Shell::GetInstance()->GetGridSize();
91 EXPECT_EQ(WindowSizer::kDesktopBorderSize, grid); 87 EXPECT_EQ(WindowSizer::kDesktopBorderSize, grid);
92 { // 4:3 monitor case, 1024x768, no taskbar 88 { // 4:3 monitor case, 1024x768, no taskbar
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 scoped_ptr<aura::Window> popup( 610 scoped_ptr<aura::Window> popup(
615 aura::test::CreateTestWindowWithId(1, default_container)); 611 aura::test::CreateTestWindowWithId(1, default_container));
616 popup->SetBounds(gfx::Rect(16, 32, 128, 256)); 612 popup->SetBounds(gfx::Rect(16, 32, 128, 256));
617 613
618 scoped_ptr<aura::Window> panel( 614 scoped_ptr<aura::Window> panel(
619 aura::test::CreateTestWindowWithId(2, default_container)); 615 aura::test::CreateTestWindowWithId(2, default_container));
620 panel->SetBounds(gfx::Rect(32, 48, 256, 512)); 616 panel->SetBounds(gfx::Rect(32, 48, 256, 512));
621 617
622 // Create a browser which we can use to pass into the GetWindowBounds 618 // Create a browser which we can use to pass into the GetWindowBounds
623 // function. 619 // function.
624 scoped_ptr<TestingProfile> profile; 620 scoped_ptr<TestingProfile> profile(new TestingProfile());
625 profile.reset(new TestingProfile());
626 scoped_ptr<Browser> browser;
627 // Creating a popup handler here to make sure it does not interfere with the 621 // Creating a popup handler here to make sure it does not interfere with the
628 // existing windows. 622 // existing windows.
629 browser.reset(new Browser(Browser::TYPE_TABBED, profile.get())); 623 scoped_ptr<Browser> browser(
624 chrome::CreateBrowserWithTestWindowForProfile(profile.get()));
630 625
631 scoped_ptr<Browser> window_owning_browser;
632 // Creating a popup handler here to make sure it does not interfere with the 626 // Creating a popup handler here to make sure it does not interfere with the
633 // existing windows. 627 // existing windows.
634 window_owning_browser.reset(new Browser(Browser::TYPE_TABBED, 628 scoped_ptr<BrowserWindow> browser_window(
635 profile.get())); 629 new TestBrowserWindowAura(window.get()));
636 scoped_ptr<BrowserWindow> browser_window; 630 Browser::CreateParams window_params(profile.get());
637 browser_window.reset(new TestBrowserWindowAura(window_owning_browser.get(), 631 window_params.window = browser_window.get();
638 window.get())); 632 scoped_ptr<Browser> window_owning_browser(new Browser(window_params));
639 window_owning_browser->SetWindowForTesting(browser_window.get());
640 633
641 scoped_ptr<Browser> popup_owning_browser;
642 // Creating a popup to make sure it does not interfere with the positioning. 634 // Creating a popup to make sure it does not interfere with the positioning.
643 popup_owning_browser.reset(new Browser(Browser::TYPE_POPUP, 635 scoped_ptr<BrowserWindow> browser_popup(
644 profile.get())); 636 new TestBrowserWindowAura(popup.get()));
645 scoped_ptr<BrowserWindow> browser_popup; 637 Browser::CreateParams popup_params(Browser::TYPE_POPUP, profile.get());
646 browser_popup.reset(new TestBrowserWindowAura(popup_owning_browser.get(), 638 popup_params.window = browser_popup.get();
647 popup.get())); 639 scoped_ptr<Browser> popup_owning_browser(new Browser(popup_params));
648 popup_owning_browser->SetWindowForTesting(browser_popup.get());
649 640
650 scoped_ptr<Browser> panel_owning_browser;
651 // Creating a panel to make sure it does not interfere with the positioning. 641 // Creating a panel to make sure it does not interfere with the positioning.
652 panel_owning_browser.reset(new Browser(Browser::TYPE_PANEL, 642 scoped_ptr<BrowserWindow> browser_panel(
653 profile.get())); 643 new TestBrowserWindowAura(panel.get()));
654 scoped_ptr<BrowserWindow> browser_panel; 644 Browser::CreateParams panel_params(Browser::TYPE_POPUP, profile.get());
655 browser_panel.reset(new TestBrowserWindowAura(panel_owning_browser.get(), 645 panel_params.window = browser_panel.get();
656 panel.get())); 646 scoped_ptr<Browser> panel_owning_browser(new Browser(panel_params));
657 panel_owning_browser->SetWindowForTesting(browser_panel.get());
658 647
659 window->Show(); 648 window->Show();
660 { // With a shown window it's size should get returned. 649 { // With a shown window it's size should get returned.
661 gfx::Rect window_bounds; 650 gfx::Rect window_bounds;
662 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 651 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
663 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, 652 gfx::Rect(50, 100, 300, 150), bottom_nonprimary,
664 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); 653 PERSISTED, &window_bounds, browser.get(), gfx::Rect());
665 EXPECT_EQ(gfx::Rect(16, 32, 640, 320), window_bounds); 654 EXPECT_EQ(gfx::Rect(16, 32, 640, 320), window_bounds);
666 } 655 }
667 656
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 } 700 }
712 701
713 { // Check that a window which hangs out of the screen get moved back in. 702 { // Check that a window which hangs out of the screen get moved back in.
714 gfx::Rect window_bounds; 703 gfx::Rect window_bounds;
715 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), 704 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(),
716 gfx::Rect(), DEFAULT, &window_bounds, NULL, 705 gfx::Rect(), DEFAULT, &window_bounds, NULL,
717 gfx::Rect(1020, 700, 100, 100)); 706 gfx::Rect(1020, 700, 100, 100));
718 EXPECT_EQ(gfx::Rect(924, 668, 100, 100), window_bounds); 707 EXPECT_EQ(gfx::Rect(924, 668, 100, 100), window_bounds);
719 } 708 }
720 } 709 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chrome_web_contents_handler.cc ('k') | chrome/test/base/browser_with_test_window_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698