blob: 752a7e78434c8ea54e78ee2bee3ad7291dc9c2ae [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/test/base/test_browser_window.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "ui/gfx/geometry/rect.h"
// Helpers --------------------------------------------------------------------
std::unique_ptr<Browser> CreateBrowserWithTestWindowForParams(
Browser::CreateParams* params) {
TestBrowserWindow* window = new TestBrowserWindow;
new TestBrowserWindowOwner(window);
params->window = window;
return std::make_unique<Browser>(*params);
}
// TestBrowserWindow::TestLocationBar -----------------------------------------
GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
return GURL();
}
WindowOpenDisposition
TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {
return WindowOpenDisposition::CURRENT_TAB;
}
ui::PageTransition
TestBrowserWindow::TestLocationBar::GetPageTransition() const {
return ui::PAGE_TRANSITION_LINK;
}
const OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() const {
return NULL;
}
OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() {
return NULL;
}
LocationBarTesting*
TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() {
return NULL;
}
// TestBrowserWindow ----------------------------------------------------------
TestBrowserWindow::TestBrowserWindow() {}
TestBrowserWindow::~TestBrowserWindow() {}
bool TestBrowserWindow::IsActive() const {
return false;
}
bool TestBrowserWindow::IsAlwaysOnTop() const {
return false;
}
gfx::NativeWindow TestBrowserWindow::GetNativeWindow() const {
return NULL;
}
StatusBubble* TestBrowserWindow::GetStatusBubble() {
return NULL;
}
gfx::Rect TestBrowserWindow::GetRestoredBounds() const {
return gfx::Rect();
}
ui::WindowShowState TestBrowserWindow::GetRestoredState() const {
return ui::SHOW_STATE_DEFAULT;
}
gfx::Rect TestBrowserWindow::GetBounds() const {
return gfx::Rect();
}
gfx::Size TestBrowserWindow::GetContentsSize() const {
return gfx::Size();
}
bool TestBrowserWindow::IsMaximized() const {
return false;
}
bool TestBrowserWindow::IsMinimized() const {
return false;
}
bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
return false;
}
bool TestBrowserWindow::IsFullscreen() const {
return false;
}
bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
return false;
}
bool TestBrowserWindow::IsVisible() const {
return true;
}
LocationBar* TestBrowserWindow::GetLocationBar() const {
return const_cast<TestLocationBar*>(&location_bar_);
}
PageActionIconContainer* TestBrowserWindow::GetPageActionIconContainer() {
return nullptr;
}
ToolbarActionsBar* TestBrowserWindow::GetToolbarActionsBar() {
return nullptr;
}
content::KeyboardEventProcessingResult
TestBrowserWindow::PreHandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
return content::KeyboardEventProcessingResult::NOT_HANDLED;
}
bool TestBrowserWindow::IsBookmarkBarVisible() const {
return false;
}
bool TestBrowserWindow::IsBookmarkBarAnimating() const {
return false;
}
bool TestBrowserWindow::IsTabStripEditable() const {
return false;
}
bool TestBrowserWindow::IsToolbarVisible() const {
return false;
}
bool TestBrowserWindow::IsToolbarShowing() const {
return false;
}
ShowTranslateBubbleResult TestBrowserWindow::ShowTranslateBubble(
content::WebContents* contents,
translate::TranslateStep step,
translate::TranslateErrors::Type error_type,
bool is_user_gesture) {
return ShowTranslateBubbleResult::SUCCESS;
}
autofill::SaveCardBubbleView* TestBrowserWindow::ShowSaveCreditCardBubble(
content::WebContents* contents,
autofill::SaveCardBubbleController* controller,
bool user_gesture) {
return nullptr;
}
autofill::LocalCardMigrationBubble*
TestBrowserWindow::ShowLocalCardMigrationBubble(
content::WebContents* contents,
autofill::LocalCardMigrationBubbleController* controller,
bool user_gesture) {
return nullptr;
}
bool TestBrowserWindow::IsDownloadShelfVisible() const {
return false;
}
DownloadShelf* TestBrowserWindow::GetDownloadShelf() {
return &download_shelf_;
}
FindBar* TestBrowserWindow::CreateFindBar() {
return NULL;
}
web_modal::WebContentsModalDialogHost*
TestBrowserWindow::GetWebContentsModalDialogHost() {
return NULL;
}
int TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
return 0;
}
void TestBrowserWindow::ExecuteExtensionCommand(
const extensions::Extension* extension,
const extensions::Command& command) {}
ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() {
return nullptr;
}
std::string TestBrowserWindow::GetWorkspace() const {
return std::string();
}
bool TestBrowserWindow::IsVisibleOnAllWorkspaces() const {
return false;
}
// TestBrowserWindowOwner -----------------------------------------------------
TestBrowserWindowOwner::TestBrowserWindowOwner(TestBrowserWindow* window)
: window_(window) {
BrowserList::AddObserver(this);
}
TestBrowserWindowOwner::~TestBrowserWindowOwner() {
BrowserList::RemoveObserver(this);
}
void TestBrowserWindowOwner::OnBrowserRemoved(Browser* browser) {
if (browser->window() == window_.get())
delete this;
}