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. 4 5 #ifndef CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_ 6 #define CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_ 7 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/test/base/test_location_bar.h" 15 16 namespace extensions { 17 class Extension; 18 } 19 20 // An implementation of BrowserWindow used for testing. TestBrowserWindow only 21 // contains a valid LocationBar, all other getters return NULL. 22 // See BrowserWithTestWindowTest for an example of using this class. 23 class TestBrowserWindow : public BrowserWindow { 24 public: 25 TestBrowserWindow(); 26 virtual ~TestBrowserWindow(); 27 28 // BrowserWindow: 29 virtual void Show() OVERRIDE {} 30 virtual void ShowInactive() OVERRIDE {} 31 virtual void Hide() OVERRIDE {} 32 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE {} 33 virtual void Close() OVERRIDE {} 34 virtual void Activate() OVERRIDE {} 35 virtual void Deactivate() OVERRIDE {} 36 virtual bool IsActive() const OVERRIDE; 37 virtual void FlashFrame(bool flash) OVERRIDE {} 38 virtual bool IsAlwaysOnTop() const OVERRIDE; 39 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; 40 virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE; 41 virtual StatusBubble* GetStatusBubble() OVERRIDE; 42 virtual void UpdateTitleBar() OVERRIDE {} 43 virtual void BookmarkBarStateChanged( 44 BookmarkBar::AnimateChangeType change_type) OVERRIDE {} 45 virtual void UpdateDevTools() OVERRIDE {} 46 virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE {} 47 virtual void SetStarredState(bool is_starred) OVERRIDE {} 48 virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE {} 49 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; 50 virtual ui::WindowShowState GetRestoredState() const OVERRIDE; 51 virtual gfx::Rect GetBounds() const OVERRIDE; 52 virtual bool IsMaximized() const OVERRIDE; 53 virtual bool IsMinimized() const OVERRIDE; 54 virtual void Maximize() OVERRIDE {} 55 virtual void Minimize() OVERRIDE {} 56 virtual void Restore() OVERRIDE {} 57 virtual void EnterFullscreen( 58 const GURL& url, FullscreenExitBubbleType type) OVERRIDE {} 59 virtual void ExitFullscreen() OVERRIDE {} 60 virtual void UpdateFullscreenExitBubbleContent( 61 const GURL& url, 62 FullscreenExitBubbleType bubble_type) OVERRIDE {} 63 virtual bool ShouldHideUIForFullscreen() const OVERRIDE; 64 virtual bool IsFullscreen() const OVERRIDE; 65 #if defined(OS_WIN) 66 virtual void SetMetroSnapMode(bool enable) OVERRIDE {} 67 virtual bool IsInMetroSnapMode() const; 68 #endif 69 virtual bool IsFullscreenBubbleVisible() const OVERRIDE; 70 virtual LocationBar* GetLocationBar() const OVERRIDE; 71 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE {} 72 virtual void UpdateReloadStopState(bool is_loading, bool force) OVERRIDE {} 73 virtual void UpdateToolbar(content::WebContents* contents, 74 bool should_restore_state) OVERRIDE {} 75 virtual void FocusToolbar() OVERRIDE {} 76 virtual void FocusAppMenu() OVERRIDE {} 77 virtual void FocusBookmarksToolbar() OVERRIDE {} 78 virtual void FocusInfobars() OVERRIDE {} 79 virtual void RotatePaneFocus(bool forwards) OVERRIDE {} 80 virtual void ShowAppMenu() OVERRIDE {} 81 virtual bool PreHandleKeyboardEvent( 82 const content::NativeWebKeyboardEvent& event, 83 bool* is_keyboard_shortcut) OVERRIDE; 84 virtual void HandleKeyboardEvent( 85 const content::NativeWebKeyboardEvent& event) OVERRIDE {} 86 virtual void ShowCreateChromeAppShortcutsDialog( 87 Profile* profile, 88 const extensions::Extension* app) OVERRIDE {} 89 90 virtual bool IsBookmarkBarVisible() const OVERRIDE; 91 virtual bool IsBookmarkBarAnimating() const OVERRIDE; 92 virtual bool IsTabStripEditable() const OVERRIDE; 93 virtual bool IsToolbarVisible() const OVERRIDE; 94 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; 95 virtual void ConfirmAddSearchProvider(TemplateURL* template_url, 96 Profile* profile) OVERRIDE {} 97 virtual void ToggleBookmarkBar() OVERRIDE {} 98 virtual void ShowUpdateChromeDialog() OVERRIDE {} 99 virtual void ShowBookmarkBubble(const GURL& url, 100 bool already_bookmarked) OVERRIDE {} 101 #if defined(ENABLE_ONE_CLICK_SIGNIN) 102 virtual void ShowOneClickSigninBubble( 103 OneClickSigninBubbleType type, 104 const string16& email, 105 const string16& error_message, 106 const StartSyncCallback& start_sync_callback) OVERRIDE {} 107 #endif 108 virtual bool IsDownloadShelfVisible() const OVERRIDE; 109 virtual DownloadShelf* GetDownloadShelf() OVERRIDE; 110 virtual void ConfirmBrowserCloseWithPendingDownloads() OVERRIDE {} 111 virtual void UserChangedTheme() OVERRIDE {} 112 virtual int GetExtraRenderViewHeight() const OVERRIDE; 113 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE {} 114 virtual void ShowWebsiteSettings(Profile* profile, 115 content::WebContents* web_contents, 116 const GURL& url, 117 const content::SSLStatus& ssl) OVERRIDE {} 118 virtual void Cut() OVERRIDE {} 119 virtual void Copy() OVERRIDE {} 120 virtual void Paste() OVERRIDE {} 121 #if defined(OS_MACOSX) 122 virtual void OpenTabpose() OVERRIDE {} 123 virtual void EnterFullscreenWithChrome() OVERRIDE {} 124 virtual bool IsFullscreenWithChrome() OVERRIDE; 125 virtual bool IsFullscreenWithoutChrome() OVERRIDE; 126 #endif 127 128 virtual WindowOpenDisposition GetDispositionForPopupBounds( 129 const gfx::Rect& bounds) OVERRIDE; 130 virtual FindBar* CreateFindBar() OVERRIDE; 131 virtual web_modal::WebContentsModalDialogHost* 132 GetWebContentsModalDialogHost() OVERRIDE; 133 virtual void ShowAvatarBubble(content::WebContents* web_contents, 134 const gfx::Rect& rect) OVERRIDE {} 135 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE {} 136 virtual void ShowPasswordGenerationBubble( 137 const gfx::Rect& rect, 138 const content::PasswordForm& form, 139 autofill::PasswordGenerator* generator) OVERRIDE {} 140 141 protected: 142 virtual void DestroyBrowser() OVERRIDE {} 143 144 private: 145 TestDownloadShelf download_shelf_; 146 TestLocationBar location_bar_; 147 148 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindow); 149 }; 150 151 namespace chrome { 152 153 // Helper that handle the lifetime of TestBrowserWindow instances. 154 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params); 155 156 } // namespace chrome 157 158 #endif // CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_ 159