Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / apps / app_browsertest_util.h
blob50676ab93b53b4677d719fff78572e521a290f3c
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"
12 namespace base {
13 class CommandLine;
16 namespace content {
17 class WebContents;
20 class Browser;
21 class ExtensionTestMessageListener;
23 namespace extensions {
24 class Extension;
26 class PlatformAppBrowserTest : public ExtensionApiTest {
27 public:
28 PlatformAppBrowserTest();
30 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
32 // Gets the first app window that is found for a given browser.
33 static apps::AppWindow* GetFirstAppWindowForBrowser(Browser* browser);
35 protected:
36 // Runs the app named |name| out of the platform_apps subdirectory. Waits
37 // for the provided listener to be satisifed.
38 const Extension* LoadAndLaunchPlatformApp(
39 const char* name,
40 ExtensionTestMessageListener* listener);
42 // Runs the app named |name| out of the platform_apps subdirectory. Waits
43 // until the given message is received from the app.
44 const Extension* LoadAndLaunchPlatformApp(const char* name,
45 const std::string& message);
47 // Installs the app named |name| out of the platform_apps subdirectory.
48 const Extension* InstallPlatformApp(const char* name);
50 // Installs and runs the app named |name| out of the platform_apps
51 // subdirectory. Waits until it is launched.
52 const Extension* InstallAndLaunchPlatformApp(const char* name);
54 // Launch the given platform app.
55 virtual void LaunchPlatformApp(const Extension* extension);
57 // Gets the WebContents associated with the first app window that is found
58 // (most tests only deal with one platform app window, so this is good
59 // enough).
60 content::WebContents* GetFirstAppWindowWebContents();
62 // Gets the first app window that is found (most tests only deal with one
63 // platform app window, so this is good enough).
64 apps::AppWindow* GetFirstAppWindow();
66 // Gets the first app window for an app.
67 apps::AppWindow* GetFirstAppWindowForApp(const std::string& app_id);
69 // Runs chrome.windows.getAll for the given extension and returns the number
70 // of windows that the function returns.
71 size_t RunGetWindowsFunctionForExtension(const Extension* extension);
73 // Runs chrome.windows.get(|window_id|) for the the given extension and
74 // returns whether or not a window was found.
75 bool RunGetWindowFunctionForExtension(int window_id,
76 const Extension* extension);
78 // Returns the number of app windows.
79 size_t GetAppWindowCount();
81 // Returns the number of app windows for a specific app.
82 size_t GetAppWindowCountForApp(const std::string& app_id);
84 // The command line already has an argument on it - about:blank, which
85 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app
86 // launch tests we need to clear this.
87 void ClearCommandLineArgs();
89 // Sets up the command line for running platform apps.
90 void SetCommandLineArg(const std::string& test_file);
92 // Creates an empty app window for |extension|.
93 apps::AppWindow* CreateAppWindow(const Extension* extension);
95 apps::AppWindow* CreateAppWindowFromParams(
96 const Extension* extension,
97 const apps::AppWindow::CreateParams& params);
99 // Closes |window| and waits until it's gone.
100 void CloseAppWindow(apps::AppWindow* window);
102 // Call AdjustBoundsToBeVisibleOnScreen of |window|.
103 void CallAdjustBoundsToBeVisibleOnScreenForAppWindow(
104 apps::AppWindow* window,
105 const gfx::Rect& cached_bounds,
106 const gfx::Rect& cached_screen_bounds,
107 const gfx::Rect& current_screen_bounds,
108 const gfx::Size& minimum_size,
109 gfx::Rect* bounds);
111 // Load a simple test app and create a window. The window must be closed by
112 // the caller in order to terminate the test - use CloseAppWindow().
113 // |window_create_options| are the options that will be passed to
114 // chrome.app.window.create() in the test app.
115 apps::AppWindow* CreateTestAppWindow(
116 const std::string& window_create_options);
118 private:
119 DISALLOW_COPY_AND_ASSIGN(PlatformAppBrowserTest);
122 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest {
123 public:
124 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
127 } // namespace extensions
129 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_