Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/fxcrt/include/fx_basic.h" | 5 #include "core/fxcrt/include/fx_basic.h" |
| 6 #include "public/fpdf_text.h" | 6 #include "public/fpdf_text.h" |
| 7 #include "public/fpdfview.h" | 7 #include "public/fpdfview.h" |
| 8 #include "testing/embedder_test.h" | 8 #include "testing/embedder_test.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/test_support.h" | 10 #include "testing/test_support.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 | 269 |
| 270 FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page); | 270 FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page); |
| 271 EXPECT_NE(nullptr, textpage); | 271 EXPECT_NE(nullptr, textpage); |
| 272 | 272 |
| 273 FPDF_PAGELINK pagelink = FPDFLink_LoadWebLinks(textpage); | 273 FPDF_PAGELINK pagelink = FPDFLink_LoadWebLinks(textpage); |
| 274 EXPECT_NE(nullptr, pagelink); | 274 EXPECT_NE(nullptr, pagelink); |
| 275 | 275 |
| 276 // Page contains two HTTP-style URLs. | 276 // Page contains two HTTP-style URLs. |
| 277 EXPECT_EQ(2, FPDFLink_CountWebLinks(pagelink)); | 277 EXPECT_EQ(2, FPDFLink_CountWebLinks(pagelink)); |
| 278 | 278 |
| 279 // Only a terminating NUL required for bogus links. | 279 // Zero returned for bogus links. |
|
Lei Zhang
2016/04/20 21:36:49
Isn't this changing the public API behavior? Won't
| |
| 280 EXPECT_EQ(1, FPDFLink_GetURL(pagelink, 2, nullptr, 0)); | 280 EXPECT_EQ(0, FPDFLink_GetURL(pagelink, 2, nullptr, 0)); |
| 281 EXPECT_EQ(1, FPDFLink_GetURL(pagelink, 1400, nullptr, 0)); | 281 EXPECT_EQ(0, FPDFLink_GetURL(pagelink, 1400, nullptr, 0)); |
| 282 EXPECT_EQ(1, FPDFLink_GetURL(pagelink, -1, nullptr, 0)); | 282 EXPECT_EQ(0, FPDFLink_GetURL(pagelink, -1, nullptr, 0)); |
| 283 | 283 |
| 284 // Query the number of characters required for each link (incl NUL). | 284 // Query the number of characters required for each link (incl NUL). |
| 285 EXPECT_EQ(25, FPDFLink_GetURL(pagelink, 0, nullptr, 0)); | 285 EXPECT_EQ(25, FPDFLink_GetURL(pagelink, 0, nullptr, 0)); |
| 286 EXPECT_EQ(26, FPDFLink_GetURL(pagelink, 1, nullptr, 0)); | 286 EXPECT_EQ(26, FPDFLink_GetURL(pagelink, 1, nullptr, 0)); |
| 287 | 287 |
| 288 static const char expected_url[] = "http://example.com?q=foo"; | 288 static const char expected_url[] = "http://example.com?q=foo"; |
| 289 static const size_t expected_len = sizeof(expected_url); | 289 static const size_t expected_len = sizeof(expected_url); |
| 290 unsigned short fixed_buffer[128]; | 290 unsigned short fixed_buffer[128]; |
| 291 | 291 |
| 292 // Retrieve a link with too small a buffer. Buffer will not be | 292 // Retrieve a link with too small a buffer. Buffer will not be |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}; | 381 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}; |
| 382 | 382 |
| 383 int count = FPDFText_CountChars(textpage); | 383 int count = FPDFText_CountChars(textpage); |
| 384 ASSERT_EQ(FX_ArraySize(kExpectedFontsSizes), static_cast<size_t>(count)); | 384 ASSERT_EQ(FX_ArraySize(kExpectedFontsSizes), static_cast<size_t>(count)); |
| 385 for (int i = 0; i < count; ++i) | 385 for (int i = 0; i < count; ++i) |
| 386 EXPECT_EQ(kExpectedFontsSizes[i], FPDFText_GetFontSize(textpage, i)) << i; | 386 EXPECT_EQ(kExpectedFontsSizes[i], FPDFText_GetFontSize(textpage, i)) << i; |
| 387 | 387 |
| 388 FPDFText_ClosePage(textpage); | 388 FPDFText_ClosePage(textpage); |
| 389 UnloadPage(page); | 389 UnloadPage(page); |
| 390 } | 390 } |
| OLD | NEW |