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
3 // found in the LICENSE file.
5 #include "chrome/test/base/test_browser_window.h"
7 #include "chrome/browser/ui/browser_list.h"
8 #include "chrome/browser/ui/browser_list_observer.h"
9 #include "ui/gfx/rect.h"
12 // Helpers --------------------------------------------------------------------
18 // Handles destroying a TestBrowserWindow when the Browser it is attached to is
20 class TestBrowserWindowOwner
: public chrome::BrowserListObserver
{
22 explicit TestBrowserWindowOwner(TestBrowserWindow
* window
) : window_(window
) {
23 BrowserList::AddObserver(this);
25 virtual ~TestBrowserWindowOwner() {
26 BrowserList::RemoveObserver(this);
30 // Overridden from BrowserListObserver:
31 virtual void OnBrowserRemoved(Browser
* browser
) OVERRIDE
{
32 if (browser
->window() == window_
.get())
36 scoped_ptr
<TestBrowserWindow
> window_
;
38 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner
);
43 Browser
* CreateBrowserWithTestWindowForParams(Browser::CreateParams
* params
) {
44 TestBrowserWindow
* window
= new TestBrowserWindow
;
45 new TestBrowserWindowOwner(window
);
46 params
->window
= window
;
47 return new Browser(*params
);
53 // TestBrowserWindow::TestLocationBar -----------------------------------------
55 GURL
TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
60 TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {
64 content::PageTransition
65 TestBrowserWindow::TestLocationBar::GetPageTransition() const {
66 return content::PAGE_TRANSITION_LINK
;
69 const OmniboxView
* TestBrowserWindow::TestLocationBar::GetOmniboxView() const {
73 OmniboxView
* TestBrowserWindow::TestLocationBar::GetOmniboxView() {
78 TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() {
83 // TestBrowserWindow ----------------------------------------------------------
85 TestBrowserWindow::TestBrowserWindow() {}
87 TestBrowserWindow::~TestBrowserWindow() {}
89 bool TestBrowserWindow::IsActive() const {
93 bool TestBrowserWindow::IsAlwaysOnTop() const {
97 gfx::NativeWindow
TestBrowserWindow::GetNativeWindow() {
101 BrowserWindowTesting
* TestBrowserWindow::GetBrowserWindowTesting() {
105 StatusBubble
* TestBrowserWindow::GetStatusBubble() {
109 gfx::Rect
TestBrowserWindow::GetRestoredBounds() const {
113 ui::WindowShowState
TestBrowserWindow::GetRestoredState() const {
114 return ui::SHOW_STATE_DEFAULT
;
117 gfx::Rect
TestBrowserWindow::GetBounds() const {
121 bool TestBrowserWindow::IsMaximized() const {
125 bool TestBrowserWindow::IsMinimized() const {
129 bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
133 bool TestBrowserWindow::IsFullscreen() const {
138 bool TestBrowserWindow::IsInMetroSnapMode() const {
143 bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
147 LocationBar
* TestBrowserWindow::GetLocationBar() const {
148 return const_cast<TestLocationBar
*>(&location_bar_
);
151 bool TestBrowserWindow::PreHandleKeyboardEvent(
152 const content::NativeWebKeyboardEvent
& event
,
153 bool* is_keyboard_shortcut
) {
157 bool TestBrowserWindow::IsBookmarkBarVisible() const {
161 bool TestBrowserWindow::IsBookmarkBarAnimating() const {
165 bool TestBrowserWindow::IsTabStripEditable() const {
169 bool TestBrowserWindow::IsToolbarVisible() const {
173 gfx::Rect
TestBrowserWindow::GetRootWindowResizerRect() const {
177 bool TestBrowserWindow::IsDownloadShelfVisible() const {
181 DownloadShelf
* TestBrowserWindow::GetDownloadShelf() {
182 return &download_shelf_
;
185 int TestBrowserWindow::GetExtraRenderViewHeight() const {
189 #if defined(OS_MACOSX)
190 bool TestBrowserWindow::IsFullscreenWithChrome() {
194 bool TestBrowserWindow::IsFullscreenWithoutChrome() {
199 WindowOpenDisposition
TestBrowserWindow::GetDispositionForPopupBounds(
200 const gfx::Rect
& bounds
) {
204 FindBar
* TestBrowserWindow::CreateFindBar() {
208 web_modal::WebContentsModalDialogHost
*
209 TestBrowserWindow::GetWebContentsModalDialogHost() {
214 TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {