diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-04-17 09:07:48 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-17 16:24:38 +0000 |
commit | 16b9d77ceb55e102260bc44cf1c8f519d11d6769 (patch) | |
tree | 41f8a63fa49f093a35f071bb38eda417d60ce94e /core/fxcrt/xml/cfx_saxreader.h | |
parent | ba91bed89a9fecfae3e175abcd4e333057e3f9c8 (diff) | |
download | pdfium-16b9d77ceb55e102260bc44cf1c8f519d11d6769.tar.xz |
Add unit test for CFX_SAXReader.
Make the pending re-write CL smaller, and back-fill some test.
Virtualize the handler interface so that it can be mocked.
Change-Id: Icbbc6b6789ba135b73c6fd1bbb90f5aae6ab7649
Reviewed-on: https://pdfium-review.googlesource.com/4250
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cfx_saxreader.h')
-rw-r--r-- | core/fxcrt/xml/cfx_saxreader.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/core/fxcrt/xml/cfx_saxreader.h b/core/fxcrt/xml/cfx_saxreader.h index af3c26f94a..6c76016110 100644 --- a/core/fxcrt/xml/cfx_saxreader.h +++ b/core/fxcrt/xml/cfx_saxreader.h @@ -14,7 +14,6 @@ class CFX_SAXCommentContext; class CFX_SAXContext; -class CFX_SAXReaderHandler; enum class CFX_SaxMode; class CFX_SAXItem { @@ -70,6 +69,30 @@ enum CFX_SaxParseMode { class CFX_SAXReader { public: + class HandlerIface { + public: + virtual ~HandlerIface() {} + virtual CFX_SAXContext* OnTagEnter(const CFX_ByteStringC& bsTagName, + CFX_SAXItem::Type eType, + uint32_t dwStartPos) = 0; + virtual void OnTagAttribute(CFX_SAXContext* pTag, + const CFX_ByteStringC& bsAttri, + const CFX_ByteStringC& bsValue) = 0; + virtual void OnTagBreak(CFX_SAXContext* pTag) = 0; + virtual void OnTagData(CFX_SAXContext* pTag, + CFX_SAXItem::Type eType, + const CFX_ByteStringC& bsData, + uint32_t dwStartPos) = 0; + virtual void OnTagClose(CFX_SAXContext* pTag, uint32_t dwEndPos) = 0; + virtual void OnTagEnd(CFX_SAXContext* pTag, + const CFX_ByteStringC& bsTagName, + uint32_t dwEndPos) = 0; + virtual void OnTargetData(CFX_SAXContext* pTag, + CFX_SAXItem::Type eType, + const CFX_ByteStringC& bsData, + uint32_t dwStartPos) = 0; + }; + CFX_SAXReader(); ~CFX_SAXReader(); @@ -79,7 +102,7 @@ class CFX_SAXReader { uint32_t dwParseMode = 0); int32_t ContinueParse(IFX_Pause* pPause = nullptr); void SkipCurrentNode(); - void SetHandler(CFX_SAXReaderHandler* pHandler) { m_pHandler = pHandler; } + void SetHandler(HandlerIface* pHandler) { m_pHandler = pHandler; } void AppendData(uint8_t ch); void AppendName(uint8_t ch); void ParseText(); @@ -117,7 +140,7 @@ class CFX_SAXReader { void ParseChar(uint8_t ch); CFX_SAXFile m_File; - CFX_SAXReaderHandler* m_pHandler; + HandlerIface* m_pHandler; int32_t m_iState; std::stack<std::unique_ptr<CFX_SAXItem>> m_Stack; uint32_t m_dwItemID; |