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"
20 namespace extensions {
23 class PlatformAppBrowserTest : public ExtensionApiTest {
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);
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 // Gets the WebContents associated with the first shell window that is found
45 // (most tests only deal with one platform app window, so this is good
47 content::WebContents* GetFirstShellWindowWebContents();
49 // Gets the first shell window that is found (most tests only deal with one
50 // platform app window, so this is good enough).
51 apps::ShellWindow* GetFirstShellWindow();
53 // Runs chrome.windows.getAll for the given extension and returns the number
54 // of windows that the function returns.
55 size_t RunGetWindowsFunctionForExtension(const Extension* extension);
57 // Runs chrome.windows.get(|window_id|) for the the given extension and
58 // returns whether or not a window was found.
59 bool RunGetWindowFunctionForExtension(int window_id,
60 const Extension* extension);
62 // Returns the number of shell windows.
63 size_t GetShellWindowCount();
65 // The command line already has an argument on it - about:blank, which
66 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app
67 // launch tests we need to clear this.
68 void ClearCommandLineArgs();
70 // Sets up the command line for running platform apps.
71 void SetCommandLineArg(const std::string& test_file);
73 // Creates an empty shell window for |extension|.
74 apps::ShellWindow* CreateShellWindow(const Extension* extension);
76 apps::ShellWindow* CreateShellWindowFromParams(
77 const Extension* extension,
78 const apps::ShellWindow::CreateParams& params);
80 // Closes |window| and waits until it's gone.
81 void CloseShellWindow(apps::ShellWindow* window);
83 // Call AdjustBoundsToBeVisibleOnScreen of |window|.
84 void CallAdjustBoundsToBeVisibleOnScreenForShellWindow(
85 apps::ShellWindow* window,
86 const gfx::Rect& cached_bounds,
87 const gfx::Rect& cached_screen_bounds,
88 const gfx::Rect& current_screen_bounds,
89 const gfx::Size& minimum_size,
93 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest {
95 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
98 } // namespace extensions
100 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_