Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / chrome / test / base / test_browser_window.cc
blobac2444d29fb2c6d56c75c12ebf287c8163d9f32d
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 --------------------------------------------------------------------
14 namespace chrome {
16 namespace {
18 // Handles destroying a TestBrowserWindow when the Browser it is attached to is
19 // destroyed.
20 class TestBrowserWindowOwner : public chrome::BrowserListObserver {
21 public:
22 explicit TestBrowserWindowOwner(TestBrowserWindow* window) : window_(window) {
23 BrowserList::AddObserver(this);
25 ~TestBrowserWindowOwner() override { BrowserList::RemoveObserver(this); }
27 private:
28 // Overridden from BrowserListObserver:
29 void OnBrowserRemoved(Browser* browser) override {
30 if (browser->window() == window_.get())
31 delete this;
34 scoped_ptr<TestBrowserWindow> window_;
36 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner);
39 } // namespace
41 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) {
42 TestBrowserWindow* window = new TestBrowserWindow;
43 new TestBrowserWindowOwner(window);
44 params->window = window;
45 return new Browser(*params);
48 } // namespace chrome
51 // TestBrowserWindow::TestLocationBar -----------------------------------------
53 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
54 return GURL();
57 WindowOpenDisposition
58 TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {
59 return CURRENT_TAB;
62 ui::PageTransition
63 TestBrowserWindow::TestLocationBar::GetPageTransition() const {
64 return ui::PAGE_TRANSITION_LINK;
67 bool TestBrowserWindow::TestLocationBar::ShowPageActionPopup(
68 const extensions::Extension* extension, bool grant_active_tab) {
69 return false;
72 const OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() const {
73 return NULL;
76 OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() {
77 return NULL;
80 LocationBarTesting*
81 TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() {
82 return NULL;
86 // TestBrowserWindow ----------------------------------------------------------
88 TestBrowserWindow::TestBrowserWindow() {}
90 TestBrowserWindow::~TestBrowserWindow() {}
92 bool TestBrowserWindow::IsActive() const {
93 return false;
96 bool TestBrowserWindow::IsAlwaysOnTop() const {
97 return false;
100 gfx::NativeWindow TestBrowserWindow::GetNativeWindow() const {
101 return NULL;
104 BrowserWindowTesting* TestBrowserWindow::GetBrowserWindowTesting() {
105 return NULL;
108 StatusBubble* TestBrowserWindow::GetStatusBubble() {
109 return NULL;
112 gfx::Rect TestBrowserWindow::GetRestoredBounds() const {
113 return gfx::Rect();
116 ui::WindowShowState TestBrowserWindow::GetRestoredState() const {
117 return ui::SHOW_STATE_DEFAULT;
120 gfx::Rect TestBrowserWindow::GetBounds() const {
121 return gfx::Rect();
124 bool TestBrowserWindow::IsMaximized() const {
125 return false;
128 bool TestBrowserWindow::IsMinimized() const {
129 return false;
132 bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
133 return false;
136 bool TestBrowserWindow::IsFullscreen() const {
137 return false;
140 #if defined(OS_WIN)
141 bool TestBrowserWindow::IsInMetroSnapMode() const {
142 return false;
144 #endif
146 bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
147 return false;
150 LocationBar* TestBrowserWindow::GetLocationBar() const {
151 return const_cast<TestLocationBar*>(&location_bar_);
154 bool TestBrowserWindow::PreHandleKeyboardEvent(
155 const content::NativeWebKeyboardEvent& event,
156 bool* is_keyboard_shortcut) {
157 return false;
160 bool TestBrowserWindow::IsBookmarkBarVisible() const {
161 return false;
164 bool TestBrowserWindow::IsBookmarkBarAnimating() const {
165 return false;
168 bool TestBrowserWindow::IsTabStripEditable() const {
169 return false;
172 bool TestBrowserWindow::IsToolbarVisible() const {
173 return false;
176 gfx::Rect TestBrowserWindow::GetRootWindowResizerRect() const {
177 return gfx::Rect();
180 bool TestBrowserWindow::IsDownloadShelfVisible() const {
181 return false;
184 DownloadShelf* TestBrowserWindow::GetDownloadShelf() {
185 return &download_shelf_;
188 int TestBrowserWindow::GetExtraRenderViewHeight() const {
189 return 0;
192 #if defined(OS_MACOSX)
193 bool TestBrowserWindow::IsFullscreenWithChrome() {
194 return false;
197 bool TestBrowserWindow::IsFullscreenWithoutChrome() {
198 return false;
200 #endif
202 WindowOpenDisposition TestBrowserWindow::GetDispositionForPopupBounds(
203 const gfx::Rect& bounds) {
204 return NEW_POPUP;
207 FindBar* TestBrowserWindow::CreateFindBar() {
208 return NULL;
211 web_modal::WebContentsModalDialogHost*
212 TestBrowserWindow::GetWebContentsModalDialogHost() {
213 return NULL;
217 TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
218 return 0;
221 void TestBrowserWindow::ExecuteExtensionCommand(
222 const extensions::Extension* extension,
223 const extensions::Command& command) {}