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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 "base/macros.h"
6 #include "base/message_loop/message_loop.h"
7 #include "media/base/android/url_demuxer_stream.h"
8 #include "media/base/android/url_demuxer_stream_provider.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "url/gurl.h"
12
13 namespace media {
14
15 class UrlDemuxerStreamProviderTest : public testing::Test {
16 public:
17 UrlDemuxerStreamProviderTest() {}
18
19 void Initialize(const std::string& url) {
20 demuxer_.reset(new UrlDemuxerStreamProvider(GURL(url)));
21 }
22
23 void Initialize() { Initialize(kDefaultUrl); }
24
25 UrlDemuxerStream* GetCastedUrlStream() {
26 return (UrlDemuxerStream*)demuxer_->GetStream(DemuxerStream::URL);
27 }
28
29 const std::string kDefaultUrl = "http://example.com";
30
31 std::unique_ptr<Demuxer> demuxer_;
32
33 private:
34 // A message loop needs to be instantiated in order for the test to run
35 // properly.
36 base::MessageLoop message_loop_;
37
38 DISALLOW_COPY_AND_ASSIGN(UrlDemuxerStreamProviderTest);
39 };
40
41 TEST_F(UrlDemuxerStreamProviderTest, ProvidesExpectedStreamTypes) {
42 Initialize();
43
44 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::Type::AUDIO);
45 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::Type::VIDEO);
46 DemuxerStream* text_stream = demuxer_->GetStream(DemuxerStream::Type::TEXT);
47 DemuxerStream* url_stream = demuxer_->GetStream(DemuxerStream::Type::URL);
48
49 // Should not return AUDIO/VIDEO/TEXT streams
50 ASSERT_EQ(nullptr, audio_stream);
51 ASSERT_EQ(nullptr, video_stream);
52 ASSERT_EQ(nullptr, text_stream);
53
54 // Should return a URL stream, of UrlDemuxerStream type
55 ASSERT_NE(nullptr, url_stream);
56 }
57
58 // Whether or not the UrlDemuxerStreamProvider should accept emptry strings is
59 // up for debate.
60 TEST_F(UrlDemuxerStreamProviderTest, AcceptsEmptyStrings) {
61 Initialize("");
62
63 UrlDemuxerStream* stream = GetCastedUrlStream();
64
65 ASSERT_NE(nullptr, stream);
66 ASSERT_EQ(GURL::EmptyGURL(), stream->url());
67 }
68
69 TEST_F(UrlDemuxerStreamProviderTest, AcceptsNormalUrl) {
70 Initialize();
71
72 UrlDemuxerStream* stream = GetCastedUrlStream();
73
74 ASSERT_NE(nullptr, stream);
75 ASSERT_EQ(GURL(kDefaultUrl), stream->url());
76 }
77
78 TEST_F(UrlDemuxerStreamProviderTest, VerifyIdempotenceOfGetStream) {
79 Initialize();
80
81 UrlDemuxerStream* stream1 = GetCastedUrlStream();
82 UrlDemuxerStream* stream2 = GetCastedUrlStream();
83
84 ASSERT_EQ(stream1, stream2);
85 ASSERT_EQ(stream1->url(), stream2->url());
86 }
87
88 } // namespace media
OLDNEW
« 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