Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: core/fpdfapi/fpdf_parser/cpdf_parser_unittest.cpp

Issue 2430743003: in the attempt to fix 627393, changed IFX_FileRead's readBlock to return the length it reads
Patch Set: remove .tmp files Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/fpdfapi/fpdf_parser/cpdf_parser_unittest.cpp
diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser_unittest.cpp
index 7a08511e816586f0821dfa5d9d447b706f462a9a..3cfc82f5cbdc5fbdb5865661486d7a1f1a75aaef 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_parser_unittest.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_parser_unittest.cpp
@@ -16,25 +16,28 @@
class CFX_TestBufferRead : public IFX_FileRead {
public:
CFX_TestBufferRead(const unsigned char* buffer_in, size_t buf_size)
- : buffer_(buffer_in), total_size_(buf_size) {}
+ : buffer_(buffer_in), total_size_(buf_size), m_nCurPos(0) {}
// IFX_Stream
void Release() override { delete this; }
// IFX_FileRead
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
+ FX_BOOL IsEOF() override { return m_nCurPos >= total_size_; }
Tom Sepez 2016/10/19 23:12:47 nit: can we make this just a |bool|, we've been tr
Tom Sepez 2016/10/19 23:12:48 We may get a signed vs unsigned comparison error o
+
+ size_t ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
if (offset < 0 || offset + size > total_size_) {
- return FALSE;
+ return 0;
}
-
memcpy(buffer, buffer_ + offset, size);
- return TRUE;
+ m_nCurPos = offset + size;
+ return size;
}
FX_FILESIZE GetSize() override { return (FX_FILESIZE)total_size_; };
protected:
const unsigned char* buffer_;
size_t total_size_;
Tom Sepez 2016/10/19 23:12:47 |total_size_| probably needs to be a FX_FILESIZE a
+ FX_FILESIZE m_nCurPos;
Tom Sepez 2016/10/19 23:12:47 nit: use pre-existing convention, eg. current_pos_
};
// A wrapper class to help test member functions of CPDF_Parser.

Powered by Google App Engine
This is Rietveld 408576698