[andorid_webview] Don't 'jiggle' on overscroll
[chromium-blink-merge.git] / chrome / utility / media_galleries / picasa_album_table_reader_unittest.cc
blobfe9b828c7ab99d8693164d91446d24448a4bbb71
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 "chrome/common/media_galleries/pmp_constants.h"
6 #include "chrome/common/media_galleries/pmp_test_helper.h"
7 #include "chrome/utility/media_galleries/picasa_album_table_reader.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace picasa {
12 namespace {
14 TEST(PicasaAlbumTableReaderTest, FoldersAndAlbums) {
15 PmpTestHelper test_helper(kPicasaAlbumTableName);
16 ASSERT_TRUE(test_helper.Init());
18 int test_time_delta = 100;
20 std::vector<uint32> category_vector;
21 category_vector.push_back(kAlbumCategoryFolder);
22 category_vector.push_back(kAlbumCategoryInvalid);
23 category_vector.push_back(kAlbumCategoryAlbum);
25 std::vector<double> date_vector;
26 date_vector.push_back(0.0);
27 date_vector.push_back(0.0);
28 date_vector.push_back(0.0 + test_time_delta);
30 std::string test_folder_name = "Pix4dalulz";
31 std::string test_album_name = "Cats";
33 base::FilePath test_folder_path =
34 base::FilePath(base::FilePath::FromUTF8Unsafe("C:\\Pix4dalulz"));
36 // Only folders require filenames. Tests handling of different length columns.
37 std::vector<std::string> filename_vector;
38 filename_vector.push_back(test_folder_path.AsUTF8Unsafe());
40 std::vector<std::string> name_vector;
41 name_vector.push_back(test_folder_name);
42 name_vector.push_back("");
43 name_vector.push_back(test_album_name);
45 std::vector<std::string> token_vector;
46 token_vector.push_back("");
47 token_vector.push_back("");
48 token_vector.push_back(std::string(kAlbumTokenPrefix) + "uid3");
50 std::vector<std::string> uid_vector;
51 uid_vector.push_back("uid1");
52 uid_vector.push_back("uid2");
53 uid_vector.push_back("uid3");
55 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
56 "category", PMP_TYPE_UINT32, category_vector));
57 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
58 "date", PMP_TYPE_DOUBLE64, date_vector));
59 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
60 "filename", PMP_TYPE_STRING, filename_vector));
61 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
62 "name", PMP_TYPE_STRING, name_vector));
63 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
64 "token", PMP_TYPE_STRING, token_vector));
65 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
66 "uid", PMP_TYPE_STRING, uid_vector));
68 AlbumTableFiles album_table_files(test_helper.GetTempDirPath());
69 PicasaAlbumTableReader reader(album_table_files);
71 ASSERT_TRUE(reader.Init());
72 CloseAlbumTableFiles(&album_table_files);
74 const std::vector<AlbumInfo>& albums = reader.albums();
75 const std::vector<AlbumInfo>& folders = reader.folders();
77 ASSERT_EQ(1u, albums.size());
78 ASSERT_EQ(1u, folders.size());
80 EXPECT_EQ(test_album_name, albums[0].name);
81 EXPECT_EQ(test_folder_name, folders[0].name);
83 EXPECT_EQ(test_folder_path, folders[0].path);
85 base::TimeDelta time_delta = albums[0].timestamp - folders[0].timestamp;
87 EXPECT_EQ(test_time_delta, time_delta.InDays());
90 } // namespace
92 } // namespace picasa