| 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/strings/utf_string_conversions.h" | |
| 9 #include "chrome/browser/media_galleries/fileapi/picasa/pmp_column_reader.h" | |
| 10 #include "chrome/browser/media_galleries/fileapi/picasa/pmp_constants.h" | |
| 11 #include "chrome/browser/media_galleries/fileapi/picasa/pmp_table_reader.h" | |
| 12 #include "chrome/browser/media_galleries/fileapi/picasa/pmp_test_helper.h" | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 using picasa::PmpTestHelper; | |
| 18 | |
| 19 TEST(PmpTableReaderTest, RowCountAndFieldType) { | |
| 20 std::string table_name("tabletest"); | |
| 21 PmpTestHelper test_helper(table_name); | |
| 22 ASSERT_TRUE(test_helper.Init()); | |
| 23 | |
| 24 std::vector<std::string> column_names; | |
| 25 column_names.push_back("strings"); | |
| 26 column_names.push_back("uint32s"); | |
| 27 column_names.push_back("doubles"); | |
| 28 | |
| 29 const std::vector<std::string> strings_vector(10, "Hello"); | |
| 30 const std::vector<uint32> uint32s_vector(30, 42); | |
| 31 const std::vector<double> doubles_vector(20, 0.5); | |
| 32 | |
| 33 picasa::PmpFieldType column_field_types[] = { | |
| 34 picasa::PMP_TYPE_STRING, | |
| 35 picasa::PMP_TYPE_UINT32, | |
| 36 picasa::PMP_TYPE_DOUBLE64 | |
| 37 }; | |
| 38 | |
| 39 const uint32 max_rows = uint32s_vector.size(); | |
| 40 | |
| 41 // Write three column files, one each for strings, uint32s, and doubles. | |
| 42 | |
| 43 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( | |
| 44 column_names[0], column_field_types[0], strings_vector)); | |
| 45 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( | |
| 46 column_names[1], column_field_types[1], uint32s_vector)); | |
| 47 ASSERT_TRUE(test_helper.WriteColumnFileFromVector( | |
| 48 column_names[2], column_field_types[2], doubles_vector)); | |
| 49 | |
| 50 picasa::PmpTableReader table_reader(table_name, | |
| 51 test_helper.GetTempDirPath()); | |
| 52 | |
| 53 for (unsigned int i = 0; i < column_names.size(); i++) { | |
| 54 ASSERT_TRUE( | |
| 55 table_reader.AddColumn(column_names[i], column_field_types[i]) != NULL); | |
| 56 } | |
| 57 | |
| 58 EXPECT_EQ(max_rows, table_reader.RowCount()); | |
| 59 } | |
| 60 | |
| 61 } // namespace | |
| OLD | NEW |