| 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 FileSystemURL url = CreateURL(kPicasaDirFolders); | 296 FileSystemURL url = CreateURL(kPicasaDirFolders); |
| 297 bool completed = false; | 297 bool completed = false; |
| 298 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 298 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 299 | 299 |
| 300 ASSERT_TRUE(completed); | 300 ASSERT_TRUE(completed); |
| 301 ASSERT_EQ(test_folders.size(), contents.size()); | 301 ASSERT_EQ(test_folders.size(), contents.size()); |
| 302 | 302 |
| 303 for (size_t i = 0; i < contents.size(); ++i) { | 303 for (size_t i = 0; i < contents.size(); ++i) { |
| 304 EXPECT_TRUE(contents[i].is_directory); | 304 EXPECT_TRUE(contents[i].is_directory); |
| 305 | 305 |
| 306 // Because the timestamp is written out as a floating point Microsoft | |
| 307 // variant time, we only expect it to be accurate to within a second. | |
| 308 base::TimeDelta delta = test_folders[i]->folder_info().timestamp - | |
| 309 contents[i].last_modified_time; | |
| 310 EXPECT_LT(delta, base::TimeDelta::FromSeconds(1)); | |
| 311 | |
| 312 FileSystemOperation::FileEntryList folder_contents; | 306 FileSystemOperation::FileEntryList folder_contents; |
| 313 FileSystemURL folder_url = CreateURL( | 307 FileSystemURL folder_url = CreateURL( |
| 314 std::string(kPicasaDirFolders) + "/" + | 308 std::string(kPicasaDirFolders) + "/" + |
| 315 base::FilePath(contents[i].name).AsUTF8Unsafe()); | 309 base::FilePath(contents[i].name).AsUTF8Unsafe()); |
| 316 bool folder_read_completed = false; | 310 bool folder_read_completed = false; |
| 317 ReadDirectoryTestHelper(operation_runner(), folder_url, &folder_contents, | 311 ReadDirectoryTestHelper(operation_runner(), folder_url, &folder_contents, |
| 318 &folder_read_completed); | 312 &folder_read_completed); |
| 319 | 313 |
| 320 EXPECT_TRUE(folder_read_completed); | 314 EXPECT_TRUE(folder_read_completed); |
| 321 | 315 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 FileSystemOperation::FileEntryList contents; | 428 FileSystemOperation::FileEntryList contents; |
| 435 FileSystemURL url = CreateURL(kPicasaDirFolders); | 429 FileSystemURL url = CreateURL(kPicasaDirFolders); |
| 436 bool completed = false; | 430 bool completed = false; |
| 437 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 431 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 438 | 432 |
| 439 ASSERT_TRUE(completed); | 433 ASSERT_TRUE(completed); |
| 440 ASSERT_EQ(expected_names.size(), contents.size()); | 434 ASSERT_EQ(expected_names.size(), contents.size()); |
| 441 for (size_t i = 0; i < contents.size(); ++i) { | 435 for (size_t i = 0; i < contents.size(); ++i) { |
| 442 EXPECT_EQ(expected_names[i], | 436 EXPECT_EQ(expected_names[i], |
| 443 base::FilePath(contents[i].name).AsUTF8Unsafe()); | 437 base::FilePath(contents[i].name).AsUTF8Unsafe()); |
| 444 EXPECT_EQ(test_folders[i]->timestamp(), contents[i].last_modified_time); | |
| 445 EXPECT_TRUE(contents[i].is_directory); | 438 EXPECT_TRUE(contents[i].is_directory); |
| 446 } | 439 } |
| 447 } | 440 } |
| 448 | 441 |
| 449 TEST_F(PicasaFileUtilTest, RootFolders) { | 442 TEST_F(PicasaFileUtilTest, RootFolders) { |
| 450 ScopedVector<TestFolder> empty_folders_list; | 443 ScopedVector<TestFolder> empty_folders_list; |
| 451 SetupFolders(&empty_folders_list, std::vector<AlbumInfo>(), AlbumImagesMap()); | 444 SetupFolders(&empty_folders_list, std::vector<AlbumInfo>(), AlbumImagesMap()); |
| 452 | 445 |
| 453 FileSystemOperation::FileEntryList contents; | 446 FileSystemOperation::FileEntryList contents; |
| 454 FileSystemURL url = CreateURL(""); | 447 FileSystemURL url = CreateURL(""); |
| 455 bool completed = false; | 448 bool completed = false; |
| 456 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); | 449 ReadDirectoryTestHelper(operation_runner(), url, &contents, &completed); |
| 457 | 450 |
| 458 ASSERT_TRUE(completed); | 451 ASSERT_TRUE(completed); |
| 459 ASSERT_EQ(2u, contents.size()); | 452 ASSERT_EQ(2u, contents.size()); |
| 460 | 453 |
| 461 EXPECT_TRUE(contents.front().is_directory); | 454 EXPECT_TRUE(contents.front().is_directory); |
| 462 EXPECT_TRUE(contents.back().is_directory); | 455 EXPECT_TRUE(contents.back().is_directory); |
| 463 | 456 |
| 464 EXPECT_EQ(0, contents.front().size); | |
| 465 EXPECT_EQ(0, contents.back().size); | |
| 466 | |
| 467 EXPECT_EQ(FILE_PATH_LITERAL("albums"), contents.front().name); | 457 EXPECT_EQ(FILE_PATH_LITERAL("albums"), contents.front().name); |
| 468 EXPECT_EQ(FILE_PATH_LITERAL("folders"), contents.back().name); | 458 EXPECT_EQ(FILE_PATH_LITERAL("folders"), contents.back().name); |
| 469 } | 459 } |
| 470 | 460 |
| 471 TEST_F(PicasaFileUtilTest, NonexistentFolder) { | 461 TEST_F(PicasaFileUtilTest, NonexistentFolder) { |
| 472 ScopedVector<TestFolder> empty_folders_list; | 462 ScopedVector<TestFolder> empty_folders_list; |
| 473 SetupFolders(&empty_folders_list, std::vector<AlbumInfo>(), AlbumImagesMap()); | 463 SetupFolders(&empty_folders_list, std::vector<AlbumInfo>(), AlbumImagesMap()); |
| 474 | 464 |
| 475 TestNonexistentDirectory(std::string(kPicasaDirFolders) + "/foo"); | 465 TestNonexistentDirectory(std::string(kPicasaDirFolders) + "/foo"); |
| 476 TestNonexistentDirectory(std::string(kPicasaDirFolders) + "/foo/bar"); | 466 TestNonexistentDirectory(std::string(kPicasaDirFolders) + "/foo/bar"); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 operation_runner()->CreateSnapshotFile( | 581 operation_runner()->CreateSnapshotFile( |
| 592 CreateURL(std::string(kPicasaDirAlbums) + | 582 CreateURL(std::string(kPicasaDirAlbums) + |
| 593 "/albumname 2013-04-16/mapped_name.jpg"), | 583 "/albumname 2013-04-16/mapped_name.jpg"), |
| 594 snapshot_callback); | 584 snapshot_callback); |
| 595 loop.Run(); | 585 loop.Run(); |
| 596 EXPECT_EQ(base::File::FILE_OK, error); | 586 EXPECT_EQ(base::File::FILE_OK, error); |
| 597 EXPECT_EQ(image_path, platform_path_result); | 587 EXPECT_EQ(image_path, platform_path_result); |
| 598 } | 588 } |
| 599 | 589 |
| 600 } // namespace picasa | 590 } // namespace picasa |
| OLD | NEW |