OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
8 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
9 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
10 #include "remoting/proto/video.pb.h" | 11 #include "remoting/proto/video.pb.h" |
11 #include "remoting/protocol/fake_session.h" | 12 #include "remoting/protocol/fake_session.h" |
12 #include "remoting/protocol/rtp_utils.h" | 13 #include "remoting/protocol/rtp_utils.h" |
13 #include "remoting/protocol/rtp_video_reader.h" | 14 #include "remoting/protocol/rtp_video_reader.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 using net::IOBuffer; | 17 using net::IOBuffer; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 InitData(100); | 59 InitData(100); |
59 } | 60 } |
60 | 61 |
61 virtual void TearDown() { | 62 virtual void TearDown() { |
62 message_loop_.RunAllPending(); | 63 message_loop_.RunAllPending(); |
63 } | 64 } |
64 | 65 |
65 void Reset() { | 66 void Reset() { |
66 session_.reset(new FakeSession()); | 67 session_.reset(new FakeSession()); |
67 reader_.reset(new RtpVideoReader()); | 68 reader_.reset(new RtpVideoReader()); |
68 reader_->Init(session_.get(), this); | 69 reader_->Init(session_.get(), this, |
| 70 base::Bind(&RtpVideoReaderTest::OnReaderInitialized, |
| 71 base::Unretained(this))); |
69 received_packets_.clear(); | 72 received_packets_.clear(); |
70 } | 73 } |
71 | 74 |
| 75 void OnReaderInitialized(bool success) { |
| 76 ASSERT_TRUE(success); |
| 77 } |
| 78 |
72 void InitData(int size) { | 79 void InitData(int size) { |
73 data_.resize(size); | 80 data_.resize(size); |
74 for (int i = 0; i < size; ++i) { | 81 for (int i = 0; i < size; ++i) { |
75 data_[i] = static_cast<char>(i); | 82 data_[i] = static_cast<char>(i); |
76 } | 83 } |
77 } | 84 } |
78 | 85 |
79 bool CompareData(const CompoundBuffer& buffer, char* data, int size) { | 86 bool CompareData(const CompoundBuffer& buffer, char* data, int size) { |
80 scoped_refptr<IOBuffer> buffer_data = buffer.ToIOBufferWithSize(); | 87 scoped_refptr<IOBuffer> buffer_data = buffer.ToIOBufferWithSize(); |
81 return buffer.total_bytes() == size && | 88 return buffer.total_bytes() == size && |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 368 |
362 ExpectedPacket expected[] = { | 369 ExpectedPacket expected[] = { |
363 { 123, VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET, 0, 30 }, | 370 { 123, VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET, 0, 30 }, |
364 { 223, VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET, 40, 50 }, | 371 { 223, VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET, 40, 50 }, |
365 }; | 372 }; |
366 CheckResults(expected, arraysize(expected)); | 373 CheckResults(expected, arraysize(expected)); |
367 } | 374 } |
368 | 375 |
369 } // namespace protocol | 376 } // namespace protocol |
370 } // namespace remoting | 377 } // namespace remoting |
OLD | NEW |