Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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/media_url_demuxer.h" | |
| 8 #include "testing/gmock/include/gmock/gmock.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace media { | |
| 12 | |
| 13 class MediaUrlDemuxerTest : public testing::Test { | |
| 14 public: | |
| 15 MediaUrlDemuxerTest() {} | |
| 16 | |
| 17 void Initialize(const GURL& gurl) { | |
| 18 demuxer_.reset(new MediaUrlDemuxer(gurl)); | |
| 19 } | |
| 20 | |
| 21 void Initialize() { Initialize(GURL(kDefaultUrl)); } | |
| 22 | |
| 23 const std::string kDefaultUrl = "http://example.com/"; | |
| 24 | |
| 25 std::unique_ptr<Demuxer> demuxer_; | |
| 26 | |
| 27 private: | |
| 28 // A message loop needs to be instantiated in order for the test to run | |
| 29 // properly. | |
| 30 base::MessageLoop message_loop_; | |
|
xhwang
2016/06/24 03:19:47
Use RunLoop now.
Actually, why do you need a mess
tguilbert
2016/06/24 21:18:42
I don't, removed! (artifact of copy-pasting)
| |
| 31 | |
| 32 DISALLOW_COPY_AND_ASSIGN(MediaUrlDemuxerTest); | |
| 33 }; | |
| 34 | |
| 35 TEST_F(MediaUrlDemuxerTest, DoesNotReturnStreams) { | |
|
xhwang
2016/06/24 03:19:47
Check the type.
tguilbert
2016/06/24 21:18:42
Done.
| |
| 36 Initialize(); | |
| 37 | |
| 38 DemuxerStream* audio_stream = demuxer_->GetStream(DemuxerStream::Type::AUDIO); | |
| 39 DemuxerStream* video_stream = demuxer_->GetStream(DemuxerStream::Type::VIDEO); | |
| 40 DemuxerStream* text_stream = demuxer_->GetStream(DemuxerStream::Type::TEXT); | |
|
xhwang
2016/06/24 03:19:47
We can specify in the API that if the type is URL,
tguilbert
2016/06/24 21:18:42
Done.
| |
| 41 | |
| 42 // Should not return AUDIO/VIDEO/TEXT streams | |
| 43 ASSERT_EQ(nullptr, audio_stream); | |
| 44 ASSERT_EQ(nullptr, video_stream); | |
| 45 ASSERT_EQ(nullptr, text_stream); | |
| 46 } | |
| 47 | |
| 48 TEST_F(MediaUrlDemuxerTest, AcceptsNormalUrl) { | |
| 49 Initialize(); | |
| 50 | |
| 51 GURL url = demuxer_->GetUrl(); | |
| 52 | |
| 53 ASSERT_EQ(kDefaultUrl, url.spec()); | |
| 54 } | |
| 55 | |
| 56 TEST_F(MediaUrlDemuxerTest, AcceptsEmptyStrings) { | |
| 57 Initialize(GURL()); | |
| 58 | |
| 59 GURL url = demuxer_->GetUrl(); | |
| 60 | |
| 61 ASSERT_EQ(GURL::EmptyGURL(), url); | |
| 62 } | |
| 63 | |
| 64 TEST_F(MediaUrlDemuxerTest, VerifyIdempotenceOfGetUrl) { | |
| 65 Initialize(); | |
| 66 | |
| 67 GURL url = demuxer_->GetUrl(); | |
| 68 GURL url_clone = demuxer_->GetUrl(); | |
| 69 | |
| 70 ASSERT_EQ(url, url_clone); | |
| 71 } | |
| 72 | |
| 73 } // namespace media | |
| OLD | NEW |