| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_ | 6 #define CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_ |
| 7 | 7 |
| 8 | 8 #include "apps/app_window.h" |
| 9 #include "apps/shell_window.h" | |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 11 #include "content/public/common/page_transition_types.h" | 10 #include "content/public/common/page_transition_types.h" |
| 12 | 11 |
| 13 namespace content { | 12 namespace content { |
| 14 class WebContents; | 13 class WebContents; |
| 15 } | 14 } |
| 16 | 15 |
| 17 class Browser; | 16 class Browser; |
| 18 class CommandLine; | 17 class CommandLine; |
| 19 | 18 |
| 20 namespace extensions { | 19 namespace extensions { |
| 21 class Extension; | 20 class Extension; |
| 22 | 21 |
| 23 class PlatformAppBrowserTest : public ExtensionApiTest { | 22 class PlatformAppBrowserTest : public ExtensionApiTest { |
| 24 public: | 23 public: |
| 25 PlatformAppBrowserTest(); | 24 PlatformAppBrowserTest(); |
| 26 | 25 |
| 27 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 26 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 28 | 27 |
| 29 // Gets the first shell window that is found for a given browser. | 28 // Gets the first app window that is found for a given browser. |
| 30 static apps::ShellWindow* GetFirstShellWindowForBrowser(Browser* browser); | 29 static apps::AppWindow* GetFirstAppWindowForBrowser(Browser* browser); |
| 31 | 30 |
| 32 protected: | 31 protected: |
| 33 // Runs the app named |name| out of the platform_apps subdirectory. Waits | 32 // Runs the app named |name| out of the platform_apps subdirectory. Waits |
| 34 // until it is launched. | 33 // until it is launched. |
| 35 const Extension* LoadAndLaunchPlatformApp(const char* name); | 34 const Extension* LoadAndLaunchPlatformApp(const char* name); |
| 36 | 35 |
| 37 // Installs the app named |name| out of the platform_apps subdirectory. | 36 // Installs the app named |name| out of the platform_apps subdirectory. |
| 38 const Extension* InstallPlatformApp(const char* name); | 37 const Extension* InstallPlatformApp(const char* name); |
| 39 | 38 |
| 40 // Installs and runs the app named |name| out of the platform_apps | 39 // Installs and runs the app named |name| out of the platform_apps |
| 41 // subdirectory. Waits until it is launched. | 40 // subdirectory. Waits until it is launched. |
| 42 const Extension* InstallAndLaunchPlatformApp(const char* name); | 41 const Extension* InstallAndLaunchPlatformApp(const char* name); |
| 43 | 42 |
| 44 // Launch the given platform app. | 43 // Launch the given platform app. |
| 45 void LaunchPlatformApp(const Extension* extension); | 44 void LaunchPlatformApp(const Extension* extension); |
| 46 | 45 |
| 47 // Gets the WebContents associated with the first shell window that is found | 46 // Gets the WebContents associated with the first app window that is found |
| 48 // (most tests only deal with one platform app window, so this is good | 47 // (most tests only deal with one platform app window, so this is good |
| 49 // enough). | 48 // enough). |
| 50 content::WebContents* GetFirstShellWindowWebContents(); | 49 content::WebContents* GetFirstAppWindowWebContents(); |
| 51 | 50 |
| 52 // Gets the first shell window that is found (most tests only deal with one | 51 // Gets the first app window that is found (most tests only deal with one |
| 53 // platform app window, so this is good enough). | 52 // platform app window, so this is good enough). |
| 54 apps::ShellWindow* GetFirstShellWindow(); | 53 apps::AppWindow* GetFirstAppWindow(); |
| 55 | 54 |
| 56 // Gets the first shell window for an app. | 55 // Gets the first app window for an app. |
| 57 apps::ShellWindow* GetFirstShellWindowForApp(const std::string& app_id); | 56 apps::AppWindow* GetFirstAppWindowForApp(const std::string& app_id); |
| 58 | 57 |
| 59 // Runs chrome.windows.getAll for the given extension and returns the number | 58 // Runs chrome.windows.getAll for the given extension and returns the number |
| 60 // of windows that the function returns. | 59 // of windows that the function returns. |
| 61 size_t RunGetWindowsFunctionForExtension(const Extension* extension); | 60 size_t RunGetWindowsFunctionForExtension(const Extension* extension); |
| 62 | 61 |
| 63 // Runs chrome.windows.get(|window_id|) for the the given extension and | 62 // Runs chrome.windows.get(|window_id|) for the the given extension and |
| 64 // returns whether or not a window was found. | 63 // returns whether or not a window was found. |
| 65 bool RunGetWindowFunctionForExtension(int window_id, | 64 bool RunGetWindowFunctionForExtension(int window_id, |
| 66 const Extension* extension); | 65 const Extension* extension); |
| 67 | 66 |
| 68 // Returns the number of shell windows. | 67 // Returns the number of app windows. |
| 69 size_t GetShellWindowCount(); | 68 size_t GetAppWindowCount(); |
| 70 | 69 |
| 71 // Returns the number of shell windows for a specific app. | 70 // Returns the number of app windows for a specific app. |
| 72 size_t GetShellWindowCountForApp(const std::string& app_id); | 71 size_t GetAppWindowCountForApp(const std::string& app_id); |
| 73 | 72 |
| 74 // The command line already has an argument on it - about:blank, which | 73 // The command line already has an argument on it - about:blank, which |
| 75 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app | 74 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app |
| 76 // launch tests we need to clear this. | 75 // launch tests we need to clear this. |
| 77 void ClearCommandLineArgs(); | 76 void ClearCommandLineArgs(); |
| 78 | 77 |
| 79 // Sets up the command line for running platform apps. | 78 // Sets up the command line for running platform apps. |
| 80 void SetCommandLineArg(const std::string& test_file); | 79 void SetCommandLineArg(const std::string& test_file); |
| 81 | 80 |
| 82 // Creates an empty shell window for |extension|. | 81 // Creates an empty app window for |extension|. |
| 83 apps::ShellWindow* CreateShellWindow(const Extension* extension); | 82 apps::AppWindow* CreateAppWindow(const Extension* extension); |
| 84 | 83 |
| 85 apps::ShellWindow* CreateShellWindowFromParams( | 84 apps::AppWindow* CreateAppWindowFromParams( |
| 86 const Extension* extension, | 85 const Extension* extension, |
| 87 const apps::ShellWindow::CreateParams& params); | 86 const apps::AppWindow::CreateParams& params); |
| 88 | 87 |
| 89 // Closes |window| and waits until it's gone. | 88 // Closes |window| and waits until it's gone. |
| 90 void CloseShellWindow(apps::ShellWindow* window); | 89 void CloseAppWindow(apps::AppWindow* window); |
| 91 | 90 |
| 92 // Call AdjustBoundsToBeVisibleOnScreen of |window|. | 91 // Call AdjustBoundsToBeVisibleOnScreen of |window|. |
| 93 void CallAdjustBoundsToBeVisibleOnScreenForShellWindow( | 92 void CallAdjustBoundsToBeVisibleOnScreenForAppWindow( |
| 94 apps::ShellWindow* window, | 93 apps::AppWindow* window, |
| 95 const gfx::Rect& cached_bounds, | 94 const gfx::Rect& cached_bounds, |
| 96 const gfx::Rect& cached_screen_bounds, | 95 const gfx::Rect& cached_screen_bounds, |
| 97 const gfx::Rect& current_screen_bounds, | 96 const gfx::Rect& current_screen_bounds, |
| 98 const gfx::Size& minimum_size, | 97 const gfx::Size& minimum_size, |
| 99 gfx::Rect* bounds); | 98 gfx::Rect* bounds); |
| 100 }; | 99 }; |
| 101 | 100 |
| 102 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest { | 101 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest { |
| 103 public: | 102 public: |
| 104 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 103 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 105 }; | 104 }; |
| 106 | 105 |
| 107 } // namespace extensions | 106 } // namespace extensions |
| 108 | 107 |
| 109 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_ | 108 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_ |
| OLD | NEW |