Showing the changes to test/BaseDecoderTest.cpp (1 of 8 files). Show all
Unified · Split
| @@ -43,7 +43,8 @@ static void ReadFrame(std::ifstream* file, BufferedData* buf) { · 42 unmodified lines | |||
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | BaseDecoderTest::BaseDecoderTest() : decoder_(NULL) {} | 46 | BaseDecoderTest::BaseDecoderTest() |
| 47 | : decoder_(NULL), decodeStatus_(OpenFile) {} | ||
| 47 | 48 | ||
| 48 | void BaseDecoderTest::SetUp() { | 49 | void BaseDecoderTest::SetUp() { |
| 49 | long rv = CreateDecoder(&decoder_); | 50 | long rv = CreateDecoder(&decoder_); |
| @@ -126,3 +127,41 @@ void BaseDecoderTest::DecodeFile(const char* fileName, Callback* cbk) { · 76 unmodified lines | |||
| 126 | // Get pending last frame | 127 | // Get pending last frame |
| 127 | DecodeFrame(NULL, 0, cbk); | 128 | DecodeFrame(NULL, 0, cbk); |
| 128 | } | 129 | } |
| 130 | |||
| 131 | bool BaseDecoderTest::Open(const char* fileName) { | ||
| 132 | if (decodeStatus_ == OpenFile) { | ||
| 133 | file_.open(fileName); | ||
| 134 | if (file_.is_open()) { | ||
| 135 | decodeStatus_ = Decoding; | ||
| 136 | return true; | ||
| 137 | } | ||
| 138 | } | ||
| 139 | return false; | ||
| 140 | } | ||
| 141 | |||
| 142 | bool BaseDecoderTest::DecodeNextFrame(Callback* cbk) { | ||
| 143 | switch (decodeStatus_) { | ||
| 144 | case Decoding: | ||
| 145 | ReadFrame(&file_, &buf_); | ||
| 146 | if (::testing::Test::HasFatalFailure()) { | ||
| 147 | return false; | ||
| 148 | } | ||
| 149 | if (buf_.Length() == 0) { | ||
| 150 | decodeStatus_ = EndOfStream; | ||
| 151 | return true; | ||
| 152 | } | ||
| 153 | DecodeFrame(buf_.data(), buf_.Length(), cbk); | ||
| 154 | if (::testing::Test::HasFatalFailure()) { | ||
| 155 | return false; | ||
| 156 | } | ||
| 157 | return true; | ||
| 158 | case EndOfStream: { | ||
| 159 | int32_t iEndOfStreamFlag = 1; | ||
| 160 | decoder_->SetOption(DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag); | ||
| 161 | DecodeFrame(NULL, 0, cbk); | ||
| 162 | decodeStatus_ = End; | ||
| 163 | break; | ||
| 164 | } | ||
| 165 | } | ||
| 166 | return false; | ||
| 167 | } | ||