Chromium Code Reviews| 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 #ifndef WEBKIT_FILEAPI_MEDIA_PICASA_PMP_TEST_HELPER_H_ | |
| 6 #define WEBKIT_FILEAPI_MEDIA_PICASA_PMP_TEST_HELPER_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/files/scoped_temp_dir.h" | |
| 12 | |
| 13 namespace base { | |
| 14 | |
| 15 class FilePath; | |
| 16 | |
| 17 } // namespace base | |
| 18 | |
| 19 namespace picasaimport { | |
| 20 | |
| 21 class PmpColumnReader; | |
| 22 | |
| 23 // A helper class used for unit tests only | |
| 24 class PmpTestHelper { | |
| 25 public: | |
| 26 PmpTestHelper(); | |
| 27 | |
| 28 bool Init(); | |
|
vandebo (ex-Chrome)
2013/04/02 22:17:58
Why an empty Init, just put it in the constructor.
tommycli
2013/04/05 16:49:24
This can fail if the temporary directory is not su
| |
| 29 | |
| 30 base::FilePath GetTempDirPath(); | |
|
vandebo (ex-Chrome)
2013/04/02 22:17:58
nit: temp_dir()
tommycli
2013/04/05 16:49:24
The body of this is actually "return temp_dir_.pat
| |
| 31 | |
| 32 template<class T> | |
| 33 bool WriteColumnFileFromVector(std::string table_name, | |
| 34 std::string column_name, | |
| 35 const uint16 field_type, | |
| 36 std::vector<T> elements_vector); | |
| 37 | |
| 38 bool InitColumnReaderFromBytes(PmpColumnReader* const reader, | |
| 39 std::vector<uint8> data, uint32* rows_read); | |
| 40 | |
| 41 static std::vector<uint8> MakeHeader(const uint16 field_type, | |
| 42 const uint32 row_count); | |
| 43 | |
| 44 template<class T> | |
| 45 static std::vector<uint8> MakeHeaderAndBody(const uint16 field_type, | |
| 46 const uint32 row_count, | |
| 47 const std::vector<T>& elems); | |
| 48 | |
| 49 private: | |
| 50 static bool WriteToFile(const base::FilePath& path, std::vector<uint8> data); | |
|
vandebo (ex-Chrome)
2013/04/02 22:17:58
These don't need to be part of the class, just mak
tommycli
2013/04/05 16:49:24
Good call.
| |
| 51 | |
| 52 // Flatten a vector of elements into an array of bytes. | |
| 53 template<class T> | |
| 54 static std::vector<uint8> Flatten(const std::vector<T>& elems); | |
| 55 | |
| 56 // Returns a new vector with the concatenated contents of |a| and |b|. | |
| 57 static std::vector<uint8> CombinedVectors(const std::vector<uint8>& a, | |
| 58 const std::vector<uint8>& b); | |
| 59 | |
| 60 base::ScopedTempDir temp_dir_; | |
| 61 }; | |
| 62 | |
| 63 } // namespace picasaimport | |
| 64 | |
| 65 #endif // WEBKIT_FILEAPI_MEDIA_PICASA_PMP_TEST_HELPER_H_ | |
| OLD | NEW |