Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chrome/browser/media_galleries/fileapi/picasa/picasa_album_table_reader_unittest.cc

Issue 17101030: Media Galleries API - Picasa: Change PMP Parsing to deal with PlatformFile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/media_galleries/fileapi/picasa/picasa_album_table_reade r.h" 5 #include "chrome/browser/media_galleries/fileapi/picasa/picasa_album_table_reade r.h"
6 #include "chrome/browser/media_galleries/fileapi/picasa/pmp_constants.h" 6 #include "chrome/browser/media_galleries/fileapi/picasa/pmp_constants.h"
7 #include "chrome/browser/media_galleries/fileapi/picasa/pmp_test_helper.h" 7 #include "chrome/browser/media_galleries/fileapi/picasa/pmp_test_helper.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace picasa {
11
10 namespace { 12 namespace {
11 13
12 using picasa::PmpTestHelper;
13 using picasa::PMP_TYPE_UINT32;
14
15 TEST(PicasaAlbumTableReaderTest, FoldersAndAlbums) { 14 TEST(PicasaAlbumTableReaderTest, FoldersAndAlbums) {
16 PmpTestHelper test_helper(picasa::kPicasaAlbumTableName); 15 PmpTestHelper test_helper(kPicasaAlbumTableName);
17 ASSERT_TRUE(test_helper.Init()); 16 ASSERT_TRUE(test_helper.Init());
18 17
19 int test_time_delta = 100; 18 int test_time_delta = 100;
20 19
21 std::vector<uint32> category_vector; 20 std::vector<uint32> category_vector;
22 category_vector.push_back(picasa::kAlbumCategoryFolder); 21 category_vector.push_back(kAlbumCategoryFolder);
23 category_vector.push_back(picasa::kAlbumCategoryInvalid); 22 category_vector.push_back(kAlbumCategoryInvalid);
24 category_vector.push_back(picasa::kAlbumCategoryAlbum); 23 category_vector.push_back(kAlbumCategoryAlbum);
25 24
26 std::vector<double> date_vector; 25 std::vector<double> date_vector;
27 date_vector.push_back(0.0); 26 date_vector.push_back(0.0);
28 date_vector.push_back(0.0); 27 date_vector.push_back(0.0);
29 date_vector.push_back(0.0 + test_time_delta); 28 date_vector.push_back(0.0 + test_time_delta);
30 29
31 std::string test_folder_name = "Pix4dalulz"; 30 std::string test_folder_name = "Pix4dalulz";
32 std::string test_album_name = "Cats"; 31 std::string test_album_name = "Cats";
33 32
34 base::FilePath test_folder_path = 33 base::FilePath test_folder_path =
35 base::FilePath(base::FilePath::FromUTF8Unsafe("C:\\Pix4dalulz")); 34 base::FilePath(base::FilePath::FromUTF8Unsafe("C:\\Pix4dalulz"));
36 35
37 // Only folders require filenames. Tests handling of different length columns. 36 // Only folders require filenames. Tests handling of different length columns.
38 std::vector<std::string> filename_vector; 37 std::vector<std::string> filename_vector;
39 filename_vector.push_back(test_folder_path.AsUTF8Unsafe()); 38 filename_vector.push_back(test_folder_path.AsUTF8Unsafe());
40 39
41 std::vector<std::string> name_vector; 40 std::vector<std::string> name_vector;
42 name_vector.push_back(test_folder_name); 41 name_vector.push_back(test_folder_name);
43 name_vector.push_back(""); 42 name_vector.push_back("");
44 name_vector.push_back(test_album_name); 43 name_vector.push_back(test_album_name);
45 44
46 std::vector<std::string> token_vector; 45 std::vector<std::string> token_vector;
47 token_vector.push_back(""); 46 token_vector.push_back("");
48 token_vector.push_back(""); 47 token_vector.push_back("");
49 token_vector.push_back(std::string(picasa::kAlbumTokenPrefix) + "uid3"); 48 token_vector.push_back(std::string(kAlbumTokenPrefix) + "uid3");
50 49
51 std::vector<std::string> uid_vector; 50 std::vector<std::string> uid_vector;
52 uid_vector.push_back("uid1"); 51 uid_vector.push_back("uid1");
53 uid_vector.push_back("uid2"); 52 uid_vector.push_back("uid2");
54 uid_vector.push_back("uid3"); 53 uid_vector.push_back("uid3");
55 54
56 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( 55 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
57 "category", picasa::PMP_TYPE_UINT32, category_vector)); 56 "category", PMP_TYPE_UINT32, category_vector));
58 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( 57 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
59 "date", picasa::PMP_TYPE_DOUBLE64, date_vector)); 58 "date", PMP_TYPE_DOUBLE64, date_vector));
60 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( 59 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
61 "filename", picasa::PMP_TYPE_STRING, filename_vector)); 60 "filename", PMP_TYPE_STRING, filename_vector));
62 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( 61 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
63 "name", picasa::PMP_TYPE_STRING, name_vector)); 62 "name", PMP_TYPE_STRING, name_vector));
64 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( 63 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
65 "token", picasa::PMP_TYPE_STRING, token_vector)); 64 "token", PMP_TYPE_STRING, token_vector));
66 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( 65 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
67 "uid", picasa::PMP_TYPE_STRING, uid_vector)); 66 "uid", PMP_TYPE_STRING, uid_vector));
68 67
69 picasa::PicasaAlbumTableReader reader(test_helper.GetTempDirPath()); 68 PicasaAlbumTableFiles album_table_files(test_helper.GetTempDirPath());
69 PicasaAlbumTableReader reader(album_table_files);
70 70
71 ASSERT_TRUE(reader.Init()); 71 ASSERT_TRUE(reader.Init());
72 ClosePicasaAlbumTableFiles(&album_table_files);
72 73
73 const std::vector<picasa::AlbumInfo>& albums = reader.albums(); 74 const std::vector<AlbumInfo>& albums = reader.albums();
74 const std::vector<picasa::AlbumInfo>& folders = reader.folders(); 75 const std::vector<AlbumInfo>& folders = reader.folders();
75 76
76 ASSERT_EQ(1u, albums.size()); 77 ASSERT_EQ(1u, albums.size());
77 ASSERT_EQ(1u, folders.size()); 78 ASSERT_EQ(1u, folders.size());
78 79
79 EXPECT_EQ(test_album_name, albums[0].name); 80 EXPECT_EQ(test_album_name, albums[0].name);
80 EXPECT_EQ(test_folder_name, folders[0].name); 81 EXPECT_EQ(test_folder_name, folders[0].name);
81 82
82 EXPECT_EQ(test_folder_path, folders[0].path); 83 EXPECT_EQ(test_folder_path, folders[0].path);
83 84
84 base::TimeDelta time_delta = albums[0].timestamp - folders[0].timestamp; 85 base::TimeDelta time_delta = albums[0].timestamp - folders[0].timestamp;
85 86
86 EXPECT_EQ(test_time_delta, time_delta.InDays()); 87 EXPECT_EQ(test_time_delta, time_delta.InDays());
87 } 88 }
88 89
89 } // namespace 90 } // namespace
91
92 } // namespace picasa
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698