Use app list item shadow for app list folders.
[chromium-blink-merge.git] / chrome / browser / apps / app_browsertest_util.h
blob23aba873b76dad193869b540586c6b04b8739946
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 // The command line already has an argument on it - about:blank, which
90 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app
91 // launch tests we need to clear this.
92 void ClearCommandLineArgs();
94 // Sets up the command line for running platform apps.
95 void SetCommandLineArg(const std::string& test_file);
97 // Creates an empty app window for |extension|.
98 AppWindow* CreateAppWindow(const Extension* extension);
100 AppWindow* CreateAppWindowFromParams(const Extension* extension,
101 const AppWindow::CreateParams& params);
103 // Closes |window| and waits until it's gone.
104 void CloseAppWindow(AppWindow* window);
106 // Call AdjustBoundsToBeVisibleOnScreen of |window|.
107 void CallAdjustBoundsToBeVisibleOnScreenForAppWindow(
108 AppWindow* window,
109 const gfx::Rect& cached_bounds,
110 const gfx::Rect& cached_screen_bounds,
111 const gfx::Rect& current_screen_bounds,
112 const gfx::Size& minimum_size,
113 gfx::Rect* bounds);
115 // Load a simple test app and create a window. The window must be closed by
116 // the caller in order to terminate the test - use CloseAppWindow().
117 // |window_create_options| are the options that will be passed to
118 // chrome.app.window.create() in the test app.
119 AppWindow* CreateTestAppWindow(const std::string& window_create_options);
121 private:
122 DISALLOW_COPY_AND_ASSIGN(PlatformAppBrowserTest);
125 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest {
126 public:
127 void SetUpCommandLine(base::CommandLine* command_line) override;
130 } // namespace extensions
132 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_