Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: core/fpdfdoc/cpdf_filespec_unittest.cpp

Issue 2187073005: Splitting fpdfdoc/doc_* part II. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@fpdf_doc_III
Patch Set: Rebase to master Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_filespec.cpp ('k') | core/fpdfdoc/cpdf_nametree.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "core/fpdfdoc/include/cpdf_filespec.h" 11 #include "core/fpdfdoc/include/cpdf_filespec.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/test_support.h" 13 #include "testing/test_support.h"
14 14
15 namespace { 15 namespace {
16 16
17 using ScopedObj = std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>>; 17 using ScopedObj = std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>>;
18 using ScopedDict = 18 using ScopedDict =
19 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>; 19 std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>;
20 } 20 }
21 21
22 TEST(doc_basic_filespec, EncodeDecodeFileName) { 22 TEST(cpdf_filespec, EncodeDecodeFileName) {
23 std::vector<pdfium::NullTermWstrFuncTestData> test_data = { 23 std::vector<pdfium::NullTermWstrFuncTestData> test_data = {
24 // Empty src string. 24 // Empty src string.
25 {L"", L""}, 25 {L"", L""},
26 // only file name. 26 // only file name.
27 {L"test.pdf", L"test.pdf"}, 27 {L"test.pdf", L"test.pdf"},
28 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 28 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
29 // With drive identifier. 29 // With drive identifier.
30 {L"r:\\pdfdocs\\spec.pdf", L"/r/pdfdocs/spec.pdf"}, 30 {L"r:\\pdfdocs\\spec.pdf", L"/r/pdfdocs/spec.pdf"},
31 // Relative path. 31 // Relative path.
32 {L"My Document\\test.pdf", L"My Document/test.pdf"}, 32 {L"My Document\\test.pdf", L"My Document/test.pdf"},
(...skipping 19 matching lines...) Expand all
52 }; 52 };
53 for (const auto& data : test_data) { 53 for (const auto& data : test_data) {
54 CFX_WideString encoded_str = CPDF_FileSpec::EncodeFileName(data.input); 54 CFX_WideString encoded_str = CPDF_FileSpec::EncodeFileName(data.input);
55 EXPECT_TRUE(encoded_str == data.expected); 55 EXPECT_TRUE(encoded_str == data.expected);
56 // DecodeFileName is the reverse procedure of EncodeFileName. 56 // DecodeFileName is the reverse procedure of EncodeFileName.
57 CFX_WideString decoded_str = CPDF_FileSpec::DecodeFileName(data.expected); 57 CFX_WideString decoded_str = CPDF_FileSpec::DecodeFileName(data.expected);
58 EXPECT_TRUE(decoded_str == data.input); 58 EXPECT_TRUE(decoded_str == data.input);
59 } 59 }
60 } 60 }
61 61
62 TEST(doc_basic_filespec, GetFileName) { 62 TEST(cpdf_filespec, GetFileName) {
63 { 63 {
64 // String object. 64 // String object.
65 pdfium::NullTermWstrFuncTestData test_data = { 65 pdfium::NullTermWstrFuncTestData test_data = {
66 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 66 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
67 L"/C/docs/test.pdf", 67 L"/C/docs/test.pdf",
68 L"C:\\docs\\test.pdf" 68 L"C:\\docs\\test.pdf"
69 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 69 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
70 L"/Mac HD/docs/test.pdf", 70 L"/Mac HD/docs/test.pdf",
71 L"Mac HD:docs:test.pdf" 71 L"Mac HD:docs:test.pdf"
72 #else 72 #else
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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));
129 } 129 }
130 } 130 }
131 131
132 TEST(doc_basic_filespec, SetFileName) { 132 TEST(cpdf_filespec, SetFileName) {
133 pdfium::NullTermWstrFuncTestData test_data = { 133 pdfium::NullTermWstrFuncTestData test_data = {
134 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 134 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
135 L"C:\\docs\\test.pdf", 135 L"C:\\docs\\test.pdf",
136 L"/C/docs/test.pdf" 136 L"/C/docs/test.pdf"
137 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 137 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
138 L"Mac HD:docs:test.pdf", 138 L"Mac HD:docs:test.pdf",
139 L"/Mac HD/docs/test.pdf" 139 L"/Mac HD/docs/test.pdf"
140 #else 140 #else
141 L"/docs/test.pdf", 141 L"/docs/test.pdf",
142 L"/docs/test.pdf" 142 L"/docs/test.pdf"
(...skipping 17 matching lines...) Expand all
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->GetUnicodeTextBy("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->GetUnicodeTextBy("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 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_filespec.cpp ('k') | core/fpdfdoc/cpdf_nametree.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698