OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 {L"/docs/d/test.pdf", L"/docs/d/test.pdf"}, | 102 {L"/docs/d/test.pdf", L"/docs/d/test.pdf"}, |
103 {L"/docs/e/test.pdf", L"/docs/e/test.pdf"}, | 103 {L"/docs/e/test.pdf", L"/docs/e/test.pdf"}, |
104 #endif | 104 #endif |
105 }; | 105 }; |
106 // Keyword fields in reverse order of precedence to retrieve the file name. | 106 // Keyword fields in reverse order of precedence to retrieve the file name. |
107 const char* const keywords[5] = {"Unix", "Mac", "DOS", "F", "UF"}; | 107 const char* const keywords[5] = {"Unix", "Mac", "DOS", "F", "UF"}; |
108 ScopedDict dict_obj(new CPDF_Dictionary); | 108 ScopedDict dict_obj(new CPDF_Dictionary); |
109 CPDF_FileSpec file_spec(dict_obj.get()); | 109 CPDF_FileSpec file_spec(dict_obj.get()); |
110 CFX_WideString file_name; | 110 CFX_WideString file_name; |
111 for (int i = 0; i < 5; ++i) { | 111 for (int i = 0; i < 5; ++i) { |
112 dict_obj->SetAt(keywords[i], new CPDF_String(test_data[i].input)); | 112 dict_obj->SetFor(keywords[i], new CPDF_String(test_data[i].input)); |
113 EXPECT_TRUE(file_spec.GetFileName(&file_name)); | 113 EXPECT_TRUE(file_spec.GetFileName(&file_name)); |
114 EXPECT_TRUE(file_name == test_data[i].expected); | 114 EXPECT_TRUE(file_name == test_data[i].expected); |
115 } | 115 } |
116 | 116 |
117 // With all the former fields and 'FS' field suggests 'URL' type. | 117 // With all the former fields and 'FS' field suggests 'URL' type. |
118 dict_obj->SetAtString("FS", "URL"); | 118 dict_obj->SetStringFor("FS", "URL"); |
119 EXPECT_TRUE(file_spec.GetFileName(&file_name)); | 119 EXPECT_TRUE(file_spec.GetFileName(&file_name)); |
120 // Url string is not decoded. | 120 // Url string is not decoded. |
121 EXPECT_TRUE(file_name == test_data[4].input); | 121 EXPECT_TRUE(file_name == test_data[4].input); |
122 } | 122 } |
123 { | 123 { |
124 // Invalid object. | 124 // Invalid object. |
125 ScopedObj name_obj(new CPDF_Name("test.pdf")); | 125 ScopedObj name_obj(new CPDF_Name("test.pdf")); |
126 CPDF_FileSpec file_spec(name_obj.get()); | 126 CPDF_FileSpec file_spec(name_obj.get()); |
127 CFX_WideString file_name; | 127 CFX_WideString file_name; |
128 EXPECT_FALSE(file_spec.GetFileName(&file_name)); | 128 EXPECT_FALSE(file_spec.GetFileName(&file_name)); |
(...skipping 23 matching lines...) Expand all Loading... |
152 // Check we can get the file name back. | 152 // Check we can get the file name back. |
153 CFX_WideString file_name; | 153 CFX_WideString file_name; |
154 EXPECT_TRUE(file_spec1.GetFileName(&file_name)); | 154 EXPECT_TRUE(file_spec1.GetFileName(&file_name)); |
155 EXPECT_TRUE(file_name == test_data.input); | 155 EXPECT_TRUE(file_name == test_data.input); |
156 | 156 |
157 // Dictionary object. | 157 // Dictionary object. |
158 ScopedDict dict_obj(new CPDF_Dictionary); | 158 ScopedDict dict_obj(new CPDF_Dictionary); |
159 CPDF_FileSpec file_spec2(dict_obj.get()); | 159 CPDF_FileSpec file_spec2(dict_obj.get()); |
160 file_spec2.SetFileName(test_data.input); | 160 file_spec2.SetFileName(test_data.input); |
161 // Check internal object value. | 161 // Check internal object value. |
162 file_name = dict_obj->GetUnicodeTextBy("F"); | 162 file_name = dict_obj->GetUnicodeTextFor("F"); |
163 EXPECT_TRUE(file_name == test_data.expected); | 163 EXPECT_TRUE(file_name == test_data.expected); |
164 file_name = dict_obj->GetUnicodeTextBy("UF"); | 164 file_name = dict_obj->GetUnicodeTextFor("UF"); |
165 EXPECT_TRUE(file_name == test_data.expected); | 165 EXPECT_TRUE(file_name == test_data.expected); |
166 // Check we can get the file name back. | 166 // Check we can get the file name back. |
167 EXPECT_TRUE(file_spec2.GetFileName(&file_name)); | 167 EXPECT_TRUE(file_spec2.GetFileName(&file_name)); |
168 EXPECT_TRUE(file_name == test_data.input); | 168 EXPECT_TRUE(file_name == test_data.input); |
169 } | 169 } |
OLD | NEW |