Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: media/gpu/jpeg_decode_accelerator_unittest.cc

Issue 2893953002: Revert of Remove ScopedVector from all other codes in media/ (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <string.h> 11 #include <string.h>
12 12
13 #include <memory> 13 #include <memory>
14 14
15 #include "base/at_exit.h" 15 #include "base/at_exit.h"
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/memory/ptr_util.h" 21 #include "base/memory/scoped_vector.h"
22 #include "base/path_service.h" 22 #include "base/path_service.h"
23 #include "base/strings/string_piece.h" 23 #include "base/strings/string_piece.h"
24 #include "base/strings/string_split.h" 24 #include "base/strings/string_split.h"
25 #include "base/threading/thread_task_runner_handle.h" 25 #include "base/threading/thread_task_runner_handle.h"
26 #include "build/build_config.h" 26 #include "build/build_config.h"
27 #include "media/base/test_data_util.h" 27 #include "media/base/test_data_util.h"
28 #include "media/filters/jpeg_parser.h" 28 #include "media/filters/jpeg_parser.h"
29 #include "media/gpu/video_accelerator_unittest_helpers.h" 29 #include "media/gpu/video_accelerator_unittest_helpers.h"
30 #include "media/video/jpeg_decode_accelerator.h" 30 #include "media/video/jpeg_decode_accelerator.h"
31 #include "third_party/libyuv/include/libyuv.h" 31 #include "third_party/libyuv/include/libyuv.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 std::unique_ptr<TestImageFile> image_data_1280x720_black_; 317 std::unique_ptr<TestImageFile> image_data_1280x720_black_;
318 // Parsed data of |test_640x368_jpeg_file_|. 318 // Parsed data of |test_640x368_jpeg_file_|.
319 std::unique_ptr<TestImageFile> image_data_640x368_black_; 319 std::unique_ptr<TestImageFile> image_data_640x368_black_;
320 // Parsed data of |test_640x360_jpeg_file_|. 320 // Parsed data of |test_640x360_jpeg_file_|.
321 std::unique_ptr<TestImageFile> image_data_640x360_black_; 321 std::unique_ptr<TestImageFile> image_data_640x360_black_;
322 // Parsed data of "peach_pi-1280x720.jpg". 322 // Parsed data of "peach_pi-1280x720.jpg".
323 std::unique_ptr<TestImageFile> image_data_1280x720_default_; 323 std::unique_ptr<TestImageFile> image_data_1280x720_default_;
324 // Parsed data of failure image. 324 // Parsed data of failure image.
325 std::unique_ptr<TestImageFile> image_data_invalid_; 325 std::unique_ptr<TestImageFile> image_data_invalid_;
326 // Parsed data from command line. 326 // Parsed data from command line.
327 std::vector<std::unique_ptr<TestImageFile>> image_data_user_; 327 ScopedVector<TestImageFile> image_data_user_;
328 328
329 private: 329 private:
330 const base::FilePath::CharType* user_jpeg_filenames_; 330 const base::FilePath::CharType* user_jpeg_filenames_;
331 331
332 // Used for InputSizeChange test case. The image size should be smaller than 332 // Used for InputSizeChange test case. The image size should be smaller than
333 // |kDefaultJpegFilename|. 333 // |kDefaultJpegFilename|.
334 base::FilePath test_1280x720_jpeg_file_; 334 base::FilePath test_1280x720_jpeg_file_;
335 // Used for ResolutionChange test case. 335 // Used for ResolutionChange test case.
336 base::FilePath test_640x368_jpeg_file_; 336 base::FilePath test_640x368_jpeg_file_;
337 // Used for testing some drivers which will align the output resolution to a 337 // Used for testing some drivers which will align the output resolution to a
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 image_data_invalid_->visible_size.SetSize(1280, 720); 369 image_data_invalid_->visible_size.SetSize(1280, 720);
370 image_data_invalid_->output_size = VideoFrame::AllocationSize( 370 image_data_invalid_->output_size = VideoFrame::AllocationSize(
371 PIXEL_FORMAT_I420, image_data_invalid_->visible_size); 371 PIXEL_FORMAT_I420, image_data_invalid_->visible_size);
372 372
373 // |user_jpeg_filenames_| may include many files and use ';' as delimiter. 373 // |user_jpeg_filenames_| may include many files and use ';' as delimiter.
374 std::vector<base::FilePath::StringType> filenames = base::SplitString( 374 std::vector<base::FilePath::StringType> filenames = base::SplitString(
375 user_jpeg_filenames_, base::FilePath::StringType(1, ';'), 375 user_jpeg_filenames_, base::FilePath::StringType(1, ';'),
376 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 376 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
377 for (const auto& filename : filenames) { 377 for (const auto& filename : filenames) {
378 base::FilePath input_file = GetTestDataFilePath(filename); 378 base::FilePath input_file = GetTestDataFilePath(filename);
379 auto image_data = base::MakeUnique<TestImageFile>(filename); 379 TestImageFile* image_data = new TestImageFile(filename);
380 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(input_file, image_data)); 380 ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(input_file, image_data));
381 image_data_user_.push_back(image_data); 381 image_data_user_.push_back(image_data);
382 } 382 }
383 } 383 }
384 384
385 void JpegDecodeAcceleratorTestEnvironment::TearDown() { 385 void JpegDecodeAcceleratorTestEnvironment::TearDown() {
386 base::DeleteFile(test_1280x720_jpeg_file_, false); 386 base::DeleteFile(test_1280x720_jpeg_file_, false);
387 base::DeleteFile(test_640x368_jpeg_file_, false); 387 base::DeleteFile(test_640x368_jpeg_file_, false);
388 base::DeleteFile(test_640x360_jpeg_file_, false); 388 base::DeleteFile(test_640x360_jpeg_file_, false);
389 } 389 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 436
437 protected: 437 protected:
438 DISALLOW_COPY_AND_ASSIGN(JpegDecodeAcceleratorTest); 438 DISALLOW_COPY_AND_ASSIGN(JpegDecodeAcceleratorTest);
439 }; 439 };
440 440
441 void JpegDecodeAcceleratorTest::TestDecode(size_t num_concurrent_decoders) { 441 void JpegDecodeAcceleratorTest::TestDecode(size_t num_concurrent_decoders) {
442 LOG_ASSERT(test_image_files_.size() >= expected_status_.size()); 442 LOG_ASSERT(test_image_files_.size() >= expected_status_.size());
443 base::Thread decoder_thread("DecoderThread"); 443 base::Thread decoder_thread("DecoderThread");
444 ASSERT_TRUE(decoder_thread.Start()); 444 ASSERT_TRUE(decoder_thread.Start());
445 445
446 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>> notes; 446 ScopedVector<ClientStateNotification<ClientState>> notes;
447 std::vector<std::unique_ptr<JpegClient>> clients; 447 ScopedVector<JpegClient> clients;
448 448
449 for (size_t i = 0; i < num_concurrent_decoders; i++) { 449 for (size_t i = 0; i < num_concurrent_decoders; i++) {
450 notes.push_back(base::MakeUnique<ClientStateNotification<ClientState>>()); 450 notes.push_back(new ClientStateNotification<ClientState>());
451 clients.push_back( 451 clients.push_back(new JpegClient(test_image_files_, notes.back()));
452 base::MakeUnique<JpegClient>(test_image_files_, notes.back()));
453 decoder_thread.task_runner()->PostTask( 452 decoder_thread.task_runner()->PostTask(
454 FROM_HERE, base::Bind(&JpegClient::CreateJpegDecoder, 453 FROM_HERE, base::Bind(&JpegClient::CreateJpegDecoder,
455 base::Unretained(clients.back().get()))); 454 base::Unretained(clients.back())));
456 ASSERT_EQ(notes[i]->Wait(), CS_INITIALIZED); 455 ASSERT_EQ(notes[i]->Wait(), CS_INITIALIZED);
457 } 456 }
458 457
459 for (size_t index = 0; index < test_image_files_.size(); index++) { 458 for (size_t index = 0; index < test_image_files_.size(); index++) {
460 for (size_t i = 0; i < num_concurrent_decoders; i++) { 459 for (size_t i = 0; i < num_concurrent_decoders; i++) {
461 decoder_thread.task_runner()->PostTask( 460 decoder_thread.task_runner()->PostTask(
462 FROM_HERE, base::Bind(&JpegClient::StartDecode, 461 FROM_HERE, base::Bind(&JpegClient::StartDecode,
463 base::Unretained(clients[i].get(), index)); 462 base::Unretained(clients[i]), index));
464 } 463 }
465 if (index < expected_status_.size()) { 464 if (index < expected_status_.size()) {
466 for (size_t i = 0; i < num_concurrent_decoders; i++) { 465 for (size_t i = 0; i < num_concurrent_decoders; i++) {
467 ASSERT_EQ(notes[i]->Wait(), expected_status_[index]); 466 ASSERT_EQ(notes[i]->Wait(), expected_status_[index]);
468 } 467 }
469 } 468 }
470 } 469 }
471 470
472 for (size_t i = 0; i < num_concurrent_decoders; i++) { 471 for (size_t i = 0; i < num_concurrent_decoders; i++) {
473 decoder_thread.task_runner()->PostTask( 472 decoder_thread.task_runner()->PostTask(
474 FROM_HERE, base::Bind(&JpegClient::DestroyJpegDecoder, 473 FROM_HERE, base::Bind(&JpegClient::DestroyJpegDecoder,
475 base::Unretained(clients[i].get()))); 474 base::Unretained(clients[i])));
476 } 475 }
477 decoder_thread.Stop(); 476 decoder_thread.Stop();
478 } 477 }
479 478
480 TEST_F(JpegDecodeAcceleratorTest, SimpleDecode) { 479 TEST_F(JpegDecodeAcceleratorTest, SimpleDecode) {
481 for (auto* image : g_env->image_data_user_) { 480 for (auto* image : g_env->image_data_user_) {
482 test_image_files_.push_back(image); 481 test_image_files_.push_back(image);
483 expected_status_.push_back(CS_DECODE_PASS); 482 expected_status_.push_back(CS_DECODE_PASS);
484 } 483 }
485 TestDecode(1); 484 TestDecode(1);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 582 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
584 media::VaapiWrapper::PreSandboxInitialization(); 583 media::VaapiWrapper::PreSandboxInitialization();
585 #endif 584 #endif
586 585
587 media::g_env = reinterpret_cast<media::JpegDecodeAcceleratorTestEnvironment*>( 586 media::g_env = reinterpret_cast<media::JpegDecodeAcceleratorTestEnvironment*>(
588 testing::AddGlobalTestEnvironment( 587 testing::AddGlobalTestEnvironment(
589 new media::JpegDecodeAcceleratorTestEnvironment(jpeg_filenames))); 588 new media::JpegDecodeAcceleratorTestEnvironment(jpeg_filenames)));
590 589
591 return RUN_ALL_TESTS(); 590 return RUN_ALL_TESTS();
592 } 591 }
OLDNEW
« no previous file with comments | « media/formats/webm/webm_cluster_parser_unittest.cc ('k') | media/gpu/video_encode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698