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