| 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 #include "remoting/protocol/audio_pump.h" | 5 #include "remoting/protocol/audio_pump.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> |
| 9 #include <utility> | 10 #include <utility> |
| 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/scoped_vector.h" | |
| 14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 16 #include "remoting/codec/audio_encoder.h" | 17 #include "remoting/codec/audio_encoder.h" |
| 17 #include "remoting/proto/audio.pb.h" | 18 #include "remoting/proto/audio.pb.h" |
| 18 #include "remoting/protocol/audio_source.h" | 19 #include "remoting/protocol/audio_source.h" |
| 19 #include "remoting/protocol/audio_stub.h" | 20 #include "remoting/protocol/audio_stub.h" |
| 20 #include "remoting/protocol/fake_audio_source.h" | 21 #include "remoting/protocol/fake_audio_source.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 23 |
| 23 namespace remoting { | 24 namespace remoting { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 63 |
| 63 protected: | 64 protected: |
| 64 base::MessageLoop message_loop_; | 65 base::MessageLoop message_loop_; |
| 65 | 66 |
| 66 // |source_| and |encoder_| are owned by the |pump_|. | 67 // |source_| and |encoder_| are owned by the |pump_|. |
| 67 FakeAudioSource* source_; | 68 FakeAudioSource* source_; |
| 68 FakeAudioEncoder* encoder_; | 69 FakeAudioEncoder* encoder_; |
| 69 | 70 |
| 70 std::unique_ptr<AudioPump> pump_; | 71 std::unique_ptr<AudioPump> pump_; |
| 71 | 72 |
| 72 ScopedVector<AudioPacket> sent_packets_; | 73 std::vector<std::unique_ptr<AudioPacket>> sent_packets_; |
| 73 std::vector<base::Closure> done_closures_; | 74 std::vector<base::Closure> done_closures_; |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(AudioPumpTest); | 77 DISALLOW_COPY_AND_ASSIGN(AudioPumpTest); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 void AudioPumpTest::SetUp() { | 80 void AudioPumpTest::SetUp() { |
| 80 source_ = new FakeAudioSource(); | 81 source_ = new FakeAudioSource(); |
| 81 encoder_ = new FakeAudioEncoder(); | 82 encoder_ = new FakeAudioEncoder(); |
| 82 pump_.reset(new AudioPump(message_loop_.task_runner(), | 83 pump_.reset(new AudioPump(message_loop_.task_runner(), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 base::RunLoop().RunUntilIdle(); | 122 base::RunLoop().RunUntilIdle(); |
| 122 | 123 |
| 123 // Verify that the pump continues to send captured audio. | 124 // Verify that the pump continues to send captured audio. |
| 124 source_->callback().Run(MakeAudioPacket()); | 125 source_->callback().Run(MakeAudioPacket()); |
| 125 base::RunLoop().RunUntilIdle(); | 126 base::RunLoop().RunUntilIdle(); |
| 126 EXPECT_EQ(num_sent_packets + 1, sent_packets_.size()); | 127 EXPECT_EQ(num_sent_packets + 1, sent_packets_.size()); |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // namespace protocol | 130 } // namespace protocol |
| 130 } // namespace remoting | 131 } // namespace remoting |
| OLD | NEW |