OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 "base/bind.h" | |
6 #include "base/files/file_path.h" | |
7 #include "base/path_service.h" | |
8 #include "base/run_loop.h" | |
9 #include "chrome/common/chrome_paths.h" | |
10 #include "chrome/utility/media_galleries/image_metadata_extractor.h" | |
11 #include "media/filters/file_data_source.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | |
14 namespace metadata { | |
15 | |
16 void QuitLoop(base::RunLoop* loop, bool* output, bool success) { | |
17 loop->Quit(); | |
18 *output = success; | |
19 } | |
20 | |
21 base::FilePath GetTestDataFilePath(const std::string& filename) { | |
22 base::FilePath path; | |
23 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | |
24 path = path.AppendASCII("extensions").AppendASCII("api_test") | |
25 .AppendASCII("wallpaper").AppendASCII(filename); | |
26 return path; | |
27 } | |
28 | |
29 scoped_ptr<ImageMetadataExtractor> GetExtractor( | |
30 const std::string& filename, | |
31 bool expected_result) { | |
32 media::FileDataSource source; | |
33 base::FilePath test_path; | |
34 | |
35 EXPECT_TRUE(source.Initialize(GetTestDataFilePath(filename))); | |
36 | |
37 scoped_ptr<ImageMetadataExtractor> extractor(new ImageMetadataExtractor); | |
38 | |
39 base::RunLoop loop; | |
40 bool extracted = false; | |
41 extractor->Extract(&source, base::Bind(&QuitLoop, &loop, &extracted)); | |
42 EXPECT_EQ(expected_result, extracted); | |
43 | |
44 return extractor.Pass(); | |
45 } | |
46 | |
47 TEST(ImageMetadataExtractorTest, JPGFile) { | |
48 scoped_ptr<ImageMetadataExtractor> extractor = | |
49 GetExtractor("test.jpg", true); | |
50 | |
51 EXPECT_EQ(5616, extractor->width()); | |
52 EXPECT_EQ(3744, extractor->height()); | |
53 EXPECT_EQ(0, extractor->rotation()); | |
54 EXPECT_EQ(300.0, extractor->x_resolution()); | |
55 EXPECT_EQ(300.0, extractor->y_resolution()); | |
56 EXPECT_EQ("2012:03:01 17:06:07", extractor->date()); | |
57 EXPECT_EQ("Canon", extractor->camera_make()); | |
58 EXPECT_EQ("Canon EOS 5D Mark II", extractor->camera_model()); | |
59 EXPECT_EQ(0.01, extractor->exposure_time_sec()); | |
60 EXPECT_FALSE(extractor->flash_fired()); | |
61 EXPECT_EQ(3.2, extractor->f_number()); | |
62 EXPECT_EQ(100, extractor->focal_length_mm()); | |
63 EXPECT_EQ(1600, extractor->iso_equivalent()); | |
64 } | |
65 | |
66 } // namespace metadata | |
OLD | NEW |