summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorrmichela <deltahat@gmail.com>2012-03-06 01:15:00 -0500
committerEvilSeph <evilseph@gmail.com>2012-03-08 02:02:28 -0500
commit561f73664585ead28f0cacd5dcbb44f91d9c84d4 (patch)
tree16e3c013f5d12f046ac5e2d20ac796675c8ffc2c /src/test
parent76cc01077697400558991c1b7a597e7300a9fe53 (diff)
downloadbukkit-561f73664585ead28f0cacd5dcbb44f91d9c84d4.tar
bukkit-561f73664585ead28f0cacd5dcbb44f91d9c84d4.tar.gz
bukkit-561f73664585ead28f0cacd5dcbb44f91d9c84d4.tar.lz
bukkit-561f73664585ead28f0cacd5dcbb44f91d9c84d4.tar.xz
bukkit-561f73664585ead28f0cacd5dcbb44f91d9c84d4.zip
[Bleeding] ChatPaginator now preserves the color of a line after wrapping the line of text. Fixes BUKKIT-1048
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/bukkit/ChatPaginatorTest.java83
1 files changed, 46 insertions, 37 deletions
diff --git a/src/test/java/org/bukkit/ChatPaginatorTest.java b/src/test/java/org/bukkit/ChatPaginatorTest.java
index 6e20456e..0a8acae9 100644
--- a/src/test/java/org/bukkit/ChatPaginatorTest.java
+++ b/src/test/java/org/bukkit/ChatPaginatorTest.java
@@ -12,12 +12,12 @@ import static org.junit.Assert.assertThat;
public class ChatPaginatorTest {
@Test
public void testWordWrap1() {
- String rawString = "123456789 123456789 123456789";
+ String rawString = ChatColor.RED + "123456789 123456789 123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
- assertThat(lines[0], is("123456789 123456789"));
- assertThat(lines[1], is("123456789"));
+ assertThat(lines[0], is(ChatColor.RED + "123456789 123456789"));
+ assertThat(lines[1], is(ChatColor.RED.toString() + "123456789"));
}
@Test
@@ -26,19 +26,19 @@ public class ChatPaginatorTest {
String[] lines = ChatPaginator.wordWrap(rawString, 22);
assertThat(lines.length, is(2));
- assertThat(lines[0], is("123456789 123456789"));
- assertThat(lines[1], is("123456789"));
+ assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456789 123456789"));
+ assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789"));
}
@Test
public void testWordWrap3() {
- String rawString = "123456789 123456789 123456789";
+ String rawString = ChatColor.RED + "123456789 " + ChatColor.RED + ChatColor.RED + "123456789 " + ChatColor.RED + "123456789";
String[] lines = ChatPaginator.wordWrap(rawString, 16);
assertThat(lines.length, is(3));
- assertThat(lines[0], is("123456789"));
- assertThat(lines[1], is("123456789"));
- assertThat(lines[2], is("123456789"));
+ assertThat(lines[0], is(ChatColor.RED + "123456789"));
+ assertThat(lines[1], is(ChatColor.RED.toString() + ChatColor.RED + "123456789"));
+ assertThat(lines[2], is(ChatColor.RED + "123456789"));
}
@Test
@@ -47,8 +47,8 @@ public class ChatPaginatorTest {
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
- assertThat(lines[0], is("123456789 123456789"));
- assertThat(lines[1], is("123456789 12345"));
+ assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456789 123456789"));
+ assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789 12345"));
}
@Test
@@ -57,8 +57,8 @@ public class ChatPaginatorTest {
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
- assertThat(lines[0], is("123456789"));
- assertThat(lines[1], is("123456789 123456789"));
+ assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456789"));
+ assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789 123456789"));
}
@Test
@@ -67,8 +67,8 @@ public class ChatPaginatorTest {
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
- assertThat(lines[0], is("12345678 23456789"));
- assertThat(lines[1], is("123456789"));
+ assertThat(lines[0], is(ChatColor.WHITE.toString() + "12345678 23456789"));
+ assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789"));
}
@Test
@@ -77,8 +77,8 @@ public class ChatPaginatorTest {
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
- assertThat(lines[0], is("12345678 23456789"));
- assertThat(lines[1], is("123456789"));
+ assertThat(lines[0], is(ChatColor.WHITE.toString() + "12345678 23456789"));
+ assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789"));
}
@Test
@@ -87,12 +87,12 @@ public class ChatPaginatorTest {
String[] lines = ChatPaginator.wordWrap(rawString, 6);
assertThat(lines.length, is(6));
- assertThat(lines[0], is("123456"));
- assertThat(lines[1], is("789"));
- assertThat(lines[2], is("123456"));
- assertThat(lines[3], is("789"));
- assertThat(lines[4], is("123456"));
- assertThat(lines[5], is("789"));
+ assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456"));
+ assertThat(lines[1], is(ChatColor.WHITE.toString() + "789"));
+ assertThat(lines[2], is(ChatColor.WHITE.toString() + "123456"));
+ assertThat(lines[3], is(ChatColor.WHITE.toString() + "789"));
+ assertThat(lines[4], is(ChatColor.WHITE.toString() + "123456"));
+ assertThat(lines[5], is(ChatColor.WHITE.toString() + "789"));
}
@Test
@@ -101,13 +101,13 @@ public class ChatPaginatorTest {
String[] lines = ChatPaginator.wordWrap(rawString, 6);
assertThat(lines.length, is(7));
- assertThat(lines[0], is("1234"));
- assertThat(lines[1], is("123456"));
- assertThat(lines[2], is("789"));
- assertThat(lines[3], is("123456"));
- assertThat(lines[4], is("789"));
- assertThat(lines[5], is("123456"));
- assertThat(lines[6], is("789"));
+ assertThat(lines[0], is(ChatColor.WHITE.toString() + "1234"));
+ assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456"));
+ assertThat(lines[2], is(ChatColor.WHITE.toString() + "789"));
+ assertThat(lines[3], is(ChatColor.WHITE.toString() + "123456"));
+ assertThat(lines[4], is(ChatColor.WHITE.toString() + "789"));
+ assertThat(lines[5], is(ChatColor.WHITE.toString() + "123456"));
+ assertThat(lines[6], is(ChatColor.WHITE.toString() + "789"));
}
@Test
@@ -116,8 +116,17 @@ public class ChatPaginatorTest {
String[] lines = ChatPaginator.wordWrap(rawString, 19);
assertThat(lines.length, is(2));
- assertThat(lines[0], is("123456789"));
- assertThat(lines[1], is("123456789"));
+ assertThat(lines[0], is(ChatColor.WHITE.toString() + "123456789"));
+ assertThat(lines[1], is(ChatColor.WHITE.toString() + "123456789"));
+ }
+
+ @Test
+ public void testWordWrap11() {
+ String rawString = ChatColor.RED + "a a a " + ChatColor.BLUE + "a a";
+ String[] lines = ChatPaginator.wordWrap(rawString, 9);
+
+ assertThat(lines.length, is(1));
+ assertThat(lines[0], is(ChatColor.RED + "a a a " + ChatColor.BLUE + "a a"));
}
@Test
@@ -128,8 +137,8 @@ public class ChatPaginatorTest {
assertThat(page.getPageNumber(), is(1));
assertThat(page.getTotalPages(), is(4));
assertThat(page.getLines().length, is(2));
- assertThat(page.getLines()[0], is("1234"));
- assertThat(page.getLines()[1], is("123456"));
+ assertThat(page.getLines()[0], is(ChatColor.WHITE.toString() + "1234"));
+ assertThat(page.getLines()[1], is(ChatColor.WHITE.toString() + "123456"));
}
@Test
@@ -140,8 +149,8 @@ public class ChatPaginatorTest {
assertThat(page.getPageNumber(), is(2));
assertThat(page.getTotalPages(), is(4));
assertThat(page.getLines().length, is(2));
- assertThat(page.getLines()[0], is("789"));
- assertThat(page.getLines()[1], is("123456"));
+ assertThat(page.getLines()[0], is(ChatColor.WHITE.toString() + "789"));
+ assertThat(page.getLines()[1], is(ChatColor.WHITE.toString() + "123456"));
}
@Test
@@ -152,6 +161,6 @@ public class ChatPaginatorTest {
assertThat(page.getPageNumber(), is(4));
assertThat(page.getTotalPages(), is(4));
assertThat(page.getLines().length, is(1));
- assertThat(page.getLines()[0], is("789"));
+ assertThat(page.getLines()[0], is(ChatColor.WHITE.toString() + "789"));
}
}