Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / apps / app_browsertest_util.h
blobe322fc039019a834358709c7909aa1f3e4c8a60b
1 // Copyright 2013 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_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_
6 #define CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_
9 #include "apps/shell_window.h"
10 #include "chrome/browser/extensions/extension_apitest.h"
11 #include "content/public/common/page_transition_types.h"
13 namespace content {
14 class WebContents;
17 class Browser;
18 class CommandLine;
20 namespace extensions {
21 class Extension;
23 class PlatformAppBrowserTest : public ExtensionApiTest {
24 public:
25 PlatformAppBrowserTest();
27 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
29 // Gets the first shell window that is found for a given browser.
30 static apps::ShellWindow* GetFirstShellWindowForBrowser(Browser* browser);
32 protected:
33 // Runs the app named |name| out of the platform_apps subdirectory. Waits
34 // until it is launched.
35 const Extension* LoadAndLaunchPlatformApp(const char* name);
37 // Installs the app named |name| out of the platform_apps subdirectory.
38 const Extension* InstallPlatformApp(const char* name);
40 // Installs and runs the app named |name| out of the platform_apps
41 // subdirectory. Waits until it is launched.
42 const Extension* InstallAndLaunchPlatformApp(const char* name);
44 // Launch the given platform app.
45 void LaunchPlatformApp(const Extension* extension);
47 // Gets the WebContents associated with the first shell window that is found
48 // (most tests only deal with one platform app window, so this is good
49 // enough).
50 content::WebContents* GetFirstShellWindowWebContents();
52 // Gets the first shell window that is found (most tests only deal with one
53 // platform app window, so this is good enough).
54 apps::ShellWindow* GetFirstShellWindow();
56 // Gets the first shell window for an app.
57 apps::ShellWindow* GetFirstShellWindowForApp(const std::string& app_id);
59 // Runs chrome.windows.getAll for the given extension and returns the number
60 // of windows that the function returns.
61 size_t RunGetWindowsFunctionForExtension(const Extension* extension);
63 // Runs chrome.windows.get(|window_id|) for the the given extension and
64 // returns whether or not a window was found.
65 bool RunGetWindowFunctionForExtension(int window_id,
66 const Extension* extension);
68 // Returns the number of shell windows.
69 size_t GetShellWindowCount();
71 // Returns the number of shell windows for a specific app.
72 size_t GetShellWindowCountForApp(const std::string& app_id);
74 // The command line already has an argument on it - about:blank, which
75 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app
76 // launch tests we need to clear this.
77 void ClearCommandLineArgs();
79 // Sets up the command line for running platform apps.
80 void SetCommandLineArg(const std::string& test_file);
82 // Creates an empty shell window for |extension|.
83 apps::ShellWindow* CreateShellWindow(const Extension* extension);
85 apps::ShellWindow* CreateShellWindowFromParams(
86 const Extension* extension,
87 const apps::ShellWindow::CreateParams& params);
89 // Closes |window| and waits until it's gone.
90 void CloseShellWindow(apps::ShellWindow* window);
92 // Call AdjustBoundsToBeVisibleOnScreen of |window|.
93 void CallAdjustBoundsToBeVisibleOnScreenForShellWindow(
94 apps::ShellWindow* window,
95 const gfx::Rect& cached_bounds,
96 const gfx::Rect& cached_screen_bounds,
97 const gfx::Rect& current_screen_bounds,
98 const gfx::Size& minimum_size,
99 gfx::Rect* bounds);
102 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest {
103 public:
104 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
107 } // namespace extensions
109 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_