| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "apps/shell_window.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/ui/extensions/shell_window.h" | |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 class WebContents; | 13 class WebContents; |
| 14 } | 14 } |
| 15 | 15 |
| 16 class CommandLine; | 16 class CommandLine; |
| 17 class ShellWindow; | |
| 18 | 17 |
| 19 namespace extensions { | 18 namespace extensions { |
| 20 class Extension; | 19 class Extension; |
| 21 | 20 |
| 22 class PlatformAppBrowserTest : public ExtensionApiTest { | 21 class PlatformAppBrowserTest : public ExtensionApiTest { |
| 23 public: | 22 public: |
| 24 PlatformAppBrowserTest(); | 23 PlatformAppBrowserTest(); |
| 25 | 24 |
| 26 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 25 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 27 | 26 |
| 28 protected: | 27 protected: |
| 29 // Runs the app named |name| out of the platform_apps subdirectory. Waits | 28 // Runs the app named |name| out of the platform_apps subdirectory. Waits |
| 30 // until it is launched. | 29 // until it is launched. |
| 31 const Extension* LoadAndLaunchPlatformApp(const char* name); | 30 const Extension* LoadAndLaunchPlatformApp(const char* name); |
| 32 | 31 |
| 33 // Installs and runs the app named |name| out of the platform_apps | 32 // Installs and runs the app named |name| out of the platform_apps |
| 34 // subdirectory. Waits until it is launched. | 33 // subdirectory. Waits until it is launched. |
| 35 const Extension* InstallAndLaunchPlatformApp(const char* name); | 34 const Extension* InstallAndLaunchPlatformApp(const char* name); |
| 36 | 35 |
| 37 // Gets the WebContents associated with the first shell window that is found | 36 // Gets the WebContents associated with the first shell window that is found |
| 38 // (most tests only deal with one platform app window, so this is good | 37 // (most tests only deal with one platform app window, so this is good |
| 39 // enough). | 38 // enough). |
| 40 content::WebContents* GetFirstShellWindowWebContents(); | 39 content::WebContents* GetFirstShellWindowWebContents(); |
| 41 | 40 |
| 42 // Gets the first shell window that is found (most tests only deal with one | 41 // Gets the first shell window that is found (most tests only deal with one |
| 43 // platform app window, so this is good enough). | 42 // platform app window, so this is good enough). |
| 44 ShellWindow* GetFirstShellWindow(); | 43 apps::ShellWindow* GetFirstShellWindow(); |
| 45 | 44 |
| 46 // Runs chrome.windows.getAll for the given extension and returns the number | 45 // Runs chrome.windows.getAll for the given extension and returns the number |
| 47 // of windows that the function returns. | 46 // of windows that the function returns. |
| 48 size_t RunGetWindowsFunctionForExtension(const Extension* extension); | 47 size_t RunGetWindowsFunctionForExtension(const Extension* extension); |
| 49 | 48 |
| 50 // Runs chrome.windows.get(|window_id|) for the the given extension and | 49 // Runs chrome.windows.get(|window_id|) for the the given extension and |
| 51 // returns whether or not a window was found. | 50 // returns whether or not a window was found. |
| 52 bool RunGetWindowFunctionForExtension(int window_id, | 51 bool RunGetWindowFunctionForExtension(int window_id, |
| 53 const Extension* extension); | 52 const Extension* extension); |
| 54 | 53 |
| 55 // Returns the number of shell windows. | 54 // Returns the number of shell windows. |
| 56 size_t GetShellWindowCount(); | 55 size_t GetShellWindowCount(); |
| 57 | 56 |
| 58 // The command line already has an argument on it - about:blank, which | 57 // The command line already has an argument on it - about:blank, which |
| 59 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app | 58 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app |
| 60 // launch tests we need to clear this. | 59 // launch tests we need to clear this. |
| 61 void ClearCommandLineArgs(); | 60 void ClearCommandLineArgs(); |
| 62 | 61 |
| 63 // Sets up the command line for running platform apps. | 62 // Sets up the command line for running platform apps. |
| 64 void SetCommandLineArg(const std::string& test_file); | 63 void SetCommandLineArg(const std::string& test_file); |
| 65 | 64 |
| 66 // Creates an empty shell window for |extension|. | 65 // Creates an empty shell window for |extension|. |
| 67 ShellWindow* CreateShellWindow(const Extension* extension); | 66 apps::ShellWindow* CreateShellWindow(const Extension* extension); |
| 68 | 67 |
| 69 ShellWindow* CreateShellWindowFromParams( | 68 apps::ShellWindow* CreateShellWindowFromParams( |
| 70 const Extension* extension, const ShellWindow::CreateParams& params); | 69 const Extension* extension, |
| 70 const apps::ShellWindow::CreateParams& params); |
| 71 | 71 |
| 72 // Closes |window| and waits until it's gone. | 72 // Closes |window| and waits until it's gone. |
| 73 void CloseShellWindow(ShellWindow* window); | 73 void CloseShellWindow(apps::ShellWindow* window); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest { | 76 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest { |
| 77 public: | 77 public: |
| 78 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 78 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } | 81 } // namespace extensions |
| 82 | 82 |
| 83 #endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_ | 83 #endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_ |
| OLD | NEW |