1 // Copyright 2014 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_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_TESTING_H_ 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_TESTING_H_ 7 8 #include "base/callback.h" 9 #include "chrome/browser/devtools/devtools_window.h" 10 #include "ui/gfx/rect.h" 11 12 class Browser; 13 class Profile; 14 15 namespace content { 16 class DevToolsAgentHost; 17 class WebContents; 18 } 19 20 class DevToolsWindowTesting { 21 public: 22 virtual ~DevToolsWindowTesting(); 23 24 // The following methods block until DevToolsWindow is completely loaded. 25 static DevToolsWindow* OpenDevToolsWindowSync( 26 content::WebContents* inspected_web_contents, 27 bool is_docked); 28 static DevToolsWindow* OpenDevToolsWindowSync( 29 Browser* browser, bool is_docked); 30 static DevToolsWindow* OpenDevToolsWindowForWorkerSync( 31 Profile* profile, content::DevToolsAgentHost* worker_agent); 32 33 // Closes the window like it was user-initiated. 34 static void CloseDevToolsWindow(DevToolsWindow* window); 35 // Blocks until window is closed. 36 static void CloseDevToolsWindowSync(DevToolsWindow* window); 37 38 static DevToolsWindowTesting* Get(DevToolsWindow* window); 39 40 Browser* browser(); 41 content::WebContents* main_web_contents(); 42 content::WebContents* toolbox_web_contents(); 43 void SetInspectedPageBounds(const gfx::Rect& bounds); 44 void SetCloseCallback(const base::Closure& closure); 45 46 private: 47 friend class DevToolsWindow; 48 49 explicit DevToolsWindowTesting(DevToolsWindow* window); 50 static void WaitForDevToolsWindowLoad(DevToolsWindow* window); 51 static void WindowClosed(DevToolsWindow* window); 52 static DevToolsWindowTesting* Find(DevToolsWindow* window); 53 54 DevToolsWindow* devtools_window_; 55 base::Closure close_callback_; 56 57 DISALLOW_COPY_AND_ASSIGN(DevToolsWindowTesting); 58 }; 59 60 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_TESTING_H_ 61