Chromium Code Reviews| Index: content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc |
| diff --git a/content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc b/content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc |
| index ffbdb294f48fd5c8f661f06dfacbcc2f74a59649..1e223c44dd79a50cdfadd7d361992d9fbc0540bb 100644 |
| --- a/content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc |
| +++ b/content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc |
| @@ -7,6 +7,9 @@ |
| #include <dwrite.h> |
| #include <dwrite_2.h> |
| +#include <memory> |
| + |
| +#include "base/files/file.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/run_loop.h" |
| #include "base/test/test_simple_task_runner.h" |
| @@ -127,7 +130,8 @@ TEST_F(DWriteFontProxyMessageFilterUnitTest, GetFontFiles) { |
| filter_->ResetReply(); |
| std::vector<base::string16> files; |
| - Send(new DWriteFontProxyMsg_GetFontFiles(arial_index, &files)); |
| + std::vector<uint32_t> handles; |
| + Send(new DWriteFontProxyMsg_GetFontFiles(arial_index, &files, &handles)); |
| EXPECT_LT(0u, files.size()); |
| for (const base::string16& file : files) { |
| @@ -137,8 +141,9 @@ TEST_F(DWriteFontProxyMessageFilterUnitTest, GetFontFiles) { |
| TEST_F(DWriteFontProxyMessageFilterUnitTest, GetFontFilesIndexOutOfBounds) { |
| std::vector<base::string16> files; |
| + std::vector<uint32_t> handles; |
| UINT32 invalid_index = 1000000; |
| - Send(new DWriteFontProxyMsg_GetFontFiles(invalid_index, &files)); |
| + Send(new DWriteFontProxyMsg_GetFontFiles(invalid_index, &files, &handles)); |
| EXPECT_EQ(0u, files.size()); |
| } |
| @@ -208,6 +213,31 @@ TEST_F(DWriteFontProxyMessageFilterUnitTest, MapCharacterInvalidAfterValid) { |
| EXPECT_NE(0, result.font_style.font_stretch); |
| } |
| +TEST_F(DWriteFontProxyMessageFilterUnitTest, TestCustomFontFiles) { |
| + // Override windows fonts path to force the custom font file codepath. |
| + filter_->SetWindowsFontsPathForTesting(L"X:\\NotWindowsFonts"); |
| + // Set the peer process so the filter duplicates handles into the current |
| + // process. |
| + filter_->set_peer_process_for_testing(base::Process::Current()); |
| + |
| + UINT32 arial_index = 0; |
| + Send(new DWriteFontProxyMsg_FindFamily(L"Arial", &arial_index)); |
| + filter_->ResetReply(); |
| + |
| + std::vector<base::string16> files; |
| + std::vector<uint32_t> handles; |
| + Send(new DWriteFontProxyMsg_GetFontFiles(arial_index, &files, &handles)); |
| + |
| + EXPECT_EQ(0u, files.size()); |
| + EXPECT_LT(0u, handles.size()); |
|
ananta
2016/07/20 01:34:59
Perhaps using EXPECT_FALSE(handles.empty()) would
Ilya Kulshin
2016/07/21 04:17:37
Done.
|
| + for (uint32_t handle : handles) { |
| + EXPECT_NE(0u, handle); |
| + EXPECT_NE(static_cast<uint32_t>(PtrToLong(INVALID_HANDLE_VALUE)), handle); |
| + base::File file(reinterpret_cast<HANDLE>(handle)); |
| + EXPECT_LT(0, file.GetLength()); // Check the file exists |
| + } |
| +} |
| + |
| } // namespace |
| } // namespace content |