| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #include <algorithm> |
| 6 #include <vector> |
| 7 |
| 8 #include "base/file_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "webkit/fileapi/media/picasa/pmp_column_reader.h" |
| 11 #include "webkit/fileapi/media/picasa/pmp_constants.h" |
| 12 #include "webkit/fileapi/media/picasa/pmp_table_reader.h" |
| 13 #include "webkit/fileapi/media/picasa/pmp_test_helper.h" |
| 14 |
| 15 namespace { |
| 16 |
| 17 using picasaimport::PmpTestHelper; |
| 18 |
| 19 TEST(PmpTableReaderTest, RowCountAndFieldType) { |
| 20 PmpTestHelper test_helper; |
| 21 ASSERT_TRUE(test_helper.Init()); |
| 22 |
| 23 std::string table_name = "testtable"; |
| 24 |
| 25 std::vector<std::string> column_names; |
| 26 column_names.push_back("strings"); |
| 27 column_names.push_back("uint32s"); |
| 28 column_names.push_back("doubles"); |
| 29 |
| 30 const std::vector<std::string> strings_vector(10, "Hello"); |
| 31 const std::vector<uint32> uint32s_vector(30, 42); |
| 32 const std::vector<double> doubles_vector(20, 0.5); |
| 33 |
| 34 uint16 column_field_types[] = { |
| 35 picasaimport::STRING_TYPE, |
| 36 picasaimport::UINT32_TYPE, |
| 37 picasaimport::DOUBLE64_TYPE |
| 38 }; |
| 39 |
| 40 const uint32 max_rows = uint32s_vector.size(); |
| 41 |
| 42 ASSERT_EQ(0, file_util::WriteFile( |
| 43 test_helper.GetTempDirPath().Append(table_name + "_0"), NULL, 0)); |
| 44 // Write three column files, one each for strings, uint32s, and doubles. |
| 45 |
| 46 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( |
| 47 table_name, column_names[0], column_field_types[0], strings_vector)); |
| 48 |
| 49 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( |
| 50 table_name, column_names[1], column_field_types[1], uint32s_vector)); |
| 51 |
| 52 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( |
| 53 table_name, column_names[2], column_field_types[2], doubles_vector)); |
| 54 |
| 55 picasaimport::PmpTableReader table_reader; |
| 56 ASSERT_TRUE(table_reader.Init( |
| 57 table_name, test_helper.GetTempDirPath(), column_names)); |
| 58 |
| 59 EXPECT_EQ(max_rows, table_reader.RowCount()); |
| 60 |
| 61 const std::vector<const picasaimport::PmpColumnReader*> column_readers = |
| 62 table_reader.GetColumns(); |
| 63 |
| 64 for(int i = 0; i < 3; i++) { |
| 65 EXPECT_EQ(column_field_types[i], column_readers[i]->field_type()); |
| 66 } |
| 67 } |
| 68 |
| 69 } // namespace |
| OLD | NEW |