Chromium Code Reviews| Index: chrome/browser/extensions/platform_app_browsertest.cc |
| diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc |
| index 44f615afecdb4d819f41889cfb051bf532c218e4..55e94f5c567297e43b254b04cd01516402c2a425 100644 |
| --- a/chrome/browser/extensions/platform_app_browsertest.cc |
| +++ b/chrome/browser/extensions/platform_app_browsertest.cc |
| @@ -74,7 +74,8 @@ class PlatformAppBrowserTest : public ExtensionApiTest { |
| extension, |
| extension_misc::LAUNCH_NONE, |
| GURL(), |
| - NEW_WINDOW); |
| + NEW_WINDOW, |
| + NULL); |
| app_loaded_observer.Wait(); |
| } |
| @@ -94,6 +95,25 @@ class PlatformAppBrowserTest : public ExtensionApiTest { |
| return NULL; |
| } |
| + |
| + // The command line already has an argument on it - about:blank, which |
| + // is set by InProcessBrowserTest::PrepareTestCommandLine. For platform app |
| + // launch tests we need to clear this. |
| + void ClearCommandLineArgs() { |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + CommandLine::StringVector args = command_line->GetArgs(); |
| + CommandLine::StringVector argv = command_line->argv(); |
| + for (size_t i=0; i<args.size(); i++) |
|
Mihai Parparita -not on Chrome
2012/05/18 04:26:04
Nit: add space before/after = and <
benwells
2012/05/22 13:15:03
Done.
|
| + argv.pop_back(); |
| + command_line->InitFromArgv(argv); |
| + } |
| + |
| + void SetCommandLineArg(const std::string& test_file) { |
| + ClearCommandLineArgs(); |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + FilePath test_doc(test_data_dir_.AppendASCII(test_file)); |
| + command_line->AppendArg(test_doc.value()); |
| + } |
| }; |
| // Tests that platform apps received the "launch" event when launched. |
| @@ -193,3 +213,65 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Isolation) { |
| // see the cookie. |
| ASSERT_TRUE(RunPlatformAppTest("platform_apps/isolation")) << message_; |
| } |
| + |
| +// Tests that command line parameters get passed through to platform apps |
| +// via launchData correctly when launching with a file. |
| +IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) { |
| + SetCommandLineArg( "platform_apps/launch_files/test.txt"); |
| + ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_file")) |
| + << message_; |
| +} |
| + |
| +// Tests that no launch data is sent through if the platform app provides |
| +// an intent with the wrong action. |
| +IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithWrongIntent) { |
| + SetCommandLineArg("platform_apps/launch_files/test.txt"); |
| + ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_wrong_intent")) |
| + << message_; |
| +} |
| + |
| +// Tests that no launch data is sent through if the file is of the wrong MIME |
| +// type. |
| +IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithWrongType) { |
| + SetCommandLineArg("platform_apps/launch_files/test.txt"); |
| + ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_wrong_type")) |
| + << message_; |
| +} |
| + |
| +// Tests that no launch data is sent through if the platform app does not |
| +// provide an intent. |
| +IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNoIntent) { |
| + SetCommandLineArg("platform_apps/launch_files/test.txt"); |
| + ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_no_intent")) |
| + << message_; |
| +} |
| + |
| +// Tests that no launch data is sent through if the file MIME type cannot |
| +// be read. |
| +IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNoType) { |
| + SetCommandLineArg("platform_apps/launch_files/test.unknownextension"); |
| + ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_invalid")) |
| + << message_; |
| +} |
| + |
| +// Tests that no launch data is sent through if the file does not exist. |
| +IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNoFile) { |
| + SetCommandLineArg("platform_apps/launch_files/doesnotexist.txt"); |
| + ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_invalid")) |
| + << message_; |
| +} |
| + |
| +// Tests that no launch data is sent through if the argument is a directory. |
| +IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithDirectory) { |
| + SetCommandLineArg("platform_apps/launch_files"); |
| + ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_invalid")) |
| + << message_; |
| +} |
| + |
| +// Tests that no launch data is sent through if there are no arguments passed |
| +// on the command line |
| +IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNothing) { |
| + ClearCommandLineArgs(); |
| + ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_nothing")) |
| + << message_; |
| +} |