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 "apps/saved_files_service.h" | 5 #include "apps/saved_files_service.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/scoped_observer.h" | 9 #include "base/scoped_observer.h" |
| 10 #include "base/threading/thread_restrictions.h" |
10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
11 #include "chrome/browser/apps/app_browsertest_util.h" | 12 #include "chrome/browser/apps/app_browsertest_util.h" |
12 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 13 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
15 #include "extensions/browser/extension_prefs.h" | 16 #include "extensions/browser/extension_prefs.h" |
16 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
17 #include "extensions/browser/extension_registry_observer.h" | 18 #include "extensions/browser/extension_registry_observer.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 79 } |
79 | 80 |
80 void TearDown() override { | 81 void TearDown() override { |
81 FileSystemChooseEntryFunction::StopSkippingPickerForTest(); | 82 FileSystemChooseEntryFunction::StopSkippingPickerForTest(); |
82 PlatformAppBrowserTest::TearDown(); | 83 PlatformAppBrowserTest::TearDown(); |
83 }; | 84 }; |
84 | 85 |
85 protected: | 86 protected: |
86 base::FilePath TempFilePath(const std::string& destination_name, | 87 base::FilePath TempFilePath(const std::string& destination_name, |
87 bool copy_gold) { | 88 bool copy_gold) { |
| 89 base::ThreadRestrictions::ScopedAllowIO allow_io; |
88 if (!temp_dir_.CreateUniqueTempDir()) { | 90 if (!temp_dir_.CreateUniqueTempDir()) { |
89 ADD_FAILURE() << "CreateUniqueTempDir failed"; | 91 ADD_FAILURE() << "CreateUniqueTempDir failed"; |
90 return base::FilePath(); | 92 return base::FilePath(); |
91 } | 93 } |
92 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( | 94 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
93 "test_temp", temp_dir_.GetPath()); | 95 "test_temp", temp_dir_.GetPath()); |
94 | 96 |
95 base::FilePath destination = | 97 base::FilePath destination = |
96 temp_dir_.GetPath().AppendASCII(destination_name); | 98 temp_dir_.GetPath().AppendASCII(destination_name); |
97 if (copy_gold) { | 99 if (copy_gold) { |
98 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); | 100 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); |
99 EXPECT_TRUE(base::CopyFile(source, destination)); | 101 EXPECT_TRUE(base::CopyFile(source, destination)); |
100 } | 102 } |
101 return destination; | 103 return destination; |
102 } | 104 } |
103 | 105 |
104 std::vector<base::FilePath> TempFilePaths( | 106 std::vector<base::FilePath> TempFilePaths( |
105 const std::vector<std::string>& destination_names, | 107 const std::vector<std::string>& destination_names, |
106 bool copy_gold) { | 108 bool copy_gold) { |
| 109 base::ThreadRestrictions::ScopedAllowIO allow_io; |
107 if (!temp_dir_.CreateUniqueTempDir()) { | 110 if (!temp_dir_.CreateUniqueTempDir()) { |
108 ADD_FAILURE() << "CreateUniqueTempDir failed"; | 111 ADD_FAILURE() << "CreateUniqueTempDir failed"; |
109 return std::vector<base::FilePath>(); | 112 return std::vector<base::FilePath>(); |
110 } | 113 } |
111 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( | 114 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
112 "test_temp", temp_dir_.GetPath()); | 115 "test_temp", temp_dir_.GetPath()); |
113 | 116 |
114 std::vector<base::FilePath> result; | 117 std::vector<base::FilePath> result; |
115 for (std::vector<std::string>::const_iterator it = | 118 for (std::vector<std::string>::const_iterator it = |
116 destination_names.begin(); | 119 destination_names.begin(); |
117 it != destination_names.end(); ++it) { | 120 it != destination_names.end(); ++it) { |
118 base::FilePath destination = temp_dir_.GetPath().AppendASCII(*it); | 121 base::FilePath destination = temp_dir_.GetPath().AppendASCII(*it); |
119 if (copy_gold) { | 122 if (copy_gold) { |
120 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); | 123 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); |
121 EXPECT_TRUE(base::CopyFile(source, destination)); | 124 EXPECT_TRUE(base::CopyFile(source, destination)); |
122 } | 125 } |
123 result.push_back(destination); | 126 result.push_back(destination); |
124 } | 127 } |
125 return result; | 128 return result; |
126 } | 129 } |
127 | 130 |
128 void CheckStoredDirectoryMatches(const base::FilePath& filename) { | 131 void CheckStoredDirectoryMatches(const base::FilePath& filename) { |
| 132 base::ThreadRestrictions::ScopedAllowIO allow_io; |
129 const Extension* extension = GetSingleLoadedExtension(); | 133 const Extension* extension = GetSingleLoadedExtension(); |
130 ASSERT_TRUE(extension); | 134 ASSERT_TRUE(extension); |
131 std::string extension_id = extension->id(); | 135 std::string extension_id = extension->id(); |
132 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 136 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
133 base::FilePath stored_value = | 137 base::FilePath stored_value = |
134 file_system_api::GetLastChooseEntryDirectory(prefs, extension_id); | 138 file_system_api::GetLastChooseEntryDirectory(prefs, extension_id); |
135 if (filename.empty()) { | 139 if (filename.empty()) { |
136 EXPECT_TRUE(stored_value.empty()); | 140 EXPECT_TRUE(stored_value.empty()); |
137 } else { | 141 } else { |
138 EXPECT_EQ(base::MakeAbsoluteFilePath(filename.DirName()), | 142 EXPECT_EQ(base::MakeAbsoluteFilePath(filename.DirName()), |
139 base::MakeAbsoluteFilePath(stored_value)); | 143 base::MakeAbsoluteFilePath(stored_value)); |
140 } | 144 } |
141 } | 145 } |
142 | 146 |
143 base::FilePath test_root_folder_; | 147 base::FilePath test_root_folder_; |
144 base::ScopedTempDir temp_dir_; | 148 base::ScopedTempDir temp_dir_; |
145 }; | 149 }; |
146 | 150 |
147 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetDisplayPath) { | 151 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetDisplayPath) { |
148 base::FilePath test_file = test_root_folder_.AppendASCII("gold.txt"); | 152 base::FilePath test_file = test_root_folder_.AppendASCII("gold.txt"); |
149 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 153 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
150 &test_file); | 154 &test_file); |
151 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/get_display_path")) | 155 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/get_display_path")) |
152 << message_; | 156 << message_; |
153 } | 157 } |
154 | 158 |
155 #if defined(OS_WIN) || defined(OS_POSIX) | 159 #if defined(OS_WIN) || defined(OS_POSIX) |
156 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetDisplayPathPrettify) { | 160 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetDisplayPathPrettify) { |
157 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(base::DIR_HOME, | 161 { |
158 test_root_folder_, false, false)); | 162 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 163 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 164 base::DIR_HOME, test_root_folder_, false, false)); |
| 165 } |
159 | 166 |
160 base::FilePath test_file = test_root_folder_.AppendASCII("gold.txt"); | 167 base::FilePath test_file = test_root_folder_.AppendASCII("gold.txt"); |
161 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 168 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
162 &test_file); | 169 &test_file); |
163 ASSERT_TRUE(RunPlatformAppTest( | 170 ASSERT_TRUE(RunPlatformAppTest( |
164 "api_test/file_system/get_display_path_prettify")) << message_; | 171 "api_test/file_system/get_display_path_prettify")) << message_; |
165 } | 172 } |
166 #endif | 173 #endif |
167 | 174 |
168 #if defined(OS_MACOSX) | 175 #if defined(OS_MACOSX) |
169 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 176 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
170 FileSystemApiGetDisplayPathPrettifyMac) { | 177 FileSystemApiGetDisplayPathPrettifyMac) { |
171 // On Mac, "test.localized" will be localized into just "test". | 178 base::FilePath test_file; |
172 base::FilePath test_path = TempFilePath("test.localized", false); | 179 { |
173 ASSERT_TRUE(base::CreateDirectory(test_path)); | 180 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 181 // On Mac, "test.localized" will be localized into just "test". |
| 182 base::FilePath test_path = TempFilePath("test.localized", false); |
| 183 ASSERT_TRUE(base::CreateDirectory(test_path)); |
174 | 184 |
175 base::FilePath test_file = test_path.AppendASCII("gold.txt"); | 185 test_file = test_path.AppendASCII("gold.txt"); |
176 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); | 186 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); |
177 EXPECT_TRUE(base::CopyFile(source, test_file)); | 187 EXPECT_TRUE(base::CopyFile(source, test_file)); |
| 188 } |
178 | 189 |
179 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 190 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
180 &test_file); | 191 &test_file); |
181 ASSERT_TRUE(RunPlatformAppTest( | 192 ASSERT_TRUE(RunPlatformAppTest( |
182 "api_test/file_system/get_display_path_prettify_mac")) << message_; | 193 "api_test/file_system/get_display_path_prettify_mac")) << message_; |
183 } | 194 } |
184 #endif | 195 #endif |
185 | 196 |
186 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenExistingFileTest) { | 197 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenExistingFileTest) { |
187 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 198 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
(...skipping 19 matching lines...) Expand all Loading... |
207 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing")) | 218 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing")) |
208 << message_; | 219 << message_; |
209 } | 220 } |
210 CheckStoredDirectoryMatches(test_file); | 221 CheckStoredDirectoryMatches(test_file); |
211 } | 222 } |
212 | 223 |
213 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 224 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
214 FileSystemApiOpenExistingFilePreviousPathDoesNotExistTest) { | 225 FileSystemApiOpenExistingFilePreviousPathDoesNotExistTest) { |
215 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 226 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
216 ASSERT_FALSE(test_file.empty()); | 227 ASSERT_FALSE(test_file.empty()); |
217 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( | 228 { |
218 chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false, false)); | 229 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 230 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 231 chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false, false)); |
| 232 } |
219 FileSystemChooseEntryFunction:: | 233 FileSystemChooseEntryFunction:: |
220 SkipPickerAndSelectSuggestedPathForTest(); | 234 SkipPickerAndSelectSuggestedPathForTest(); |
221 { | 235 { |
222 AppLoadObserver observer( | 236 AppLoadObserver observer( |
223 profile(), | 237 profile(), |
224 base::Bind(SetLastChooseEntryDirectory, | 238 base::Bind(SetLastChooseEntryDirectory, |
225 test_file.DirName().Append(base::FilePath::FromUTF8Unsafe( | 239 test_file.DirName().Append(base::FilePath::FromUTF8Unsafe( |
226 "fake_directory_does_not_exist")), | 240 "fake_directory_does_not_exist")), |
227 ExtensionPrefs::Get(profile()))); | 241 ExtensionPrefs::Get(profile()))); |
228 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing")) | 242 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing")) |
229 << message_; | 243 << message_; |
230 } | 244 } |
231 CheckStoredDirectoryMatches(test_file); | 245 CheckStoredDirectoryMatches(test_file); |
232 } | 246 } |
233 | 247 |
234 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 248 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
235 FileSystemApiOpenExistingFileDefaultPathTest) { | 249 FileSystemApiOpenExistingFileDefaultPathTest) { |
236 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 250 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
237 ASSERT_FALSE(test_file.empty()); | 251 ASSERT_FALSE(test_file.empty()); |
238 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( | 252 { |
239 chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false, false)); | 253 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 254 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 255 chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false, false)); |
| 256 } |
240 FileSystemChooseEntryFunction:: | 257 FileSystemChooseEntryFunction:: |
241 SkipPickerAndSelectSuggestedPathForTest(); | 258 SkipPickerAndSelectSuggestedPathForTest(); |
242 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing")) | 259 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing")) |
243 << message_; | 260 << message_; |
244 CheckStoredDirectoryMatches(test_file); | 261 CheckStoredDirectoryMatches(test_file); |
245 } | 262 } |
246 | 263 |
247 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenMultipleSuggested) { | 264 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenMultipleSuggested) { |
248 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 265 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
249 ASSERT_FALSE(test_file.empty()); | 266 ASSERT_FALSE(test_file.empty()); |
250 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( | 267 { |
251 chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false, false)); | 268 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 269 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 270 chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false, false)); |
| 271 } |
252 FileSystemChooseEntryFunction::SkipPickerAndSelectSuggestedPathForTest(); | 272 FileSystemChooseEntryFunction::SkipPickerAndSelectSuggestedPathForTest(); |
253 ASSERT_TRUE(RunPlatformAppTest( | 273 ASSERT_TRUE(RunPlatformAppTest( |
254 "api_test/file_system/open_multiple_with_suggested_name")) | 274 "api_test/file_system/open_multiple_with_suggested_name")) |
255 << message_; | 275 << message_; |
256 CheckStoredDirectoryMatches(test_file); | 276 CheckStoredDirectoryMatches(test_file); |
257 } | 277 } |
258 | 278 |
259 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 279 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
260 FileSystemApiOpenMultipleExistingFilesTest) { | 280 FileSystemApiOpenMultipleExistingFilesTest) { |
261 std::vector<std::string> names; | 281 std::vector<std::string> names; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 CheckStoredDirectoryMatches(base::FilePath()); | 339 CheckStoredDirectoryMatches(base::FilePath()); |
320 } | 340 } |
321 | 341 |
322 #if defined(OS_WIN) || defined(OS_POSIX) | 342 #if defined(OS_WIN) || defined(OS_POSIX) |
323 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 343 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
324 FileSystemApiOpenDirectoryOnGraylistAndAllowTest) { | 344 FileSystemApiOpenDirectoryOnGraylistAndAllowTest) { |
325 FileSystemChooseEntryFunction::SkipDirectoryConfirmationForTest(); | 345 FileSystemChooseEntryFunction::SkipDirectoryConfirmationForTest(); |
326 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 346 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
327 ASSERT_FALSE(test_file.empty()); | 347 ASSERT_FALSE(test_file.empty()); |
328 base::FilePath test_directory = test_file.DirName(); | 348 base::FilePath test_directory = test_file.DirName(); |
329 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( | 349 { |
330 kGraylistedPath, test_directory, false, false)); | 350 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 351 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 352 kGraylistedPath, test_directory, false, false)); |
| 353 } |
331 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 354 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
332 &test_directory); | 355 &test_directory); |
333 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_directory")) | 356 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_directory")) |
334 << message_; | 357 << message_; |
335 CheckStoredDirectoryMatches(test_file); | 358 CheckStoredDirectoryMatches(test_file); |
336 } | 359 } |
337 | 360 |
338 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 361 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
339 FileSystemApiOpenDirectoryOnGraylistTest) { | 362 FileSystemApiOpenDirectoryOnGraylistTest) { |
340 FileSystemChooseEntryFunction::AutoCancelDirectoryConfirmationForTest(); | 363 FileSystemChooseEntryFunction::AutoCancelDirectoryConfirmationForTest(); |
341 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 364 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
342 ASSERT_FALSE(test_file.empty()); | 365 ASSERT_FALSE(test_file.empty()); |
343 base::FilePath test_directory = test_file.DirName(); | 366 base::FilePath test_directory = test_file.DirName(); |
344 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( | 367 { |
345 kGraylistedPath, test_directory, false, false)); | 368 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 369 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 370 kGraylistedPath, test_directory, false, false)); |
| 371 } |
346 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 372 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
347 &test_directory); | 373 &test_directory); |
348 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_directory_cancel")) | 374 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_directory_cancel")) |
349 << message_; | 375 << message_; |
350 CheckStoredDirectoryMatches(test_file); | 376 CheckStoredDirectoryMatches(test_file); |
351 } | 377 } |
352 | 378 |
353 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 379 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
354 FileSystemApiOpenDirectoryContainingGraylistTest) { | 380 FileSystemApiOpenDirectoryContainingGraylistTest) { |
355 FileSystemChooseEntryFunction::AutoCancelDirectoryConfirmationForTest(); | 381 FileSystemChooseEntryFunction::AutoCancelDirectoryConfirmationForTest(); |
356 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 382 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
357 ASSERT_FALSE(test_file.empty()); | 383 ASSERT_FALSE(test_file.empty()); |
358 base::FilePath test_directory = test_file.DirName(); | 384 base::FilePath test_directory = test_file.DirName(); |
359 base::FilePath parent_directory = test_directory.DirName(); | 385 base::FilePath parent_directory = test_directory.DirName(); |
360 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( | 386 { |
361 kGraylistedPath, test_directory, false, false)); | 387 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 388 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 389 kGraylistedPath, test_directory, false, false)); |
| 390 } |
362 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 391 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
363 &parent_directory); | 392 &parent_directory); |
364 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_directory_cancel")) | 393 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_directory_cancel")) |
365 << message_; | 394 << message_; |
366 CheckStoredDirectoryMatches(test_directory); | 395 CheckStoredDirectoryMatches(test_directory); |
367 } | 396 } |
368 | 397 |
369 // Test that choosing a subdirectory of a path does not require confirmation. | 398 // Test that choosing a subdirectory of a path does not require confirmation. |
370 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 399 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
371 FileSystemApiOpenDirectorySubdirectoryOfGraylistTest) { | 400 FileSystemApiOpenDirectorySubdirectoryOfGraylistTest) { |
372 // If a dialog is erroneously displayed, auto cancel it, so that the test | 401 // If a dialog is erroneously displayed, auto cancel it, so that the test |
373 // fails. | 402 // fails. |
374 FileSystemChooseEntryFunction::AutoCancelDirectoryConfirmationForTest(); | 403 FileSystemChooseEntryFunction::AutoCancelDirectoryConfirmationForTest(); |
375 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 404 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
376 ASSERT_FALSE(test_file.empty()); | 405 ASSERT_FALSE(test_file.empty()); |
377 base::FilePath test_directory = test_file.DirName(); | 406 base::FilePath test_directory = test_file.DirName(); |
378 base::FilePath parent_directory = test_directory.DirName(); | 407 base::FilePath parent_directory = test_directory.DirName(); |
379 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( | 408 { |
380 kGraylistedPath, parent_directory, false, false)); | 409 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 410 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 411 kGraylistedPath, parent_directory, false, false)); |
| 412 } |
381 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 413 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
382 &test_directory); | 414 &test_directory); |
383 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_directory")) | 415 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_directory")) |
384 << message_; | 416 << message_; |
385 CheckStoredDirectoryMatches(test_file); | 417 CheckStoredDirectoryMatches(test_file); |
386 } | 418 } |
387 #endif // defined(OS_WIN) || defined(OS_POSIX) | 419 #endif // defined(OS_WIN) || defined(OS_POSIX) |
388 | 420 |
389 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 421 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
390 FileSystemApiInvalidChooseEntryTypeTest) { | 422 FileSystemApiInvalidChooseEntryTypeTest) { |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 #if !defined(OS_CHROMEOS) | 671 #if !defined(OS_CHROMEOS) |
640 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, RequestFileSystem_NotChromeOS) { | 672 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, RequestFileSystem_NotChromeOS) { |
641 ASSERT_TRUE(RunPlatformAppTestWithFlags( | 673 ASSERT_TRUE(RunPlatformAppTestWithFlags( |
642 "api_test/file_system/request_file_system_not_chromeos", | 674 "api_test/file_system/request_file_system_not_chromeos", |
643 kFlagIgnoreManifestWarnings)) | 675 kFlagIgnoreManifestWarnings)) |
644 << message_; | 676 << message_; |
645 } | 677 } |
646 #endif | 678 #endif |
647 | 679 |
648 } // namespace extensions | 680 } // namespace extensions |
OLD | NEW |