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

Side by Side Diff: remoting/host/audio_pump_unittest.cc

Issue 1549493004: Use std::move() instead of .Pass() in remoting/host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass
Patch Set: Created 5 years 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 #include "remoting/host/audio_pump.h" 5 #include "remoting/host/audio_pump.h"
6 6
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "remoting/codec/audio_encoder.h" 10 #include "remoting/codec/audio_encoder.h"
11 #include "remoting/host/audio_capturer.h" 11 #include "remoting/host/audio_capturer.h"
12 #include "remoting/proto/audio.pb.h" 12 #include "remoting/proto/audio.pb.h"
13 #include "remoting/protocol/audio_stub.h" 13 #include "remoting/protocol/audio_stub.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 namespace { 18 namespace {
19 19
20 // Creates a dummy packet with 1k data 20 // Creates a dummy packet with 1k data
21 scoped_ptr<AudioPacket> MakeAudioPacket() { 21 scoped_ptr<AudioPacket> MakeAudioPacket() {
22 scoped_ptr<AudioPacket> packet(new AudioPacket); 22 scoped_ptr<AudioPacket> packet(new AudioPacket);
23 packet->add_data()->resize(1000); 23 packet->add_data()->resize(1000);
24 return packet.Pass(); 24 return packet;
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 class FakeAudioCapturer : public AudioCapturer { 29 class FakeAudioCapturer : public AudioCapturer {
30 public: 30 public:
31 FakeAudioCapturer() {} 31 FakeAudioCapturer() {}
32 ~FakeAudioCapturer() override {} 32 ~FakeAudioCapturer() override {}
33 33
34 bool Start(const PacketCapturedCallback& callback) override { 34 bool Start(const PacketCapturedCallback& callback) override {
35 callback_ = callback; 35 callback_ = callback;
36 return true; 36 return true;
37 } 37 }
38 38
39 const PacketCapturedCallback& callback() { return callback_; } 39 const PacketCapturedCallback& callback() { return callback_; }
40 40
41 private: 41 private:
42 PacketCapturedCallback callback_; 42 PacketCapturedCallback callback_;
43 43
44 DISALLOW_COPY_AND_ASSIGN(FakeAudioCapturer); 44 DISALLOW_COPY_AND_ASSIGN(FakeAudioCapturer);
45 }; 45 };
46 46
47 class FakeAudioEncoder : public AudioEncoder { 47 class FakeAudioEncoder : public AudioEncoder {
48 public: 48 public:
49 FakeAudioEncoder() {} 49 FakeAudioEncoder() {}
50 ~FakeAudioEncoder() override {} 50 ~FakeAudioEncoder() override {}
51 51
52 scoped_ptr<AudioPacket> Encode(scoped_ptr<AudioPacket> packet) override { 52 scoped_ptr<AudioPacket> Encode(scoped_ptr<AudioPacket> packet) override {
53 return packet.Pass(); 53 return packet;
54 } 54 }
55 int GetBitrate() override { 55 int GetBitrate() override {
56 return 160000; 56 return 160000;
57 } 57 }
58 58
59 private: 59 private:
60 DISALLOW_COPY_AND_ASSIGN(FakeAudioEncoder); 60 DISALLOW_COPY_AND_ASSIGN(FakeAudioEncoder);
61 }; 61 };
62 62
63 class AudioPumpTest : public testing::Test, public protocol::AudioStub { 63 class AudioPumpTest : public testing::Test, public protocol::AudioStub {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 void AudioPumpTest::TearDown() { 98 void AudioPumpTest::TearDown() {
99 pump_.reset(); 99 pump_.reset();
100 100
101 // Let the message loop run to finish destroying the capturer. 101 // Let the message loop run to finish destroying the capturer.
102 base::RunLoop().RunUntilIdle(); 102 base::RunLoop().RunUntilIdle();
103 } 103 }
104 104
105 void AudioPumpTest::ProcessAudioPacket( 105 void AudioPumpTest::ProcessAudioPacket(
106 scoped_ptr<AudioPacket> audio_packet, 106 scoped_ptr<AudioPacket> audio_packet,
107 const base::Closure& done) { 107 const base::Closure& done) {
108 sent_packets_.push_back(audio_packet.Pass()); 108 sent_packets_.push_back(std::move(audio_packet));
109 done_closures_.push_back(done); 109 done_closures_.push_back(done);
110 } 110 }
111 111
112 // Verify that the pump pauses pumping when the network is congested. 112 // Verify that the pump pauses pumping when the network is congested.
113 TEST_F(AudioPumpTest, BufferSizeLimit) { 113 TEST_F(AudioPumpTest, BufferSizeLimit) {
114 // Run message loop to let the pump start the capturer. 114 // Run message loop to let the pump start the capturer.
115 base::RunLoop().RunUntilIdle(); 115 base::RunLoop().RunUntilIdle();
116 ASSERT_FALSE(capturer_->callback().is_null()); 116 ASSERT_FALSE(capturer_->callback().is_null());
117 117
118 // Try sending 100 packets, 1k each. The pump should stop pumping and start 118 // Try sending 100 packets, 1k each. The pump should stop pumping and start
(...skipping 12 matching lines...) Expand all
131 done_closures_.front().Run(); 131 done_closures_.front().Run();
132 base::RunLoop().RunUntilIdle(); 132 base::RunLoop().RunUntilIdle();
133 133
134 // Verify that the pump continues to send captured audio. 134 // Verify that the pump continues to send captured audio.
135 capturer_->callback().Run(MakeAudioPacket()); 135 capturer_->callback().Run(MakeAudioPacket());
136 base::RunLoop().RunUntilIdle(); 136 base::RunLoop().RunUntilIdle();
137 EXPECT_EQ(num_sent_packets + 1, sent_packets_.size()); 137 EXPECT_EQ(num_sent_packets + 1, sent_packets_.size());
138 } 138 }
139 139
140 } // namespace remoting 140 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698