Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 10332071: Pass command line arguments onto platform apps which provide the right intent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bad merge Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..668be21f5230c02ef8a669237f1d5f1c9ed994de 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();
}
@@ -193,3 +194,108 @@ 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) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ FilePath test_doc(test_data_dir_.AppendASCII(
+ "platform_apps/test_files/test.txt"));
+ // 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
+ // clear any existing arguments and replace with our test file.
+ CommandLine::StringVector args = command_line->GetArgs();
+ CommandLine::StringVector argv = command_line->argv();
+ for (size_t i=0; i<args.size(); i++)
+ 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.
+ argv.push_back(test_doc.value());
+ command_line->InitFromArgv(argv);
+ 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) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ FilePath test_doc(test_data_dir_.AppendASCII(
+ "platform_apps/test_files/test.txt"));
+ // The command line already has arguments on it ("about:blank"). We want to
+ // clear any existing arguments and replace with our test file.
+ CommandLine::StringVector args = command_line->GetArgs();
+ CommandLine::StringVector argv = command_line->argv();
+ for (size_t i=0; i<args.size(); i++)
+ argv.pop_back();
+ argv.push_back(test_doc.value());
+ command_line->InitFromArgv(argv);
+ 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) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ FilePath test_doc(test_data_dir_.AppendASCII(
+ "platform_apps/test_files/test.txt"));
+ // The command line already has arguments on it ("about:blank"). We want to
+ // clear any existing arguments and replace with our test file.
+ CommandLine::StringVector args = command_line->GetArgs();
+ CommandLine::StringVector argv = command_line->argv();
+ for (size_t i=0; i<args.size(); i++)
+ argv.pop_back();
+ argv.push_back(test_doc.value());
+ command_line->InitFromArgv(argv);
+ 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) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ FilePath test_doc(test_data_dir_.AppendASCII(
+ "platform_apps/test_files/test.txt"));
+ // The command line already has arguments on it ("about:blank"). We want to
+ // clear any existing arguments and replace with our test file.
+ CommandLine::StringVector args = command_line->GetArgs();
+ CommandLine::StringVector argv = command_line->argv();
+ for (size_t i=0; i<args.size(); i++)
+ argv.pop_back();
+ argv.push_back(test_doc.value());
+ command_line->InitFromArgv(argv);
+ 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) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ FilePath test_doc(test_data_dir_.AppendASCII(
+ "platform_apps/test_files/test.unknownextension"));
+ // The command line already has arguments on it ("about:blank"). We want to
+ // clear any existing arguments and replace with our test file.
+ CommandLine::StringVector args = command_line->GetArgs();
+ CommandLine::StringVector argv = command_line->argv();
+ for (size_t i=0; i<args.size(); i++)
+ argv.pop_back();
+ argv.push_back(test_doc.value());
+ command_line->InitFromArgv(argv);
+ ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_no_type"))
+ << 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) {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ // The command line already has arguments on it ("about:blank"). We want to
+ // clear all of these.
+ CommandLine::StringVector args = command_line->GetArgs();
+ CommandLine::StringVector argv = command_line->argv();
+ for (size_t i=0; i<args.size(); i++)
+ argv.pop_back();
+ command_line->InitFromArgv(argv);
+ ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_nothing"))
+ << message_;
+}

Powered by Google App Engine
This is Rietveld 408576698