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

Unified Diff: content/browser/renderer_host/dwrite_font_proxy_message_filter_win_unittest.cc

Issue 2153343002: Implement support for loading font files from outside system directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test patchset to run try job Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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..068ec12697c9f99683ed53bbbaabbb978f1331dc 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_TRUE(files.empty());
+ EXPECT_FALSE(handles.empty());
+ 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

Powered by Google App Engine
This is Rietveld 408576698