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

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: Add some more comments 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..83832bf26cf3fea9a10bca125996115ffe71c6be 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<IPC::PlatformFileForTransit> 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<IPC::PlatformFileForTransit> 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,30 @@ 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<IPC::PlatformFileForTransit> handles;
+ Send(new DWriteFontProxyMsg_GetFontFiles(arial_index, &files, &handles));
+
+ EXPECT_TRUE(files.empty());
+ EXPECT_FALSE(handles.empty());
+ for (const IPC::PlatformFileForTransit& handle : handles) {
+ EXPECT_TRUE(handle.IsValid());
+ base::File file = IPC::PlatformFileForTransitToFile(handle);
+ EXPECT_LT(0, file.GetLength()); // Check the file exists
+ }
+}
+
} // namespace
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698