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 #include "apps/app_window.h" | |
9 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "content/public/common/page_transition_types.h" | 9 #include "content/public/common/page_transition_types.h" |
| 10 #include "extensions/browser/app_window/app_window.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class CommandLine; | 13 class CommandLine; |
14 } | 14 } |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 class WebContents; | 17 class WebContents; |
18 } | 18 } |
19 | 19 |
20 class Browser; | 20 class Browser; |
21 class ExtensionTestMessageListener; | 21 class ExtensionTestMessageListener; |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 class Extension; | 24 class Extension; |
25 | 25 |
26 class PlatformAppBrowserTest : public ExtensionApiTest { | 26 class PlatformAppBrowserTest : public ExtensionApiTest { |
27 public: | 27 public: |
28 PlatformAppBrowserTest(); | 28 PlatformAppBrowserTest(); |
29 | 29 |
30 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; | 30 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; |
31 | 31 |
32 // Gets the first app window that is found for a given browser. | 32 // Gets the first app window that is found for a given browser. |
33 static apps::AppWindow* GetFirstAppWindowForBrowser(Browser* browser); | 33 static AppWindow* GetFirstAppWindowForBrowser(Browser* browser); |
34 | 34 |
35 protected: | 35 protected: |
36 // Runs the app named |name| out of the platform_apps subdirectory. Waits | 36 // Runs the app named |name| out of the platform_apps subdirectory. Waits |
37 // for the provided listener to be satisifed. | 37 // for the provided listener to be satisifed. |
38 const Extension* LoadAndLaunchPlatformApp( | 38 const Extension* LoadAndLaunchPlatformApp( |
39 const char* name, | 39 const char* name, |
40 ExtensionTestMessageListener* listener); | 40 ExtensionTestMessageListener* listener); |
41 | 41 |
42 // Runs the app named |name| out of the platform_apps subdirectory. Waits | 42 // Runs the app named |name| out of the platform_apps subdirectory. Waits |
43 // until the given message is received from the app. | 43 // until the given message is received from the app. |
(...skipping 10 matching lines...) Expand all Loading... |
54 // Launch the given platform app. | 54 // Launch the given platform app. |
55 virtual void LaunchPlatformApp(const Extension* extension); | 55 virtual void LaunchPlatformApp(const Extension* extension); |
56 | 56 |
57 // Gets the WebContents associated with the first app window that is found | 57 // Gets the WebContents associated with the first app window that is found |
58 // (most tests only deal with one platform app window, so this is good | 58 // (most tests only deal with one platform app window, so this is good |
59 // enough). | 59 // enough). |
60 content::WebContents* GetFirstAppWindowWebContents(); | 60 content::WebContents* GetFirstAppWindowWebContents(); |
61 | 61 |
62 // Gets the first app window that is found (most tests only deal with one | 62 // Gets the first app window that is found (most tests only deal with one |
63 // platform app window, so this is good enough). | 63 // platform app window, so this is good enough). |
64 apps::AppWindow* GetFirstAppWindow(); | 64 AppWindow* GetFirstAppWindow(); |
65 | 65 |
66 // Gets the first app window for an app. | 66 // Gets the first app window for an app. |
67 apps::AppWindow* GetFirstAppWindowForApp(const std::string& app_id); | 67 AppWindow* GetFirstAppWindowForApp(const std::string& app_id); |
68 | 68 |
69 // Runs chrome.windows.getAll for the given extension and returns the number | 69 // Runs chrome.windows.getAll for the given extension and returns the number |
70 // of windows that the function returns. | 70 // of windows that the function returns. |
71 size_t RunGetWindowsFunctionForExtension(const Extension* extension); | 71 size_t RunGetWindowsFunctionForExtension(const Extension* extension); |
72 | 72 |
73 // Runs chrome.windows.get(|window_id|) for the the given extension and | 73 // Runs chrome.windows.get(|window_id|) for the the given extension and |
74 // returns whether or not a window was found. | 74 // returns whether or not a window was found. |
75 bool RunGetWindowFunctionForExtension(int window_id, | 75 bool RunGetWindowFunctionForExtension(int window_id, |
76 const Extension* extension); | 76 const Extension* extension); |
77 | 77 |
78 // Returns the number of app windows. | 78 // Returns the number of app windows. |
79 size_t GetAppWindowCount(); | 79 size_t GetAppWindowCount(); |
80 | 80 |
81 // Returns the number of app windows for a specific app. | 81 // Returns the number of app windows for a specific app. |
82 size_t GetAppWindowCountForApp(const std::string& app_id); | 82 size_t GetAppWindowCountForApp(const std::string& app_id); |
83 | 83 |
84 // The command line already has an argument on it - about:blank, which | 84 // The command line already has an argument on it - about:blank, which |
85 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app | 85 // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app |
86 // launch tests we need to clear this. | 86 // launch tests we need to clear this. |
87 void ClearCommandLineArgs(); | 87 void ClearCommandLineArgs(); |
88 | 88 |
89 // Sets up the command line for running platform apps. | 89 // Sets up the command line for running platform apps. |
90 void SetCommandLineArg(const std::string& test_file); | 90 void SetCommandLineArg(const std::string& test_file); |
91 | 91 |
92 // Creates an empty app window for |extension|. | 92 // Creates an empty app window for |extension|. |
93 apps::AppWindow* CreateAppWindow(const Extension* extension); | 93 AppWindow* CreateAppWindow(const Extension* extension); |
94 | 94 |
95 apps::AppWindow* CreateAppWindowFromParams( | 95 AppWindow* CreateAppWindowFromParams(const Extension* extension, |
96 const Extension* extension, | 96 const AppWindow::CreateParams& params); |
97 const apps::AppWindow::CreateParams& params); | |
98 | 97 |
99 // Closes |window| and waits until it's gone. | 98 // Closes |window| and waits until it's gone. |
100 void CloseAppWindow(apps::AppWindow* window); | 99 void CloseAppWindow(AppWindow* window); |
101 | 100 |
102 // Call AdjustBoundsToBeVisibleOnScreen of |window|. | 101 // Call AdjustBoundsToBeVisibleOnScreen of |window|. |
103 void CallAdjustBoundsToBeVisibleOnScreenForAppWindow( | 102 void CallAdjustBoundsToBeVisibleOnScreenForAppWindow( |
104 apps::AppWindow* window, | 103 AppWindow* window, |
105 const gfx::Rect& cached_bounds, | 104 const gfx::Rect& cached_bounds, |
106 const gfx::Rect& cached_screen_bounds, | 105 const gfx::Rect& cached_screen_bounds, |
107 const gfx::Rect& current_screen_bounds, | 106 const gfx::Rect& current_screen_bounds, |
108 const gfx::Size& minimum_size, | 107 const gfx::Size& minimum_size, |
109 gfx::Rect* bounds); | 108 gfx::Rect* bounds); |
110 | 109 |
111 // Load a simple test app and create a window. The window must be closed by | 110 // Load a simple test app and create a window. The window must be closed by |
112 // the caller in order to terminate the test - use CloseAppWindow(). | 111 // the caller in order to terminate the test - use CloseAppWindow(). |
113 // |window_create_options| are the options that will be passed to | 112 // |window_create_options| are the options that will be passed to |
114 // chrome.app.window.create() in the test app. | 113 // chrome.app.window.create() in the test app. |
115 apps::AppWindow* CreateTestAppWindow( | 114 AppWindow* CreateTestAppWindow(const std::string& window_create_options); |
116 const std::string& window_create_options); | |
117 | 115 |
118 private: | 116 private: |
119 DISALLOW_COPY_AND_ASSIGN(PlatformAppBrowserTest); | 117 DISALLOW_COPY_AND_ASSIGN(PlatformAppBrowserTest); |
120 }; | 118 }; |
121 | 119 |
122 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest { | 120 class ExperimentalPlatformAppBrowserTest : public PlatformAppBrowserTest { |
123 public: | 121 public: |
124 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; | 122 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; |
125 }; | 123 }; |
126 | 124 |
127 } // namespace extensions | 125 } // namespace extensions |
128 | 126 |
129 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_ | 127 #endif // CHROME_BROWSER_APPS_APP_BROWSERTEST_UTIL_H_ |
OLD | NEW |