OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2015 Google Inc. All rights reserved. | 2 * Copyright (C) 2015 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef TestFontSelector_h | 31 #ifndef TestFontSelector_h |
32 #define TestFontSelector_h | 32 #define TestFontSelector_h |
33 | 33 |
34 #include "platform/fonts/FontCustomPlatformData.h" | 34 #include "platform/fonts/FontCustomPlatformData.h" |
35 #include "platform/fonts/FontSelector.h" | 35 #include "platform/fonts/FontSelector.h" |
36 #include "public/platform/Platform.h" | 36 #include "platform/testing/UnitTestHelpers.h" |
37 #include "public/platform/WebUnitTestSupport.h" | |
38 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
39 #include "wtf/RefPtr.h" | 38 #include "wtf/RefPtr.h" |
40 #include "wtf/text/AtomicString.h" | 39 #include "wtf/text/AtomicString.h" |
41 | 40 |
42 namespace blink { | 41 namespace blink { |
43 | 42 |
44 class TestFontSelector : public FontSelector { | 43 class TestFontSelector : public FontSelector { |
45 public: | 44 public: |
46 static PassRefPtrWillBeRawPtr<TestFontSelector> create(const String& path) | 45 static PassRefPtrWillBeRawPtr<TestFontSelector> create(const String& path) |
47 { | 46 { |
48 WebUnitTestSupport* unitTestSupport = Platform::current()-> | 47 RefPtr<SharedBuffer> fontBuffer = testing::readFromFile(path); |
49 unitTestSupport(); | |
50 RefPtr<SharedBuffer> fontBuffer = static_cast<PassRefPtr<SharedBuffer>>( | |
51 unitTestSupport->readFromFile(path)); | |
52 String otsParseMessage; | 48 String otsParseMessage; |
53 return adoptRefWillBeNoop(new TestFontSelector(FontCustomPlatformData::c
reate( | 49 return adoptRefWillBeNoop(new TestFontSelector(FontCustomPlatformData::c
reate( |
54 fontBuffer.get(), otsParseMessage))); | 50 fontBuffer.get(), otsParseMessage))); |
55 } | 51 } |
56 | 52 |
57 ~TestFontSelector() override { } | 53 ~TestFontSelector() override { } |
58 | 54 |
59 PassRefPtr<FontData> getFontData(const FontDescription& fontDescription, | 55 PassRefPtr<FontData> getFontData(const FontDescription& fontDescription, |
60 const AtomicString& familyName) override | 56 const AtomicString& familyName) override |
61 { | 57 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 fontDescription.setComputedSize(size); | 92 fontDescription.setComputedSize(size); |
97 | 93 |
98 Font font(fontDescription); | 94 Font font(fontDescription); |
99 font.update(TestFontSelector::create(fontPath)); | 95 font.update(TestFontSelector::create(fontPath)); |
100 return font; | 96 return font; |
101 } | 97 } |
102 | 98 |
103 } // namespace blink | 99 } // namespace blink |
104 | 100 |
105 #endif // TestFontSelector_h | 101 #endif // TestFontSelector_h |
OLD | NEW |