| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/threading/thread_restrictions.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 #include "chrome/app/chrome_command_ids.h" | 20 #include "chrome/app/chrome_command_ids.h" |
| 20 #include "chrome/browser/apps/app_browsertest_util.h" | 21 #include "chrome/browser/apps/app_browsertest_util.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/devtools/devtools_window.h" | 23 #include "chrome/browser/devtools/devtools_window.h" |
| 23 #include "chrome/browser/extensions/api/permissions/permissions_api.h" | 24 #include "chrome/browser/extensions/api/permissions/permissions_api.h" |
| 24 #include "chrome/browser/extensions/component_loader.h" | 25 #include "chrome/browser/extensions/component_loader.h" |
| 25 #include "chrome/browser/extensions/extension_browsertest.h" | 26 #include "chrome/browser/extensions/extension_browsertest.h" |
| 26 #include "chrome/browser/extensions/extension_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
| 27 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 28 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 ASSERT_TRUE(RunPlatformAppTestWithFileInTestDataDir( | 595 ASSERT_TRUE(RunPlatformAppTestWithFileInTestDataDir( |
| 595 "platform_apps/launch_file_with_no_extension", | 596 "platform_apps/launch_file_with_no_extension", |
| 596 "platform_apps/launch_files/test")) << message_; | 597 "platform_apps/launch_files/test")) << message_; |
| 597 } | 598 } |
| 598 | 599 |
| 599 #if !defined(OS_WIN) | 600 #if !defined(OS_WIN) |
| 600 // Tests that launch data is sent through for a file with an empty extension if | 601 // Tests that launch data is sent through for a file with an empty extension if |
| 601 // a handler accepts "". | 602 // a handler accepts "". |
| 602 IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, | 603 IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, |
| 603 LaunchWithFileEmptyExtension) { | 604 LaunchWithFileEmptyExtension) { |
| 605 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 604 base::ScopedTempDir temp_dir; | 606 base::ScopedTempDir temp_dir; |
| 605 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 607 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 606 base::FilePath test_file; | 608 base::FilePath test_file; |
| 607 ASSERT_TRUE( | 609 ASSERT_TRUE( |
| 608 CopyTestDataAndGetTestFilePath(test_data_dir_.AppendASCII(kTestFilePath), | 610 CopyTestDataAndGetTestFilePath(test_data_dir_.AppendASCII(kTestFilePath), |
| 609 temp_dir.GetPath(), "test.", &test_file)); | 611 temp_dir.GetPath(), "test.", &test_file)); |
| 610 ASSERT_TRUE(RunPlatformAppTestWithFile( | 612 ASSERT_TRUE(RunPlatformAppTestWithFile( |
| 611 "platform_apps/launch_file_with_no_extension", test_file)) << message_; | 613 "platform_apps/launch_file_with_no_extension", test_file)) << message_; |
| 612 } | 614 } |
| 613 | 615 |
| 614 // Tests that launch data is sent through for a file with an empty extension if | 616 // Tests that launch data is sent through for a file with an empty extension if |
| 615 // a handler accepts *. | 617 // a handler accepts *. |
| 616 IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, | 618 IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, |
| 617 LaunchWithFileEmptyExtensionAcceptAny) { | 619 LaunchWithFileEmptyExtensionAcceptAny) { |
| 620 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 618 base::ScopedTempDir temp_dir; | 621 base::ScopedTempDir temp_dir; |
| 619 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 622 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 620 base::FilePath test_file; | 623 base::FilePath test_file; |
| 621 ASSERT_TRUE( | 624 ASSERT_TRUE( |
| 622 CopyTestDataAndGetTestFilePath(test_data_dir_.AppendASCII(kTestFilePath), | 625 CopyTestDataAndGetTestFilePath(test_data_dir_.AppendASCII(kTestFilePath), |
| 623 temp_dir.GetPath(), "test.", &test_file)); | 626 temp_dir.GetPath(), "test.", &test_file)); |
| 624 ASSERT_TRUE(RunPlatformAppTestWithFile( | 627 ASSERT_TRUE(RunPlatformAppTestWithFile( |
| 625 "platform_apps/launch_file_with_any_extension", test_file)) << message_; | 628 "platform_apps/launch_file_with_any_extension", test_file)) << message_; |
| 626 } | 629 } |
| 627 #endif | 630 #endif |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 // Test that platform apps can use the chrome.fileSystem.getDisplayPath | 719 // Test that platform apps can use the chrome.fileSystem.getDisplayPath |
| 717 // function to get the native file system path of a file they are launched with. | 720 // function to get the native file system path of a file they are launched with. |
| 718 IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, GetDisplayPath) { | 721 IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, GetDisplayPath) { |
| 719 ASSERT_TRUE(RunPlatformAppTestWithFileInTestDataDir( | 722 ASSERT_TRUE(RunPlatformAppTestWithFileInTestDataDir( |
| 720 "platform_apps/get_display_path", kTestFilePath)) << message_; | 723 "platform_apps/get_display_path", kTestFilePath)) << message_; |
| 721 } | 724 } |
| 722 | 725 |
| 723 // Tests that the file is created if the file does not exist and the app has the | 726 // Tests that the file is created if the file does not exist and the app has the |
| 724 // fileSystem.write permission. | 727 // fileSystem.write permission. |
| 725 IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, LaunchNewFile) { | 728 IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, LaunchNewFile) { |
| 729 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 726 base::ScopedTempDir temp_dir; | 730 base::ScopedTempDir temp_dir; |
| 727 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 731 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 728 ASSERT_TRUE(RunPlatformAppTestWithFile( | 732 ASSERT_TRUE(RunPlatformAppTestWithFile( |
| 729 "platform_apps/launch_new_file", | 733 "platform_apps/launch_new_file", |
| 730 temp_dir.GetPath().AppendASCII("new_file.txt"))) | 734 temp_dir.GetPath().AppendASCII("new_file.txt"))) |
| 731 << message_; | 735 << message_; |
| 732 } | 736 } |
| 733 | 737 |
| 734 #endif // !defined(OS_CHROMEOS) | 738 #endif // !defined(OS_CHROMEOS) |
| 735 | 739 |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 } | 1365 } |
| 1362 | 1366 |
| 1363 // Sends chrome.test.sendMessage from chrome.app.window.create's callback. | 1367 // Sends chrome.test.sendMessage from chrome.app.window.create's callback. |
| 1364 // The app window also adds an <iframe> to the page during window.onload. | 1368 // The app window also adds an <iframe> to the page during window.onload. |
| 1365 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWindowIframe) { | 1369 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWindowIframe) { |
| 1366 LoadAndLaunchPlatformApp("app_window_send_message", | 1370 LoadAndLaunchPlatformApp("app_window_send_message", |
| 1367 "APP_WINDOW_CREATE_CALLBACK"); | 1371 "APP_WINDOW_CREATE_CALLBACK"); |
| 1368 } | 1372 } |
| 1369 | 1373 |
| 1370 } // namespace extensions | 1374 } // namespace extensions |
| OLD | NEW |