OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include "platform/fonts/GlyphBuffer.h" | 6 #include "platform/fonts/GlyphBuffer.h" |
7 | 7 |
8 #include "platform/fonts/SimpleFontData.h" | 8 #include "platform/fonts/SimpleFontData.h" |
9 #include "wtf/PassRefPtr.h" | 9 #include "wtf/PassRefPtr.h" |
10 #include "wtf/RefPtr.h" | 10 #include "wtf/RefPtr.h" |
11 #include <gtest/gtest.h> | 11 #include <gtest/gtest.h> |
12 | 12 |
13 using namespace blink; | 13 using namespace blink; |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // Minimal TestSimpleFontData implementation. | 17 // Minimal TestSimpleFontData implementation. |
18 // Font has no glyphs, but that's okay. | 18 // Font has no glyphs, but that's okay. |
19 class TestSimpleFontData : public SimpleFontData { | 19 class TestSimpleFontData : public SimpleFontData { |
20 public: | 20 public: |
21 static PassRefPtr<TestSimpleFontData> create() | 21 static PassRefPtr<TestSimpleFontData> create() |
22 { | 22 { |
23 return adoptRef(new TestSimpleFontData); | 23 return adoptRef(new TestSimpleFontData); |
24 } | 24 } |
25 | 25 |
26 private: | 26 private: |
27 TestSimpleFontData() : SimpleFontData(nullptr, 10, false, false) { } | 27 TestSimpleFontData() : SimpleFontData(nullptr, 10, false, false) { } |
28 | 28 |
29 bool fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsigned length,
UChar* buffer, unsigned bufferLength) const OVERRIDE | 29 bool fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsigned length,
UChar* buffer, unsigned bufferLength) const override |
30 { | 30 { |
31 return false; | 31 return false; |
32 } | 32 } |
33 }; | 33 }; |
34 | 34 |
35 TEST(GlyphBufferTest, StartsEmpty) | 35 TEST(GlyphBufferTest, StartsEmpty) |
36 { | 36 { |
37 GlyphBuffer glyphBuffer; | 37 GlyphBuffer glyphBuffer; |
38 EXPECT_TRUE(glyphBuffer.isEmpty()); | 38 EXPECT_TRUE(glyphBuffer.isEmpty()); |
39 EXPECT_EQ(0u, glyphBuffer.size()); | 39 EXPECT_EQ(0u, glyphBuffer.size()); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 GlyphBuffer glyphBuffer; | 198 GlyphBuffer glyphBuffer; |
199 glyphBuffer.add(42, font1.get(), 10); | 199 glyphBuffer.add(42, font1.get(), 10); |
200 glyphBuffer.add(43, font1.get(), 15); | 200 glyphBuffer.add(43, font1.get(), 15); |
201 glyphBuffer.add(44, font2.get(), 12); | 201 glyphBuffer.add(44, font2.get(), 12); |
202 | 202 |
203 glyphBuffer.expandLastAdvance(20); | 203 glyphBuffer.expandLastAdvance(20); |
204 EXPECT_EQ(32, glyphBuffer.advanceAt(2)); | 204 EXPECT_EQ(32, glyphBuffer.advanceAt(2)); |
205 } | 205 } |
206 | 206 |
207 } // namespace | 207 } // namespace |
OLD | NEW |