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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSFontFaceSourceTest.cpp

Issue 1973153004: Fix FontCacheKey-keyed HashMap usage in core/css (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: readd the fix Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/css/CSSFontFaceSource.h"
6
7 #include "platform/fonts/FontCacheKey.h"
8 #include "platform/fonts/FontDescription.h"
9 #include "platform/fonts/FontPlatformData.h"
10 #include "platform/fonts/SimpleFontData.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace blink {
14
15 class DummyFontFaceSource : public CSSFontFaceSource {
16 public:
17 PassRefPtr<SimpleFontData> createFontData(const FontDescription&) override
18 {
19 return SimpleFontData::create(FontPlatformData(adoptRef(SkTypeface::RefD efault()), "", 0, false, false));
20 }
21
22 DummyFontFaceSource() { }
23
24 PassRefPtr<SimpleFontData> getFontDataForSize(float size)
25 {
26 FontDescription fontDescription;
27 fontDescription.setSizeAdjust(size);
28 fontDescription.setAdjustedSize(size);
29 return getFontData(fontDescription);
30 }
31 };
32
33 namespace {
34
35 unsigned simulateHashCalculation(float size)
36 {
37 FontDescription fontDescription;
38 fontDescription.setSizeAdjust(size);
39 fontDescription.setAdjustedSize(size);
40 return fontDescription.cacheKey(FontFaceCreationParams()).hash();
41 }
42
43 }
44
45 TEST(CSSFontFaceSourceTest, HashCollision)
46 {
47 DummyFontFaceSource fontFaceSource;
kouhei (in TOK) 2016/05/13 09:06:40 // Even if the hash value collide, fontface cache
tzik 2016/05/14 11:57:16 Done
48 EXPECT_EQ(simulateHashCalculation(2821), simulateHashCalculation(3346));
49 EXPECT_NE(fontFaceSource.getFontDataForSize(2821), fontFaceSource.getFontDat aForSize(3346));
50 }
51
52 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSFontFaceSource.cpp ('k') | third_party/WebKit/Source/core/css/CSSSegmentedFontFace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698