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

Side by Side Diff: chrome/browser/ui/views/ash/window_positioner_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/views/ash/window_positioner.h" 5 #include "chrome/browser/ui/views/ash/window_positioner.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/test/test_shell_delegate.h" 10 #include "ash/test/test_shell_delegate.h"
(...skipping 15 matching lines...) Expand all
26 26
27 namespace ash { 27 namespace ash {
28 namespace test { 28 namespace test {
29 29
30 namespace { 30 namespace {
31 31
32 // A browser window proxy which is able to associate an aura native window with 32 // A browser window proxy which is able to associate an aura native window with
33 // it. 33 // it.
34 class TestBrowserWindowAura : public TestBrowserWindow { 34 class TestBrowserWindowAura : public TestBrowserWindow {
35 public: 35 public:
36 TestBrowserWindowAura(Browser* browser, aura::Window *native_window); 36 explicit TestBrowserWindowAura(aura::Window *native_window);
37 virtual ~TestBrowserWindowAura(); 37 virtual ~TestBrowserWindowAura();
38 38
39 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE { 39 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE {
40 return native_window_; 40 return native_window_;
41 } 41 }
42 42
43 private: 43 private:
44 gfx::NativeWindow native_window_; 44 gfx::NativeWindow native_window_;
45 45
46 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura); 46 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura);
47 }; 47 };
48 48
49 TestBrowserWindowAura::TestBrowserWindowAura(Browser* browser, 49 TestBrowserWindowAura::TestBrowserWindowAura(aura::Window *native_window)
50 aura::Window *native_window) : 50 : native_window_(native_window) {
51 TestBrowserWindow(browser),
52 native_window_(native_window) {
53 } 51 }
54 52
55 TestBrowserWindowAura::~TestBrowserWindowAura() {} 53 TestBrowserWindowAura::~TestBrowserWindowAura() {}
56 54
57 // A test class for preparing window positioner tests - it creates a testing 55 // A test class for preparing window positioner tests - it creates a testing
58 // base by adding a window, a popup and a panel which can be independently 56 // base by adding a window, a popup and a panel which can be independently
59 // positioned to see where the positioner will place the window. 57 // positioned to see where the positioner will place the window.
60 class WindowPositionerTest : public AshTestBase { 58 class WindowPositionerTest : public AshTestBase {
61 public: 59 public:
62 WindowPositionerTest(); 60 WindowPositionerTest();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 ash::Shell::GetPrimaryRootWindow(), 123 ash::Shell::GetPrimaryRootWindow(),
126 ash::internal::kShellWindowId_DefaultContainer); 124 ash::internal::kShellWindowId_DefaultContainer);
127 window_.reset(aura::test::CreateTestWindowWithId(0, default_container)); 125 window_.reset(aura::test::CreateTestWindowWithId(0, default_container));
128 window_->SetBounds(gfx::Rect(16, 32, 640, 320)); 126 window_->SetBounds(gfx::Rect(16, 32, 640, 320));
129 popup_.reset(aura::test::CreateTestWindowWithId(1, default_container)); 127 popup_.reset(aura::test::CreateTestWindowWithId(1, default_container));
130 popup_->SetBounds(gfx::Rect(16, 32, 128, 256)); 128 popup_->SetBounds(gfx::Rect(16, 32, 128, 256));
131 panel_.reset(aura::test::CreateTestWindowWithId(2, default_container)); 129 panel_.reset(aura::test::CreateTestWindowWithId(2, default_container));
132 panel_->SetBounds(gfx::Rect(32, 48, 256, 512)); 130 panel_->SetBounds(gfx::Rect(32, 48, 256, 512));
133 131
134 // Create a browser for the window. 132 // Create a browser for the window.
135 window_owning_browser_.reset(new Browser(Browser::TYPE_TABBED, 133 browser_window_.reset(new TestBrowserWindowAura(window_.get()));
136 profile_.get())); 134 Browser::CreateParams window_params(profile_.get());
137 browser_window_.reset(new TestBrowserWindowAura( 135 window_params.window = browser_window_.get();
138 window_owning_browser_.get(), 136 window_owning_browser_.reset(new Browser(window_params));
139 window_.get()));
140 window_owning_browser_->SetWindowForTesting(browser_window_.get());
141 137
142 // Creating a browser for the popup. 138 // Creating a browser for the popup.
143 popup_owning_browser_.reset(new Browser(Browser::TYPE_POPUP, 139 browser_popup_.reset(new TestBrowserWindowAura(popup_.get()));
144 profile_.get())); 140 Browser::CreateParams popup_params(Browser::TYPE_POPUP, profile_.get());
145 browser_popup_.reset(new TestBrowserWindowAura( 141 popup_params.window = browser_popup_.get();
146 popup_owning_browser_.get(), 142 popup_owning_browser_.reset(new Browser(popup_params));
147 popup_.get()));
148 popup_owning_browser_->SetWindowForTesting(browser_popup_.get());
149 143
150 // Creating a browser for the panel. 144 // Creating a browser for the panel.
151 panel_owning_browser_.reset(new Browser(Browser::TYPE_PANEL, 145 browser_panel_.reset(new TestBrowserWindowAura(panel_.get()));
152 profile_.get())); 146 Browser::CreateParams panel_params(Browser::TYPE_PANEL, profile_.get());
153 browser_panel_.reset(new TestBrowserWindowAura( 147 panel_params.window = browser_panel_.get();
154 panel_owning_browser_.get(), 148 panel_owning_browser_.reset(new Browser(panel_params));
155 panel_.get()));
156 panel_owning_browser_->SetWindowForTesting(browser_panel_.get());
157 // We hide all windows upon start - each user is required to set it up 149 // We hide all windows upon start - each user is required to set it up
158 // as he needs it. 150 // as he needs it.
159 window()->Hide(); 151 window()->Hide();
160 popup()->Hide(); 152 popup()->Hide();
161 panel()->Hide(); 153 panel()->Hide();
162 window_positioner_ = new WindowPositioner(); 154 window_positioner_ = new WindowPositioner();
163 155
164 // Get the alignment size. 156 // Get the alignment size.
165 grid_size_ = ash::Shell::GetInstance()->GetGridSize(); 157 grid_size_ = ash::Shell::GetInstance()->GetGridSize();
166 if (!grid_size_) { 158 if (!grid_size_) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 322
331 // Check that the popup is placed full screen. 323 // Check that the popup is placed full screen.
332 gfx::Rect full = window_positioner()->GetPopupPosition(pop_position); 324 gfx::Rect full = window_positioner()->GetPopupPosition(pop_position);
333 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(), 325 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(),
334 pop_position.width(), pop_position.height()), 326 pop_position.width(), pop_position.height()),
335 full); 327 full);
336 } 328 }
337 329
338 } // namespace test 330 } // namespace test
339 } // namespace ash 331 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698