| 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 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 } // anonymous namespace |
| 36 |
| 35 TEST(GlyphBufferTest, StartsEmpty) | 37 TEST(GlyphBufferTest, StartsEmpty) |
| 36 { | 38 { |
| 37 GlyphBuffer glyphBuffer; | 39 GlyphBuffer glyphBuffer; |
| 38 EXPECT_TRUE(glyphBuffer.isEmpty()); | 40 EXPECT_TRUE(glyphBuffer.isEmpty()); |
| 39 EXPECT_EQ(0u, glyphBuffer.size()); | 41 EXPECT_EQ(0u, glyphBuffer.size()); |
| 40 } | 42 } |
| 41 | 43 |
| 42 TEST(GlyphBufferTest, StoresGlyphs) | 44 TEST(GlyphBufferTest, StoresGlyphs) |
| 43 { | 45 { |
| 44 RefPtr<SimpleFontData> font1 = TestSimpleFontData::create(); | 46 RefPtr<SimpleFontData> font1 = TestSimpleFontData::create(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 EXPECT_EQ(43, glyphBuffer.glyphAt(1)); | 216 EXPECT_EQ(43, glyphBuffer.glyphAt(1)); |
| 215 EXPECT_EQ(42, glyphBuffer.glyphAt(2)); | 217 EXPECT_EQ(42, glyphBuffer.glyphAt(2)); |
| 216 EXPECT_EQ(font2.get(), glyphBuffer.fontDataAt(0)); | 218 EXPECT_EQ(font2.get(), glyphBuffer.fontDataAt(0)); |
| 217 EXPECT_EQ(font1.get(), glyphBuffer.fontDataAt(1)); | 219 EXPECT_EQ(font1.get(), glyphBuffer.fontDataAt(1)); |
| 218 EXPECT_EQ(font1.get(), glyphBuffer.fontDataAt(2)); | 220 EXPECT_EQ(font1.get(), glyphBuffer.fontDataAt(2)); |
| 219 EXPECT_EQ(70, glyphBuffer.xOffsetAt(0)); | 221 EXPECT_EQ(70, glyphBuffer.xOffsetAt(0)); |
| 220 EXPECT_EQ(75, glyphBuffer.xOffsetAt(1)); | 222 EXPECT_EQ(75, glyphBuffer.xOffsetAt(1)); |
| 221 EXPECT_EQ(85, glyphBuffer.xOffsetAt(2)); | 223 EXPECT_EQ(85, glyphBuffer.xOffsetAt(2)); |
| 222 } | 224 } |
| 223 | 225 |
| 224 } // namespace | 226 } // namespace blink |
| OLD | NEW |