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

Side by Side Diff: remoting/test/test_video_renderer_unittest.cc

Issue 2627433003: Remove ScopedVector from remoting/. (Closed)
Patch Set: rev Created 3 years, 11 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
« no previous file with comments | « remoting/signaling/xmpp_stream_parser_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "remoting/test/test_video_renderer.h" 5 #include "remoting/test/test_video_renderer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <memory>
10 #include <utility> 11 #include <utility>
12 #include <vector>
11 13
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
14 #include "base/memory/scoped_vector.h"
15 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
16 #include "base/run_loop.h" 17 #include "base/run_loop.h"
17 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
19 #include "remoting/codec/video_encoder.h" 20 #include "remoting/codec/video_encoder.h"
20 #include "remoting/codec/video_encoder_verbatim.h" 21 #include "remoting/codec/video_encoder_verbatim.h"
21 #include "remoting/codec/video_encoder_vpx.h" 22 #include "remoting/codec/video_encoder_vpx.h"
22 #include "remoting/proto/video.pb.h" 23 #include "remoting/proto/video.pb.h"
23 #include "remoting/test/rgb_value.h" 24 #include "remoting/test/rgb_value.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 TEST_F(TestVideoRendererTest, VerifyMultipleVideoProcessing) { 393 TEST_F(TestVideoRendererTest, VerifyMultipleVideoProcessing) {
393 encoder_ = VideoEncoderVpx::CreateForVP8(); 394 encoder_ = VideoEncoderVpx::CreateForVP8();
394 test_video_renderer_->SetCodecForDecoding( 395 test_video_renderer_->SetCodecForDecoding(
395 protocol::ChannelConfig::CODEC_VP8); 396 protocol::ChannelConfig::CODEC_VP8);
396 397
397 // Post multiple tasks to |test_video_renderer_|, and it should not crash. 398 // Post multiple tasks to |test_video_renderer_|, and it should not crash.
398 // 20 is chosen because it's large enough to make sure that there will be 399 // 20 is chosen because it's large enough to make sure that there will be
399 // more than one task on the video decode thread, while not too large to wait 400 // more than one task on the video decode thread, while not too large to wait
400 // for too long for the unit test to complete. 401 // for too long for the unit test to complete.
401 const int task_num = 20; 402 const int task_num = 20;
402 ScopedVector<VideoPacket> video_packets; 403 std::vector<std::unique_ptr<VideoPacket>> video_packets;
403 for (int i = 0; i < task_num; ++i) { 404 for (int i = 0; i < task_num; ++i) {
404 std::unique_ptr<webrtc::DesktopFrame> original_frame = 405 std::unique_ptr<webrtc::DesktopFrame> original_frame =
405 CreateDesktopFrameWithGradient(kDefaultScreenWidthPx, 406 CreateDesktopFrameWithGradient(kDefaultScreenWidthPx,
406 kDefaultScreenHeightPx); 407 kDefaultScreenHeightPx);
407 video_packets.push_back(encoder_->Encode(*original_frame.get())); 408 video_packets.push_back(encoder_->Encode(*original_frame.get()));
408 } 409 }
409 410
410 for (int i = 0; i < task_num; ++i) { 411 for (auto& packet : video_packets) {
411 // Transfer ownership of video packet. 412 test_video_renderer_->ProcessVideoPacket(std::move(packet),
412 VideoPacket* packet = video_packets[i];
413 video_packets[i] = nullptr;
414 test_video_renderer_->ProcessVideoPacket(base::WrapUnique(packet),
415 base::Bind(&base::DoNothing)); 413 base::Bind(&base::DoNothing));
416 } 414 }
417 } 415 }
418 416
419 // Verify video packet size change is handled properly. 417 // Verify video packet size change is handled properly.
420 TEST_F(TestVideoRendererTest, VerifyVideoPacketSizeChange) { 418 TEST_F(TestVideoRendererTest, VerifyVideoPacketSizeChange) {
421 encoder_ = VideoEncoderVpx::CreateForVP8(); 419 encoder_ = VideoEncoderVpx::CreateForVP8();
422 test_video_renderer_->SetCodecForDecoding( 420 test_video_renderer_->SetCodecForDecoding(
423 protocol::ChannelConfig::Codec::CODEC_VP8); 421 protocol::ChannelConfig::Codec::CODEC_VP8);
424 422
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 TEST_F(TestVideoRendererTest, VerifyImagePatternNotMatchForVERBATIM) { 504 TEST_F(TestVideoRendererTest, VerifyImagePatternNotMatchForVERBATIM) {
507 encoder_.reset(new VideoEncoderVerbatim()); 505 encoder_.reset(new VideoEncoderVerbatim());
508 test_video_renderer_->SetCodecForDecoding( 506 test_video_renderer_->SetCodecForDecoding(
509 protocol::ChannelConfig::Codec::CODEC_VERBATIM); 507 protocol::ChannelConfig::Codec::CODEC_VERBATIM);
510 TestImagePatternMatch(kDefaultScreenWidthPx, kDefaultScreenHeightPx, 508 TestImagePatternMatch(kDefaultScreenWidthPx, kDefaultScreenHeightPx,
511 kDefaultExpectedRect, false); 509 kDefaultExpectedRect, false);
512 } 510 }
513 511
514 } // namespace test 512 } // namespace test
515 } // namespace remoting 513 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/signaling/xmpp_stream_parser_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698