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

Side by Side Diff: Source/platform/fonts/TestFontSelector.h

Issue 1240963002: Revert of Add unit tests for FontPlatformData::hasSpaceInLigaturesOrKerning (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased again. Created 5 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 unified diff | Download patch
« no previous file with comments | « Source/platform/fonts/FontPlatformDataTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef TestFontSelector_h
32 #define TestFontSelector_h
33
34 #include "platform/fonts/FontCustomPlatformData.h"
35 #include "platform/fonts/FontSelector.h"
36 #include "public/platform/Platform.h"
37 #include "public/platform/WebUnitTestSupport.h"
38 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefPtr.h"
40 #include "wtf/text/AtomicString.h"
41
42 namespace blink {
43
44 class TestFontSelector : public FontSelector {
45 public:
46 static PassRefPtr<TestFontSelector> create(const String& path)
47 {
48 WebUnitTestSupport* unitTestSupport = Platform::current()->
49 unitTestSupport();
50 RefPtr<SharedBuffer> fontBuffer = static_cast<PassRefPtr<SharedBuffer>>(
51 unitTestSupport->readFromFile(path));
52 String otsParseMessage;
53 return adoptRef(new TestFontSelector(FontCustomPlatformData::create(
54 fontBuffer.get(), otsParseMessage)));
55 }
56
57 ~TestFontSelector() override { }
58
59 PassRefPtr<FontData> getFontData(const FontDescription& fontDescription,
60 const AtomicString& familyName) override
61 {
62 FontPlatformData platformData = m_customPlatformData->fontPlatformData(
63 fontDescription.effectiveFontSize(),
64 fontDescription.isSyntheticBold(),
65 fontDescription.isSyntheticItalic(),
66 fontDescription.orientation());
67 return SimpleFontData::create(platformData, CustomFontData::create());
68 }
69
70 void willUseFontData(const FontDescription&, const AtomicString& familyName,
71 UChar32) override { }
72 unsigned version() const override { return 0; }
73 void fontCacheInvalidated() override { }
74
75 private:
76 TestFontSelector(PassOwnPtr<FontCustomPlatformData> customPlatformData)
77 : m_customPlatformData(customPlatformData)
78 {
79 }
80
81 OwnPtr<FontCustomPlatformData> m_customPlatformData;
82 };
83
84 Font createTestFont(const AtomicString& familyName,
85 const String& fontPath, float size = 16.0f)
86 {
87 FontFamily family;
88 family.setFamily(familyName);
89
90 FontDescription fontDescription;
91 fontDescription.setFamily(family);
92 fontDescription.setSpecifiedSize(size);
93 fontDescription.setComputedSize(size);
94
95 Font font(fontDescription);
96 font.update(TestFontSelector::create(fontPath));
97 return font;
98 }
99
100 } // namespace blink
101
102 #endif // TestFontSelector_h
OLDNEW
« no previous file with comments | « Source/platform/fonts/FontPlatformDataTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698