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 #ifndef CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_
6 #define CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "build/build_config.h"
11 #include "chrome/browser/download/test_download_shelf.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/omnibox/location_bar.h"
16 class LocationBarTesting
;
19 namespace extensions
{
23 // An implementation of BrowserWindow used for testing. TestBrowserWindow only
24 // contains a valid LocationBar, all other getters return NULL.
25 // See BrowserWithTestWindowTest for an example of using this class.
26 class TestBrowserWindow
: public BrowserWindow
{
29 virtual ~TestBrowserWindow();
32 virtual void Show() OVERRIDE
{}
33 virtual void ShowInactive() OVERRIDE
{}
34 virtual void Hide() OVERRIDE
{}
35 virtual void SetBounds(const gfx::Rect
& bounds
) OVERRIDE
{}
36 virtual void Close() OVERRIDE
{}
37 virtual void Activate() OVERRIDE
{}
38 virtual void Deactivate() OVERRIDE
{}
39 virtual bool IsActive() const OVERRIDE
;
40 virtual void FlashFrame(bool flash
) OVERRIDE
{}
41 virtual bool IsAlwaysOnTop() const OVERRIDE
;
42 virtual void SetAlwaysOnTop(bool always_on_top
) OVERRIDE
{}
43 virtual gfx::NativeWindow
GetNativeWindow() OVERRIDE
;
44 virtual BrowserWindowTesting
* GetBrowserWindowTesting() OVERRIDE
;
45 virtual StatusBubble
* GetStatusBubble() OVERRIDE
;
46 virtual void UpdateTitleBar() OVERRIDE
{}
47 virtual void BookmarkBarStateChanged(
48 BookmarkBar::AnimateChangeType change_type
) OVERRIDE
{}
49 virtual void UpdateDevTools() OVERRIDE
{}
50 virtual void UpdateLoadingAnimations(bool should_animate
) OVERRIDE
{}
51 virtual void SetStarredState(bool is_starred
) OVERRIDE
{}
52 virtual void SetTranslateIconToggled(bool is_lit
) OVERRIDE
{}
53 virtual void OnActiveTabChanged(content::WebContents
* old_contents
,
54 content::WebContents
* new_contents
,
56 int reason
) OVERRIDE
{}
57 virtual void ZoomChangedForActiveTab(bool can_show_bubble
) OVERRIDE
{}
58 virtual gfx::Rect
GetRestoredBounds() const OVERRIDE
;
59 virtual ui::WindowShowState
GetRestoredState() const OVERRIDE
;
60 virtual gfx::Rect
GetBounds() const OVERRIDE
;
61 virtual bool IsMaximized() const OVERRIDE
;
62 virtual bool IsMinimized() const OVERRIDE
;
63 virtual void Maximize() OVERRIDE
{}
64 virtual void Minimize() OVERRIDE
{}
65 virtual void Restore() OVERRIDE
{}
66 virtual void EnterFullscreen(
67 const GURL
& url
, FullscreenExitBubbleType type
) OVERRIDE
{}
68 virtual void ExitFullscreen() OVERRIDE
{}
69 virtual void UpdateFullscreenExitBubbleContent(
71 FullscreenExitBubbleType bubble_type
) OVERRIDE
{}
72 virtual bool ShouldHideUIForFullscreen() const OVERRIDE
;
73 virtual bool IsFullscreen() const OVERRIDE
;
75 virtual void SetMetroSnapMode(bool enable
) OVERRIDE
{}
76 virtual bool IsInMetroSnapMode() const;
78 virtual bool IsFullscreenBubbleVisible() const OVERRIDE
;
79 virtual LocationBar
* GetLocationBar() const OVERRIDE
;
80 virtual void SetFocusToLocationBar(bool select_all
) OVERRIDE
{}
81 virtual void UpdateReloadStopState(bool is_loading
, bool force
) OVERRIDE
{}
82 virtual void UpdateToolbar(content::WebContents
* contents
) OVERRIDE
{}
83 virtual void FocusToolbar() OVERRIDE
{}
84 virtual void FocusAppMenu() OVERRIDE
{}
85 virtual void FocusBookmarksToolbar() OVERRIDE
{}
86 virtual void FocusInfobars() OVERRIDE
{}
87 virtual void RotatePaneFocus(bool forwards
) OVERRIDE
{}
88 virtual void ShowAppMenu() OVERRIDE
{}
89 virtual bool PreHandleKeyboardEvent(
90 const content::NativeWebKeyboardEvent
& event
,
91 bool* is_keyboard_shortcut
) OVERRIDE
;
92 virtual void HandleKeyboardEvent(
93 const content::NativeWebKeyboardEvent
& event
) OVERRIDE
{}
95 virtual bool IsBookmarkBarVisible() const OVERRIDE
;
96 virtual bool IsBookmarkBarAnimating() const OVERRIDE
;
97 virtual bool IsTabStripEditable() const OVERRIDE
;
98 virtual bool IsToolbarVisible() const OVERRIDE
;
99 virtual gfx::Rect
GetRootWindowResizerRect() const OVERRIDE
;
100 virtual void ConfirmAddSearchProvider(TemplateURL
* template_url
,
101 Profile
* profile
) OVERRIDE
{}
102 virtual void ShowUpdateChromeDialog() OVERRIDE
{}
103 virtual void ShowBookmarkBubble(const GURL
& url
,
104 bool already_bookmarked
) OVERRIDE
{}
105 virtual void ShowTranslateBubble(
106 content::WebContents
* contents
,
107 TranslateBubbleModel::ViewState view_state
,
108 TranslateErrors::Type error_type
) OVERRIDE
{}
109 #if defined(ENABLE_ONE_CLICK_SIGNIN)
110 virtual void ShowOneClickSigninBubble(
111 OneClickSigninBubbleType type
,
112 const base::string16
& email
,
113 const base::string16
& error_message
,
114 const StartSyncCallback
& start_sync_callback
) OVERRIDE
{}
116 virtual bool IsDownloadShelfVisible() const OVERRIDE
;
117 virtual DownloadShelf
* GetDownloadShelf() OVERRIDE
;
118 virtual void ConfirmBrowserCloseWithPendingDownloads(
120 Browser::DownloadClosePreventionType dialog_type
,
122 const base::Callback
<void(bool)>& callback
) OVERRIDE
{}
123 virtual void UserChangedTheme() OVERRIDE
{}
124 virtual int GetExtraRenderViewHeight() const OVERRIDE
;
125 virtual void WebContentsFocused(content::WebContents
* contents
) OVERRIDE
{}
126 virtual void ShowWebsiteSettings(Profile
* profile
,
127 content::WebContents
* web_contents
,
129 const content::SSLStatus
& ssl
) OVERRIDE
{}
130 virtual void Cut() OVERRIDE
{}
131 virtual void Copy() OVERRIDE
{}
132 virtual void Paste() OVERRIDE
{}
133 #if defined(OS_MACOSX)
134 virtual void OpenTabpose() OVERRIDE
{}
135 virtual void EnterFullscreenWithChrome() OVERRIDE
{}
136 virtual bool IsFullscreenWithChrome() OVERRIDE
;
137 virtual bool IsFullscreenWithoutChrome() OVERRIDE
;
140 virtual WindowOpenDisposition
GetDispositionForPopupBounds(
141 const gfx::Rect
& bounds
) OVERRIDE
;
142 virtual FindBar
* CreateFindBar() OVERRIDE
;
143 virtual web_modal::WebContentsModalDialogHost
*
144 GetWebContentsModalDialogHost() OVERRIDE
;
145 virtual void ShowAvatarBubble(content::WebContents
* web_contents
,
146 const gfx::Rect
& rect
) OVERRIDE
{}
147 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE
{}
148 virtual void ShowPasswordGenerationBubble(
149 const gfx::Rect
& rect
,
150 const autofill::PasswordForm
& form
,
151 autofill::PasswordGenerator
* generator
) OVERRIDE
{}
152 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() OVERRIDE
;
155 virtual void DestroyBrowser() OVERRIDE
{}
158 class TestLocationBar
: public LocationBar
{
160 TestLocationBar() : LocationBar(NULL
) {}
161 virtual ~TestLocationBar() {}
164 virtual void ShowFirstRunBubble() OVERRIDE
{}
165 virtual GURL
GetDestinationURL() const OVERRIDE
;
166 virtual WindowOpenDisposition
GetWindowOpenDisposition() const OVERRIDE
;
167 virtual content::PageTransition
GetPageTransition() const OVERRIDE
;
168 virtual void AcceptInput() OVERRIDE
{}
169 virtual void FocusLocation(bool select_all
) OVERRIDE
{}
170 virtual void FocusSearch() OVERRIDE
{}
171 virtual void UpdateContentSettingsIcons() OVERRIDE
{}
172 virtual void UpdateManagePasswordsIconAndBubble() OVERRIDE
{}
173 virtual void UpdatePageActions() OVERRIDE
{}
174 virtual void InvalidatePageActions() OVERRIDE
{}
175 virtual void UpdateOpenPDFInReaderPrompt() OVERRIDE
{}
176 virtual void UpdateGeneratedCreditCardView() OVERRIDE
{}
177 virtual void SaveStateToContents(content::WebContents
* contents
) OVERRIDE
{}
178 virtual void Revert() OVERRIDE
{}
179 virtual const OmniboxView
* GetOmniboxView() const OVERRIDE
;
180 virtual OmniboxView
* GetOmniboxView() OVERRIDE
;
181 virtual LocationBarTesting
* GetLocationBarForTesting() OVERRIDE
;
184 DISALLOW_COPY_AND_ASSIGN(TestLocationBar
);
187 TestDownloadShelf download_shelf_
;
188 TestLocationBar location_bar_
;
190 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindow
);
195 // Helper that handle the lifetime of TestBrowserWindow instances.
196 Browser
* CreateBrowserWithTestWindowForParams(Browser::CreateParams
* params
);
198 } // namespace chrome
200 #endif // CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_