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 #include <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
11 #include "chrome/common/media_galleries/pmp_constants.h" | 11 #include "chrome/common/media_galleries/pmp_constants.h" |
12 #include "chrome/common/media_galleries/pmp_test_util.h" | 12 #include "chrome/common/media_galleries/pmp_test_util.h" |
13 #include "chrome/utility/media_galleries/pmp_column_reader.h" | 13 #include "chrome/utility/media_galleries/pmp_column_reader.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace picasa { | 16 namespace picasa { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 bool InitColumnReaderFromBytes( | 20 bool InitColumnReaderFromBytes( |
21 PmpColumnReader* const reader, | 21 PmpColumnReader* const reader, |
22 const std::vector<char>& data, | 22 const std::vector<char>& data, |
23 const PmpFieldType expected_type) { | 23 const PmpFieldType expected_type) { |
24 base::ScopedTempDir temp_dir; | 24 base::ScopedTempDir temp_dir; |
25 if (!temp_dir.CreateUniqueTempDir()) | 25 if (!temp_dir.CreateUniqueTempDir()) |
26 return false; | 26 return false; |
27 | 27 |
28 base::FilePath temp_path; | 28 base::FilePath temp_path; |
29 if (!file_util::CreateTemporaryFileInDir(temp_dir.path(), &temp_path)) | 29 if (!base::CreateTemporaryFileInDir(temp_dir.path(), &temp_path)) |
30 return false; | 30 return false; |
31 | 31 |
32 // Explicit conversion from signed to unsigned. | 32 // Explicit conversion from signed to unsigned. |
33 size_t bytes_written = file_util::WriteFile(temp_path, &data[0], data.size()); | 33 size_t bytes_written = file_util::WriteFile(temp_path, &data[0], data.size()); |
34 if (bytes_written != data.size()) | 34 if (bytes_written != data.size()) |
35 return false; | 35 return false; |
36 | 36 |
37 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; | 37 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; |
38 base::PlatformFile platform_file = | 38 base::PlatformFile platform_file = |
39 base::CreatePlatformFile(temp_path, flags, NULL, NULL); | 39 base::CreatePlatformFile(temp_path, flags, NULL, NULL); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 TEST(PmpColumnReaderTest, PrimitiveParsing) { | 202 TEST(PmpColumnReaderTest, PrimitiveParsing) { |
203 TestPrimitive<uint32>(PMP_TYPE_UINT32); | 203 TestPrimitive<uint32>(PMP_TYPE_UINT32); |
204 TestPrimitive<double>(PMP_TYPE_DOUBLE64); | 204 TestPrimitive<double>(PMP_TYPE_DOUBLE64); |
205 TestPrimitive<uint8>(PMP_TYPE_UINT8); | 205 TestPrimitive<uint8>(PMP_TYPE_UINT8); |
206 TestPrimitive<uint64>(PMP_TYPE_UINT64); | 206 TestPrimitive<uint64>(PMP_TYPE_UINT64); |
207 } | 207 } |
208 | 208 |
209 } // namespace | 209 } // namespace |
210 | 210 |
211 } // namespace picasa | 211 } // namespace picasa |
OLD | NEW |