| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/font_warmup_win.h" | 5 #include "content/common/font_warmup_win.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 const char* kTestFontFamily = "GDITest"; | 126 const char* kTestFontFamily = "GDITest"; |
| 127 const wchar_t* kTestFontFamilyW = L"GDITest"; | 127 const wchar_t* kTestFontFamilyW = L"GDITest"; |
| 128 const SkFontTableTag kTestFontTableTag = 0x11223344; | 128 const SkFontTableTag kTestFontTableTag = 0x11223344; |
| 129 const char* kTestFontData = "GDITestGDITest"; | 129 const char* kTestFontData = "GDITestGDITest"; |
| 130 const wchar_t* kTestFontFamilyInvalid = L"InvalidFont"; | 130 const wchar_t* kTestFontFamilyInvalid = L"InvalidFont"; |
| 131 | 131 |
| 132 class TestSkFontMgr : public SkFontMgr { | 132 class TestSkFontMgr : public SkFontMgr { |
| 133 public: | 133 public: |
| 134 TestSkFontMgr() { content::SetPreSandboxWarmupFontMgrForTesting(this); } | 134 TestSkFontMgr() { content::SetPreSandboxWarmupFontMgrForTesting(this); } |
| 135 ~TestSkFontMgr() { content::SetPreSandboxWarmupFontMgrForTesting(nullptr); } | 135 ~TestSkFontMgr() override { |
| 136 content::SetPreSandboxWarmupFontMgrForTesting(nullptr); |
| 137 } |
| 136 | 138 |
| 137 protected: | 139 protected: |
| 138 int onCountFamilies() const override { return 1; } | 140 int onCountFamilies() const override { return 1; } |
| 139 | 141 |
| 140 void onGetFamilyName(int index, SkString* familyName) const override { | 142 void onGetFamilyName(int index, SkString* familyName) const override { |
| 141 if (index == 0) | 143 if (index == 0) |
| 142 *familyName = kTestFontFamily; | 144 *familyName = kTestFontFamily; |
| 143 } | 145 } |
| 144 | 146 |
| 145 SkFontStyleSet* onCreateStyleSet(int index) const override { | 147 SkFontStyleSet* onCreateStyleSet(int index) const override { |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 DWORD data_size = static_cast<DWORD>(strlen(kTestFontData)); | 423 DWORD data_size = static_cast<DWORD>(strlen(kTestFontData)); |
| 422 std::vector<char> data(data_size); | 424 std::vector<char> data(data_size); |
| 423 DWORD size = GetFontData(hdc, kTestFontTableTag, 0, &data[0], data.size()); | 425 DWORD size = GetFontData(hdc, kTestFontTableTag, 0, &data[0], data.size()); |
| 424 EXPECT_EQ(size, data_size); | 426 EXPECT_EQ(size, data_size); |
| 425 EXPECT_EQ(memcmp(&data[0], kTestFontData, data.size()), 0); | 427 EXPECT_EQ(memcmp(&data[0], kTestFontData, data.size()), 0); |
| 426 EXPECT_TRUE(DeleteObject(font)); | 428 EXPECT_TRUE(DeleteObject(font)); |
| 427 EXPECT_TRUE(DeleteDC(hdc)); | 429 EXPECT_TRUE(DeleteDC(hdc)); |
| 428 } | 430 } |
| 429 | 431 |
| 430 } // namespace content | 432 } // namespace content |
| OLD | NEW |