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

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

Issue 1846433005: Implement direct write fallback proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a missing SUCCEEDED call Created 4 years, 8 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 b9772c1a9acf6f057c187f974eb6b660ff6ba173..6b14a3780320aa6ecc3166b927b97143145c67b7 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
@@ -5,11 +5,13 @@
#include "content/browser/renderer_host/dwrite_font_proxy_message_filter_win.h"
#include <dwrite.h>
+#include <dwrite_2.h>
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/test/test_simple_task_runner.h"
#include "base/thread_task_runner_handle.h"
+#include "base/win/windows_version.h"
#include "content/common/dwrite_font_proxy_messages.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "ipc/ipc_message_macros.h"
@@ -56,6 +58,19 @@ class DWriteFontProxyMessageFilterUnitTest : public testing::Test {
serializer->SerializeOutputParameters(*(filter_->GetReply()));
}
+ bool IsDWrite2Available() {
+ mswr::ComPtr<IDWriteFactory> factory;
+ gfx::win::CreateDWriteFactory(&factory);
+ mswr::ComPtr<IDWriteFactory2> factory2;
+ factory.As<IDWriteFactory2>(&factory2);
+
+ if (!factory2.Get()) {
+ // IDWriteFactory2 is expected to not be available before Win8.1
+ EXPECT_LT(base::win::GetVersion(), base::win::VERSION_WIN8_1);
+ }
+ return factory2.Get();
+ }
+
scoped_refptr<FilterWithFakeSender> filter_;
content::TestBrowserThreadBundle thread_bundle_;
};
@@ -140,6 +155,71 @@ TEST_F(DWriteFontProxyMessageFilterUnitTest, GetFontFilesIndexOutOfBounds) {
EXPECT_EQ(0u, files.size());
}
+TEST_F(DWriteFontProxyMessageFilterUnitTest, MapCharacter) {
+ if (!gfx::win::ShouldUseDirectWrite() || !IsDWrite2Available())
+ return;
+
+ DWriteFontStyle font_style;
+ font_style.font_weight = DWRITE_FONT_WEIGHT_NORMAL;
+ font_style.font_slant = DWRITE_FONT_STYLE_NORMAL;
+ font_style.font_stretch = DWRITE_FONT_STRETCH_NORMAL;
+
+ MapCharactersResult result;
+ Send(new DWriteFontProxyMsg_MapCharacters(
+ L"abc", font_style, L"", DWRITE_READING_DIRECTION_LEFT_TO_RIGHT, L"",
+ &result));
+
+ EXPECT_NE(UINT32_MAX, result.family_index);
+ EXPECT_STRNE(L"", result.family_name.c_str());
+ EXPECT_EQ(3u, result.mapped_length);
+ EXPECT_NE(0.0, result.scale);
+ EXPECT_NE(0, result.font_style.font_weight);
+ EXPECT_EQ(DWRITE_FONT_STYLE_NORMAL, result.font_style.font_slant);
+ EXPECT_NE(0, result.font_style.font_stretch);
+}
+
+TEST_F(DWriteFontProxyMessageFilterUnitTest, MapCharacterInvalidCharacter) {
+ if (!gfx::win::ShouldUseDirectWrite() || !IsDWrite2Available())
+ return;
+
+ DWriteFontStyle font_style;
+ font_style.font_weight = DWRITE_FONT_WEIGHT_NORMAL;
+ font_style.font_slant = DWRITE_FONT_STYLE_NORMAL;
+ font_style.font_stretch = DWRITE_FONT_STRETCH_NORMAL;
+
+ MapCharactersResult result;
+ Send(new DWriteFontProxyMsg_MapCharacters(
+ L"\ufffe\uffffabc", font_style, L"en-us",
+ DWRITE_READING_DIRECTION_LEFT_TO_RIGHT, L"", &result));
+
+ EXPECT_EQ(UINT32_MAX, result.family_index);
+ EXPECT_STREQ(L"", result.family_name.c_str());
+ EXPECT_EQ(2u, result.mapped_length);
+}
+
+TEST_F(DWriteFontProxyMessageFilterUnitTest, MapCharacterInvalidAfterValid) {
+ if (!gfx::win::ShouldUseDirectWrite() || !IsDWrite2Available())
+ return;
+
+ DWriteFontStyle font_style;
+ font_style.font_weight = DWRITE_FONT_WEIGHT_NORMAL;
+ font_style.font_slant = DWRITE_FONT_STYLE_NORMAL;
+ font_style.font_stretch = DWRITE_FONT_STRETCH_NORMAL;
+
+ MapCharactersResult result;
+ Send(new DWriteFontProxyMsg_MapCharacters(
+ L"abc\ufffe\uffff", font_style, L"en-us",
+ DWRITE_READING_DIRECTION_LEFT_TO_RIGHT, L"", &result));
+
+ EXPECT_NE(UINT32_MAX, result.family_index);
+ EXPECT_STRNE(L"", result.family_name.c_str());
+ EXPECT_EQ(3u, result.mapped_length);
+ EXPECT_NE(0.0, result.scale);
+ EXPECT_NE(0, result.font_style.font_weight);
+ EXPECT_EQ(DWRITE_FONT_STYLE_NORMAL, result.font_style.font_slant);
+ EXPECT_NE(0, result.font_style.font_stretch);
+}
+
} // namespace
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698