| 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 <limits> | 5 #include <limits> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "../../testing/embedder_test.h" | 8 #include "../../testing/embedder_test.h" |
| 9 #include "../../fpdfsdk/include/fpdfview.h" | 9 #include "../../fpdfsdk/include/fpdfview.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::min(), | 133 dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::min(), |
| 134 fixed_buffer, buffer_size); | 134 fixed_buffer, buffer_size); |
| 135 EXPECT_EQ(nullptr, dest); | 135 EXPECT_EQ(nullptr, dest); |
| 136 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. | 136 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. |
| 137 | 137 |
| 138 buffer_size = sizeof(fixed_buffer); | 138 buffer_size = sizeof(fixed_buffer); |
| 139 dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, buffer_size); | 139 dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, buffer_size); |
| 140 EXPECT_EQ(nullptr, dest); | 140 EXPECT_EQ(nullptr, dest); |
| 141 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. | 141 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. |
| 142 } | 142 } |
| 143 |
| 144 TEST_F(FPDFViewEmbeddertest, NamedDestsByName) { |
| 145 EXPECT_TRUE(OpenDocument("testing/resources/named_dests.pdf")); |
| 146 |
| 147 // Null pointer returns NULL. |
| 148 FPDF_DEST dest = FPDF_GetNamedDestByName(document(), nullptr); |
| 149 EXPECT_EQ(nullptr, dest); |
| 150 |
| 151 // Empty string returns NULL. |
| 152 dest = FPDF_GetNamedDestByName(document(), ""); |
| 153 EXPECT_EQ(nullptr, dest); |
| 154 |
| 155 // Item from Dests NameTree. |
| 156 dest = FPDF_GetNamedDestByName(document(), "First"); |
| 157 EXPECT_NE(nullptr, dest); |
| 158 |
| 159 long ignore_len = 0; |
| 160 FPDF_DEST dest_by_index = |
| 161 FPDF_GetNamedDest(document(), 0, nullptr, ignore_len); |
| 162 EXPECT_EQ(dest_by_index, dest); |
| 163 |
| 164 // Item from Dests dictionary. |
| 165 dest = FPDF_GetNamedDestByName(document(), "FirstAlternate"); |
| 166 EXPECT_NE(nullptr, dest); |
| 167 |
| 168 ignore_len = 0; |
| 169 dest_by_index = FPDF_GetNamedDest(document(), 4, nullptr, ignore_len); |
| 170 EXPECT_EQ(dest_by_index, dest); |
| 171 |
| 172 // Bad value type for item from Dests NameTree array. |
| 173 dest = FPDF_GetNamedDestByName(document(), "WrongType"); |
| 174 EXPECT_EQ(nullptr, dest); |
| 175 |
| 176 // No such destination in either Dest NameTree or dictionary. |
| 177 dest = FPDF_GetNamedDestByName(document(), "Bogus"); |
| 178 EXPECT_EQ(nullptr, dest); |
| 179 } |
| OLD | NEW |