| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/css/CSSFontFaceSource.h" | 5 #include "core/css/CSSFontFaceSource.h" |
| 6 | 6 |
| 7 #include "platform/fonts/FontCacheKey.h" | 7 #include "platform/fonts/FontCacheKey.h" |
| 8 #include "platform/fonts/FontDescription.h" | 8 #include "platform/fonts/FontDescription.h" |
| 9 #include "platform/fonts/FontPlatformData.h" | 9 #include "platform/fonts/FontPlatformData.h" |
| 10 #include "platform/fonts/SimpleFontData.h" | 10 #include "platform/fonts/SimpleFontData.h" |
| 11 #include "platform/graphics/skia/SkiaUtils.h" | 11 #include "platform/graphics/skia/SkiaUtils.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class DummyFontFaceSource : public CSSFontFaceSource { | 16 class DummyFontFaceSource : public CSSFontFaceSource { |
| 17 public: | 17 public: |
| 18 PassRefPtr<SimpleFontData> createFontData(const FontDescription&) override | 18 PassRefPtr<SimpleFontData> createFontData(const FontDescription&) override |
| 19 { | 19 { |
| 20 return SimpleFontData::create(FontPlatformData(fromSkSp(SkTypeface::Make
Default()), "", 0, false, false)); | 20 return SimpleFontData::create(FontPlatformData(SkTypeface::MakeDefault()
, "", 0, false, false)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 DummyFontFaceSource() { } | 23 DummyFontFaceSource() { } |
| 24 | 24 |
| 25 PassRefPtr<SimpleFontData> getFontDataForSize(float size) | 25 PassRefPtr<SimpleFontData> getFontDataForSize(float size) |
| 26 { | 26 { |
| 27 FontDescription fontDescription; | 27 FontDescription fontDescription; |
| 28 fontDescription.setSizeAdjust(size); | 28 fontDescription.setSizeAdjust(size); |
| 29 fontDescription.setAdjustedSize(size); | 29 fontDescription.setAdjustedSize(size); |
| 30 return getFontData(fontDescription); | 30 return getFontData(fontDescription); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 45 | 45 |
| 46 TEST(CSSFontFaceSourceTest, HashCollision) | 46 TEST(CSSFontFaceSourceTest, HashCollision) |
| 47 { | 47 { |
| 48 DummyFontFaceSource fontFaceSource; | 48 DummyFontFaceSource fontFaceSource; |
| 49 // Even if the hash value collide, fontface cache should return different va
lue for different fonts. | 49 // Even if the hash value collide, fontface cache should return different va
lue for different fonts. |
| 50 EXPECT_EQ(simulateHashCalculation(2821), simulateHashCalculation(3346)); | 50 EXPECT_EQ(simulateHashCalculation(2821), simulateHashCalculation(3346)); |
| 51 EXPECT_NE(fontFaceSource.getFontDataForSize(2821), fontFaceSource.getFontDat
aForSize(3346)); | 51 EXPECT_NE(fontFaceSource.getFontDataForSize(2821), fontFaceSource.getFontDat
aForSize(3346)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace blink | 54 } // namespace blink |
| OLD | NEW |