Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Unified Diff: webkit/fileapi/media/picasa/pmp_test_helper.h

Issue 12704024: Simple PMP reader to parse Picasa's metadata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make PmpTestHelper stateful and possess the temporary directory. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/fileapi/media/picasa/pmp_test_helper.h
diff --git a/webkit/fileapi/media/picasa/pmp_test_helper.h b/webkit/fileapi/media/picasa/pmp_test_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..b74d46c111bcac9784a2a0c08f2c724d85a98d1a
--- /dev/null
+++ b/webkit/fileapi/media/picasa/pmp_test_helper.h
@@ -0,0 +1,65 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_FILEAPI_MEDIA_PICASA_PMP_TEST_HELPER_H_
+#define WEBKIT_FILEAPI_MEDIA_PICASA_PMP_TEST_HELPER_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/files/scoped_temp_dir.h"
+
+namespace base {
+
+class FilePath;
+
+} // namespace base
+
+namespace picasaimport {
+
+class PmpColumnReader;
+
+// A helper class used for unit tests only
+class PmpTestHelper {
+ public:
+ PmpTestHelper();
+
+ 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
+
+ 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
+
+ template<class T>
+ bool WriteColumnFileFromVector(std::string table_name,
+ std::string column_name,
+ const uint16 field_type,
+ std::vector<T> elements_vector);
+
+ bool InitColumnReaderFromBytes(PmpColumnReader* const reader,
+ std::vector<uint8> data, uint32* rows_read);
+
+ static std::vector<uint8> MakeHeader(const uint16 field_type,
+ const uint32 row_count);
+
+ template<class T>
+ static std::vector<uint8> MakeHeaderAndBody(const uint16 field_type,
+ const uint32 row_count,
+ const std::vector<T>& elems);
+
+ private:
+ 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.
+
+ // Flatten a vector of elements into an array of bytes.
+ template<class T>
+ static std::vector<uint8> Flatten(const std::vector<T>& elems);
+
+ // Returns a new vector with the concatenated contents of |a| and |b|.
+ static std::vector<uint8> CombinedVectors(const std::vector<uint8>& a,
+ const std::vector<uint8>& b);
+
+ base::ScopedTempDir temp_dir_;
+};
+
+} // namespace picasaimport
+
+#endif // WEBKIT_FILEAPI_MEDIA_PICASA_PMP_TEST_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698