diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-19 14:49:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-20 00:02:36 +0300 |
commit | e224a077737739a895fe533c9cce93783621d8e9 (patch) | |
tree | 28194260919ffcc8aa77f52caf45cbf3a1747334 /src/gui/fonts/font_unittest.cc | |
parent | fd85f62f2e3003a79e90611e95b09e23710be479 (diff) | |
download | manaverse-e224a077737739a895fe533c9cce93783621d8e9.tar.gz manaverse-e224a077737739a895fe533c9cce93783621d8e9.tar.bz2 manaverse-e224a077737739a895fe533c9cce93783621d8e9.tar.xz manaverse-e224a077737739a895fe533c9cce93783621d8e9.zip |
Add fast way for draw not changed text strings.
TextChunk with colors and image stored inside draw object.
If string or color changed old string image moved to cache.
New string image generated or moved from cache.
Use new way in drawing string in label.
Diffstat (limited to 'src/gui/fonts/font_unittest.cc')
-rw-r--r-- | src/gui/fonts/font_unittest.cc | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/src/gui/fonts/font_unittest.cc b/src/gui/fonts/font_unittest.cc index 8b8d027c5..f41249f96 100644 --- a/src/gui/fonts/font_unittest.cc +++ b/src/gui/fonts/font_unittest.cc @@ -369,7 +369,6 @@ TEST(TextChunkList, clear5) TextChunk *chunk3 = new TextChunk("test3", Color(1, 2, 3), Color(2, 0, 2), nullptr); - chunk1->refCount = 1; list.insertFirst(chunk1); list.insertFirst(chunk2); list.insertFirst(chunk3); @@ -389,6 +388,78 @@ TEST(TextChunkList, clear5) EXPECT_EQ(0, list.searchWidth.size()); } +TEST(TextChunkList, remove1) +{ + TextChunkList list; + int chunksLeft = textChunkCnt; + + TextChunk *chunk = new TextChunk("test", + Color(), Color(), nullptr); + + list.insertFirst(chunk); + list.remove(chunk); + delete chunk; + + EXPECT_EQ(0, list.size); + EXPECT_EQ(nullptr, list.start); + EXPECT_EQ(nullptr, list.end); + EXPECT_EQ(chunksLeft, textChunkCnt); + EXPECT_EQ(0, list.search.size()); + EXPECT_EQ(0, list.searchWidth.size()); +} + +TEST(TextChunkList, remove2) +{ + TextChunkList list; + int chunksLeft = textChunkCnt; + + TextChunk *chunk1 = new TextChunk("test1", + Color(1, 2, 3), Color(2, 0, 0), nullptr); + TextChunk *chunk2 = new TextChunk("test2", + Color(1, 2, 3), Color(2, 0, 1), nullptr); + TextChunk *chunk3 = new TextChunk("test3", + Color(1, 2, 3), Color(2, 0, 2), nullptr); + + list.insertFirst(chunk1); + list.insertFirst(chunk2); + list.insertFirst(chunk3); + list.remove(chunk1); + delete chunk1; + + EXPECT_EQ(2, list.size); + EXPECT_EQ(chunk3, list.start); + EXPECT_EQ(chunk2, list.end); + EXPECT_EQ(chunksLeft + 2, textChunkCnt); + EXPECT_EQ(2, list.search.size()); + EXPECT_EQ(2, list.searchWidth.size()); +} + +TEST(TextChunkList, remove3) +{ + TextChunkList list; + int chunksLeft = textChunkCnt; + + TextChunk *chunk1 = new TextChunk("test1", + Color(1, 2, 3), Color(2, 0, 0), nullptr); + TextChunk *chunk2 = new TextChunk("test2", + Color(1, 2, 3), Color(2, 0, 1), nullptr); + TextChunk *chunk3 = new TextChunk("test3", + Color(1, 2, 3), Color(2, 0, 2), nullptr); + + list.insertFirst(chunk1); + list.insertFirst(chunk2); + list.insertFirst(chunk3); + list.remove(chunk2); + delete chunk2; + + EXPECT_EQ(2, list.size); + EXPECT_EQ(chunk3, list.start); + EXPECT_EQ(chunk1, list.end); + EXPECT_EQ(chunksLeft + 2, textChunkCnt); + EXPECT_EQ(2, list.search.size()); + EXPECT_EQ(2, list.searchWidth.size()); +} + TEST(TextChunkList, sort1) { TextChunkSmall item1("test line1", |