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

Unified Diff: media/base/android/url_demuxer_stream_unittest.cc

Issue 2099453002: [DO NOT COMMIT/REVIEW] For reference: UrlDemuxerStreamProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/base/android/url_demuxer_stream_provider.cc ('k') | media/base/demuxer_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/url_demuxer_stream_unittest.cc
diff --git a/media/base/android/url_demuxer_stream_unittest.cc b/media/base/android/url_demuxer_stream_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db5fe6c064720238cc0f59d21508e6e12d040439
--- /dev/null
+++ b/media/base/android/url_demuxer_stream_unittest.cc
@@ -0,0 +1,88 @@
+// Copyright 2015 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 "base/macros.h"
+#include "base/message_loop/message_loop.h"
+#include "media/base/android/url_demuxer_stream.h"
+#include "media/base/android/url_demuxer_stream_provider.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
+
+namespace media {
+
+class UrlDemuxerStreamProviderTest : public testing::Test {
+ public:
+ UrlDemuxerStreamProviderTest() {}
+
+ void Initialize(const std::string& url) {
+ demuxer_.reset(new UrlDemuxerStreamProvider(GURL(url)));
+ }
+
+ void Initialize() { Initialize(kDefaultUrl); }
+
+ UrlDemuxerStream* GetCastedUrlStream() {
+ return (UrlDemuxerStream*)demuxer_->GetStream(DemuxerStream::URL);
+ }
+
+ const std::string kDefaultUrl = "http://example.com";
+
+ std::unique_ptr<Demuxer> demuxer_;
+
+ private:
+ // A message loop needs to be instantiated in order for the test to run
+ // properly.
+ base::MessageLoop message_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(UrlDemuxerStreamProviderTest);
+};
+
+TEST_F(UrlDemuxerStreamProviderTest, ProvidesExpectedStreamTypes) {
+ Initialize();
+
+ DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::Type::AUDIO);
+ DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::Type::VIDEO);
+ DemuxerStream* text_stream = demuxer_->GetStream(DemuxerStream::Type::TEXT);
+ DemuxerStream* url_stream = demuxer_->GetStream(DemuxerStream::Type::URL);
+
+ // Should not return AUDIO/VIDEO/TEXT streams
+ ASSERT_EQ(nullptr, audio_stream);
+ ASSERT_EQ(nullptr, video_stream);
+ ASSERT_EQ(nullptr, text_stream);
+
+ // Should return a URL stream, of UrlDemuxerStream type
+ ASSERT_NE(nullptr, url_stream);
+}
+
+// Whether or not the UrlDemuxerStreamProvider should accept emptry strings is
+// up for debate.
+TEST_F(UrlDemuxerStreamProviderTest, AcceptsEmptyStrings) {
+ Initialize("");
+
+ UrlDemuxerStream* stream = GetCastedUrlStream();
+
+ ASSERT_NE(nullptr, stream);
+ ASSERT_EQ(GURL::EmptyGURL(), stream->url());
+}
+
+TEST_F(UrlDemuxerStreamProviderTest, AcceptsNormalUrl) {
+ Initialize();
+
+ UrlDemuxerStream* stream = GetCastedUrlStream();
+
+ ASSERT_NE(nullptr, stream);
+ ASSERT_EQ(GURL(kDefaultUrl), stream->url());
+}
+
+TEST_F(UrlDemuxerStreamProviderTest, VerifyIdempotenceOfGetStream) {
+ Initialize();
+
+ UrlDemuxerStream* stream1 = GetCastedUrlStream();
+ UrlDemuxerStream* stream2 = GetCastedUrlStream();
+
+ ASSERT_EQ(stream1, stream2);
+ ASSERT_EQ(stream1->url(), stream2->url());
+}
+
+} // namespace media
« no previous file with comments | « media/base/android/url_demuxer_stream_provider.cc ('k') | media/base/demuxer_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698