Chromium Code Reviews| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/automation/automation_util.h" | 8 #include "chrome/browser/automation/automation_util.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 ExtensionService* service = browser()->profile()->GetExtensionService(); | 67 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 68 const Extension* extension = service->GetExtensionById( | 68 const Extension* extension = service->GetExtensionById( |
| 69 last_loaded_extension_id_, false); | 69 last_loaded_extension_id_, false); |
| 70 EXPECT_TRUE(extension); | 70 EXPECT_TRUE(extension); |
| 71 | 71 |
| 72 Browser::OpenApplication( | 72 Browser::OpenApplication( |
| 73 browser()->profile(), | 73 browser()->profile(), |
| 74 extension, | 74 extension, |
| 75 extension_misc::LAUNCH_NONE, | 75 extension_misc::LAUNCH_NONE, |
| 76 GURL(), | 76 GURL(), |
| 77 NEW_WINDOW); | 77 NEW_WINDOW, |
| 78 NULL); | |
| 78 | 79 |
| 79 app_loaded_observer.Wait(); | 80 app_loaded_observer.Wait(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 // Gets the WebContents associated with the first shell window that is found | 83 // Gets the WebContents associated with the first shell window that is found |
| 83 // (most tests only deal with one platform app window, so this is good | 84 // (most tests only deal with one platform app window, so this is good |
| 84 // enough). | 85 // enough). |
| 85 WebContents* GetFirstShellWindowWebContents() { | 86 WebContents* GetFirstShellWindowWebContents() { |
| 86 ShellWindowRegistry* app_registry = | 87 ShellWindowRegistry* app_registry = |
| 87 ShellWindowRegistry::Get(browser()->profile()); | 88 ShellWindowRegistry::Get(browser()->profile()); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 set_cookie_url, | 187 set_cookie_url, |
| 187 browser()->GetWebContentsAt(0), | 188 browser()->GetWebContentsAt(0), |
| 188 &cookie_size, | 189 &cookie_size, |
| 189 &cookie_value); | 190 &cookie_value); |
| 190 ASSERT_EQ("testCookie=1", cookie_value); | 191 ASSERT_EQ("testCookie=1", cookie_value); |
| 191 | 192 |
| 192 // Let the platform app request the same URL, and make sure that it doesn't | 193 // Let the platform app request the same URL, and make sure that it doesn't |
| 193 // see the cookie. | 194 // see the cookie. |
| 194 ASSERT_TRUE(RunPlatformAppTest("platform_apps/isolation")) << message_; | 195 ASSERT_TRUE(RunPlatformAppTest("platform_apps/isolation")) << message_; |
| 195 } | 196 } |
| 197 | |
| 198 // Tests that command line parameters get passed through to platform apps | |
| 199 // via launchData correctly when launching with a file. | |
| 200 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) { | |
| 201 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 202 FilePath test_doc(test_data_dir_.AppendASCII( | |
| 203 "platform_apps/test_files/test.txt")); | |
| 204 // The command line already has arguments on it ("about:blank"). We want to | |
|
Mihai Parparita -not on Chrome
2012/05/15 00:39:28
What is adding the about:blank?
benwells
2012/05/18 03:36:02
Its added here
http://code.google.com/p/chromium/s
| |
| 205 // clear any existing arguments and replace with our test file. | |
| 206 CommandLine::StringVector args = command_line->GetArgs(); | |
| 207 CommandLine::StringVector argv = command_line->argv(); | |
| 208 for (size_t i=0; i<args.size(); i++) | |
| 209 argv.pop_back(); | |
|
benwells
2012/05/14 23:50:33
The removal of existing command line args should b
benwells
2012/05/18 03:36:02
Done.
| |
| 210 argv.push_back(test_doc.value()); | |
| 211 command_line->InitFromArgv(argv); | |
| 212 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_file")) | |
| 213 << message_; | |
| 214 } | |
| 215 | |
| 216 // Tests that no launch data is sent through if the platform app provides | |
| 217 // an intent with the wrong action. | |
| 218 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithWrongIntent) { | |
| 219 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 220 FilePath test_doc(test_data_dir_.AppendASCII( | |
| 221 "platform_apps/test_files/test.txt")); | |
| 222 // The command line already has arguments on it ("about:blank"). We want to | |
| 223 // clear any existing arguments and replace with our test file. | |
| 224 CommandLine::StringVector args = command_line->GetArgs(); | |
| 225 CommandLine::StringVector argv = command_line->argv(); | |
| 226 for (size_t i=0; i<args.size(); i++) | |
| 227 argv.pop_back(); | |
| 228 argv.push_back(test_doc.value()); | |
| 229 command_line->InitFromArgv(argv); | |
| 230 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_wrong_intent")) | |
| 231 << message_; | |
| 232 } | |
| 233 | |
| 234 // Tests that no launch data is sent through if the file is of the wrong MIME | |
| 235 // type. | |
| 236 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithWrongType) { | |
| 237 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 238 FilePath test_doc(test_data_dir_.AppendASCII( | |
| 239 "platform_apps/test_files/test.txt")); | |
| 240 // The command line already has arguments on it ("about:blank"). We want to | |
| 241 // clear any existing arguments and replace with our test file. | |
| 242 CommandLine::StringVector args = command_line->GetArgs(); | |
| 243 CommandLine::StringVector argv = command_line->argv(); | |
| 244 for (size_t i=0; i<args.size(); i++) | |
| 245 argv.pop_back(); | |
| 246 argv.push_back(test_doc.value()); | |
| 247 command_line->InitFromArgv(argv); | |
| 248 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_wrong_type")) | |
| 249 << message_; | |
| 250 } | |
| 251 | |
| 252 // Tests that no launch data is sent through if the platform app does not | |
| 253 // provide an intent. | |
| 254 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNoIntent) { | |
| 255 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 256 FilePath test_doc(test_data_dir_.AppendASCII( | |
| 257 "platform_apps/test_files/test.txt")); | |
| 258 // The command line already has arguments on it ("about:blank"). We want to | |
| 259 // clear any existing arguments and replace with our test file. | |
| 260 CommandLine::StringVector args = command_line->GetArgs(); | |
| 261 CommandLine::StringVector argv = command_line->argv(); | |
| 262 for (size_t i=0; i<args.size(); i++) | |
| 263 argv.pop_back(); | |
| 264 argv.push_back(test_doc.value()); | |
| 265 command_line->InitFromArgv(argv); | |
| 266 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_no_intent")) | |
| 267 << message_; | |
| 268 } | |
| 269 | |
| 270 // Tests that no launch data is sent through if the file MIME type cannot | |
| 271 // be read. | |
| 272 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNoType) { | |
| 273 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 274 FilePath test_doc(test_data_dir_.AppendASCII( | |
| 275 "platform_apps/test_files/test.unknownextension")); | |
| 276 // The command line already has arguments on it ("about:blank"). We want to | |
| 277 // clear any existing arguments and replace with our test file. | |
| 278 CommandLine::StringVector args = command_line->GetArgs(); | |
| 279 CommandLine::StringVector argv = command_line->argv(); | |
| 280 for (size_t i=0; i<args.size(); i++) | |
| 281 argv.pop_back(); | |
| 282 argv.push_back(test_doc.value()); | |
| 283 command_line->InitFromArgv(argv); | |
| 284 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_no_type")) | |
| 285 << message_; | |
| 286 } | |
| 287 | |
| 288 // Tests that no launch data is sent through if there are no arguments passed | |
| 289 // on the command line | |
| 290 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNothing) { | |
| 291 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 292 // The command line already has arguments on it ("about:blank"). We want to | |
| 293 // clear all of these. | |
| 294 CommandLine::StringVector args = command_line->GetArgs(); | |
| 295 CommandLine::StringVector argv = command_line->argv(); | |
| 296 for (size_t i=0; i<args.size(); i++) | |
| 297 argv.pop_back(); | |
| 298 command_line->InitFromArgv(argv); | |
| 299 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_nothing")) | |
| 300 << message_; | |
| 301 } | |
| OLD | NEW |