OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // This has to be included first. | 5 // This has to be included first. |
6 // See http://code.google.com/p/googletest/issues/detail?id=371 | 6 // See http://code.google.com/p/googletest/issues/detail?id=371 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 } | 306 } |
307 void SetUp() override; | 307 void SetUp() override; |
308 void TearDown() override; | 308 void TearDown() override; |
309 | 309 |
310 // Create all black test image with |width| and |height| size. | 310 // Create all black test image with |width| and |height| size. |
311 bool CreateTestJpegImage(int width, int height, base::FilePath* filename); | 311 bool CreateTestJpegImage(int width, int height, base::FilePath* filename); |
312 | 312 |
313 // Read image from |filename| to |image_data|. | 313 // Read image from |filename| to |image_data|. |
314 void ReadTestJpegImage(base::FilePath& filename, TestImageFile* image_data); | 314 void ReadTestJpegImage(base::FilePath& filename, TestImageFile* image_data); |
315 | 315 |
316 // Returns a file path for a file in what name specified or media/test/data | |
317 // directory. If the original file path is existed, returns it first. | |
318 base::FilePath GetOriginalOrTestDataFilePath(const std::string& name); | |
319 | |
316 // Parsed data of |test_1280x720_jpeg_file_|. | 320 // Parsed data of |test_1280x720_jpeg_file_|. |
317 std::unique_ptr<TestImageFile> image_data_1280x720_black_; | 321 std::unique_ptr<TestImageFile> image_data_1280x720_black_; |
318 // Parsed data of |test_640x368_jpeg_file_|. | 322 // Parsed data of |test_640x368_jpeg_file_|. |
319 std::unique_ptr<TestImageFile> image_data_640x368_black_; | 323 std::unique_ptr<TestImageFile> image_data_640x368_black_; |
320 // Parsed data of |test_640x360_jpeg_file_|. | 324 // Parsed data of |test_640x360_jpeg_file_|. |
321 std::unique_ptr<TestImageFile> image_data_640x360_black_; | 325 std::unique_ptr<TestImageFile> image_data_640x360_black_; |
322 // Parsed data of "peach_pi-1280x720.jpg". | 326 // Parsed data of "peach_pi-1280x720.jpg". |
323 std::unique_ptr<TestImageFile> image_data_1280x720_default_; | 327 std::unique_ptr<TestImageFile> image_data_1280x720_default_; |
324 // Parsed data of failure image. | 328 // Parsed data of failure image. |
325 std::unique_ptr<TestImageFile> image_data_invalid_; | 329 std::unique_ptr<TestImageFile> image_data_invalid_; |
(...skipping 26 matching lines...) Expand all Loading... | |
352 image_data_640x368_black_.reset( | 356 image_data_640x368_black_.reset( |
353 new TestImageFile(test_640x368_jpeg_file_.value())); | 357 new TestImageFile(test_640x368_jpeg_file_.value())); |
354 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(test_640x368_jpeg_file_, | 358 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(test_640x368_jpeg_file_, |
355 image_data_640x368_black_.get())); | 359 image_data_640x368_black_.get())); |
356 | 360 |
357 image_data_640x360_black_.reset( | 361 image_data_640x360_black_.reset( |
358 new TestImageFile(test_640x360_jpeg_file_.value())); | 362 new TestImageFile(test_640x360_jpeg_file_.value())); |
359 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(test_640x360_jpeg_file_, | 363 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(test_640x360_jpeg_file_, |
360 image_data_640x360_black_.get())); | 364 image_data_640x360_black_.get())); |
361 | 365 |
362 base::FilePath default_jpeg_file = GetTestDataFilePath(kDefaultJpegFilename); | 366 base::FilePath default_jpeg_file = |
367 GetOriginalOrTestDataFilePath(kDefaultJpegFilename); | |
363 image_data_1280x720_default_.reset(new TestImageFile(kDefaultJpegFilename)); | 368 image_data_1280x720_default_.reset(new TestImageFile(kDefaultJpegFilename)); |
364 ASSERT_NO_FATAL_FAILURE( | 369 ASSERT_NO_FATAL_FAILURE( |
365 ReadTestJpegImage(default_jpeg_file, image_data_1280x720_default_.get())); | 370 ReadTestJpegImage(default_jpeg_file, image_data_1280x720_default_.get())); |
366 | 371 |
367 image_data_invalid_.reset(new TestImageFile("failure.jpg")); | 372 image_data_invalid_.reset(new TestImageFile("failure.jpg")); |
368 image_data_invalid_->data_str.resize(100, 0); | 373 image_data_invalid_->data_str.resize(100, 0); |
369 image_data_invalid_->visible_size.SetSize(1280, 720); | 374 image_data_invalid_->visible_size.SetSize(1280, 720); |
370 image_data_invalid_->output_size = VideoFrame::AllocationSize( | 375 image_data_invalid_->output_size = VideoFrame::AllocationSize( |
371 PIXEL_FORMAT_I420, image_data_invalid_->visible_size); | 376 PIXEL_FORMAT_I420, image_data_invalid_->visible_size); |
372 | 377 |
373 // |user_jpeg_filenames_| may include many files and use ';' as delimiter. | 378 // |user_jpeg_filenames_| may include many files and use ';' as delimiter. |
374 std::vector<base::FilePath::StringType> filenames = base::SplitString( | 379 std::vector<base::FilePath::StringType> filenames = base::SplitString( |
375 user_jpeg_filenames_, base::FilePath::StringType(1, ';'), | 380 user_jpeg_filenames_, base::FilePath::StringType(1, ';'), |
376 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 381 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
377 for (const auto& filename : filenames) { | 382 for (const auto& filename : filenames) { |
378 base::FilePath input_file = GetTestDataFilePath(filename); | 383 base::FilePath input_file = GetOriginalOrTestDataFilePath(filename); |
379 auto image_data = base::MakeUnique<TestImageFile>(filename); | 384 auto image_data = base::MakeUnique<TestImageFile>(filename); |
380 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(input_file, image_data.get())); | 385 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(input_file, image_data.get())); |
381 image_data_user_.push_back(std::move(image_data)); | 386 image_data_user_.push_back(std::move(image_data)); |
382 } | 387 } |
383 } | 388 } |
384 | 389 |
385 void JpegDecodeAcceleratorTestEnvironment::TearDown() { | 390 void JpegDecodeAcceleratorTestEnvironment::TearDown() { |
386 base::DeleteFile(test_1280x720_jpeg_file_, false); | 391 base::DeleteFile(test_1280x720_jpeg_file_, false); |
387 base::DeleteFile(test_640x368_jpeg_file_, false); | 392 base::DeleteFile(test_640x368_jpeg_file_, false); |
388 base::DeleteFile(test_640x360_jpeg_file_, false); | 393 base::DeleteFile(test_640x360_jpeg_file_, false); |
(...skipping 27 matching lines...) Expand all Loading... | |
416 ASSERT_TRUE(ParseJpegPicture( | 421 ASSERT_TRUE(ParseJpegPicture( |
417 reinterpret_cast<const uint8_t*>(image_data->data_str.data()), | 422 reinterpret_cast<const uint8_t*>(image_data->data_str.data()), |
418 image_data->data_str.size(), &image_data->parse_result)); | 423 image_data->data_str.size(), &image_data->parse_result)); |
419 image_data->visible_size.SetSize( | 424 image_data->visible_size.SetSize( |
420 image_data->parse_result.frame_header.visible_width, | 425 image_data->parse_result.frame_header.visible_width, |
421 image_data->parse_result.frame_header.visible_height); | 426 image_data->parse_result.frame_header.visible_height); |
422 image_data->output_size = | 427 image_data->output_size = |
423 VideoFrame::AllocationSize(PIXEL_FORMAT_I420, image_data->visible_size); | 428 VideoFrame::AllocationSize(PIXEL_FORMAT_I420, image_data->visible_size); |
424 } | 429 } |
425 | 430 |
431 base::FilePath | |
432 JpegDecodeAcceleratorTestEnvironment::GetOriginalOrTestDataFilePath( | |
433 const std::string& name) { | |
434 base::FilePath original_file_path = base::FilePath(name); | |
435 | |
436 if (PathExists(original_file_path)) | |
437 return original_file_path; | |
438 | |
439 return GetTestDataFilePath(name); | |
henryhsu
2017/06/12 07:58:45
how about print the final path to know the path we
mojahsu1
2017/06/14 06:49:12
Done.
| |
440 } | |
441 | |
426 class JpegDecodeAcceleratorTest : public ::testing::Test { | 442 class JpegDecodeAcceleratorTest : public ::testing::Test { |
427 protected: | 443 protected: |
428 JpegDecodeAcceleratorTest() {} | 444 JpegDecodeAcceleratorTest() {} |
429 | 445 |
430 void TestDecode(size_t num_concurrent_decoders); | 446 void TestDecode(size_t num_concurrent_decoders); |
431 | 447 |
432 // The elements of |test_image_files_| are owned by | 448 // The elements of |test_image_files_| are owned by |
433 // JpegDecodeAcceleratorTestEnvironment. | 449 // JpegDecodeAcceleratorTestEnvironment. |
434 std::vector<TestImageFile*> test_image_files_; | 450 std::vector<TestImageFile*> test_image_files_; |
435 std::vector<ClientState> expected_status_; | 451 std::vector<ClientState> expected_status_; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
583 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 599 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
584 media::VaapiWrapper::PreSandboxInitialization(); | 600 media::VaapiWrapper::PreSandboxInitialization(); |
585 #endif | 601 #endif |
586 | 602 |
587 media::g_env = reinterpret_cast<media::JpegDecodeAcceleratorTestEnvironment*>( | 603 media::g_env = reinterpret_cast<media::JpegDecodeAcceleratorTestEnvironment*>( |
588 testing::AddGlobalTestEnvironment( | 604 testing::AddGlobalTestEnvironment( |
589 new media::JpegDecodeAcceleratorTestEnvironment(jpeg_filenames))); | 605 new media::JpegDecodeAcceleratorTestEnvironment(jpeg_filenames))); |
590 | 606 |
591 return RUN_ALL_TESTS(); | 607 return RUN_ALL_TESTS(); |
592 } | 608 } |
OLD | NEW |