Created Test Handler CachingMediaHandler
Renamed "FakeMediaHandler" to "CachingMediaHandler" so that it is easier to differentiate from "FakeInputMediaHandler". It will be used as the single method to verify media handler output. This is part of an effort to find a cleaner way to test media handlers. Change-Id: Ie391fe23ee3389d13b012ae3093744a453106c19
This commit is contained in:
parent
33792ca2da
commit
60df64705b
|
@ -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<StreamData> stream_data) {
|
||||
Status CachingMediaHandler::Process(std::unique_ptr<StreamData> 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<MediaHandler> 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<FakeMediaHandler>();
|
||||
// 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<CachingMediaHandler>();
|
||||
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<std::unique_ptr<StreamData>>&
|
||||
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
|
||||
|
|
|
@ -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<std::unique_ptr<StreamData>>& stream_data_vector() const {
|
||||
const std::vector<std::unique_ptr<StreamData>>& 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<StreamData> stream_data) override;
|
||||
Status OnFlushRequest(size_t input_stream_index) override;
|
||||
|
@ -381,7 +382,7 @@ class MediaHandlerGraphTestBase : public MediaHandlerTestBase {
|
|||
std::shared_ptr<MediaHandler> some_handler() { return some_handler_; }
|
||||
|
||||
/// @return some a downstream handler that can be used for connecting.
|
||||
std::shared_ptr<FakeMediaHandler> next_handler() { return next_handler_; }
|
||||
std::shared_ptr<CachingMediaHandler> 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<FakeMediaHandler> next_handler_;
|
||||
std::shared_ptr<CachingMediaHandler> next_handler_;
|
||||
// Some random handler which can be used for testing.
|
||||
std::shared_ptr<MediaHandler> some_handler_;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue