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/at_exit.h" |
| 6 #include "base/files/memory_mapped_file.h" |
| 7 #include "base/path_service.h" |
| 8 #include "content/common/gpu/media/vaapi_jpeg_parser.h" |
| 9 #include "media/base/test_data_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 TEST(VaapiJpegParserTest, Parsing) { |
| 15 base::FilePath data_dir; |
| 16 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir)); |
| 17 data_dir = data_dir.AppendASCII("content") |
| 18 .AppendASCII("test") |
| 19 .AppendASCII("data") |
| 20 .AppendASCII("jpeg"); |
| 21 |
| 22 // This sample frame is captured from Chromebook Pixel |
| 23 base::FilePath file_path = data_dir.AppendASCII("pixel-1280x720.bin"); |
| 24 |
| 25 base::MemoryMappedFile stream; |
| 26 ASSERT_TRUE(stream.Initialize(file_path)) |
| 27 << "Couldn't open stream file: " << file_path.MaybeAsASCII(); |
| 28 |
| 29 VaapiJpegParser parser(stream.data(), stream.length()); |
| 30 |
| 31 const JpegParseResult* result = parser.Parse(); |
| 32 ASSERT_TRUE(result != NULL); |
| 33 |
| 34 // Verify selected fields |
| 35 // SOF fields |
| 36 EXPECT_EQ(result->visible_width, 1280); |
| 37 EXPECT_EQ(result->visible_height, 720); |
| 38 EXPECT_EQ(result->num_component, 3); |
| 39 EXPECT_EQ(result->components[0].id, 1); |
| 40 EXPECT_EQ(result->components[1].id, 2); |
| 41 EXPECT_EQ(result->components[2].id, 3); |
| 42 |
| 43 // DQT fields |
| 44 EXPECT_TRUE(result->q_table[0].valid); |
| 45 EXPECT_TRUE(result->q_table[1].valid); |
| 46 |
| 47 // SOS fields |
| 48 EXPECT_EQ(result->scan.components[1].dc_selector, 1); |
| 49 EXPECT_EQ(result->scan.components[1].ac_selector, 1); |
| 50 EXPECT_EQ(result->scan.data_size, 121150u); |
| 51 } |
| 52 |
| 53 } // namespace content |
| 54 |
| 55 int main(int argc, char** argv) { |
| 56 testing::InitGoogleTest(&argc, argv); |
| 57 base::AtExitManager exit_manager; |
| 58 return RUN_ALL_TESTS(); |
| 59 } |
OLD | NEW |