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 #include "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_test_api.h" | 10 #include "chrome/browser/extensions/extension_test_api.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 bool ExtensionApiTest::RunPageTest(const std::string& page_url) { | 149 bool ExtensionApiTest::RunPageTest(const std::string& page_url) { |
150 return RunExtensionSubtest("", page_url); | 150 return RunExtensionSubtest("", page_url); |
151 } | 151 } |
152 | 152 |
153 bool ExtensionApiTest::RunPageTest(const std::string& page_url, | 153 bool ExtensionApiTest::RunPageTest(const std::string& page_url, |
154 int flags) { | 154 int flags) { |
155 return RunExtensionSubtest("", page_url, flags); | 155 return RunExtensionSubtest("", page_url, flags); |
156 } | 156 } |
157 | 157 |
158 bool ExtensionApiTest::RunPlatformAppTest(const char* extension_name) { | 158 bool ExtensionApiTest::RunPlatformAppTest(const char* extension_name) { |
159 return RunExtensionTestImpl(extension_name, "", kFlagLaunchAppShell); | 159 return RunExtensionTestImpl(extension_name, "", kFlagLaunchPlatformApp); |
160 } | 160 } |
161 | 161 |
162 // Load |extension_name| extension and/or |page_url| and wait for | 162 // Load |extension_name| extension and/or |page_url| and wait for |
163 // PASSED or FAILED notification. | 163 // PASSED or FAILED notification. |
164 bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, | 164 bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, |
165 const std::string& page_url, | 165 const std::string& page_url, |
166 int flags) { | 166 int flags) { |
167 bool enable_incognito = (flags & kFlagEnableIncognito) != 0; | 167 bool enable_incognito = (flags & kFlagEnableIncognito) != 0; |
168 bool enable_fileaccess = (flags & kFlagEnableFileAccess) != 0; | 168 bool enable_fileaccess = (flags & kFlagEnableFileAccess) != 0; |
169 bool load_as_component = (flags & kFlagLoadAsComponent) != 0; | 169 bool load_as_component = (flags & kFlagLoadAsComponent) != 0; |
170 bool launch_shell = (flags & kFlagLaunchAppShell) != 0; | 170 bool launch_platform_app = (flags & kFlagLaunchPlatformApp) != 0; |
171 bool use_incognito = (flags & kFlagUseIncognito) != 0; | 171 bool use_incognito = (flags & kFlagUseIncognito) != 0; |
172 | 172 |
173 ResultCatcher catcher; | 173 ResultCatcher catcher; |
174 DCHECK(!std::string(extension_name).empty() || !page_url.empty()) << | 174 DCHECK(!std::string(extension_name).empty() || !page_url.empty()) << |
175 "extension_name and page_url cannot both be empty"; | 175 "extension_name and page_url cannot both be empty"; |
176 | 176 |
177 const Extension* extension = NULL; | 177 const Extension* extension = NULL; |
178 if (!std::string(extension_name).empty()) { | 178 if (!std::string(extension_name).empty()) { |
179 FilePath extension_path = test_data_dir_.AppendASCII(extension_name); | 179 FilePath extension_path = test_data_dir_.AppendASCII(extension_name); |
180 if (load_as_component) { | 180 if (load_as_component) { |
(...skipping 20 matching lines...) Expand all Loading... |
201 "Relative page_url given with no extension_name"; | 201 "Relative page_url given with no extension_name"; |
202 | 202 |
203 url = extension->GetResourceURL(page_url); | 203 url = extension->GetResourceURL(page_url); |
204 } | 204 } |
205 | 205 |
206 if (use_incognito) | 206 if (use_incognito) |
207 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), url); | 207 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), url); |
208 else | 208 else |
209 ui_test_utils::NavigateToURL(browser(), url); | 209 ui_test_utils::NavigateToURL(browser(), url); |
210 | 210 |
211 } else if (launch_shell) { | 211 } else if (launch_platform_app) { |
212 Browser::OpenApplication( | 212 Browser::OpenApplication( |
213 browser()->profile(), | 213 browser()->profile(), |
214 extension, | 214 extension, |
215 extension_misc::LAUNCH_SHELL, | 215 extension_misc::LAUNCH_NONE, |
216 GURL(), | 216 GURL(), |
217 NEW_WINDOW); | 217 NEW_WINDOW); |
218 } | 218 } |
219 | 219 |
220 if (!catcher.GetNextResult()) { | 220 if (!catcher.GetNextResult()) { |
221 message_ = catcher.message(); | 221 message_ = catcher.message(); |
222 return false; | 222 return false; |
223 } else { | 223 } else { |
224 return true; | 224 return true; |
225 } | 225 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 ExtensionApiTest::SetUpCommandLine(command_line); | 291 ExtensionApiTest::SetUpCommandLine(command_line); |
292 | 292 |
293 // If someone is using this class, we're going to insist on management of the | 293 // If someone is using this class, we're going to insist on management of the |
294 // relevant flags. If these flags are already set, die. | 294 // relevant flags. If these flags are already set, die. |
295 DCHECK(!command_line->HasSwitch(switches::kEnablePlatformApps)); | 295 DCHECK(!command_line->HasSwitch(switches::kEnablePlatformApps)); |
296 DCHECK(!command_line->HasSwitch(switches::kEnableExperimentalExtensionApis)); | 296 DCHECK(!command_line->HasSwitch(switches::kEnableExperimentalExtensionApis)); |
297 | 297 |
298 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 298 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
299 command_line->AppendSwitch(switches::kEnablePlatformApps); | 299 command_line->AppendSwitch(switches::kEnablePlatformApps); |
300 } | 300 } |
OLD | NEW |