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/parser/cpdf_dictionary.h" | 8 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
9 #include "core/fpdfapi/parser/cpdf_name.h" | 9 #include "core/fpdfapi/parser/cpdf_name.h" |
10 #include "core/fpdfapi/parser/cpdf_string.h" | 10 #include "core/fpdfapi/parser/cpdf_string.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 108 } |
109 | 109 |
110 // With all the former fields and 'FS' field suggests 'URL' type. | 110 // With all the former fields and 'FS' field suggests 'URL' type. |
111 dict_obj->SetStringFor("FS", "URL"); | 111 dict_obj->SetStringFor("FS", "URL"); |
112 EXPECT_TRUE(file_spec.GetFileName(&file_name)); | 112 EXPECT_TRUE(file_spec.GetFileName(&file_name)); |
113 // Url string is not decoded. | 113 // Url string is not decoded. |
114 EXPECT_TRUE(file_name == test_data[4].input); | 114 EXPECT_TRUE(file_name == test_data[4].input); |
115 } | 115 } |
116 { | 116 { |
117 // Invalid object. | 117 // Invalid object. |
118 std::unique_ptr<CPDF_Object> name_obj(new CPDF_Name("test.pdf")); | 118 std::unique_ptr<CPDF_Object> name_obj(new CPDF_Name(nullptr, "test.pdf")); |
119 CPDF_FileSpec file_spec(name_obj.get()); | 119 CPDF_FileSpec file_spec(name_obj.get()); |
120 CFX_WideString file_name; | 120 CFX_WideString file_name; |
121 EXPECT_FALSE(file_spec.GetFileName(&file_name)); | 121 EXPECT_FALSE(file_spec.GetFileName(&file_name)); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 TEST(cpdf_filespec, SetFileName) { | 125 TEST(cpdf_filespec, SetFileName) { |
126 pdfium::NullTermWstrFuncTestData test_data = { | 126 pdfium::NullTermWstrFuncTestData test_data = { |
127 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 127 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
128 L"C:\\docs\\test.pdf", | 128 L"C:\\docs\\test.pdf", |
(...skipping 24 matching lines...) Expand all Loading... |
153 file_spec2.SetFileName(test_data.input); | 153 file_spec2.SetFileName(test_data.input); |
154 // Check internal object value. | 154 // Check internal object value. |
155 file_name = dict_obj->GetUnicodeTextFor("F"); | 155 file_name = dict_obj->GetUnicodeTextFor("F"); |
156 EXPECT_TRUE(file_name == test_data.expected); | 156 EXPECT_TRUE(file_name == test_data.expected); |
157 file_name = dict_obj->GetUnicodeTextFor("UF"); | 157 file_name = dict_obj->GetUnicodeTextFor("UF"); |
158 EXPECT_TRUE(file_name == test_data.expected); | 158 EXPECT_TRUE(file_name == test_data.expected); |
159 // Check we can get the file name back. | 159 // Check we can get the file name back. |
160 EXPECT_TRUE(file_spec2.GetFileName(&file_name)); | 160 EXPECT_TRUE(file_spec2.GetFileName(&file_name)); |
161 EXPECT_TRUE(file_name == test_data.input); | 161 EXPECT_TRUE(file_name == test_data.input); |
162 } | 162 } |
OLD | NEW |