| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 8 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 10 | 10 |
| 11 using extensions::FileSystemChooseEntryFunction; | 11 using extensions::FileSystemChooseEntryFunction; |
| 12 | 12 |
| 13 class FileSystemApiTest : public extensions::PlatformAppBrowserTest { | 13 class FileSystemApiTest : public extensions::PlatformAppBrowserTest { |
| 14 public: | 14 public: |
| 15 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 15 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 16 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); | 16 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 17 test_root_folder_ = test_data_dir_.AppendASCII("api_test") | 17 test_root_folder_ = test_data_dir_.AppendASCII("api_test") |
| 18 .AppendASCII("file_system"); | 18 .AppendASCII("file_system"); |
| 19 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
| 20 "test_root", test_root_folder_); |
| 19 } | 21 } |
| 20 | 22 |
| 21 virtual void TearDown() OVERRIDE { | 23 virtual void TearDown() OVERRIDE { |
| 22 FileSystemChooseEntryFunction::StopSkippingPickerForTest(); | 24 FileSystemChooseEntryFunction::StopSkippingPickerForTest(); |
| 23 extensions::PlatformAppBrowserTest::TearDown(); | 25 extensions::PlatformAppBrowserTest::TearDown(); |
| 24 }; | 26 }; |
| 25 | 27 |
| 26 protected: | 28 protected: |
| 27 base::FilePath TempFilePath(const std::string& destination_name, | 29 base::FilePath TempFilePath(const std::string& destination_name, |
| 28 bool copy_gold) { | 30 bool copy_gold) { |
| 29 if (!temp_dir_.CreateUniqueTempDir()) { | 31 if (!temp_dir_.CreateUniqueTempDir()) { |
| 30 ADD_FAILURE() << "CreateUniqueTempDir failed"; | 32 ADD_FAILURE() << "CreateUniqueTempDir failed"; |
| 31 return base::FilePath(); | 33 return base::FilePath(); |
| 32 } | 34 } |
| 35 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
| 36 "test_temp", temp_dir_.path()); |
| 37 |
| 33 base::FilePath destination = temp_dir_.path().AppendASCII(destination_name); | 38 base::FilePath destination = temp_dir_.path().AppendASCII(destination_name); |
| 34 if (copy_gold) { | 39 if (copy_gold) { |
| 35 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); | 40 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); |
| 36 EXPECT_TRUE(file_util::CopyFile(source, destination)); | 41 EXPECT_TRUE(file_util::CopyFile(source, destination)); |
| 37 } | 42 } |
| 38 return destination; | 43 return destination; |
| 39 } | 44 } |
| 40 | 45 |
| 41 base::FilePath test_root_folder_; | 46 base::FilePath test_root_folder_; |
| 42 base::ScopedTempDir temp_dir_; | 47 base::ScopedTempDir temp_dir_; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 229 } |
| 225 | 230 |
| 226 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetEntryId) { | 231 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetEntryId) { |
| 227 base::FilePath test_file = TempFilePath("writable.txt", true); | 232 base::FilePath test_file = TempFilePath("writable.txt", true); |
| 228 ASSERT_FALSE(test_file.empty()); | 233 ASSERT_FALSE(test_file.empty()); |
| 229 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 234 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
| 230 &test_file); | 235 &test_file); |
| 231 ASSERT_TRUE(RunPlatformAppTest( | 236 ASSERT_TRUE(RunPlatformAppTest( |
| 232 "api_test/file_system/get_entry_id")) << message_; | 237 "api_test/file_system/get_entry_id")) << message_; |
| 233 } | 238 } |
| OLD | NEW |