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

Side by Side Diff: media/cast/net/cast_transport_sender_impl_unittest.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <gtest/gtest.h> 5 #include <gtest/gtest.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/test/simple_test_tick_clock.h" 11 #include "base/test/simple_test_tick_clock.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "media/cast/net/cast_transport_config.h" 13 #include "media/cast/net/cast_transport_config.h"
14 #include "media/cast/net/cast_transport_sender_impl.h" 14 #include "media/cast/net/cast_transport_sender_impl.h"
15 #include "media/cast/net/rtcp/rtcp.h" 15 #include "media/cast/net/rtcp/rtcp.h"
16 #include "media/cast/test/fake_single_thread_task_runner.h" 16 #include "media/cast/test/fake_single_thread_task_runner.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace media { 19 namespace media {
20 namespace cast { 20 namespace cast {
21 21
22 namespace { 22 namespace {
23 const int64 kStartMillisecond = INT64_C(12345678900000); 23 const int64_t kStartMillisecond = INT64_C(12345678900000);
24 const uint32 kVideoSsrc = 1; 24 const uint32_t kVideoSsrc = 1;
25 const uint32 kAudioSsrc = 2; 25 const uint32_t kAudioSsrc = 2;
26 } // namespace 26 } // namespace
27 27
28 class FakePacketSender : public PacketSender { 28 class FakePacketSender : public PacketSender {
29 public: 29 public:
30 FakePacketSender() 30 FakePacketSender()
31 : paused_(false), packets_sent_(0), bytes_sent_(0) {} 31 : paused_(false), packets_sent_(0), bytes_sent_(0) {}
32 32
33 bool SendPacket(PacketRef packet, const base::Closure& cb) final { 33 bool SendPacket(PacketRef packet, const base::Closure& cb) final {
34 if (paused_) { 34 if (paused_) {
35 stored_packet_ = packet; 35 stored_packet_ = packet;
36 callback_ = cb; 36 callback_ = cb;
37 return false; 37 return false;
38 } 38 }
39 ++packets_sent_; 39 ++packets_sent_;
40 bytes_sent_ += packet->data.size(); 40 bytes_sent_ += packet->data.size();
41 return true; 41 return true;
42 } 42 }
43 43
44 int64 GetBytesSent() final { return bytes_sent_; } 44 int64_t GetBytesSent() final { return bytes_sent_; }
45 45
46 void SetPaused(bool paused) { 46 void SetPaused(bool paused) {
47 paused_ = paused; 47 paused_ = paused;
48 if (!paused && stored_packet_.get()) { 48 if (!paused && stored_packet_.get()) {
49 SendPacket(stored_packet_, callback_); 49 SendPacket(stored_packet_, callback_);
50 callback_.Run(); 50 callback_.Run();
51 } 51 }
52 } 52 }
53 53
54 int packets_sent() const { return packets_sent_; } 54 int packets_sent() const { return packets_sent_; }
55 55
56 private: 56 private:
57 bool paused_; 57 bool paused_;
58 base::Closure callback_; 58 base::Closure callback_;
59 PacketRef stored_packet_; 59 PacketRef stored_packet_;
60 int packets_sent_; 60 int packets_sent_;
61 int64 bytes_sent_; 61 int64_t bytes_sent_;
62 62
63 DISALLOW_COPY_AND_ASSIGN(FakePacketSender); 63 DISALLOW_COPY_AND_ASSIGN(FakePacketSender);
64 }; 64 };
65 65
66 class CastTransportSenderImplTest : public ::testing::Test { 66 class CastTransportSenderImplTest : public ::testing::Test {
67 protected: 67 protected:
68 CastTransportSenderImplTest() : num_times_logging_callback_called_(0) { 68 CastTransportSenderImplTest() : num_times_logging_callback_called_(0) {
69 testing_clock_.Advance( 69 testing_clock_.Advance(
70 base::TimeDelta::FromMilliseconds(kStartMillisecond)); 70 base::TimeDelta::FromMilliseconds(kStartMillisecond));
71 task_runner_ = new test::FakeSingleThreadTaskRunner(&testing_clock_); 71 task_runner_ = new test::FakeSingleThreadTaskRunner(&testing_clock_);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 transport_.SetPaused(true); 250 transport_.SetPaused(true);
251 DedupInfo dedup_info; 251 DedupInfo dedup_info;
252 dedup_info.resend_interval = base::TimeDelta::FromMilliseconds(10); 252 dedup_info.resend_interval = base::TimeDelta::FromMilliseconds(10);
253 transport_sender_->ResendPackets( 253 transport_sender_->ResendPackets(
254 kVideoSsrc, missing_packets, true, dedup_info); 254 kVideoSsrc, missing_packets, true, dedup_info);
255 255
256 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(10)); 256 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(10));
257 EXPECT_EQ(2, num_times_logging_callback_called_); 257 EXPECT_EQ(2, num_times_logging_callback_called_);
258 258
259 std::vector<uint32> cancel_sending_frames; 259 std::vector<uint32_t> cancel_sending_frames;
260 cancel_sending_frames.push_back(1); 260 cancel_sending_frames.push_back(1);
261 transport_sender_->CancelSendingFrames(kVideoSsrc, 261 transport_sender_->CancelSendingFrames(kVideoSsrc,
262 cancel_sending_frames); 262 cancel_sending_frames);
263 transport_.SetPaused(false); 263 transport_.SetPaused(false);
264 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(10)); 264 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(10));
265 EXPECT_EQ(2, num_times_logging_callback_called_); 265 EXPECT_EQ(2, num_times_logging_callback_called_);
266 266
267 // Resend one packet in the socket when unpaused. 267 // Resend one packet in the socket when unpaused.
268 EXPECT_EQ(5, transport_.packets_sent()); 268 EXPECT_EQ(5, transport_.packets_sent());
269 } 269 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 task_runner_->RunTasks(); 386 task_runner_->RunTasks();
387 EXPECT_EQ(7, transport_.packets_sent()); 387 EXPECT_EQ(7, transport_.packets_sent());
388 EXPECT_EQ(1, num_times_logging_callback_called_); // Only 8 ms since last. 388 EXPECT_EQ(1, num_times_logging_callback_called_); // Only 8 ms since last.
389 389
390 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(2)); 390 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(2));
391 EXPECT_EQ(2, num_times_logging_callback_called_); 391 EXPECT_EQ(2, num_times_logging_callback_called_);
392 } 392 }
393 393
394 } // namespace cast 394 } // namespace cast
395 } // namespace media 395 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698