Index: content/common/gpu/media/vaapi_jpeg_parser_unittest.cc |
diff --git a/content/common/gpu/media/vaapi_jpeg_parser_unittest.cc b/content/common/gpu/media/vaapi_jpeg_parser_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eee6371e3a3f3e8dfeebb0a71c84b5c55f51b626 |
--- /dev/null |
+++ b/content/common/gpu/media/vaapi_jpeg_parser_unittest.cc |
@@ -0,0 +1,60 @@ |
+// Copyright 2014 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. |
+ |
+#include "base/at_exit.h" |
+#include "base/files/memory_mapped_file.h" |
+#include "base/path_service.h" |
+#include "content/common/gpu/media/vaapi_jpeg_parser.h" |
+#include "media/base/test_data_util.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace content { |
+ |
+TEST(VaapiJpegParserTest, Parsing) { |
wuchengli
2014/12/08 09:25:11
Is there any Parse() failure case worth testing?
|
+ base::FilePath data_dir; |
+ ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir)); |
+ data_dir = data_dir.AppendASCII("content") |
+ .AppendASCII("test") |
+ .AppendASCII("data") |
+ .AppendASCII("jpeg"); |
+ |
+ // This sample frame is captured from Chromebook Pixel |
+ base::FilePath file_path = data_dir.AppendASCII("pixel-1280x720.bin"); |
wuchengli
2014/12/08 09:25:11
Combine this with previous statement.
base::FilePa
|
+ |
+ base::MemoryMappedFile stream; |
+ ASSERT_TRUE(stream.Initialize(file_path)) |
+ << "Couldn't open stream file: " << file_path.MaybeAsASCII(); |
+ |
+ VaapiJpegParser parser(stream.data(), stream.length()); |
+ |
+ ASSERT_TRUE(parser.Parse()); |
+ |
+ const JpegParseResult* result = parser.GetParsedResult(); |
+ |
+ // Verify selected fields |
+ // SOF fields |
+ ASSERT_EQ(result->visible_width, 1280); |
wuchengli
2014/12/08 09:25:11
Use EXPECT_ for all the following cases to verify
kcwu
2014/12/16 06:23:55
Done.
|
+ ASSERT_EQ(result->visible_height, 720); |
+ ASSERT_EQ(result->num_component, 3); |
+ ASSERT_EQ(result->components[0].id, 1); |
+ ASSERT_EQ(result->components[1].id, 2); |
+ ASSERT_EQ(result->components[2].id, 3); |
+ |
+ // DQT fields |
+ ASSERT_TRUE(result->q_table[0].valid); |
+ ASSERT_TRUE(result->q_table[1].valid); |
+ |
+ // SOS fields |
+ ASSERT_EQ(result->scan.components[1].dc_selector, 1); |
+ ASSERT_EQ(result->scan.components[1].ac_selector, 1); |
+ ASSERT_EQ(result->scan.data_size, 121150u); |
wuchengli
2014/12/08 09:25:11
You should verify all or most the fields in vaapi_
|
+} |
+ |
+} // namespace content |
+ |
+int main(int argc, char** argv) { |
+ testing::InitGoogleTest(&argc, argv); |
+ base::AtExitManager exit_manager; |
+ return RUN_ALL_TESTS(); |
+} |