Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "testing/gtest/include/gtest/gtest.h" | |
| 6 #include "webkit/fileapi/media/picasa/picasa_album_table_reader.h" | |
| 7 #include "webkit/fileapi/media/picasa/pmp_constants.h" | |
| 8 #include "webkit/fileapi/media/picasa/pmp_test_helper.h" | |
| 9 | |
| 10 namespace { | |
| 11 | |
| 12 using picasaimport::PmpTestHelper; | |
| 13 using picasaimport::PMP_TYPE_UINT32; | |
| 14 | |
| 15 TEST(PicasaAlbumTableReaderTest, FoldersAndAlbums) { | |
| 16 PmpTestHelper test_helper(picasaimport::kPicasaAlbumTableName); | |
| 17 ASSERT_TRUE(test_helper.Init()); | |
| 18 | |
| 19 int test_time_delta = 100; | |
| 20 | |
| 21 std::vector<uint32> category_vector; | |
| 22 category_vector.push_back(picasaimport::kAlbumCategoryFolder); | |
| 23 category_vector.push_back(picasaimport::kAlbumCategoryInvalid); | |
| 24 category_vector.push_back(picasaimport::kAlbumCategoryUserAlbum); | |
| 25 | |
| 26 std::vector<double> date_vector; | |
| 27 date_vector.push_back(0.0); | |
| 28 date_vector.push_back(0.0); | |
| 29 date_vector.push_back(0.0 + test_time_delta); | |
| 30 | |
| 31 std::string test_folder_name = "Pix4dalulz"; | |
| 32 std::string test_user_album_name = "Cats"; | |
| 33 | |
| 34 base::FilePath test_folder_path = | |
| 35 base::FilePath(base::FilePath::FromUTF8Unsafe("C:\\Pix4dalulz")); | |
|
Greg Billock
2013/04/12 23:17:58
Get the base dir from the test machinery with Scop
tommycli
2013/04/12 23:44:04
This is supposed to represent a location where the
| |
| 36 | |
| 37 // Only folders require filenames. Tests handling of different length columns. | |
| 38 std::vector<std::string> filename_vector; | |
| 39 filename_vector.push_back(test_folder_path.AsUTF8Unsafe()); | |
| 40 | |
| 41 std::vector<std::string> name_vector; | |
| 42 name_vector.push_back(test_folder_name); | |
| 43 name_vector.push_back(""); | |
| 44 name_vector.push_back(test_user_album_name); | |
| 45 | |
| 46 std::vector<std::string> token_vector; | |
| 47 token_vector.push_back(""); | |
| 48 token_vector.push_back(""); | |
| 49 token_vector.push_back(std::string(picasaimport::kAlbumTokenPrefix) + "uid3"); | |
| 50 | |
| 51 std::vector<std::string> uid_vector; | |
| 52 uid_vector.push_back("uid1"); | |
| 53 uid_vector.push_back("uid2"); | |
| 54 uid_vector.push_back("uid3"); | |
| 55 | |
| 56 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( | |
| 57 "category", picasaimport::PMP_TYPE_UINT32, category_vector)); | |
| 58 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( | |
| 59 "date", picasaimport::PMP_TYPE_DOUBLE64, date_vector)); | |
| 60 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( | |
| 61 "filename", picasaimport::PMP_TYPE_STRING, filename_vector)); | |
| 62 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( | |
| 63 "name", picasaimport::PMP_TYPE_STRING, name_vector)); | |
| 64 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( | |
| 65 "token", picasaimport::PMP_TYPE_STRING, token_vector)); | |
| 66 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( | |
| 67 "uid", picasaimport::PMP_TYPE_STRING, uid_vector)); | |
| 68 | |
| 69 picasaimport::PicasaAlbumTableReader reader(test_helper.GetTempDirPath()); | |
| 70 | |
| 71 ASSERT_TRUE(reader.Init()); | |
| 72 | |
| 73 const std::vector<picasaimport::FolderInfo>& folders = reader.folders(); | |
| 74 const std::vector<picasaimport::AlbumInfo>& user_albums = | |
| 75 reader.user_albums(); | |
| 76 | |
| 77 ASSERT_EQ(1u, folders.size()); | |
| 78 ASSERT_EQ(1u, user_albums.size()); | |
| 79 | |
| 80 EXPECT_EQ(test_folder_name, folders[0].name); | |
| 81 EXPECT_EQ(test_user_album_name, user_albums[0].name); | |
| 82 | |
| 83 EXPECT_EQ(test_folder_path, folders[0].path); | |
| 84 | |
| 85 base::TimeDelta time_delta = user_albums[0].timestamp - folders[0].timestamp; | |
| 86 | |
| 87 EXPECT_EQ(test_time_delta, time_delta.InDays()); | |
| 88 } | |
| 89 | |
| 90 } // namespace | |
| OLD | NEW |