diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/embedder_test.cpp | 14 | ||||
-rw-r--r-- | testing/mock_ifx_renderdevicedriver.h | 59 | ||||
-rw-r--r-- | testing/test_support.cpp | 18 | ||||
-rw-r--r-- | testing/test_support.h | 4 |
4 files changed, 23 insertions, 72 deletions
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index 79074153fb..1baeb57206 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -42,18 +42,6 @@ FPDF_BOOL Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) { void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) {} -std::string CRYPT_ToBase16(const uint8_t* digest) { - static char const zEncode[] = "0123456789abcdef"; - std::string ret; - ret.resize(32); - for (int i = 0, j = 0; i < 16; i++, j += 2) { - uint8_t a = digest[i]; - ret[j] = zEncode[(a >> 4) & 0xf]; - ret[j + 1] = zEncode[a & 0xf]; - } - return ret; -} - } // namespace EmbedderTest::EmbedderTest() @@ -352,7 +340,7 @@ void EmbedderTest::CompareBitmap(FPDF_BITMAP bitmap, uint8_t digest[16]; CRYPT_MD5Generate(static_cast<uint8_t*>(FPDFBitmap_GetBuffer(bitmap)), expected_stride * expected_height, digest); - EXPECT_EQ(expected_md5sum, CRYPT_ToBase16(digest)); + EXPECT_EQ(expected_md5sum, CryptToBase16(digest)); } // Can't use gtest-provided main since we need to stash the path to the diff --git a/testing/mock_ifx_renderdevicedriver.h b/testing/mock_ifx_renderdevicedriver.h deleted file mode 100644 index c9061d88b8..0000000000 --- a/testing/mock_ifx_renderdevicedriver.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef TESTING_MOCK_IFX_RENDERDEVICEDRIVER_H_ -#define TESTING_MOCK_IFX_RENDERDEVICEDRIVER_H_ - -#include <memory> - -#include "core/fxge/ifx_renderdevicedriver.h" -#include "testing/gmock/include/gmock/gmock.h" - -class MockIFXRenderDeviceDriver : public IFX_RenderDeviceDriver { - public: - MOCK_CONST_METHOD1(GetDeviceCaps, int(int caps_id)); - MOCK_METHOD0(SaveState, void()); - MOCK_METHOD1(RestoreState, void(bool bKeepSaved)); - MOCK_METHOD3(SetClip_PathFill, - bool(const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - int fill_mode)); - MOCK_METHOD7(DrawPath, - bool(const CFX_PathData* pPathData, - const CFX_Matrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - uint32_t fill_color, - uint32_t stroke_color, - int fill_mode, - int blend_type)); - MOCK_METHOD1(GetClipBox, bool(FX_RECT* pRect)); - MOCK_METHOD6(SetDIBits, - bool(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, - uint32_t color, - const FX_RECT* pSrcRect, - int dest_left, - int dest_top, - int blend_type)); - - MOCK_METHOD7(StartDIBits, - bool(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, - int bitmap_alpha, - uint32_t color, - const CFX_Matrix* pMatrix, - uint32_t flags, - std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type)); - MOCK_METHOD9(StretchDIBits, - bool(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, - uint32_t color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - uint32_t flags, - int blend_type)); -}; - -#endif // TESTING_MOCK_IFX_RENDERDEVICEDRIVER_H_ diff --git a/testing/test_support.cpp b/testing/test_support.cpp index a2e9a6a6dd..608e4ae75b 100644 --- a/testing/test_support.cpp +++ b/testing/test_support.cpp @@ -150,6 +150,24 @@ std::unique_ptr<unsigned short, pdfium::FreeDeleter> GetFPDFWideString( return result; } +std::string CryptToBase16(const uint8_t* digest) { + static char const zEncode[] = "0123456789abcdef"; + std::string ret; + ret.resize(32); + for (int i = 0, j = 0; i < 16; i++, j += 2) { + uint8_t a = digest[i]; + ret[j] = zEncode[(a >> 4) & 0xf]; + ret[j + 1] = zEncode[a & 0xf]; + } + return ret; +} + +std::string GenerateMD5Base16(const uint8_t* data, uint32_t size) { + uint8_t digest[16]; + CRYPT_MD5Generate(data, size, digest); + return CryptToBase16(digest); +} + #ifdef PDF_ENABLE_V8 #ifdef V8_USE_EXTERNAL_STARTUP_DATA bool InitializeV8ForPDFium(const std::string& exe_path, diff --git a/testing/test_support.h b/testing/test_support.h index 4fe7c295cd..a2d3528e73 100644 --- a/testing/test_support.h +++ b/testing/test_support.h @@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "core/fdrm/crypto/fx_crypt.h" #include "public/fpdf_save.h" #include "public/fpdfview.h" #include "testing/gtest/include/gtest/gtest.h" @@ -76,6 +77,9 @@ std::wstring GetPlatformWString(const FPDF_WIDESTRING wstr); std::unique_ptr<unsigned short, pdfium::FreeDeleter> GetFPDFWideString( const std::wstring& wstr); +std::string CryptToBase16(const uint8_t* digest); +std::string GenerateMD5Base16(const uint8_t* data, uint32_t size); + #ifdef PDF_ENABLE_V8 #ifdef V8_USE_EXTERNAL_STARTUP_DATA bool InitializeV8ForPDFium(const std::string& exe_path, |