summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_filespec_unittest.cpp
diff options
context:
space:
mode:
authorJane Liu <janeliulwq@google.com>2017-07-13 10:37:59 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-13 15:18:44 +0000
commitc8a17e550d4d4a6f68598f8eed70eb6f8f301442 (patch)
tree9b6820db32d532689d086608233b9587216b0197 /core/fpdfdoc/cpdf_filespec_unittest.cpp
parentc3eca649ce2213b06551e8de8793e24ec6f9cef5 (diff)
downloadpdfium-c8a17e550d4d4a6f68598f8eed70eb6f8f301442.tar.xz
Changed CPDF_FileSpec::GetFileName() to directly return CFX_WideString
Changed CPDF_FileSpec::GetFileName() to directly return CFX_WideString, instead of taking in a CFX_WideString* and returning a bool. Also fixed test calls in the unit test. Bug=pdfium:808 Change-Id: Ie081fc9f4f1c15d23c86d7222d8480ab9cb56056 Reviewed-on: https://pdfium-review.googlesource.com/7671 Commit-Queue: Jane Liu <janeliulwq@google.com> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_filespec_unittest.cpp')
-rw-r--r--core/fpdfdoc/cpdf_filespec_unittest.cpp39
1 files changed, 14 insertions, 25 deletions
diff --git a/core/fpdfdoc/cpdf_filespec_unittest.cpp b/core/fpdfdoc/cpdf_filespec_unittest.cpp
index 7e2975c5f0..8d151c9dd8 100644
--- a/core/fpdfdoc/cpdf_filespec_unittest.cpp
+++ b/core/fpdfdoc/cpdf_filespec_unittest.cpp
@@ -48,11 +48,11 @@ TEST(cpdf_filespec, EncodeDecodeFileName) {
#endif
};
for (const auto& data : test_data) {
- CFX_WideString encoded_str = CPDF_FileSpec::EncodeFileName(data.input);
- EXPECT_TRUE(encoded_str == data.expected);
+ EXPECT_STREQ(data.expected,
+ CPDF_FileSpec::EncodeFileName(data.input).c_str());
// DecodeFileName is the reverse procedure of EncodeFileName.
- CFX_WideString decoded_str = CPDF_FileSpec::DecodeFileName(data.expected);
- EXPECT_TRUE(decoded_str == data.input);
+ EXPECT_STREQ(data.input,
+ CPDF_FileSpec::DecodeFileName(data.expected).c_str());
}
}
@@ -73,9 +73,7 @@ TEST(cpdf_filespec, GetFileName) {
};
auto str_obj = pdfium::MakeUnique<CPDF_String>(nullptr, test_data.input);
CPDF_FileSpec file_spec(str_obj.get());
- CFX_WideString file_name;
- EXPECT_TRUE(file_spec.GetFileName(&file_name));
- EXPECT_TRUE(file_name == test_data.expected);
+ EXPECT_STREQ(test_data.expected, file_spec.GetFileName().c_str());
}
{
// Dictionary object.
@@ -104,25 +102,22 @@ TEST(cpdf_filespec, GetFileName) {
const char* const keywords[5] = {"Unix", "Mac", "DOS", "F", "UF"};
auto dict_obj = pdfium::MakeUnique<CPDF_Dictionary>();
CPDF_FileSpec file_spec(dict_obj.get());
- CFX_WideString file_name;
+ EXPECT_TRUE(file_spec.GetFileName().IsEmpty());
for (int i = 0; i < 5; ++i) {
dict_obj->SetNewFor<CPDF_String>(keywords[i], test_data[i].input);
- EXPECT_TRUE(file_spec.GetFileName(&file_name));
- EXPECT_TRUE(file_name == test_data[i].expected);
+ EXPECT_STREQ(test_data[i].expected, file_spec.GetFileName().c_str());
}
// With all the former fields and 'FS' field suggests 'URL' type.
dict_obj->SetNewFor<CPDF_String>("FS", "URL", false);
- EXPECT_TRUE(file_spec.GetFileName(&file_name));
// Url string is not decoded.
- EXPECT_TRUE(file_name == test_data[4].input);
+ EXPECT_STREQ(test_data[4].input, file_spec.GetFileName().c_str());
}
{
// Invalid object.
auto name_obj = pdfium::MakeUnique<CPDF_Name>(nullptr, "test.pdf");
CPDF_FileSpec file_spec(name_obj.get());
- CFX_WideString file_name;
- EXPECT_FALSE(file_spec.GetFileName(&file_name));
+ EXPECT_TRUE(file_spec.GetFileName().IsEmpty());
}
}
@@ -144,25 +139,19 @@ TEST(cpdf_filespec, SetFileName) {
CPDF_FileSpec file_spec1(str_obj.get());
file_spec1.SetFileName(test_data.input);
// Check internal object value.
- CFX_ByteString str = CFX_ByteString::FromUnicode(test_data.expected);
- EXPECT_TRUE(str == str_obj->GetString());
+ EXPECT_STREQ(test_data.expected, str_obj->GetUnicodeText().c_str());
// Check we can get the file name back.
- CFX_WideString file_name;
- EXPECT_TRUE(file_spec1.GetFileName(&file_name));
- EXPECT_TRUE(file_name == test_data.input);
+ EXPECT_STREQ(test_data.input, file_spec1.GetFileName().c_str());
// Dictionary object.
auto dict_obj = pdfium::MakeUnique<CPDF_Dictionary>();
CPDF_FileSpec file_spec2(dict_obj.get());
file_spec2.SetFileName(test_data.input);
// Check internal object value.
- file_name = dict_obj->GetUnicodeTextFor("F");
- EXPECT_TRUE(file_name == test_data.expected);
- file_name = dict_obj->GetUnicodeTextFor("UF");
- EXPECT_TRUE(file_name == test_data.expected);
+ EXPECT_STREQ(test_data.expected, dict_obj->GetUnicodeTextFor("F").c_str());
+ EXPECT_STREQ(test_data.expected, dict_obj->GetUnicodeTextFor("UF").c_str());
// Check we can get the file name back.
- EXPECT_TRUE(file_spec2.GetFileName(&file_name));
- EXPECT_TRUE(file_name == test_data.input);
+ EXPECT_STREQ(test_data.input, file_spec2.GetFileName().c_str());
}
TEST(cpdf_filespec, GetFileStream) {