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

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

Issue 388663003: Cast: Reshuffle files under media/cast (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing includes Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <gtest/gtest.h>
6 #include <stdint.h>
7
8 #include "base/bind.h"
9 #include "base/bind_helpers.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
13 #include "base/test/simple_test_tick_clock.h"
14 #include "media/cast/cast_config.h"
15 #include "media/cast/rtcp/rtcp.h"
16 #include "media/cast/test/fake_single_thread_task_runner.h"
17 #include "media/cast/transport/cast_transport_config.h"
18 #include "media/cast/transport/cast_transport_sender_impl.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20
21 namespace media {
22 namespace cast {
23 namespace transport {
24
25 static const int64 kStartMillisecond = INT64_C(12345678900000);
26
27 class FakePacketSender : public transport::PacketSender {
28 public:
29 FakePacketSender() {}
30
31 virtual bool SendPacket(PacketRef packet, const base::Closure& cb) OVERRIDE {
32 return true;
33 }
34 };
35
36 class CastTransportSenderImplTest : public ::testing::Test {
37 protected:
38 CastTransportSenderImplTest()
39 : num_times_callback_called_(0) {
40 testing_clock_.Advance(
41 base::TimeDelta::FromMilliseconds(kStartMillisecond));
42 task_runner_ = new test::FakeSingleThreadTaskRunner(&testing_clock_);
43 }
44
45 virtual ~CastTransportSenderImplTest() {}
46
47 void InitWithoutLogging() {
48 transport_sender_.reset(
49 new CastTransportSenderImpl(NULL,
50 &testing_clock_,
51 net::IPEndPoint(),
52 base::Bind(&UpdateCastTransportStatus),
53 BulkRawEventsCallback(),
54 base::TimeDelta(),
55 task_runner_,
56 &transport_));
57 task_runner_->RunTasks();
58 }
59
60 void InitWithLogging() {
61 transport_sender_.reset(new CastTransportSenderImpl(
62 NULL,
63 &testing_clock_,
64 net::IPEndPoint(),
65 base::Bind(&UpdateCastTransportStatus),
66 base::Bind(&CastTransportSenderImplTest::LogRawEvents,
67 base::Unretained(this)),
68 base::TimeDelta::FromMilliseconds(10),
69 task_runner_,
70 &transport_));
71 task_runner_->RunTasks();
72 }
73
74 void LogRawEvents(const std::vector<PacketEvent>& packet_events) {
75 num_times_callback_called_++;
76 if (num_times_callback_called_ == 3) {
77 run_loop_.Quit();
78 }
79 }
80
81 static void UpdateCastTransportStatus(transport::CastTransportStatus status) {
82 }
83
84 base::SimpleTestTickClock testing_clock_;
85 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_;
86 scoped_ptr<CastTransportSenderImpl> transport_sender_;
87 FakePacketSender transport_;
88 base::MessageLoopForIO message_loop_;
89 base::RunLoop run_loop_;
90 int num_times_callback_called_;
91 };
92
93 TEST_F(CastTransportSenderImplTest, InitWithoutLogging) {
94 InitWithoutLogging();
95 message_loop_.PostDelayedTask(FROM_HERE,
96 run_loop_.QuitClosure(),
97 base::TimeDelta::FromMilliseconds(50));
98 run_loop_.Run();
99 EXPECT_EQ(0, num_times_callback_called_);
100 }
101
102 TEST_F(CastTransportSenderImplTest, InitWithLogging) {
103 InitWithLogging();
104 message_loop_.PostDelayedTask(FROM_HERE,
105 run_loop_.QuitClosure(),
106 base::TimeDelta::FromMilliseconds(50));
107 run_loop_.Run();
108 EXPECT_GT(num_times_callback_called_, 1);
109 }
110
111 } // namespace transport
112 } // namespace cast
113 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/transport/cast_transport_sender_impl.cc ('k') | media/cast/transport/frame_id_wrap_helper_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698