From e685dd1a7346ed2be938089bdb9d85090344b63b Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Thu, 9 Oct 2014 16:33:56 -0700 Subject: [PATCH] Move test files in media/base to test directory Also rename mpd/base/bandwidth_estimator_test.cc to bandwidth_estimator_unittest.cc for consistency. And remove mpd/base/simple_vod_mpd_notifier.* as they are not used anywhere. Change-Id: Iaeb096aef9259837a4eb356c18d5ca15f08d2376 --- packager/media/base/buffer_writer_unittest.cc | 2 +- .../media/base/http_key_fetcher_unittest.cc | 2 +- packager/media/base/media_base.gyp | 10 +- .../base/producer_consumer_queue_unittest.cc | 2 +- packager/media/base/rsa_key_unittest.cc | 4 +- .../media/base/status_test_util_unittest.cc | 2 +- packager/media/base/{ => test}/fake_prng.cc | 2 +- packager/media/base/{ => test}/fake_prng.h | 0 .../media/base/{ => test}/rsa_test_data.cc | 2 +- .../media/base/{ => test}/rsa_test_data.h | 0 .../media/base/{ => test}/status_test_util.h | 0 .../base/widevine_key_source_unittest.cc | 4 +- packager/media/test/packager_test.cc | 2 +- ...est.cc => bandwidth_estimator_unittest.cc} | 0 packager/mpd/base/simple_vod_mpd_notifier.cc | 106 ------------------ packager/mpd/base/simple_vod_mpd_notifier.h | 79 ------------- packager/mpd/mpd.gyp | 3 +- 17 files changed, 18 insertions(+), 202 deletions(-) rename packager/media/base/{ => test}/fake_prng.cc (97%) rename packager/media/base/{ => test}/fake_prng.h (100%) rename packager/media/base/{ => test}/rsa_test_data.cc (99%) rename packager/media/base/{ => test}/rsa_test_data.h (100%) rename packager/media/base/{ => test}/status_test_util.h (100%) rename packager/mpd/base/{bandwidth_estimator_test.cc => bandwidth_estimator_unittest.cc} (100%) delete mode 100644 packager/mpd/base/simple_vod_mpd_notifier.cc delete mode 100644 packager/mpd/base/simple_vod_mpd_notifier.h diff --git a/packager/media/base/buffer_writer_unittest.cc b/packager/media/base/buffer_writer_unittest.cc index 40680d5358..1fbb8433c2 100644 --- a/packager/media/base/buffer_writer_unittest.cc +++ b/packager/media/base/buffer_writer_unittest.cc @@ -11,7 +11,7 @@ #include "packager/base/file_util.h" #include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/buffer_reader.h" -#include "packager/media/base/status_test_util.h" +#include "packager/media/base/test/status_test_util.h" #include "packager/media/file/file.h" namespace { diff --git a/packager/media/base/http_key_fetcher_unittest.cc b/packager/media/base/http_key_fetcher_unittest.cc index 8c862343ef..6307794c32 100644 --- a/packager/media/base/http_key_fetcher_unittest.cc +++ b/packager/media/base/http_key_fetcher_unittest.cc @@ -9,7 +9,7 @@ #include "packager/base/logging.h" #include "packager/base/strings/string_number_conversions.h" #include "packager/base/strings/string_util.h" -#include "packager/media/base/status_test_util.h" +#include "packager/media/base/test/status_test_util.h" namespace { const char kTestUrl[] = "http://packager-test.appspot.com/http_test"; diff --git a/packager/media/base/media_base.gyp b/packager/media/base/media_base.gyp index 07ff719e2f..36ea032ea1 100644 --- a/packager/media/base/media_base.gyp +++ b/packager/media/base/media_base.gyp @@ -90,18 +90,18 @@ 'buffer_writer_unittest.cc', 'closure_thread_unittest.cc', 'container_names_unittest.cc', - 'fake_prng.cc', # For rsa_key_unittest - 'fake_prng.h', # For rsa_key_unittest 'http_key_fetcher_unittest.cc', 'muxer_util_unittest.cc', 'offset_byte_queue_unittest.cc', 'producer_consumer_queue_unittest.cc', 'rsa_key_unittest.cc', - 'rsa_test_data.cc', # For rsa_key_unittest - 'rsa_test_data.h', # For rsa_key_unittest - 'status_test_util.h', 'status_test_util_unittest.cc', 'status_unittest.cc', + 'test/fake_prng.cc', # For rsa_key_unittest + 'test/fake_prng.h', # For rsa_key_unittest + 'test/rsa_test_data.cc', # For rsa_key_unittest + 'test/rsa_test_data.h', # For rsa_key_unittest + 'test/status_test_util.h', 'widevine_key_source_unittest.cc', ], 'dependencies': [ diff --git a/packager/media/base/producer_consumer_queue_unittest.cc b/packager/media/base/producer_consumer_queue_unittest.cc index ef331fb791..1f27015438 100644 --- a/packager/media/base/producer_consumer_queue_unittest.cc +++ b/packager/media/base/producer_consumer_queue_unittest.cc @@ -10,7 +10,7 @@ #include "packager/base/synchronization/waitable_event.h" #include "packager/media/base/closure_thread.h" #include "packager/media/base/producer_consumer_queue.h" -#include "packager/media/base/status_test_util.h" +#include "packager/media/base/test/status_test_util.h" namespace edash_packager { namespace { diff --git a/packager/media/base/rsa_key_unittest.cc b/packager/media/base/rsa_key_unittest.cc index 0db071e0bb..8acb8dee75 100644 --- a/packager/media/base/rsa_key_unittest.cc +++ b/packager/media/base/rsa_key_unittest.cc @@ -9,9 +9,9 @@ #include #include "packager/base/memory/scoped_ptr.h" -#include "packager/media/base/fake_prng.h" #include "packager/media/base/rsa_key.h" -#include "packager/media/base/rsa_test_data.h" +#include "packager/media/base/test/fake_prng.h" +#include "packager/media/base/test/rsa_test_data.h" namespace edash_packager { namespace media { diff --git a/packager/media/base/status_test_util_unittest.cc b/packager/media/base/status_test_util_unittest.cc index b7c3b22624..63beb03dd7 100644 --- a/packager/media/base/status_test_util_unittest.cc +++ b/packager/media/base/status_test_util_unittest.cc @@ -6,7 +6,7 @@ #include -#include "packager/media/base/status_test_util.h" +#include "packager/media/base/test/status_test_util.h" namespace edash_packager { namespace media { diff --git a/packager/media/base/fake_prng.cc b/packager/media/base/test/fake_prng.cc similarity index 97% rename from packager/media/base/fake_prng.cc rename to packager/media/base/test/fake_prng.cc index c047656562..266ef0c9c7 100644 --- a/packager/media/base/fake_prng.cc +++ b/packager/media/base/test/fake_prng.cc @@ -4,7 +4,7 @@ // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd -#include "packager/media/base/fake_prng.h" +#include "packager/media/base/test/fake_prng.h" #include diff --git a/packager/media/base/fake_prng.h b/packager/media/base/test/fake_prng.h similarity index 100% rename from packager/media/base/fake_prng.h rename to packager/media/base/test/fake_prng.h diff --git a/packager/media/base/rsa_test_data.cc b/packager/media/base/test/rsa_test_data.cc similarity index 99% rename from packager/media/base/rsa_test_data.cc rename to packager/media/base/test/rsa_test_data.cc index 3cc61418c3..d2fbaddb0d 100644 --- a/packager/media/base/rsa_test_data.cc +++ b/packager/media/base/test/rsa_test_data.cc @@ -4,7 +4,7 @@ // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd -#include "packager/media/base/rsa_test_data.h" +#include "packager/media/base/test/rsa_test_data.h" #include diff --git a/packager/media/base/rsa_test_data.h b/packager/media/base/test/rsa_test_data.h similarity index 100% rename from packager/media/base/rsa_test_data.h rename to packager/media/base/test/rsa_test_data.h diff --git a/packager/media/base/status_test_util.h b/packager/media/base/test/status_test_util.h similarity index 100% rename from packager/media/base/status_test_util.h rename to packager/media/base/test/status_test_util.h diff --git a/packager/media/base/widevine_key_source_unittest.cc b/packager/media/base/widevine_key_source_unittest.cc index 3ddecbfaeb..56ab7805c2 100644 --- a/packager/media/base/widevine_key_source_unittest.cc +++ b/packager/media/base/widevine_key_source_unittest.cc @@ -12,7 +12,7 @@ #include "packager/base/strings/stringprintf.h" #include "packager/media/base/key_fetcher.h" #include "packager/media/base/request_signer.h" -#include "packager/media/base/status_test_util.h" +#include "packager/media/base/test/status_test_util.h" #include "packager/media/base/widevine_key_source.h" using ::testing::_; @@ -224,7 +224,7 @@ TEST_F(WidevineKeySourceTest, HttpFetchFailure) { kSignerName); const Status kMockStatus = Status::UNKNOWN; EXPECT_CALL(*mock_key_fetcher_, - FetchKeys(kServerUrl, expected_post_data, _)) + FetchKeys(StrEq(kServerUrl), expected_post_data, _)) .WillOnce(Return(kMockStatus)); CreateWidevineKeySource(); diff --git a/packager/media/test/packager_test.cc b/packager/media/test/packager_test.cc index 198436c4a2..abe198b08a 100644 --- a/packager/media/test/packager_test.cc +++ b/packager/media/test/packager_test.cc @@ -14,8 +14,8 @@ #include "packager/media/base/key_source.h" #include "packager/media/base/media_stream.h" #include "packager/media/base/muxer.h" -#include "packager/media/base/status_test_util.h" #include "packager/media/base/stream_info.h" +#include "packager/media/base/test/status_test_util.h" #include "packager/media/formats/mp4/mp4_muxer.h" #include "packager/media/test/test_data_util.h" diff --git a/packager/mpd/base/bandwidth_estimator_test.cc b/packager/mpd/base/bandwidth_estimator_unittest.cc similarity index 100% rename from packager/mpd/base/bandwidth_estimator_test.cc rename to packager/mpd/base/bandwidth_estimator_unittest.cc diff --git a/packager/mpd/base/simple_vod_mpd_notifier.cc b/packager/mpd/base/simple_vod_mpd_notifier.cc deleted file mode 100644 index 19660ec6ee..0000000000 --- a/packager/mpd/base/simple_vod_mpd_notifier.cc +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -#include "packager/mpd/base/simple_vod_mpd_notifier.h" - -#include "packager/base/stl_util.h" -#include "packager/mpd/base/content_protection_element.h" -#include "packager/mpd/base/media_info.pb.h" - -namespace edash_packager { - -SimpleVodMpdNotifier::SimpleVodMpdNotifier(MpdBuilder* mpd_builder) - : mpd_builder_(mpd_builder), - video_adaptation_set_(NULL), - audio_adaptation_set_(NULL), - representation_(NULL) { - DCHECK(mpd_builder); -} - -SimpleVodMpdNotifier::~SimpleVodMpdNotifier() {} - -bool SimpleVodMpdNotifier::Init() { - return true; -} - -bool SimpleVodMpdNotifier::NotifyNewContainer(const MediaInfo& media_info, - uint32_t* container_id) { - DCHECK(container_id); - - if (media_info.video_info_size() > 0 && media_info.audio_info_size() > 0) { - LOG(ERROR) << "SimpleVodMpdNotifier cannot handle media container with " - "both video and audio"; - return false; - } - - ContainerType container_type = kVideo; - if (media_info.video_info_size() > 0) { - container_type = kVideo; - } else if (media_info.audio_info_size() > 0) { - container_type = kAudio; - } else { - LOG(ERROR) << "Either video_info or audio_info must be populated."; - return false; - } - - if (!AddNewRepresentation(container_type, media_info, container_id)) - return false; - - return mpd_builder_->WriteMpd(); -} - -bool SimpleVodMpdNotifier::NotifyNewSegment(uint32_t container_id, - uint64_t start_time, - uint64_t duration) { - DLOG(INFO) << "VOD does not support this operation."; - return false; -} - -bool SimpleVodMpdNotifier::AddContentProtectionElement( - uint32_t container_id, - const ContentProtectionElement& content_protection_element) { - if (!ContainsKey(id_to_representation_, container_id)) - return false; - - Representation* representation = id_to_representation_[container_id]; - - DCHECK(representation); - representation->AddContentProtectionElement(content_protection_element); - return mpd_builder_->WriteMpd(); -} - -bool SimpleVodMpdNotifier::AddNewRepresentation(ContainerType type, - const MediaInfo& media_info, - uint32_t* container_id) { - // Use pointer-pointer to set {video,audio}_adaptation_set_. - AdaptationSet** adaptation_set_pp = NULL; - if (type == kVideo) { - adaptation_set_pp = &video_adaptation_set_; - } else if (type == kAudio){ - adaptation_set_pp = &audio_adaptation_set_; - } else { - NOTREACHED() << "Unknown container type: " << type; - return false; - } - - if (!*adaptation_set_pp) - *adaptation_set_pp = mpd_builder_->AddAdaptationSet(); - - AdaptationSet* const adaptation_set = *adaptation_set_pp; - Representation* new_representation = - adaptation_set->AddRepresentation(media_info); - - if (!new_representation) - return false; - - const uint32_t representation_id = new_representation->id(); - id_to_representation_[representation_id] = new_representation; - *container_id = representation_id; - - return true; -} - -} // namespace edash_packager diff --git a/packager/mpd/base/simple_vod_mpd_notifier.h b/packager/mpd/base/simple_vod_mpd_notifier.h deleted file mode 100644 index 58f93de56e..0000000000 --- a/packager/mpd/base/simple_vod_mpd_notifier.h +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd -// -// Very simple implementation of MpdNotifier. Holds an instance of MpdBuilder -// and calls methods on the object directly. - -#ifndef MPD_BASE_SIMPLE_MPD_NOTIFIER_H_ -#define MPD_BASE_SIMPLE_MPD_NOTIFIER_H_ - -#include "packager/mpd/base/mpd_notifier.h" - -#include "packager/mpd/base/mpd_builder.h" - -namespace edash_packager { - -// This assumes that MpdBuilder is for VOD. This class also assumes that all the -// container is for an AdaptationSet. -class SimpleVodMpdNotifier : public MpdNotifier { - public: - // MpdBuilder must be initialized before passing a pointer to this object. - // The ownership of |mpd_builder| does not transfer to this object and it must - // be non-NULL. - explicit SimpleVodMpdNotifier(MpdBuilder* mpd_builder); - virtual ~SimpleVodMpdNotifier(); - - // MpdNotifier implementation. - // This should be called only once. - virtual bool Init() OVERRIDE; - - // Notifies MpdBuilder to add a container. The container must have audio - // (logical exclusive) or video, IOW it cannot have both audio and video nor - // can both audio and video be empty. - // On success this writes out MPD and returns true, otherwise returns false. - virtual bool NotifyNewContainer(const MediaInfo& media_info, - uint32_t* id) OVERRIDE; - - // As documented in MpdNotifier. This is Live only feature. This will return - // false. - virtual bool NotifyNewSegment(uint32_t id, - uint64_t start_time, - uint64_t duration) OVERRIDE; - - // Adds content protection information to the container added via - // NotifyNewContainer(). This will fail if |id| is not a value populated by - // calling NotifyNewContainer(). - // On success this writes out MPD and returns true, otherwise returns false. - virtual bool AddContentProtectionElement( - uint32_t id, - const ContentProtectionElement& content_protection_element) OVERRIDE; - - private: - enum ContainerType { - kVideo, - kAudio - }; - - // Adds new Representation to mpd_builder_ on success. - // Sets {audio,video}_adaptation_set_ depending on |type|, if it is NULL. - bool AddNewRepresentation(ContainerType type, - const MediaInfo& media_info, - uint32_t* id); - - // None of these are owned by this object. - MpdBuilder* const mpd_builder_; - AdaptationSet* audio_adaptation_set_; - AdaptationSet* video_adaptation_set_; - Representation* representation_; - - std::map id_to_representation_; - - DISALLOW_COPY_AND_ASSIGN(SimpleVodMpdNotifier); -}; - -} // namespace edash_packager - -#endif // MPD_BASE_SIMPLE_MPD_NOTIFIER_H_ diff --git a/packager/mpd/mpd.gyp b/packager/mpd/mpd.gyp index cdd49e8268..5af2ccfb38 100644 --- a/packager/mpd/mpd.gyp +++ b/packager/mpd/mpd.gyp @@ -42,6 +42,7 @@ 'base/mpd_notifier.h', 'base/mpd_utils.cc', 'base/mpd_utils.h', + 'base/segment_info.h', 'base/simple_mpd_notifier.cc', 'base/simple_mpd_notifier.h', 'base/xml/scoped_xml_ptr.h', @@ -63,7 +64,7 @@ 'target_name': 'mpd_unittest', 'type': '<(gtest_target_type)', 'sources': [ - 'base/bandwidth_estimator_test.cc', + 'base/bandwidth_estimator_unittest.cc', 'base/mpd_builder_unittest.cc', 'base/xml/xml_node_unittest.cc', 'test/mpd_builder_test_helper.cc',