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_
8 #include "apps/app_window.h"
9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "content/public/common/page_transition_types.h"
19 namespace extensions {
22 class PlatformAppBrowserTest : public ExtensionApiTest {
24 PlatformAppBrowserTest();
26 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
28 // Gets the first app window that is found for a given browser.
29 static apps::AppWindow* GetFirstAppWindowForBrowser(Browser* browser);
32 // Runs the app named |name| out of the platform_apps subdirectory. Waits
33 // until it is launched.
34 const Extension* LoadAndLaunchPlatformApp(const char* name);
36 // Installs the app named |name| out of the platform_apps subdirectory.
37 const Extension* InstallPlatformApp(const char* name);
39 // Installs and runs the app named |name| out of the platform_apps
40 // subdirectory. Waits until it is launched.
41 const Extension* InstallAndLaunchPlatformApp(const char* name);
43 // Launch the given platform app.
44 void LaunchPlatformApp(const Extension* extension);
46 // Gets the WebContents associated with the first app window that is found
47 // (most tests only deal with one platform app window, so this is good
49 content::WebContents* GetFirstAppWindowWebContents();
51 // Gets the first app window that is found (most tests only deal with one
52 // platform app window, so this is good enough).
53 apps::AppWindow* GetFirstAppWindow();
55 // Gets the first app window for an app.
56 apps::AppWindow* GetFirstAppWindowForApp(const std::string& app_id);
58 // Runs chrome.windows.getAll for the given extension and returns the number
59 // of windows that the function returns.
60 size_t RunGetWindowsFunctionForExtension(const Extension* extension);
62 // Runs chrome.windows.get(|window_id|) for the the given extension and
63 // returns whether or not a window was found.
64 bool RunGetWindowFunctionForExtension(int window_id,
65 const Extension* extension);
67 // Returns the number of app windows.
68 size_t GetAppWindowCount();
70 // Returns the number of app windows for a specific app.
71 size_t GetAppWindowCountForApp(const std::string& app_id);
73 // The command line already has an argument on it - about:blank, which
74 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app
75 // launch tests we need to clear this.
76 void ClearCommandLineArgs();
78 // Sets up the command line for running platform apps.
79 void SetCommandLineArg(const std::string& test_file);
81 // Creates an empty app window for |extension|.
82 apps::AppWindow* CreateAppWindow(const Extension* extension);
84 apps::AppWindow* CreateAppWindowFromParams(
85 const Extension* extension,
86 const apps::AppWindow::CreateParams& params);
88 // Closes |window| and waits until it's gone.
89 void CloseAppWindow(apps::AppWindow* window);
91 // Call AdjustBoundsToBeVisibleOnScreen of |window|.
92 void CallAdjustBoundsToBeVisibleOnScreenForAppWindow(
93 apps::AppWindow* window,
94 const gfx::Rect& cached_bounds,
95 const gfx::Rect& cached_screen_bounds,
96 const gfx::Rect& current_screen_bounds,
97 const gfx::Size& minimum_size,
101 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest {
103 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
106 } // namespace extensions
108 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_