diff --git a/packager/media/base/media_handler_test_base.cc b/packager/media/base/media_handler_test_base.cc index 3127a2422d..69444c9d87 100644 --- a/packager/media/base/media_handler_test_base.cc +++ b/packager/media/base/media_handler_test_base.cc @@ -152,20 +152,20 @@ Status MockOutputMediaHandler::OnFlushRequest(size_t index) { return Status::OK; } -Status FakeMediaHandler::InitializeInternal() { +Status CachingMediaHandler::InitializeInternal() { return Status::OK; } -Status FakeMediaHandler::Process(std::unique_ptr stream_data) { +Status CachingMediaHandler::Process(std::unique_ptr stream_data) { stream_data_vector_.push_back(std::move(stream_data)); return Status::OK; } -Status FakeMediaHandler::OnFlushRequest(size_t input_stream_index) { +Status CachingMediaHandler::OnFlushRequest(size_t input_stream_index) { return Status::OK; } -bool FakeMediaHandler::ValidateOutputStreamIndex(size_t stream_index) const { +bool CachingMediaHandler::ValidateOutputStreamIndex(size_t stream_index) const { return true; } @@ -346,16 +346,16 @@ MockOutputMediaHandler* MediaHandlerTestBase::Output(size_t index) { } MediaHandlerGraphTestBase::MediaHandlerGraphTestBase() - : next_handler_(new FakeMediaHandler), - some_handler_(new FakeMediaHandler) {} + : next_handler_(new CachingMediaHandler), + some_handler_(new CachingMediaHandler) {} void MediaHandlerGraphTestBase::SetUpGraph( size_t num_inputs, size_t num_outputs, std::shared_ptr handler) { - // Input handler is not really used anywhere but just to satisfy one input - // one output restriction for the encryption handler. - auto input_handler = std::make_shared(); + // Input handler is not really used anywhere else except to validate number of + // allowed inputs for the handler to be tested. + auto input_handler = std::make_shared(); for (size_t i = 0; i < num_inputs; ++i) ASSERT_OK(input_handler->SetHandler(i, handler)); // All outputs are routed to |next_handler_|. @@ -365,11 +365,11 @@ void MediaHandlerGraphTestBase::SetUpGraph( const std::vector>& MediaHandlerGraphTestBase::GetOutputStreamDataVector() const { - return next_handler_->stream_data_vector(); + return next_handler_->Cache(); } void MediaHandlerGraphTestBase::ClearOutputStreamDataVector() { - next_handler_->clear_stream_data_vector(); + next_handler_->Clear(); } } // namespace media diff --git a/packager/media/base/media_handler_test_base.h b/packager/media/base/media_handler_test_base.h index bc823848f2..7742fdbf06 100644 --- a/packager/media/base/media_handler_test_base.h +++ b/packager/media/base/media_handler_test_base.h @@ -270,16 +270,17 @@ class MockOutputMediaHandler : public MediaHandler { Status OnFlushRequest(size_t index) override; }; -// TODO(vaage) : Remove this test handler and convert other tests to use -// FakeInputMediaHandler and MockOutputMediaHandler. -class FakeMediaHandler : public MediaHandler { +class CachingMediaHandler : public MediaHandler { public: - const std::vector>& stream_data_vector() const { + const std::vector>& Cache() const { return stream_data_vector_; } - void clear_stream_data_vector() { stream_data_vector_.clear(); } - protected: + // TODO(vaage) : Remove the use of clear in our tests as it can make flow + // of the test harder to understand. + void Clear() { stream_data_vector_.clear(); } + + private: Status InitializeInternal() override; Status Process(std::unique_ptr stream_data) override; Status OnFlushRequest(size_t input_stream_index) override; @@ -381,7 +382,7 @@ class MediaHandlerGraphTestBase : public MediaHandlerTestBase { std::shared_ptr some_handler() { return some_handler_; } /// @return some a downstream handler that can be used for connecting. - std::shared_ptr next_handler() { return next_handler_; } + std::shared_ptr next_handler() { return next_handler_; } private: MediaHandlerGraphTestBase(const MediaHandlerGraphTestBase&) = delete; @@ -389,7 +390,7 @@ class MediaHandlerGraphTestBase : public MediaHandlerTestBase { delete; // Downstream handler used in testing graph. - std::shared_ptr next_handler_; + std::shared_ptr next_handler_; // Some random handler which can be used for testing. std::shared_ptr some_handler_; };