| 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 #ifndef CHROME_COMMON_MEDIA_GALLERIES_PMP_TEST_HELPER_H_ | 5 #ifndef CHROME_COMMON_MEDIA_GALLERIES_PMP_TEST_HELPER_H_ |
| 6 #define CHROME_COMMON_MEDIA_GALLERIES_PMP_TEST_HELPER_H_ | 6 #define CHROME_COMMON_MEDIA_GALLERIES_PMP_TEST_HELPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/files/file_path.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 13 #include "chrome/common/media_galleries/pmp_constants.h" | 14 #include "chrome/common/media_galleries/pmp_constants.h" |
| 14 | 15 |
| 15 namespace base { | |
| 16 class FilePath; | |
| 17 } // namespace base | |
| 18 | |
| 19 namespace picasa { | 16 namespace picasa { |
| 20 | 17 |
| 21 class PmpColumnReader; | 18 class PmpColumnReader; |
| 22 | 19 |
| 23 // A helper class used for unit tests only | 20 // A helper class used for tests only |
| 24 class PmpTestHelper { | 21 class PmpTestHelper { |
| 25 public: | 22 public: |
| 23 enum ColumnFileDestination { |
| 24 DATABASE_DIRECTORY, |
| 25 TEMPORARY_DIRECTORY |
| 26 }; |
| 27 |
| 26 explicit PmpTestHelper(const std::string& table_name); | 28 explicit PmpTestHelper(const std::string& table_name); |
| 27 | 29 |
| 28 bool Init(); | 30 bool Init(ColumnFileDestination column_file_destination); |
| 29 | 31 |
| 30 base::FilePath GetTempDirPath(); | 32 base::FilePath GetDatabaseDirPath() const; |
| 33 base::FilePath GetTempDirPath() const; |
| 31 | 34 |
| 32 template<class T> | 35 template<class T> |
| 33 bool WriteColumnFileFromVector(const std::string& column_name, | 36 bool WriteColumnFileFromVector(const std::string& column_name, |
| 34 const PmpFieldType field_type, | 37 const PmpFieldType field_type, |
| 35 const std::vector<T>& elements_vector); | 38 const std::vector<T>& elements_vector) const; |
| 36 | 39 |
| 37 static std::vector<char> MakeHeader(const PmpFieldType field_type, | 40 static std::vector<char> MakeHeader(const PmpFieldType field_type, |
| 38 const uint32 row_count); | 41 const uint32 row_count); |
| 39 | 42 |
| 40 template<class T> | 43 template<class T> |
| 41 static std::vector<char> MakeHeaderAndBody(const PmpFieldType field_type, | 44 static std::vector<char> MakeHeaderAndBody(const PmpFieldType field_type, |
| 42 const uint32 row_count, | 45 const uint32 row_count, |
| 43 const std::vector<T>& elems); | 46 const std::vector<T>& elems); |
| 44 | 47 |
| 45 private: | 48 private: |
| 46 std::string table_name_; | 49 std::string table_name_; |
| 47 base::ScopedTempDir temp_dir_; | 50 base::ScopedTempDir root_dir_; |
| 51 base::FilePath column_file_destination_directory_; |
| 48 }; | 52 }; |
| 49 | 53 |
| 50 } // namespace picasa | 54 } // namespace picasa |
| 51 | 55 |
| 52 #endif // CHROME_COMMON_MEDIA_GALLERIES_PMP_TEST_HELPER_H_ | 56 #endif // CHROME_COMMON_MEDIA_GALLERIES_PMP_TEST_HELPER_H_ |
| OLD | NEW |