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

Side by Side Diff: webkit/fileapi/media/picasa/pmp_table_reader_unittest.cc

Issue 13529028: PicasaAlbumTableReader for Media Galleries API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0005-picasa-import-pmp-reader
Patch Set: Formatting fixes. Created 7 years, 8 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 14 matching lines...) Expand all
25 25
26 std::vector<std::string> column_names; 26 std::vector<std::string> column_names;
27 column_names.push_back("strings"); 27 column_names.push_back("strings");
28 column_names.push_back("uint32s"); 28 column_names.push_back("uint32s");
29 column_names.push_back("doubles"); 29 column_names.push_back("doubles");
30 30
31 const std::vector<std::string> strings_vector(10, "Hello"); 31 const std::vector<std::string> strings_vector(10, "Hello");
32 const std::vector<uint32> uint32s_vector(30, 42); 32 const std::vector<uint32> uint32s_vector(30, 42);
33 const std::vector<double> doubles_vector(20, 0.5); 33 const std::vector<double> doubles_vector(20, 0.5);
34 34
35 uint16 column_field_types[] = { 35 picasaimport::PmpFieldType column_field_types[] = {
36 picasaimport::PMP_STRING_TYPE, 36 picasaimport::PMP_STRING_TYPE,
37 picasaimport::PMP_UINT32_TYPE, 37 picasaimport::PMP_UINT32_TYPE,
38 picasaimport::PMP_DOUBLE64_TYPE 38 picasaimport::PMP_DOUBLE64_TYPE
39 }; 39 };
40 40
41 const uint32 max_rows = uint32s_vector.size(); 41 const uint32 max_rows = uint32s_vector.size();
42 42
43 #if defined(OS_WIN) 43 #if defined(OS_WIN)
44 base::FilePath indicator_path = 44 base::FilePath indicator_path =
45 test_helper.GetTempDirPath().Append(UTF8ToUTF16(table_name + "_0")); 45 test_helper.GetTempDirPath().Append(UTF8ToUTF16(table_name + "_0"));
46 #else 46 #else
47 base::FilePath indicator_path = 47 base::FilePath indicator_path =
48 test_helper.GetTempDirPath().Append(table_name + "_0"); 48 test_helper.GetTempDirPath().Append(table_name + "_0");
49 #endif 49 #endif
50 50
51 ASSERT_EQ(0, file_util::WriteFile(indicator_path, NULL, 0)); 51 ASSERT_EQ(0, file_util::WriteFile(indicator_path, NULL, 0));
52 // Write three column files, one each for strings, uint32s, and doubles. 52 // Write three column files, one each for strings, uint32s, and doubles.
53 53
54 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( 54 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
55 table_name, column_names[0], column_field_types[0], strings_vector)); 55 table_name, column_names[0], column_field_types[0], strings_vector));
56 56
57 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( 57 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
58 table_name, column_names[1], column_field_types[1], uint32s_vector)); 58 table_name, column_names[1], column_field_types[1], uint32s_vector));
59 59
60 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( 60 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
61 table_name, column_names[2], column_field_types[2], doubles_vector)); 61 table_name, column_names[2], column_field_types[2], doubles_vector));
62 62
63 picasaimport::PmpTableReader table_reader; 63 picasaimport::PmpTableReader table_reader(table_name,
64 ASSERT_TRUE(table_reader.Init( 64 test_helper.GetTempDirPath());
65 table_name, test_helper.GetTempDirPath(), column_names)); 65
66 ASSERT_TRUE(table_reader.Init());
67
68 for(unsigned int i = 0; i < column_names.size(); i++) {
69 ASSERT_TRUE(
70 table_reader.AddColumn(column_names[i], column_field_types[i]) != NULL);
71 }
66 72
67 EXPECT_EQ(max_rows, table_reader.RowCount()); 73 EXPECT_EQ(max_rows, table_reader.RowCount());
68
69 const std::vector<const picasaimport::PmpColumnReader*> column_readers =
70 table_reader.GetColumns();
71
72 for(int i = 0; i < 3; i++) {
73 EXPECT_EQ(column_field_types[i], column_readers[i]->field_type());
74 }
75 } 74 }
76 75
77 } // namespace 76 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698