Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / apps / app_browsertest_util.h
blobe72d13743826d2eb0c352948fea490f10f55d124
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 "chrome/browser/extensions/extension_apitest.h"
9 #include "extensions/browser/app_window/app_window.h"
11 namespace base {
12 class CommandLine;
15 namespace content {
16 class WebContents;
19 class Browser;
20 class ExtensionTestMessageListener;
22 namespace extensions {
23 class Extension;
25 class PlatformAppBrowserTest : public ExtensionApiTest {
26 public:
27 PlatformAppBrowserTest();
29 void SetUpCommandLine(base::CommandLine* command_line) override;
31 // Gets the first app window that is found for a given browser.
32 static AppWindow* GetFirstAppWindowForBrowser(Browser* browser);
34 protected:
35 // Runs the app named |name| out of the platform_apps subdirectory. Waits
36 // for the provided listener to be satisifed.
37 const Extension* LoadAndLaunchPlatformApp(
38 const char* name,
39 ExtensionTestMessageListener* listener);
41 // Runs the app named |name| out of the platform_apps subdirectory. Waits
42 // until the given message is received from the app.
43 const Extension* LoadAndLaunchPlatformApp(const char* name,
44 const std::string& message);
46 // Installs the app named |name| out of the platform_apps subdirectory.
47 const Extension* InstallPlatformApp(const char* name);
49 // Installs the sample hosted app.
50 const Extension* InstallHostedApp();
52 // Installs and runs the app named |name| out of the platform_apps
53 // subdirectory. Waits until it is launched.
54 const Extension* InstallAndLaunchPlatformApp(const char* name);
56 // Launch the given platform app.
57 virtual void LaunchPlatformApp(const Extension* extension);
59 // Launch the given hosted app.
60 virtual void LaunchHostedApp(const Extension* extension);
62 // Gets the WebContents associated with the first app window that is found
63 // (most tests only deal with one platform app window, so this is good
64 // enough).
65 content::WebContents* GetFirstAppWindowWebContents();
67 // Gets the first app window that is found (most tests only deal with one
68 // platform app window, so this is good enough).
69 AppWindow* GetFirstAppWindow();
71 // Gets the first app window for an app.
72 AppWindow* GetFirstAppWindowForApp(const std::string& app_id);
74 // Runs chrome.windows.getAll for the given extension and returns the number
75 // of windows that the function returns.
76 size_t RunGetWindowsFunctionForExtension(const Extension* extension);
78 // Runs chrome.windows.get(|window_id|) for the the given extension and
79 // returns whether or not a window was found.
80 bool RunGetWindowFunctionForExtension(int window_id,
81 const Extension* extension);
83 // Returns the number of app windows.
84 size_t GetAppWindowCount();
86 // Returns the number of app windows for a specific app.
87 size_t GetAppWindowCountForApp(const std::string& app_id);
89 // Creates an empty app window for |extension|.
90 AppWindow* CreateAppWindow(const Extension* extension);
92 AppWindow* CreateAppWindowFromParams(const Extension* extension,
93 const AppWindow::CreateParams& params);
95 // Closes |window| and waits until it's gone.
96 void CloseAppWindow(AppWindow* window);
98 // Call AdjustBoundsToBeVisibleOnScreen of |window|.
99 void CallAdjustBoundsToBeVisibleOnScreenForAppWindow(
100 AppWindow* window,
101 const gfx::Rect& cached_bounds,
102 const gfx::Rect& cached_screen_bounds,
103 const gfx::Rect& current_screen_bounds,
104 const gfx::Size& minimum_size,
105 gfx::Rect* bounds);
107 // Load a simple test app and create a window. The window must be closed by
108 // the caller in order to terminate the test - use CloseAppWindow().
109 // |window_create_options| are the options that will be passed to
110 // chrome.app.window.create() in the test app.
111 AppWindow* CreateTestAppWindow(const std::string& window_create_options);
113 private:
114 DISALLOW_COPY_AND_ASSIGN(PlatformAppBrowserTest);
117 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest {
118 public:
119 void SetUpCommandLine(base::CommandLine* command_line) override;
122 } // namespace extensions
124 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_