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

Unified Diff: media/cast/transport/cast_transport_sender_impl_unittest.cc

Issue 178073004: Cast: IPC from browser to renderer to send packet events from transport to cast library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/transport/cast_transport_sender_impl.cc ('k') | media/cast/transport/pacing/paced_sender.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/transport/cast_transport_sender_impl_unittest.cc
diff --git a/media/cast/transport/cast_transport_sender_impl_unittest.cc b/media/cast/transport/cast_transport_sender_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9404dccf4c33bff34ae22b767004cb8db41f3f84
--- /dev/null
+++ b/media/cast/transport/cast_transport_sender_impl_unittest.cc
@@ -0,0 +1,113 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <gtest/gtest.h>
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "base/test/simple_test_tick_clock.h"
+#include "media/cast/cast_config.h"
+#include "media/cast/rtcp/rtcp.h"
+#include "media/cast/test/fake_single_thread_task_runner.h"
+#include "media/cast/transport/cast_transport_config.h"
+#include "media/cast/transport/cast_transport_sender_impl.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media {
+namespace cast {
+namespace transport {
+
+static const int64 kStartMillisecond = GG_INT64_C(12345678900000);
+
+class FakePacketSender : public transport::PacketSender {
+ public:
+ FakePacketSender() {}
+
+ virtual bool SendPacket(const Packet& packet) OVERRIDE { return true; }
+};
+
+class CastTransportSenderImplTest : public ::testing::Test {
+ protected:
+ CastTransportSenderImplTest() : num_times_callback_called_(0) {
+ testing_clock_.Advance(
+ base::TimeDelta::FromMilliseconds(kStartMillisecond));
+ task_runner_ = new test::FakeSingleThreadTaskRunner(&testing_clock_);
+ }
+
+ virtual ~CastTransportSenderImplTest() {}
+
+ void InitWithoutLogging() {
+ transport_sender_.reset(
+ new CastTransportSenderImpl(NULL,
+ &testing_clock_,
+ net::IPEndPoint(),
+ net::IPEndPoint(),
+ GetDefaultCastSenderLoggingConfig(),
+ base::Bind(&UpdateCastTransportStatus),
+ BulkRawEventsCallback(),
+ base::TimeDelta(),
+ task_runner_,
+ &transport_));
+ task_runner_->RunTasks();
+ }
+
+ void InitWithLogging() {
+ transport_sender_.reset(new CastTransportSenderImpl(
+ NULL,
+ &testing_clock_,
+ net::IPEndPoint(),
+ net::IPEndPoint(),
+ GetLoggingConfigWithRawEventsAndStatsEnabled(),
+ base::Bind(&UpdateCastTransportStatus),
+ base::Bind(&CastTransportSenderImplTest::LogRawEvents,
+ base::Unretained(this)),
+ base::TimeDelta::FromMilliseconds(10),
+ task_runner_,
+ &transport_));
+ task_runner_->RunTasks();
+ }
+
+ void LogRawEvents(const std::vector<PacketEvent>& packet_events) {
+ num_times_callback_called_++;
+ if (num_times_callback_called_ == 3) {
+ run_loop_.Quit();
+ }
+ }
+
+ static void UpdateCastTransportStatus(transport::CastTransportStatus status) {
+ }
+
+ base::SimpleTestTickClock testing_clock_;
+ scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_;
+ scoped_ptr<CastTransportSenderImpl> transport_sender_;
+ FakePacketSender transport_;
+ base::MessageLoopForIO message_loop_;
+ base::RunLoop run_loop_;
+ int num_times_callback_called_;
+};
+
+TEST_F(CastTransportSenderImplTest, InitWithoutLogging) {
+ InitWithoutLogging();
+ message_loop_.PostDelayedTask(FROM_HERE,
+ run_loop_.QuitClosure(),
+ base::TimeDelta::FromMilliseconds(50));
+ run_loop_.Run();
+ EXPECT_EQ(0, num_times_callback_called_);
+}
+
+TEST_F(CastTransportSenderImplTest, InitWithLogging) {
+ InitWithLogging();
+ message_loop_.PostDelayedTask(FROM_HERE,
+ run_loop_.QuitClosure(),
+ base::TimeDelta::FromMilliseconds(50));
+ run_loop_.Run();
+ EXPECT_GT(num_times_callback_called_, 1);
+}
+
+} // namespace transport
+} // namespace cast
+} // namespace media
« no previous file with comments | « media/cast/transport/cast_transport_sender_impl.cc ('k') | media/cast/transport/pacing/paced_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698