| 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/cpdf_dictionary.h" | 8 #include "core/fpdfapi/fpdf_parser/cpdf_dictionary.h" |
| 9 #include "core/fpdfapi/fpdf_parser/cpdf_name.h" | 9 #include "core/fpdfapi/fpdf_parser/cpdf_name.h" |
| 10 #include "core/fpdfapi/fpdf_parser/cpdf_string.h" | 10 #include "core/fpdfapi/fpdf_parser/cpdf_string.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 #else | 98 #else |
| 99 {L"/docs/a/test.pdf", L"/docs/a/test.pdf"}, | 99 {L"/docs/a/test.pdf", L"/docs/a/test.pdf"}, |
| 100 {L"/docs/b/test.pdf", L"/docs/b/test.pdf"}, | 100 {L"/docs/b/test.pdf", L"/docs/b/test.pdf"}, |
| 101 {L"/docs/c/test.pdf", L"/docs/c/test.pdf"}, | 101 {L"/docs/c/test.pdf", L"/docs/c/test.pdf"}, |
| 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(CFX_WeakPtr<CFX_ByteStringPool>())); | 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->SetFor(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->SetStringFor("FS", "URL"); | 118 dict_obj->SetStringFor("FS", "URL"); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 148 file_spec1.SetFileName(test_data.input); | 148 file_spec1.SetFileName(test_data.input); |
| 149 // Check internal object value. | 149 // Check internal object value. |
| 150 CFX_ByteString str = CFX_ByteString::FromUnicode(test_data.expected); | 150 CFX_ByteString str = CFX_ByteString::FromUnicode(test_data.expected); |
| 151 EXPECT_TRUE(str == str_obj->GetString()); | 151 EXPECT_TRUE(str == str_obj->GetString()); |
| 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(CFX_WeakPtr<CFX_ByteStringPool>())); | 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->GetUnicodeTextFor("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->GetUnicodeTextFor("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 |