Created Mock Input and Output Media Handlers

Created media handlers that make testing a handler easier by providing
methods to send messages from upstream and check messages downstream.

Change-Id: I7b3ba3a51bcf0d73bcaacd46b2dcbc16f87d8694
This commit is contained in:
Aaron Vaage 2017-09-14 09:23:29 -07:00
parent 304f7d2a88
commit b5800fad77
2 changed files with 50 additions and 0 deletions

View File

@ -59,6 +59,33 @@ const uint8_t kData[]{
namespace shaka { namespace shaka {
namespace media { namespace media {
bool FakeInputMediaHandler::ValidateOutputStreamIndex(size_t index) const {
return true;
}
Status FakeInputMediaHandler::InitializeInternal() {
return Status::OK;
}
Status FakeInputMediaHandler::Process(std::unique_ptr<StreamData> stream_data) {
return Status::OK;
}
Status MockOutputMediaHandler::InitializeInternal() {
return Status::OK;
}
Status MockOutputMediaHandler::Process(
std::unique_ptr<StreamData> stream_data) {
OnProcess(stream_data.get());
return Status::OK;
}
Status MockOutputMediaHandler::OnFlushRequest(size_t index) {
OnFlush(index);
return Status::OK;
}
Status FakeMediaHandler::InitializeInternal() { Status FakeMediaHandler::InitializeInternal() {
return Status::OK; return Status::OK;
} }

View File

@ -74,6 +74,29 @@ MATCHER_P4(IsMediaSample, stream_index, timestamp, duration, encrypted, "") {
arg->media_sample->is_encrypted() == encrypted; arg->media_sample->is_encrypted() == encrypted;
} }
class FakeInputMediaHandler : public MediaHandler {
public:
using MediaHandler::Dispatch;
using MediaHandler::FlushAllDownstreams;
using MediaHandler::FlushDownstream;
private:
bool ValidateOutputStreamIndex(size_t index) const override;
Status InitializeInternal() override;
Status Process(std::unique_ptr<StreamData> stream_data) override;
};
class MockOutputMediaHandler : public MediaHandler {
public:
MOCK_METHOD1(OnProcess, void(const StreamData*));
MOCK_METHOD1(OnFlush, void(size_t index));
private:
Status InitializeInternal() override;
Status Process(std::unique_ptr<StreamData> stream_data) override;
Status OnFlushRequest(size_t index) override;
};
// A fake media handler definition used for testing. // A fake media handler definition used for testing.
class FakeMediaHandler : public MediaHandler { class FakeMediaHandler : public MediaHandler {
public: public: