| 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 #include "apps/launcher.h" | 5 #include "apps/launcher.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 #if !defined(OS_CHROMEOS) && !defined(OS_WIN) | 176 #if !defined(OS_CHROMEOS) && !defined(OS_WIN) |
| 177 bool CopyTestDataAndSetCommandLineArg( | 177 bool CopyTestDataAndSetCommandLineArg( |
| 178 const base::FilePath& test_data_file, | 178 const base::FilePath& test_data_file, |
| 179 const base::FilePath& temp_dir, | 179 const base::FilePath& temp_dir, |
| 180 const char* filename) { | 180 const char* filename) { |
| 181 base::FilePath path = temp_dir.AppendASCII( | 181 base::FilePath path = temp_dir.AppendASCII( |
| 182 filename).NormalizePathSeparators(); | 182 filename).NormalizePathSeparators(); |
| 183 if (!(base::CopyFile(test_data_file, path))) | 183 if (!(base::CopyFile(test_data_file, path))) |
| 184 return false; | 184 return false; |
| 185 | 185 |
| 186 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 186 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 187 command_line->AppendArgPath(path); | 187 command_line->AppendArgPath(path); |
| 188 return true; | 188 return true; |
| 189 } | 189 } |
| 190 #endif // !defined(OS_CHROMEOS) && !defined(OS_WIN) | 190 #endif // !defined(OS_CHROMEOS) && !defined(OS_WIN) |
| 191 | 191 |
| 192 #if !defined(OS_CHROMEOS) | 192 #if !defined(OS_CHROMEOS) |
| 193 const char kTestFilePath[] = "platform_apps/launch_files/test.txt"; | 193 const char kTestFilePath[] = "platform_apps/launch_files/test.txt"; |
| 194 #endif | 194 #endif |
| 195 | 195 |
| 196 } // namespace | 196 } // namespace |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 << message_; | 489 << message_; |
| 490 } | 490 } |
| 491 | 491 |
| 492 // Tests that relative paths can be passed through to the platform app. | 492 // Tests that relative paths can be passed through to the platform app. |
| 493 // This test doesn't use the normal test infrastructure as it needs to open | 493 // This test doesn't use the normal test infrastructure as it needs to open |
| 494 // the application differently to all other platform app tests, by setting | 494 // the application differently to all other platform app tests, by setting |
| 495 // the AppLaunchParams.current_directory field. | 495 // the AppLaunchParams.current_directory field. |
| 496 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithRelativeFile) { | 496 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithRelativeFile) { |
| 497 // Setup the command line | 497 // Setup the command line |
| 498 ClearCommandLineArgs(); | 498 ClearCommandLineArgs(); |
| 499 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 499 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 500 base::FilePath relative_test_doc = | 500 base::FilePath relative_test_doc = |
| 501 base::FilePath::FromUTF8Unsafe(kTestFilePath); | 501 base::FilePath::FromUTF8Unsafe(kTestFilePath); |
| 502 relative_test_doc = relative_test_doc.NormalizePathSeparators(); | 502 relative_test_doc = relative_test_doc.NormalizePathSeparators(); |
| 503 command_line->AppendArgPath(relative_test_doc); | 503 command_line->AppendArgPath(relative_test_doc); |
| 504 | 504 |
| 505 // Load the extension | 505 // Load the extension |
| 506 ResultCatcher catcher; | 506 ResultCatcher catcher; |
| 507 const Extension* extension = LoadExtension( | 507 const Extension* extension = LoadExtension( |
| 508 test_data_dir_.AppendASCII("platform_apps/launch_file")); | 508 test_data_dir_.AppendASCII("platform_apps/launch_file")); |
| 509 ASSERT_TRUE(extension); | 509 ASSERT_TRUE(extension); |
| 510 | 510 |
| 511 // Run the test | 511 // Run the test |
| 512 AppLaunchParams params(browser()->profile(), extension, LAUNCH_CONTAINER_NONE, | 512 AppLaunchParams params(browser()->profile(), extension, LAUNCH_CONTAINER_NONE, |
| 513 NEW_WINDOW, extensions::SOURCE_TEST); | 513 NEW_WINDOW, extensions::SOURCE_TEST); |
| 514 params.command_line = *CommandLine::ForCurrentProcess(); | 514 params.command_line = *base::CommandLine::ForCurrentProcess(); |
| 515 params.current_directory = test_data_dir_; | 515 params.current_directory = test_data_dir_; |
| 516 OpenApplication(params); | 516 OpenApplication(params); |
| 517 | 517 |
| 518 if (!catcher.GetNextResult()) { | 518 if (!catcher.GetNextResult()) { |
| 519 message_ = catcher.message(); | 519 message_ = catcher.message(); |
| 520 ASSERT_TRUE(0); | 520 ASSERT_TRUE(0); |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 // Tests that launch data is sent through if the file extension matches. | 524 // Tests that launch data is sent through if the file extension matches. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 ASSERT_TRUE(RunPlatformAppTest("platform_apps/get_display_path")) | 688 ASSERT_TRUE(RunPlatformAppTest("platform_apps/get_display_path")) |
| 689 << message_; | 689 << message_; |
| 690 } | 690 } |
| 691 | 691 |
| 692 // Tests that the file is created if the file does not exist and the app has the | 692 // Tests that the file is created if the file does not exist and the app has the |
| 693 // fileSystem.write permission. | 693 // fileSystem.write permission. |
| 694 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNewFile) { | 694 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchNewFile) { |
| 695 base::ScopedTempDir temp_dir; | 695 base::ScopedTempDir temp_dir; |
| 696 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 696 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 697 ClearCommandLineArgs(); | 697 ClearCommandLineArgs(); |
| 698 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 698 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 699 command_line->AppendArgPath(temp_dir.path().AppendASCII("new_file.txt")); | 699 command_line->AppendArgPath(temp_dir.path().AppendASCII("new_file.txt")); |
| 700 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_new_file")) << message_; | 700 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_new_file")) << message_; |
| 701 } | 701 } |
| 702 | 702 |
| 703 #endif // !defined(OS_CHROMEOS) | 703 #endif // !defined(OS_CHROMEOS) |
| 704 | 704 |
| 705 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { | 705 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { |
| 706 ASSERT_TRUE(StartEmbeddedTestServer()); | 706 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 707 content::WindowedNotificationObserver observer( | 707 content::WindowedNotificationObserver observer( |
| 708 chrome::NOTIFICATION_TAB_ADDED, | 708 chrome::NOTIFICATION_TAB_ADDED, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 | 857 |
| 858 // http://crbug.com/246634 | 858 // http://crbug.com/246634 |
| 859 #if defined(OS_CHROMEOS) | 859 #if defined(OS_CHROMEOS) |
| 860 #define MAYBE_ReOpenedWithID DISABLED_ReOpenedWithID | 860 #define MAYBE_ReOpenedWithID DISABLED_ReOpenedWithID |
| 861 #else | 861 #else |
| 862 #define MAYBE_ReOpenedWithID ReOpenedWithID | 862 #define MAYBE_ReOpenedWithID ReOpenedWithID |
| 863 #endif | 863 #endif |
| 864 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, MAYBE_ReOpenedWithID) { | 864 IN_PROC_BROWSER_TEST_F(PlatformAppDevToolsBrowserTest, MAYBE_ReOpenedWithID) { |
| 865 #if defined(OS_WIN) && defined(USE_ASH) | 865 #if defined(OS_WIN) && defined(USE_ASH) |
| 866 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 866 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 867 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 867 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 868 switches::kAshBrowserTests)) |
| 868 return; | 869 return; |
| 869 #endif | 870 #endif |
| 870 RunTestWithDevTools("minimal_id", RELAUNCH | HAS_ID); | 871 RunTestWithDevTools("minimal_id", RELAUNCH | HAS_ID); |
| 871 } | 872 } |
| 872 | 873 |
| 873 // http://crbug.com/246999 | 874 // http://crbug.com/246999 |
| 874 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 875 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 875 #define MAYBE_ReOpenedWithURL DISABLED_ReOpenedWithURL | 876 #define MAYBE_ReOpenedWithURL DISABLED_ReOpenedWithURL |
| 876 #else | 877 #else |
| 877 #define MAYBE_ReOpenedWithURL ReOpenedWithURL | 878 #define MAYBE_ReOpenedWithURL ReOpenedWithURL |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 minimum_dialog_size.height()); | 1173 minimum_dialog_size.height()); |
| 1173 GetFirstAppWindow()->GetBaseWindow()->Close(); | 1174 GetFirstAppWindow()->GetBaseWindow()->Close(); |
| 1174 } | 1175 } |
| 1175 #endif // ENABLE_PRINT_PREVIEW | 1176 #endif // ENABLE_PRINT_PREVIEW |
| 1176 | 1177 |
| 1177 #if defined(OS_CHROMEOS) | 1178 #if defined(OS_CHROMEOS) |
| 1178 | 1179 |
| 1179 class PlatformAppIncognitoBrowserTest : public PlatformAppBrowserTest, | 1180 class PlatformAppIncognitoBrowserTest : public PlatformAppBrowserTest, |
| 1180 public AppWindowRegistry::Observer { | 1181 public AppWindowRegistry::Observer { |
| 1181 public: | 1182 public: |
| 1182 virtual void SetUpCommandLine(CommandLine* command_line) override { | 1183 virtual void SetUpCommandLine(base::CommandLine* command_line) override { |
| 1183 // Tell chromeos to launch in Guest mode, aka incognito. | 1184 // Tell chromeos to launch in Guest mode, aka incognito. |
| 1184 command_line->AppendSwitch(switches::kIncognito); | 1185 command_line->AppendSwitch(switches::kIncognito); |
| 1185 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 1186 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 1186 } | 1187 } |
| 1187 virtual void SetUp() override { | 1188 virtual void SetUp() override { |
| 1188 // Make sure the file manager actually gets loaded. | 1189 // Make sure the file manager actually gets loaded. |
| 1189 ComponentLoader::EnableBackgroundExtensionsForTesting(); | 1190 ComponentLoader::EnableBackgroundExtensionsForTesting(); |
| 1190 PlatformAppBrowserTest::SetUp(); | 1191 PlatformAppBrowserTest::SetUp(); |
| 1191 } | 1192 } |
| 1192 | 1193 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 LoadAndLaunchPlatformApp("reinstall_data_cleanup", "Launched"); | 1329 LoadAndLaunchPlatformApp("reinstall_data_cleanup", "Launched"); |
| 1329 ASSERT_TRUE(extension); | 1330 ASSERT_TRUE(extension); |
| 1330 ASSERT_EQ(extension_id, extension->id()); | 1331 ASSERT_EQ(extension_id, extension->id()); |
| 1331 | 1332 |
| 1332 ResultCatcher result_catcher; | 1333 ResultCatcher result_catcher; |
| 1333 EXPECT_TRUE(result_catcher.GetNextResult()); | 1334 EXPECT_TRUE(result_catcher.GetNextResult()); |
| 1334 } | 1335 } |
| 1335 } | 1336 } |
| 1336 | 1337 |
| 1337 } // namespace extensions | 1338 } // namespace extensions |
| OLD | NEW |