| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |