Update V8 to version 4.7.52.
[chromium-blink-merge.git] / chrome / utility / media_galleries / picasa_album_table_reader_unittest.cc
blob53d77f2aefa9f52c4295153a7ccf270064b2bd67
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.
5 #include "base/files/scoped_temp_dir.h"
6 #include "chrome/common/media_galleries/picasa_test_util.h"
7 #include "chrome/common/media_galleries/pmp_constants.h"
8 #include "chrome/utility/media_galleries/picasa_album_table_reader.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace picasa {
13 namespace {
15 TEST(PicasaAlbumTableReaderTest, FoldersAndAlbums) {
16 base::ScopedTempDir temp_dir;
17 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
19 int test_time_delta = 100;
21 std::vector<uint32> category_vector;
22 category_vector.push_back(kAlbumCategoryFolder);
23 category_vector.push_back(kAlbumCategoryInvalid);
24 category_vector.push_back(kAlbumCategoryAlbum);
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);
31 std::string test_folder_name = "Pix4dalulz";
32 std::string test_album_name = "Cats";
34 base::FilePath test_folder_path =
35 base::FilePath(base::FilePath::FromUTF8Unsafe("C:\\Pix4dalulz"));
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());
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_album_name);
46 std::vector<std::string> token_vector;
47 token_vector.push_back("");
48 token_vector.push_back("");
49 token_vector.push_back(std::string(kAlbumTokenPrefix) + "uid3");
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");
56 WriteAlbumTable(temp_dir.path(), category_vector, date_vector,
57 filename_vector, name_vector, token_vector, uid_vector);
59 AlbumTableFiles album_table_files(temp_dir.path());
60 PicasaAlbumTableReader reader(album_table_files.Pass());
62 ASSERT_TRUE(reader.Init());
64 const std::vector<AlbumInfo>& albums = reader.albums();
65 const std::vector<AlbumInfo>& folders = reader.folders();
67 ASSERT_EQ(1u, albums.size());
68 ASSERT_EQ(1u, folders.size());
70 EXPECT_EQ(test_album_name, albums[0].name);
71 EXPECT_EQ(test_folder_name, folders[0].name);
73 EXPECT_EQ(test_folder_path, folders[0].path);
75 base::TimeDelta time_delta = albums[0].timestamp - folders[0].timestamp;
77 EXPECT_EQ(test_time_delta, time_delta.InDays());
80 } // namespace
82 } // namespace picasa