summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdftext_embeddertest.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2016-01-11 12:01:23 -0800
committerLei Zhang <thestig@chromium.org>2016-01-11 12:01:23 -0800
commit0f2ea02eb3d817993f3a5be0a5fa48f602e56483 (patch)
tree36acd17219bcbf6d6af2334b90719cbb1f789757 /fpdfsdk/src/fpdftext_embeddertest.cpp
parent375a86403b7fa8d17d7b142c270e2d8e33bb924f (diff)
downloadpdfium-0f2ea02eb3d817993f3a5be0a5fa48f602e56483.tar.xz
Merge to XFA: Fix an uninitalized read in FPDFText_GetFontSize().
BUG=pdfium:346 TBR=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/1578543002 . (cherry picked from commit 401cd2dbaaa10790077de2fd70e8101b0bdd0f36) Review URL: https://codereview.chromium.org/1578873002 .
Diffstat (limited to 'fpdfsdk/src/fpdftext_embeddertest.cpp')
-rw-r--r--fpdfsdk/src/fpdftext_embeddertest.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/fpdfsdk/src/fpdftext_embeddertest.cpp b/fpdfsdk/src/fpdftext_embeddertest.cpp
index 4653db32ad..e84a96e966 100644
--- a/fpdfsdk/src/fpdftext_embeddertest.cpp
+++ b/fpdfsdk/src/fpdftext_embeddertest.cpp
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "core/include/fxcrt/fx_basic.h"
#include "public/fpdf_text.h"
#include "public/fpdfview.h"
#include "testing/embedder_test.h"
@@ -10,9 +11,9 @@
namespace {
-static bool check_unsigned_shorts(const char* expected,
- const unsigned short* actual,
- size_t length) {
+bool check_unsigned_shorts(const char* expected,
+ const unsigned short* actual,
+ size_t length) {
if (length > strlen(expected) + 1) {
return false;
}
@@ -367,3 +368,24 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) {
FPDFText_ClosePage(textpage);
UnloadPage(page);
}
+
+TEST_F(FPDFTextEmbeddertest, GetFontSize) {
+ EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_NE(nullptr, page);
+
+ FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page);
+ EXPECT_NE(nullptr, textpage);
+
+ const double kExpectedFontsSizes[] = {12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 1, 1, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
+
+ int count = FPDFText_CountChars(textpage);
+ ASSERT_EQ(FX_ArraySize(kExpectedFontsSizes), count);
+ for (int i = 0; i < count; ++i)
+ EXPECT_EQ(kExpectedFontsSizes[i], FPDFText_GetFontSize(textpage, i)) << i;
+
+ FPDFText_ClosePage(textpage);
+ UnloadPage(page);
+}