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

Side by Side Diff: chrome/browser/media_galleries/fileapi/picasa/picasa_file_util_unittest.cc

Issue 16413007: Make FileSystemOperation NOT self-destruct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser_tests Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 bool /*has_more*/) { 184 bool /*has_more*/) {
185 DCHECK(error_result); 185 DCHECK(error_result);
186 DCHECK(file_list_result); 186 DCHECK(file_list_result);
187 *error_result = error; 187 *error_result = error;
188 *file_list_result = file_list; 188 *file_list_result = file_list;
189 run_loop->Quit(); 189 run_loop->Quit();
190 } 190 }
191 191
192 base::PlatformFileError ReadDirectoryTestHelper( 192 base::PlatformFileError ReadDirectoryTestHelper(
193 fileapi::AsyncFileUtil* file_util, 193 fileapi::AsyncFileUtil* file_util,
194 FileSystemOperationContext* operation_context, 194 scoped_ptr<FileSystemOperationContext> operation_context,
195 FileSystemURL url, 195 FileSystemURL url,
196 fileapi::AsyncFileUtil::EntryList* file_list) { 196 fileapi::AsyncFileUtil::EntryList* file_list) {
197 base::RunLoop run_loop; 197 base::RunLoop run_loop;
198 base::PlatformFileError result; 198 base::PlatformFileError result;
199 file_util->ReadDirectory( 199 file_util->ReadDirectory(
200 operation_context, 200 operation_context.Pass(),
201 url, 201 url,
202 base::Bind(&ReadDirectoryTestCallback, &run_loop, &result, file_list)); 202 base::Bind(&ReadDirectoryTestCallback, &run_loop, &result, file_list));
203 run_loop.Run(); 203 run_loop.Run();
204 return result; 204 return result;
205 } 205 }
206 206
207 } // namespace 207 } // namespace
208 208
209 class PicasaFileUtilTest : public testing::Test { 209 class PicasaFileUtilTest : public testing::Test {
210 public: 210 public:
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 expected_names.push_back("duplicate " + test_date_string + " (1)"); 400 expected_names.push_back("duplicate " + test_date_string + " (1)");
401 401
402 folders.push_back( 402 folders.push_back(
403 AlbumInfo("duplicate", test_date, "uuid5", base::FilePath())); 403 AlbumInfo("duplicate", test_date, "uuid5", base::FilePath()));
404 expected_names.push_back("duplicate " + test_date_string + " (2)"); 404 expected_names.push_back("duplicate " + test_date_string + " (2)");
405 405
406 folders.push_back( 406 folders.push_back(
407 AlbumInfo("unique_name", test_date, "uuid1", base::FilePath())); 407 AlbumInfo("unique_name", test_date, "uuid1", base::FilePath()));
408 expected_names.push_back("unique_name " + test_date_string); 408 expected_names.push_back("unique_name " + test_date_string);
409 409
410 FileSystemOperationContext operation_context(file_system_context().get()); 410 scoped_ptr<FileSystemOperationContext> operation_context(
411 new FileSystemOperationContext(file_system_context().get()));
411 412
412 scoped_ptr<chrome::MediaPathFilter> media_path_filter( 413 scoped_ptr<chrome::MediaPathFilter> media_path_filter(
413 new chrome::MediaPathFilter()); 414 new chrome::MediaPathFilter());
414 415
415 operation_context.SetUserValue( 416 operation_context->SetUserValue(
416 chrome::MediaFileSystemMountPointProvider::kMediaPathFilterKey, 417 chrome::MediaFileSystemMountPointProvider::kMediaPathFilterKey,
417 media_path_filter.get()); 418 media_path_filter.get());
418 419
419 scoped_ptr<PicasaDataProvider> data_provider( 420 scoped_ptr<PicasaDataProvider> data_provider(
420 new TestPicasaDataProvider(std::vector<AlbumInfo>(), folders)); 421 new TestPicasaDataProvider(std::vector<AlbumInfo>(), folders));
421 TestPicasaFileUtil test_file_util(data_provider.Pass()); 422 TestPicasaFileUtil test_file_util(data_provider.Pass());
422 423
423 fileapi::AsyncFileUtil::EntryList file_list; 424 fileapi::AsyncFileUtil::EntryList file_list;
424 ASSERT_EQ(base::PLATFORM_FILE_OK, 425 ASSERT_EQ(base::PLATFORM_FILE_OK,
425 ReadDirectoryTestHelper(&test_file_util, &operation_context, 426 ReadDirectoryTestHelper(&test_file_util, operation_context.Pass(),
426 CreateURL(kPicasaDirFolders), 427 CreateURL(kPicasaDirFolders),
427 &file_list)); 428 &file_list));
428 429
429 ASSERT_EQ(expected_names.size(), file_list.size()); 430 ASSERT_EQ(expected_names.size(), file_list.size());
430 for (size_t i = 0; i < file_list.size(); ++i) { 431 for (size_t i = 0; i < file_list.size(); ++i) {
431 EXPECT_EQ(expected_names[i], 432 EXPECT_EQ(expected_names[i],
432 base::FilePath(file_list[i].name).AsUTF8Unsafe()); 433 base::FilePath(file_list[i].name).AsUTF8Unsafe());
433 EXPECT_EQ(folders[i].timestamp, file_list[i].last_modified_time); 434 EXPECT_EQ(folders[i].timestamp, file_list[i].last_modified_time);
434 EXPECT_TRUE(file_list[i].is_directory); 435 EXPECT_TRUE(file_list[i].is_directory);
435 } 436 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 new TestFolder(base::StringPrintf("folder-%05d", i), 507 new TestFolder(base::StringPrintf("folder-%05d", i),
507 date, 508 date,
508 base::StringPrintf("uid%05d", i), i % 5, i % 3)); 509 base::StringPrintf("uid%05d", i), i % 5, i % 3));
509 } 510 }
510 511
511 SetupFolders(&test_folders); 512 SetupFolders(&test_folders);
512 VerifyFolderDirectoryList(test_folders); 513 VerifyFolderDirectoryList(test_folders);
513 } 514 }
514 515
515 } // namespace picasa 516 } // namespace picasa
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/fileapi/native_media_file_util.cc ('k') | content/browser/fileapi/fileapi_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698