Chromium Code Reviews| 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 using fileapi::FileSystemOperationContext; | 40 using fileapi::FileSystemOperationContext; |
| 41 using fileapi::FileSystemOperation; | 41 using fileapi::FileSystemOperation; |
| 42 using fileapi::FileSystemURL; | 42 using fileapi::FileSystemURL; |
| 43 | 43 |
| 44 namespace picasa { | 44 namespace picasa { |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 base::Time::Exploded test_date_exploded = { 2013, 4, 0, 16, 0, 0, 0, 0 }; | 48 base::Time::Exploded test_date_exploded = { 2013, 4, 0, 16, 0, 0, 0, 0 }; |
| 49 | 49 |
| 50 // Defined up here because used by TestFolder. | |
|
Greg Billock
2013/08/21 17:13:17
can omit comment
tommycli
2013/08/21 21:37:06
Done.
| |
| 51 bool WriteJPEGHeader(const base::FilePath& path) { | |
| 52 const char kJpegHeader[] = "\xFF\xD8\xFF"; // Per HTML5 specification. | |
| 53 return file_util::WriteFile(path, kJpegHeader, arraysize(kJpegHeader)) != -1; | |
| 54 } | |
| 55 | |
| 50 class TestFolder { | 56 class TestFolder { |
| 51 public: | 57 public: |
| 52 TestFolder(const std::string& name, const base::Time& timestamp, | 58 TestFolder(const std::string& name, const base::Time& timestamp, |
| 53 const std::string& uid, unsigned int image_files, | 59 const std::string& uid, unsigned int image_files, |
| 54 unsigned int non_image_files) | 60 unsigned int non_image_files) |
| 55 : name_(name), | 61 : name_(name), |
| 56 timestamp_(timestamp), | 62 timestamp_(timestamp), |
| 57 uid_(uid), | 63 uid_(uid), |
| 58 image_files_(image_files), | 64 image_files_(image_files), |
| 59 non_image_files_(non_image_files), | 65 non_image_files_(non_image_files), |
| 60 folder_info_("", base::Time(), "", base::FilePath()) { | 66 folder_info_("", base::Time(), "", base::FilePath()) { |
| 61 } | 67 } |
| 62 | 68 |
| 63 bool Init() { | 69 bool Init() { |
| 64 if (!folder_dir_.CreateUniqueTempDir()) | 70 if (!folder_dir_.CreateUniqueTempDir()) |
| 65 return false; | 71 return false; |
| 66 | 72 |
| 67 folder_info_ = AlbumInfo(name_, timestamp_, uid_, folder_dir_.path()); | 73 folder_info_ = AlbumInfo(name_, timestamp_, uid_, folder_dir_.path()); |
| 68 | 74 |
| 69 const char kJpegHeader[] = "\xFF\xD8\xFF"; // Per HTML5 specification. | |
| 70 for (unsigned int i = 0; i < image_files_; ++i) { | 75 for (unsigned int i = 0; i < image_files_; ++i) { |
| 71 std::string image_filename = base::StringPrintf("img%05d.jpg", i); | 76 std::string image_filename = base::StringPrintf("img%05d.jpg", i); |
| 72 image_filenames_.insert(image_filename); | 77 image_filenames_.insert(image_filename); |
| 73 | 78 |
| 74 base::FilePath path = folder_dir_.path().AppendASCII(image_filename); | 79 base::FilePath path = folder_dir_.path().AppendASCII(image_filename); |
| 75 | 80 |
| 76 if (file_util::WriteFile(path, kJpegHeader, arraysize(kJpegHeader)) == -1) | 81 if (!WriteJPEGHeader(path)) |
| 77 return false; | 82 return false; |
| 78 } | 83 } |
| 79 | 84 |
| 80 for (unsigned int i = 0; i < non_image_files_; ++i) { | 85 for (unsigned int i = 0; i < non_image_files_; ++i) { |
| 81 base::FilePath path = folder_dir_.path().AppendASCII( | 86 base::FilePath path = folder_dir_.path().AppendASCII( |
| 82 base::StringPrintf("hello%05d.txt", i)); | 87 base::StringPrintf("hello%05d.txt", i)); |
| 83 if (file_util::WriteFile(path, NULL, 0) == -1) | 88 if (file_util::WriteFile(path, NULL, 0) == -1) |
| 84 return false; | 89 return false; |
| 85 } | 90 } |
| 86 | 91 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 void SetUpOnMediaTaskRunner(base::WaitableEvent* event) { | 248 void SetUpOnMediaTaskRunner(base::WaitableEvent* event) { |
| 244 picasa_data_provider_.reset(new PicasaDataProvider(base::FilePath())); | 249 picasa_data_provider_.reset(new PicasaDataProvider(base::FilePath())); |
| 245 event->Signal(); | 250 event->Signal(); |
| 246 } | 251 } |
| 247 | 252 |
| 248 void TearDownOnMediaTaskRunner(base::WaitableEvent* event) { | 253 void TearDownOnMediaTaskRunner(base::WaitableEvent* event) { |
| 249 picasa_data_provider_.reset(); | 254 picasa_data_provider_.reset(); |
| 250 event->Signal(); | 255 event->Signal(); |
| 251 } | 256 } |
| 252 | 257 |
| 253 void SetupDataProvider(PicasaDataProvider* picasa_data_provider, | |
| 254 const std::vector<AlbumInfo>& albums, | |
| 255 const std::vector<AlbumInfo>& folders) { | |
| 256 PicasaDataProvider::UniquifyNames(albums, | |
| 257 &picasa_data_provider->album_map_); | |
| 258 PicasaDataProvider::UniquifyNames(folders, | |
| 259 &picasa_data_provider->folder_map_); | |
| 260 picasa_data_provider->state_ = | |
| 261 PicasaDataProvider::ALBUMS_IMAGES_FRESH_STATE; | |
| 262 } | |
| 263 | |
| 264 // |test_folders| must be in alphabetical order for easy verification | 258 // |test_folders| must be in alphabetical order for easy verification |
| 265 void SetupFolders(ScopedVector<TestFolder>* test_folders) { | 259 void SetupFolders(ScopedVector<TestFolder>* test_folders, |
| 260 const std::vector<AlbumInfo>& albums, | |
| 261 const AlbumImagesMap& albums_images) { | |
| 266 std::vector<AlbumInfo> folders; | 262 std::vector<AlbumInfo> folders; |
| 267 for (ScopedVector<TestFolder>::iterator it = test_folders->begin(); | 263 for (ScopedVector<TestFolder>::iterator it = test_folders->begin(); |
| 268 it != test_folders->end(); ++it) { | 264 it != test_folders->end(); ++it) { |
| 269 TestFolder* test_folder = *it; | 265 TestFolder* test_folder = *it; |
| 270 ASSERT_TRUE(test_folder->Init()); | 266 ASSERT_TRUE(test_folder->Init()); |
| 271 folders.push_back(test_folder->folder_info()); | 267 folders.push_back(test_folder->folder_info()); |
| 272 } | 268 } |
| 273 | 269 |
| 274 SetupDataProvider( | 270 PicasaDataProvider::UniquifyNames(albums, |
| 275 picasa_data_provider_.get(), std::vector<AlbumInfo>(), folders); | 271 &picasa_data_provider_->album_map_); |
| 272 PicasaDataProvider::UniquifyNames(folders, | |
| 273 &picasa_data_provider_->folder_map_); | |
| 274 picasa_data_provider_->albums_images_ = albums_images; | |
| 275 picasa_data_provider_->state_ = | |
| 276 PicasaDataProvider::ALBUMS_IMAGES_FRESH_STATE; | |
| 276 } | 277 } |
| 277 | 278 |
| 278 void VerifyFolderDirectoryList(const ScopedVector<TestFolder>& test_folders) { | 279 void VerifyFolderDirectoryList(const ScopedVector<TestFolder>& test_folders) { |
| 279 FileSystemOperation::FileEntryList contents; | 280 FileSystemOperation::FileEntryList contents; |
| 280 FileSystemURL url = CreateURL(kPicasaDirFolders); | 281 FileSystemURL url = CreateURL(kPicasaDirFolders); |
| 281 bool completed = false; | 282 bool completed = false; |
| 282 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 283 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 283 | 284 |
| 284 ASSERT_TRUE(completed); | 285 ASSERT_TRUE(completed); |
| 285 ASSERT_EQ(test_folders.size(), contents.size()); | 286 ASSERT_EQ(test_folders.size(), contents.size()); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 314 EXPECT_EQ(1u, image_filenames.count( | 315 EXPECT_EQ(1u, image_filenames.count( |
| 315 base::FilePath(file_it->name).AsUTF8Unsafe())); | 316 base::FilePath(file_it->name).AsUTF8Unsafe())); |
| 316 } | 317 } |
| 317 } | 318 } |
| 318 } | 319 } |
| 319 | 320 |
| 320 std::string DateToPathString(const base::Time& time) { | 321 std::string DateToPathString(const base::Time& time) { |
| 321 return PicasaDataProvider::DateToPathString(time); | 322 return PicasaDataProvider::DateToPathString(time); |
| 322 } | 323 } |
| 323 | 324 |
| 324 void TestNonexistentFolder(const std::string& path_append) { | 325 void TestNonexistentDirectory(const std::string& path) { |
| 325 FileSystemOperation::FileEntryList contents; | 326 FileSystemOperation::FileEntryList contents; |
| 326 FileSystemURL url = CreateURL( | 327 FileSystemURL url = CreateURL(path); |
| 327 std::string(kPicasaDirFolders) + path_append); | |
| 328 bool completed = false; | 328 bool completed = false; |
| 329 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 329 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 330 | 330 |
| 331 ASSERT_FALSE(completed); | 331 ASSERT_FALSE(completed); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void TestEmptyDirectory(const std::string& path) { | |
| 335 FileSystemOperation::FileEntryList contents; | |
| 336 FileSystemURL url = CreateURL(path); | |
| 337 bool completed = false; | |
| 338 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | |
| 339 | |
| 340 ASSERT_TRUE(completed); | |
| 341 EXPECT_EQ(0u, contents.size()); | |
| 342 } | |
| 343 | |
| 334 FileSystemURL CreateURL(const std::string& virtual_path) const { | 344 FileSystemURL CreateURL(const std::string& virtual_path) const { |
| 335 return file_system_context_->CreateCrackedFileSystemURL( | 345 return file_system_context_->CreateCrackedFileSystemURL( |
| 336 GURL("http://www.example.com"), fileapi::kFileSystemTypePicasa, | 346 GURL("http://www.example.com"), fileapi::kFileSystemTypePicasa, |
| 337 base::FilePath::FromUTF8Unsafe(virtual_path)); | 347 base::FilePath::FromUTF8Unsafe(virtual_path)); |
| 338 } | 348 } |
| 339 | 349 |
| 340 fileapi::FileSystemOperationRunner* operation_runner() const { | 350 fileapi::FileSystemOperationRunner* operation_runner() const { |
| 341 return file_system_context_->operation_runner(); | 351 return file_system_context_->operation_runner(); |
| 342 } | 352 } |
| 343 | 353 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 expected_names.push_back("duplicate " + test_date_string + " (1)"); | 402 expected_names.push_back("duplicate " + test_date_string + " (1)"); |
| 393 | 403 |
| 394 test_folders.push_back( | 404 test_folders.push_back( |
| 395 new TestFolder("duplicate", test_date, "uuid5", 0, 0)); | 405 new TestFolder("duplicate", test_date, "uuid5", 0, 0)); |
| 396 expected_names.push_back("duplicate " + test_date_string + " (2)"); | 406 expected_names.push_back("duplicate " + test_date_string + " (2)"); |
| 397 | 407 |
| 398 test_folders.push_back( | 408 test_folders.push_back( |
| 399 new TestFolder("unique_name", test_date, "uuid1", 0, 0)); | 409 new TestFolder("unique_name", test_date, "uuid1", 0, 0)); |
| 400 expected_names.push_back("unique_name " + test_date_string); | 410 expected_names.push_back("unique_name " + test_date_string); |
| 401 | 411 |
| 402 SetupFolders(&test_folders); | 412 SetupFolders(&test_folders, std::vector<AlbumInfo>(), AlbumImagesMap()); |
| 403 | 413 |
| 404 FileSystemOperation::FileEntryList contents; | 414 FileSystemOperation::FileEntryList contents; |
| 405 FileSystemURL url = CreateURL(kPicasaDirFolders); | 415 FileSystemURL url = CreateURL(kPicasaDirFolders); |
| 406 bool completed = false; | 416 bool completed = false; |
| 407 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 417 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 408 | 418 |
| 409 ASSERT_TRUE(completed); | 419 ASSERT_TRUE(completed); |
| 410 ASSERT_EQ(expected_names.size(), contents.size()); | 420 ASSERT_EQ(expected_names.size(), contents.size()); |
| 411 for (size_t i = 0; i < contents.size(); ++i) { | 421 for (size_t i = 0; i < contents.size(); ++i) { |
| 412 EXPECT_EQ(expected_names[i], | 422 EXPECT_EQ(expected_names[i], |
| 413 base::FilePath(contents[i].name).AsUTF8Unsafe()); | 423 base::FilePath(contents[i].name).AsUTF8Unsafe()); |
| 414 EXPECT_EQ(test_folders[i]->timestamp(), contents[i].last_modified_time); | 424 EXPECT_EQ(test_folders[i]->timestamp(), contents[i].last_modified_time); |
| 415 EXPECT_TRUE(contents[i].is_directory); | 425 EXPECT_TRUE(contents[i].is_directory); |
| 416 } | 426 } |
| 417 } | 427 } |
| 418 | 428 |
| 419 TEST_F(PicasaFileUtilTest, RootFolders) { | 429 TEST_F(PicasaFileUtilTest, RootFolders) { |
| 420 ScopedVector<TestFolder> empty_folders_list; | 430 ScopedVector<TestFolder> empty_folders_list; |
| 421 SetupFolders(&empty_folders_list); | 431 SetupFolders(&empty_folders_list, std::vector<AlbumInfo>(), AlbumImagesMap()); |
| 422 | 432 |
| 423 FileSystemOperation::FileEntryList contents; | 433 FileSystemOperation::FileEntryList contents; |
| 424 FileSystemURL url = CreateURL(""); | 434 FileSystemURL url = CreateURL(""); |
| 425 bool completed = false; | 435 bool completed = false; |
| 426 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 436 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 427 | 437 |
| 428 ASSERT_TRUE(completed); | 438 ASSERT_TRUE(completed); |
| 429 ASSERT_EQ(2u, contents.size()); | 439 ASSERT_EQ(2u, contents.size()); |
| 430 | 440 |
| 431 EXPECT_TRUE(contents.front().is_directory); | 441 EXPECT_TRUE(contents.front().is_directory); |
| 432 EXPECT_TRUE(contents.back().is_directory); | 442 EXPECT_TRUE(contents.back().is_directory); |
| 433 | 443 |
| 434 EXPECT_EQ(0, contents.front().size); | 444 EXPECT_EQ(0, contents.front().size); |
| 435 EXPECT_EQ(0, contents.back().size); | 445 EXPECT_EQ(0, contents.back().size); |
| 436 | 446 |
| 437 EXPECT_EQ(FILE_PATH_LITERAL("albums"), contents.front().name); | 447 EXPECT_EQ(FILE_PATH_LITERAL("albums"), contents.front().name); |
| 438 EXPECT_EQ(FILE_PATH_LITERAL("folders"), contents.back().name); | 448 EXPECT_EQ(FILE_PATH_LITERAL("folders"), contents.back().name); |
| 439 } | 449 } |
| 440 | 450 |
| 441 TEST_F(PicasaFileUtilTest, NonexistentFolder) { | 451 TEST_F(PicasaFileUtilTest, NonexistentFolder) { |
| 442 ScopedVector<TestFolder> empty_folders_list; | 452 ScopedVector<TestFolder> empty_folders_list; |
| 443 SetupFolders(&empty_folders_list); | 453 SetupFolders(&empty_folders_list, std::vector<AlbumInfo>(), AlbumImagesMap()); |
| 444 | 454 |
| 445 TestNonexistentFolder("/foo"); | 455 TestNonexistentDirectory(std::string(kPicasaDirFolders) + "/foo"); |
| 446 TestNonexistentFolder("/foo/bar"); | 456 TestNonexistentDirectory(std::string(kPicasaDirFolders) + "/foo/bar"); |
| 447 TestNonexistentFolder("/foo/bar/baz"); | 457 TestNonexistentDirectory(std::string(kPicasaDirFolders) + "/foo/bar/baz"); |
| 448 } | 458 } |
| 449 | 459 |
| 450 TEST_F(PicasaFileUtilTest, FolderContentsTrivial) { | 460 TEST_F(PicasaFileUtilTest, FolderContentsTrivial) { |
| 451 ScopedVector<TestFolder> test_folders; | 461 ScopedVector<TestFolder> test_folders; |
| 452 base::Time test_date = base::Time::FromLocalExploded(test_date_exploded); | 462 base::Time test_date = base::Time::FromLocalExploded(test_date_exploded); |
| 453 | 463 |
| 454 test_folders.push_back( | 464 test_folders.push_back( |
| 455 new TestFolder("folder-1-empty", test_date, "uid-empty", 0, 0)); | 465 new TestFolder("folder-1-empty", test_date, "uid-empty", 0, 0)); |
| 456 test_folders.push_back( | 466 test_folders.push_back( |
| 457 new TestFolder("folder-2-images", test_date, "uid-images", 5, 0)); | 467 new TestFolder("folder-2-images", test_date, "uid-images", 5, 0)); |
| 458 test_folders.push_back( | 468 test_folders.push_back( |
| 459 new TestFolder("folder-3-nonimages", test_date, "uid-nonimages", 0, 5)); | 469 new TestFolder("folder-3-nonimages", test_date, "uid-nonimages", 0, 5)); |
| 460 test_folders.push_back( | 470 test_folders.push_back( |
| 461 new TestFolder("folder-4-both", test_date, "uid-both", 5, 5)); | 471 new TestFolder("folder-4-both", test_date, "uid-both", 5, 5)); |
| 462 | 472 |
| 463 SetupFolders(&test_folders); | 473 SetupFolders(&test_folders, std::vector<AlbumInfo>(), AlbumImagesMap()); |
| 464 VerifyFolderDirectoryList(test_folders); | 474 VerifyFolderDirectoryList(test_folders); |
| 465 } | 475 } |
| 466 | 476 |
| 467 TEST_F(PicasaFileUtilTest, FolderWithManyFiles) { | 477 TEST_F(PicasaFileUtilTest, FolderWithManyFiles) { |
| 468 ScopedVector<TestFolder> test_folders; | 478 ScopedVector<TestFolder> test_folders; |
| 469 base::Time test_date = base::Time::FromLocalExploded(test_date_exploded); | 479 base::Time test_date = base::Time::FromLocalExploded(test_date_exploded); |
| 470 | 480 |
| 471 test_folders.push_back( | 481 test_folders.push_back( |
| 472 new TestFolder("folder-many-files", test_date, "uid-both", 500, 500)); | 482 new TestFolder("folder-many-files", test_date, "uid-both", 500, 500)); |
| 473 | 483 |
| 474 SetupFolders(&test_folders); | 484 SetupFolders(&test_folders, std::vector<AlbumInfo>(), AlbumImagesMap()); |
| 475 VerifyFolderDirectoryList(test_folders); | 485 VerifyFolderDirectoryList(test_folders); |
| 476 } | 486 } |
| 477 | 487 |
| 478 TEST_F(PicasaFileUtilTest, ManyFolders) { | 488 TEST_F(PicasaFileUtilTest, ManyFolders) { |
| 479 ScopedVector<TestFolder> test_folders; | 489 ScopedVector<TestFolder> test_folders; |
| 480 base::Time test_date = base::Time::FromLocalExploded(test_date_exploded); | 490 base::Time test_date = base::Time::FromLocalExploded(test_date_exploded); |
| 481 | 491 |
| 482 // TODO(tommycli): Turn number of test folders back up to 50 (or more) once | 492 // TODO(tommycli): Turn number of test folders back up to 50 (or more) once |
| 483 // https://codereview.chromium.org/15479003/ lands. | 493 // https://codereview.chromium.org/15479003/ lands. |
| 484 for (unsigned int i = 0; i < 25; ++i) { | 494 for (unsigned int i = 0; i < 25; ++i) { |
| 485 base::Time date = test_date - base::TimeDelta::FromDays(i); | 495 base::Time date = test_date - base::TimeDelta::FromDays(i); |
| 486 | 496 |
| 487 test_folders.push_back( | 497 test_folders.push_back( |
| 488 new TestFolder(base::StringPrintf("folder-%05d", i), | 498 new TestFolder(base::StringPrintf("folder-%05d", i), |
| 489 date, | 499 date, |
| 490 base::StringPrintf("uid%05d", i), i % 5, i % 3)); | 500 base::StringPrintf("uid%05d", i), i % 5, i % 3)); |
| 491 } | 501 } |
| 492 | 502 |
| 493 SetupFolders(&test_folders); | 503 SetupFolders(&test_folders, std::vector<AlbumInfo>(), AlbumImagesMap()); |
| 494 VerifyFolderDirectoryList(test_folders); | 504 VerifyFolderDirectoryList(test_folders); |
| 495 } | 505 } |
| 496 | 506 |
| 507 TEST_F(PicasaFileUtilTest, AlbumExistence) { | |
| 508 ScopedVector<TestFolder> test_folders; | |
| 509 base::Time test_date = base::Time::FromLocalExploded(test_date_exploded); | |
| 510 | |
| 511 std::vector<AlbumInfo> albums; | |
| 512 AlbumInfo info; | |
| 513 info.name = "albumname"; | |
| 514 info.uid = "albumuid"; | |
| 515 info.timestamp = test_date; | |
| 516 albums.push_back(info); | |
| 517 | |
| 518 AlbumImagesMap albums_images; | |
| 519 albums_images[info.uid] = AlbumImages(); | |
| 520 | |
| 521 SetupFolders(&test_folders, albums, albums_images); | |
| 522 | |
| 523 TestEmptyDirectory(std::string(kPicasaDirAlbums) + "/albumname 2013-04-16"); | |
| 524 TestNonexistentDirectory(std::string(kPicasaDirAlbums) + | |
| 525 "/albumname 2013-04-16/toodeep"); | |
| 526 TestNonexistentDirectory(std::string(kPicasaDirAlbums) + "/wrongname"); | |
| 527 } | |
| 528 | |
| 529 TEST_F(PicasaFileUtilTest, AlbumContents) { | |
| 530 ScopedVector<TestFolder> test_folders; | |
| 531 base::Time test_date = base::Time::FromLocalExploded(test_date_exploded); | |
| 532 | |
| 533 std::vector<AlbumInfo> albums; | |
| 534 AlbumInfo info; | |
| 535 info.name = "albumname"; | |
| 536 info.uid = "albumuid"; | |
| 537 info.timestamp = test_date; | |
| 538 albums.push_back(info); | |
| 539 | |
| 540 base::ScopedTempDir temp_dir; | |
| 541 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | |
| 542 | |
| 543 base::FilePath image_path = temp_dir.path().AppendASCII("img.jpg"); | |
| 544 ASSERT_TRUE(WriteJPEGHeader(image_path)); | |
| 545 | |
| 546 AlbumImagesMap albums_images; | |
| 547 albums_images[info.uid] = AlbumImages(); | |
| 548 albums_images[info.uid]["mapped_name.jpg"] = image_path; | |
| 549 | |
| 550 SetupFolders(&test_folders, albums, albums_images); | |
| 551 | |
| 552 FileSystemOperation::FileEntryList contents; | |
| 553 FileSystemURL url = | |
| 554 CreateURL(std::string(kPicasaDirAlbums) + "/albumname 2013-04-16"); | |
| 555 bool completed = false; | |
| 556 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | |
| 557 | |
| 558 ASSERT_TRUE(completed); | |
| 559 EXPECT_EQ(1u, contents.size()); | |
| 560 EXPECT_EQ("mapped_name.jpg", | |
| 561 base::FilePath(contents.begin()->name).AsUTF8Unsafe()); | |
| 562 EXPECT_FALSE(contents.begin()->is_directory); | |
|
Greg Billock
2013/08/21 17:13:17
Need to check the actual on-disk filename you get
tommycli
2013/08/21 21:37:06
I can't easily access that information. The file u
Greg Billock
2013/08/21 21:41:23
Is there a way to prove we can read it? Get the fi
tommycli
2013/08/21 22:19:26
Seems like creating a snapshot file is a way to ve
| |
| 563 } | |
| 564 | |
| 497 } // namespace picasa | 565 } // namespace picasa |
| OLD | NEW |